Skip to content

[Darwin][CompilerRT] Set compiler ID to 'Clang' for Compiler RT Tests for Apple Clang #121858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

thetruestblue
Copy link
Contributor

This patch restores previous behavior. Even when the Compiler ID is set to AppleClang, we expect Compiler RT Tests to use Clang as the compiler ID. This impacts various make and lit commands.

Caused by: https://github.com/llvm/llvm-project/pull/117812/files

rdar://141548700

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

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

That is rather annoying. I wonder how difficult it would be to accommodate that in the test suite instead of working around that in the build system.

Copy link
Member

@arichardson arichardson left a comment

Choose a reason for hiding this comment

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

Would be nice if this could be done in the test suite instead. I think this is broken though as it stands now.

Copy link
Member

@arichardson arichardson left a comment

Choose a reason for hiding this comment

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

I just looked and there are only 3 uses comparing compiler_id to "Clang", all of them in lit.common.cfg.py. I think we can just change those to also accept AppleClang (or use .endswith())?

@thetruestblue
Copy link
Contributor Author

thetruestblue commented Jan 7, 2025

I just looked and there are only 3 uses comparing compiler_id to "Clang", all of them in lit.common.cfg.py. I think we can just change those to also accept AppleClang (or use .endswith())?

This isn't the place impacted tho, right?
The compiler ID is also set as a lit feature, so all tests that refer to this lit feature would need to be changed. Or we could simply add the lit feature as Clang even for AppleClang.
However...
Various build flags are also set only whenif(COMPILER_RT_TEST_COMPILER_ID MATCHES "Clang"). ?

We'd need to change all of those cases to check for AppleClang as well? This seems not optimal. I'm just trying to get the previous behavior back so our tests can run again.

I'm not entirely sure the PR to not detect as GCC needed to change the previous behavior of setting clang strings to clang..

@compnerd
Copy link
Member

compnerd commented Jan 7, 2025

I'm not entirely sure the PR to not detect as GCC needed to change the previous behavior of setting clang strings to clang.

The point was to try to reduce the special case paths. If there is a specific reason that we cannot treat AppleClang as we do the other compiles (i.e. pass through the identity unmodified), that would be good to document.

Doing that in two phases where we first restore the behaviour and then follow up with a change to make it follow the same behaviour is fine too. But the idea is that we should try to bring the configuration into the same path if possible or document why it needs to be different.

@thetruestblue
Copy link
Contributor Author

thetruestblue commented Jan 7, 2025

The point was to try to reduce the special case paths. If there is a specific reason that we cannot treat AppleClang as we do the other compiles (i.e. pass through the identity unmodified), that would be good to document.

But this change "i.e. pass through the identity unmodified" is very new behavior added a month ago, and there are various places that don't assume that. Historically we matched any clang regex and set the compiler ID to Clang? This patch simply returns to a long standing assumption to avoid breaking tests or changing what flags are passed.

Not changing this would require a special path in lit config (no big deal) but also various CMake files where we check that (COMPILER_RT_TEST_COMPILER_ID MATCHES "Clang"). Which, I'd argue is uglier, but I agree this is pretty subpar as well.

Copy link
Member

@arichardson arichardson left a comment

Choose a reason for hiding this comment

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

Ah I missed the config.available_features.add(compiler_id). I agree we should normalize this to clang either in cmake or the top-level lit config file.

I'd prefer to do the canonicalization at the end of this if-else chain for future proofing, i.e

if ("${COMPILER_RT_TEST_COMPILER_ID}" STREQUAL "AppleClang")
    # Compiler-rt lit tests expect compiler ID 'Clang' for AppleClang.
    set(COMPILER_RT_TEST_COMPILER_ID Clang)
  endif()

but I guess the current one is fine too.

@arichardson
Copy link
Member

Sorry about the breakage, I had forgotten at the time that cmake uses a different compiler id for apple change.

@thetruestblue
Copy link
Contributor Author

I'd prefer to do the canonicalization at the end of this if-else chain for future proofing, i.e

I'm fine with this. Thanks very much!

This patch restores previous behavior we relied on. Even when the Compiler ID is set to AppleClang, we expect Compiler RT Tests to use Clang as the compiler ID. This impacts various make and lit commands.

Caused by: https://github.com/llvm/llvm-project/pull/117812/files

rdar://141548700
@thetruestblue thetruestblue force-pushed the truesblue/compiler_rt_appleclang_compilerid branch from 2107264 to a97a8c8 Compare January 7, 2025 17:25
Copy link
Contributor

@wrotki wrotki left a comment

Choose a reason for hiding this comment

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

Looks good, and we got an agreement in the discussion

@thetruestblue thetruestblue merged commit 75325c6 into llvm:main Jan 7, 2025
7 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 7, 2025

LLVM Buildbot has detected a new failure on builder clang-ppc64le-rhel running on ppc64le-clang-rhel-test while building compiler-rt at step 7 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/145/builds/4291

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_32.s' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/bin/llvm-mc -triple=x86_64-unknown-linux -position-independent      -filetype=obj -o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/test/ExecutionEngine/JITLink/x86-64/Output/ELF_R_X86_64_32.s.tmp.o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_32.s
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/bin/llvm-mc -triple=x86_64-unknown-linux -position-independent -filetype=obj -o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/test/ExecutionEngine/JITLink/x86-64/Output/ELF_R_X86_64_32.s.tmp.o /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_32.s
RUN: at line 3: /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/bin/llvm-jitlink -noexec -abs X=0x12345678 -check=/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_32.s /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/test/ExecutionEngine/JITLink/x86-64/Output/ELF_R_X86_64_32.s.tmp.o
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/bin/llvm-jitlink -noexec -abs X=0x12345678 -check=/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_32.s /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/test/ExecutionEngine/JITLink/x86-64/Output/ELF_R_X86_64_32.s.tmp.o
RUN: at line 4: not /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/bin/llvm-jitlink -noexec -abs X=0x123456789 /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/test/ExecutionEngine/JITLink/x86-64/Output/ELF_R_X86_64_32.s.tmp.o 2>&1 |    /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/bin/FileCheck -check-prefix=CHECK-ERROR /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_32.s
+ not /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/bin/llvm-jitlink -noexec -abs X=0x123456789 /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/test/ExecutionEngine/JITLink/x86-64/Output/ELF_R_X86_64_32.s.tmp.o
+ /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/bin/FileCheck -check-prefix=CHECK-ERROR /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/ELF_R_X86_64_32.s

--

********************


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.

6 participants