Skip to content

Conversation

@pratlucas
Copy link
Contributor

The tests updated by this commit are expected to fail when targetting a
darwin platform. As they rely on target detection based on the host,
this is currently checked by using the XFAIL: system-darwin
annotation.

This approach becomes a problem when trying to run such tests on a
cross-compiling build of clang on a darwin platform. When no darwin
targets are included in the build, the XFAIL will still apply even
though the target used is not related to the darwin platform, and the
tests will unexpectedly pass.

To fix this issue, this patch updates the condition used by the tests'
XFAIL annotation to target={{.*}}-darwin{{.*}}, ensuring they only are
xfailed when the relevant target is used.

The tests updated by this commit are expected to fail when targetting a
darwin platform. As they rely on target detection based on the host,
this is currently checked by using the `XFAIL: system-darwin`
annotation.

This approach becomes a problem when trying to run such tests on a
cross-compiling build of clang on a darwin platform. When no darwin
targets are included in the build, the XFAIL will still apply even
though the target used is not related to the darwin platform, and the
tests will unexpectedly pass.

To fix this issue, this patch updates the condition used by the tests'
XFAIL annotation to `target={{.*}}-darwin{{.*}}`, ensuring they only are
xfailed when the relevant target is used.
@llvmbot
Copy link
Member

llvmbot commented Mar 6, 2025

@llvm/pr-subscribers-llvm-binary-utilities

Author: Lucas Duarte Prates (pratlucas)

Changes

The tests updated by this commit are expected to fail when targetting a
darwin platform. As they rely on target detection based on the host,
this is currently checked by using the XFAIL: system-darwin
annotation.

This approach becomes a problem when trying to run such tests on a
cross-compiling build of clang on a darwin platform. When no darwin
targets are included in the build, the XFAIL will still apply even
though the target used is not related to the darwin platform, and the
tests will unexpectedly pass.

To fix this issue, this patch updates the condition used by the tests'
XFAIL annotation to target={{.*}}-darwin{{.*}}, ensuring they only are
xfailed when the relevant target is used.


Full diff: https://github.com/llvm/llvm-project/pull/130144.diff

2 Files Affected:

  • (modified) llvm/test/tools/llvm-ar/extract.test (+1-1)
  • (modified) llvm/test/tools/llvm-ar/print.test (+1-1)
diff --git a/llvm/test/tools/llvm-ar/extract.test b/llvm/test/tools/llvm-ar/extract.test
index ccad703f3a149..bf46cc0743c7d 100644
--- a/llvm/test/tools/llvm-ar/extract.test
+++ b/llvm/test/tools/llvm-ar/extract.test
@@ -1,5 +1,5 @@
 ## Test extract operation.
-# XFAIL: system-darwin
+# XFAIL: target={{.*}}-darwin{{.*}}
 
 # RUN: rm -rf %t && mkdir -p %t/extracted/
 
diff --git a/llvm/test/tools/llvm-ar/print.test b/llvm/test/tools/llvm-ar/print.test
index a27cab4a227e1..997c05f225a8b 100644
--- a/llvm/test/tools/llvm-ar/print.test
+++ b/llvm/test/tools/llvm-ar/print.test
@@ -1,5 +1,5 @@
 ## Test Print output
-# XFAIL: system-darwin
+# XFAIL: target={{.*}}-darwin{{.*}}
 
 # RUN: rm -rf %t && mkdir -p %t
 # RUN: echo file1 > %t/1.txt

Copy link
Collaborator

@jh7370 jh7370 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a Mac to test this on. It seems simple enough and I'm fairly confident it is correct. I assume you have verified that this does indeed XFAIL the tests under the condition you expect it to?

One request: please change the tag in the title to [llvm-ar], since this change has nothing to do with clang. LGTM with that.

@pratlucas pratlucas changed the title [clang] Fix darwin-related tests' XFAIL annotation [llvm-ar] Fix darwin-related tests' XFAIL annotation Mar 7, 2025
@pratlucas
Copy link
Contributor Author

Thanks for the review! I did verify it on a Mac, both with a regular LLVM build and a cross-compiling downstream project (arm/arm-toolchain).

I've updated the PR title, which will be final commit message. Sorry about mixing it up, that's what I get for copy-pasting the commit message from #130138 :)

