<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/81070>81070</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Cross-compiling with clang-cl to intel on an arm machine doesn't work great (or at all)
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          nico
      </td>
    </tr>
</table>

<pre>
    I saw https://neugierig.org/software/blog/2024/02/cross-compile.html and was like "this is super easy to do with clang-cl as long as you have a win sysroot!". Then I tried it on my Apple Silicon laptop:

```
 % cat main.c
int main() {}
```

```
 % out/gn/bin/clang-cl main.c /winsysroot ~/src/chrome/src/third_party/depot_tools/win_toolchain/vs_files/27370823e7 
clang-cl: error: unable to execute command: Executable "link.exe" doesn't exist!
clang-cl: error: linker command failed with exit code 1 (use -v to see invocation)
```

Ah right, I have to use lld, of course:

```
% out/gn/bin/clang-cl main.c /winsysroot ~/src/chrome/src/third_party/depot_tools/win_toolchain/vs_files/27370823e7 -fuse-ld=lld
% file main.exe
main.exe: PE32+ executable (console) Aarch64, for MS Windows
```

Hm. I suppose that makes sense? But let's make an intel binary. Just `-m32` picks 32-bit arm which I suppose maybe makes sense, so let's pass an explicit triple:

```
% out/gn/bin/clang-cl main.c /winsysroot ~/src/chrome/src/third_party/depot_tools/win_toolchain/vs_files/27370823e7 -fuse-ld=lld --target=x86_64-pc-windows 
clang (LLVM option parsing): Unknown command line argument '-x86-asm-syntax=intel'.  Try: 'clang (LLVM option parsing) --help'
clang (LLVM option parsing): Did you mean '--asan-stack=intel'?
```

Whaat? Why is that command line arg unknown? That should work?

I suppose this bug report is only about this very last thing. (But maybe we should default to lld too, at least on non-Win hosts, since link.exe can't possibly work there?)

@zmodem 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUVkuP2zYQ_jX0ZSBDpm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