pratlucas wrote:

For context, we're observing this issue as part of our CI builds for the 
[arm/arm-toolchain](https://github.com/arm/arm-toolchain) project.

Looking into it in more detail, I believe I didn't express myself correctly 
when I wrote "When no darwin
targets are included in the build". The actual scenario we have in our 
toolchain is that we explicitly set the value of `LLVM_DEFAULT_TARGET_TRIPLE` 
in our CMake files.
With this, the starting target triple used by clang won't be related to darwin, 
even when running on a darwin host platform. (Note that this is intentional, as 
our toolchains are only designed to target embedded and linux environments)

> This doesn't happen for tests with target=<arch>-apple<platform&version> 
> right? It's not clear to me why the tests that explicitly pass an alternative 
> way to set the target triple (e.g. with env vars or with mtargetos) fail. It 
> would be good to diagnose that first.

The issue doesn't happen if the `--target` option is used. This happens because 
the `-arch` and `-mtargetos` options don't control the entire target triple, 
but only modify specific parts of it (arch and OS). They are also only 
considered when the original target is a darwin one, taking no effect otherwise:

- The processing of the `-arch` option is guarded by the triple's 
`isOSBinFormatMachO()` method in the driver.
- The `-mtargetos=` option is only ever evaluated with the Darwin Toolchain 
implementation, as part of `Darwin::AddDeploymentTarget`. This is only 
reachable if the Darwin Toolchain is used by clang, which in turn requires a 
darwin target triple.

Given the above, I think it's reasonable to expect that these tests will only 
pass when the default target triple is a darwin one, matching the updated 
`REQUIRES` annotations.

> Do you have a bot or build to point to for test failures?

Unfortunately our CI runs are not public yet, but here's the error output for 
reference:

```
<src_path>/clang/test/Driver/apple-arm64-arch.c:6:11: error: CHECK: expected 
string not found in input
// CHECK: "-triple" "arm64-apple-macosx{{[0-9.]+}}"
          ^
<stdin>:1:1: note: scanning from here
clang version 21.0.0git
^
<stdin>:8:89: note: possible intended match here
 "<src_path>/build/llvm/bin/clang-20" "-cc1" "-triple" 
"aarch64-unknown-linux-gnu" "-emit-obj" "-disable-free" 
"-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" 
"-main-file-name" "apple-arm64-arch.c" "-mrelocation-model" "pic" "-pic-level" 
"2" "-pic-is-pie" "-mframe-pointer=non-leaf" "-fmath-errno" "-ffp-contract=on" 
"-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" 
"-enable-tlsdesc" "-target-cpu" "generic" "-target-feature" "+v8a" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-abi" "aapcs" 
"-debugger-tuning=gdb" 
"-fdebug-compilation-dir=<src_path>/build/llvm/tools/clang/test/Driver" 
"-target-linker-version" "1115.7.3" 
"-fcoverage-compilation-dir=<src_path>/build/llvm/tools/clang/test/Driver" 
"-resource-dir" "<src_path>/build/llvm/lib/clang/21" "-internal-isystem" 
"<src_path>/build/llvm/lib/clang/21/include" "-internal-isystem" 
"/usr/local/include" "-internal-externc-isystem" "/include" 
"-internal-externc-isystem" "/usr/include" "-ferror-limit" "19" 
"-fno-signed-char" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf" 
"-target-feature" "-fmv" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" 
"apple-arm64-arch.o" "-x" "c" "<src_path>/clang/test/Driver/apple-arm64-arch.c"
                                                                                
        ^

Input file: <stdin>
Check file: <src_path>/clang/test/Driver/apple-arm64-arch.c

-dump-input=help explains the following input dump.

Input was:
<<<<<<
           1: clang version 21.0.0git 
check:6'0     X~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
           2: Target: aarch64-unknown-linux-gnu 
check:6'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           3: Thread model: posix 
check:6'0     ~~~~~~~~~~~~~~~~~~~~
           4: InstalledDir: <src_path>/build/llvm/bin 
check:6'0     
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           5: Arm Toolchain ID: E0000-pre (a6d8b454) 
check:6'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           6: clang: error: unsupported option '-arch' for target 
'aarch64-linux-gnu' 
```

https://github.com/llvm/llvm-project/pull/130138
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to