@pratlucas pratlucas merged commit dc69eae into llvm:main Mar 7, 2025
13 checks passed
@pratlucas pratlucas deleted the darwin-xfail branch March 7, 2025 10:53
pratlucas added a commit to pratlucas/arm-toolchain that referenced this pull request Mar 19, 2025
This cherry-picks the upstream change from llvm/llvm-project#130144,
which landed on the `main` branch, into our 20.x release. The change is
included as a patch file for llvm.
pratlucas added a commit to arm/arm-toolchain that referenced this pull request Mar 20, 2025
This cherry-picks the upstream change from llvm/llvm-project#130144,
which landed on the `main` branch, into our 20.x release. The change is
included as a patch file for llvm.
@AnthonyLatsis
Copy link
Contributor

@pratlucas This change effectively un-XFAILed the tests for LLVM builds through the Swift build script because we use Apple platform names for the LLVM target triple rather than darwin, e.g. x86_64-apple-macosx13.0. Was the unexpected pass happening when running these tests on arm64 macOS with a cross compiled arm64 non-darwin llvm-ar?

AnthonyLatsis added a commit to swiftlang/llvm-project that referenced this pull request Sep 29, 2025
The history of these XFAILs is clouded. Initially added as target-based
checks in
llvm@629273e
for somewhat vague reasons, soon after switched to host-based checks in
llvm@20b2cd3
"due to the problem being related to the darwin host and not the
target", and recently reverted back to target-based in
llvm#130144 because, to my
understanding, the tests can unexpectedly pass on arm64 macOS with
`llvm-ar` cross-compiled to baremetal arm64.

Anyway, the problem with the current `target={{.*}}-darwin{{.*}}` is
that the Swift build script uses Apple platform names like 'macosx', not
'darwin', for the LLVM target triple, e.g. `arm64-apple-macosx13.0`.
AnthonyLatsis added a commit to swiftlang/llvm-project that referenced this pull request Oct 7, 2025
…L for some target triples

The problem with the current `target={{.*}}-darwin{{.*}}` XFAIL
condition (changed in llvm#130144)
is that the Swift build script uses Apple platform names like 'macosx',
not 'darwin', for the LLVM target triple, e.g. `arm64-apple-macosx13.0`.

These tests appear to have been originally XFAILed because the default
format on macOS (darwin) adds newlines as padding to align members.
See: https://github.com/llvm/llvm-project/blob/ee8394d9469a2946ffe2e7d192c593ecf3f93098/llvm/lib/Object/ArchiveWriter.cpp#L897-L904

Use `--format=gnu` to cope with the differences in the output and
reenable the tests.
bnbarham pushed a commit that referenced this pull request Oct 7, 2025
…L for some target triples (#159796)

The problem with the current `target={{.*}}-darwin{{.*}}` XFAIL
condition (changed in #130144)
is that the Swift build script uses Apple platform names like 'macosx',
not 'darwin', for the LLVM target triple, e.g. `arm64-apple-macosx13.0`.

These tests appear to have been originally XFAILed because the default
format on macOS (darwin) adds newlines as padding to align members. See:
https://github.com/llvm/llvm-project/blob/ee8394d9469a2946ffe2e7d192c593ecf3f93098/llvm/lib/Object/ArchiveWriter.cpp#L897-L904

Use `--format=gnu` to cope with the differences in the output and
reenable the tests.

rdar://157213658
AnthonyLatsis added a commit to swiftlang/llvm-project that referenced this pull request Oct 7, 2025
…L for some target triples (llvm#159796)

The problem with the current `target={{.*}}-darwin{{.*}}` XFAIL
condition (changed in llvm#130144)
is that the Swift build script uses Apple platform names like 'macosx',
not 'darwin', for the LLVM target triple, e.g. `arm64-apple-macosx13.0`.

These tests appear to have been originally XFAILed because the default
format on macOS (darwin) adds newlines as padding to align members. See:
https://github.com/llvm/llvm-project/blob/ee8394d9469a2946ffe2e7d192c593ecf3f93098/llvm/lib/Object/ArchiveWriter.cpp#L897-L904

Use `--format=gnu` to cope with the differences in the output and
reenable the tests.

rdar://157213658
(cherry picked from commit 33e82e6)
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Oct 7, 2025
…tent unXFAIL for some target triples (#159796)

The problem with the current `target={{.*}}-darwin{{.*}}` XFAIL
condition (changed in llvm/llvm-project#130144)
is that the Swift build script uses Apple platform names like 'macosx',
not 'darwin', for the LLVM target triple, e.g. `arm64-apple-macosx13.0`.

These tests appear to have been originally XFAILed because the default
format on macOS (darwin) adds newlines as padding to align members. See:
https://github.com/llvm/llvm-project/blob/ee8394d9469a2946ffe2e7d192c593ecf3f93098/llvm/lib/Object/ArchiveWriter.cpp#L897-L904

Use `--format=gnu` to cope with the differences in the output and
reenable the tests.

rdar://157213658
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants