Skip to content

[Driver] Fix Arm/AArch64 Link Argument tests #144582

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

Merged
merged 1 commit into from
Jun 17, 2025

Conversation

lenary
Copy link
Member

@lenary lenary commented Jun 17, 2025

The openmp-offload-amdgpu-runtime-2 bot specifies default rtlib of compiler-rt, but default unwindlib of libgcc. Change the tests to accept that there may be "--as-needed" "-lgcc_s" "--no-as-needed" between libclang_rt.builtins.a and -lc.

Relates to #121830

The openmp-offload-amdgpu-runtime-2 bot specifies default rtlib of
compiler-rt, but default unwindlib of libgcc. Change the tests to accept
that there may be `"--as-needed" "-lgcc_s" "--no-as-needed"` between
`libclang_rt.builtins.a` and `-lc`.

Relates to llvm#121830
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Jun 17, 2025
@lenary lenary changed the title [Driver] Fix Tests when specifying unwindlib [Driver] Fix Arm/AArch64 Link Argument tests Jun 17, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 17, 2025

@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Sam Elliott (lenary)

Changes

The openmp-offload-amdgpu-runtime-2 bot specifies default rtlib of compiler-rt, but default unwindlib of libgcc. Change the tests to accept that there may be "--as-needed" "-lgcc_s" "--no-as-needed" between libclang_rt.builtins.a and -lc.

Relates to #121830


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

2 Files Affected:

  • (modified) clang/test/Driver/aarch64-toolchain.c (+2-1)
  • (modified) clang/test/Driver/arm-toolchain.c (+2-1)
diff --git a/clang/test/Driver/aarch64-toolchain.c b/clang/test/Driver/aarch64-toolchain.c
index e12107fa2c506..327161b81d9f6 100644
--- a/clang/test/Driver/aarch64-toolchain.c
+++ b/clang/test/Driver/aarch64-toolchain.c
@@ -135,7 +135,8 @@
 
 // AARCH64-BAREMETAL-COMPILER-RT: "{{.*}}crt0.o"
 // AARCH64-BAREMETAL-COMPILER-RT: "{{.*}}clang_rt.crtbegin.o"
-// AARCH64-BAREMETAL-COMPILER-RT: "--start-group" "{{.*}}libclang_rt.builtins.a" "-lc" "-lgloss" "--end-group"
+// AARCH64-BAREMETAL-COMPILER-RT: "--start-group" "{{.*}}libclang_rt.builtins.a"
+// AARCH64-BAREMETAL-COMPILER-RT: "-lc" "-lgloss" "--end-group"
 // AARCH64-BAREMETAL-COMPILER-RT: "{{.*}}clang_rt.crtend.o"
 
 // RUN: %clang -### %s -fuse-ld= \
diff --git a/clang/test/Driver/arm-toolchain.c b/clang/test/Driver/arm-toolchain.c
index d4f9bf2aaf3d5..5368158cdeeda 100644
--- a/clang/test/Driver/arm-toolchain.c
+++ b/clang/test/Driver/arm-toolchain.c
@@ -136,7 +136,8 @@
 
 // ARM-BAREMETAL-COMPILER-RT: "{{.*}}crt0.o"
 // ARM-BAREMETAL-COMPILER-RT: "{{.*}}clang_rt.crtbegin.o"
-// ARM-BAREMETAL-COMPILER-RT: "--start-group" "{{.*}}libclang_rt.builtins.a" "-lc" "-lgloss" "--end-group"
+// ARM-BAREMETAL-COMPILER-RT: "--start-group" "{{.*}}libclang_rt.builtins.a"
+// ARM-BAREMETAL-COMPILER-RT: "-lc" "-lgloss" "--end-group"
 // ARM-BAREMETAL-COMPILER-RT: "{{.*}}clang_rt.crtend.o"
 
 // RUN: %clang -### %s -fuse-ld= \

@quic-garvgupt
Copy link
Contributor

`ToolChain::UnwindLibType ToolChain::GetUnwindLibType(
const ArgList &Args) const {
if (unwindLibType)
return *unwindLibType;

const Arg *A = Args.getLastArg(options::OPT_unwindlib_EQ);
StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_UNWINDLIB;`

If --unwindlib= is not set to empty explicitly, then CLANG_DEFAULT_UNWINDLIB overrides. I think, adding --unwindlib=, might fix the tests.

@quic-garvgupt
Copy link
Contributor

`ToolChain::UnwindLibType ToolChain::GetUnwindLibType( const ArgList &Args) const { if (unwindLibType) return *unwindLibType;

const Arg *A = Args.getLastArg(options::OPT_unwindlib_EQ); StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_UNWINDLIB;`

If --unwindlib= is not set to empty explicitly, then CLANG_DEFAULT_UNWINDLIB overrides. I think, adding --unwindlib=, might fix the tests.

`ToolChain::UnwindLibType ToolChain::GetUnwindLibType( const ArgList &Args) const { if (unwindLibType) return *unwindLibType;

const Arg *A = Args.getLastArg(options::OPT_unwindlib_EQ); StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_UNWINDLIB;`

If --unwindlib= is not set to empty explicitly, then CLANG_DEFAULT_UNWINDLIB overrides. I think, adding --unwindlib=, might fix the tests.

I revisited the tests and realized that for the ARM and RISC-V targets, the flow goes through GetDefaultUnwindLibType, which defaults to UNW_None. Explicitly adding --unwindlib= to the failing instance would make the test redundant, as it would no longer validate the intended behavior. Please disregard my earlier comment—I'm aligned with this fix. Thanks for pushing the change!

@Kewen12
Copy link
Contributor

Kewen12 commented Jun 17, 2025

Thanks for this quick fix!

Hi @quic-garvgupt, could you please help approve this PR if it looks good to you. It would be helpful to unblock our bots and downstream. Thanks!

@lenary
Copy link
Member Author

lenary commented Jun 17, 2025

I'm going to land this, as I'm taking "I'm aligned with this fix" as approval from garvit (I know he's in a different time zone, which may mean he's logged off for the night)

@lenary lenary merged commit a79186c into llvm:main Jun 17, 2025
10 checks passed
@lenary lenary deleted the pr/arm-fix-driver-test branch June 17, 2025 20:36
@Kewen12
Copy link
Contributor

Kewen12 commented Jun 17, 2025

Thanks again for your help @lenary

mysterymath added a commit that referenced this pull request Jun 17, 2025
#144603)

…Baremetal toolchain (#121829)"

This reverts the following stack of commits, due to them breaking the
Fuchsia toolchain and corresponding LLVM buildbot.

Revert "[Driver] Fix Arm/AArch64 Link Argument tests (#144582)" This
reverts commit a79186c.

Revert "[Driver] Add option to force undefined symbols during linking in
BareMetal toolchain object. (#132807)" This reverts commit
9cb7545.

Revert "[Driver] Fix link order of BareMetal toolchain object (#132806)"
This reverts commit 31523de.

Revert "[Driver] Add support for crtbegin.o, crtend.o and libgloss lib
to BareMetal toolchain object (#121830)" This reverts commit
ec230aa.

Revert "[Driver] Add support for GCC installation detection in Baremetal
toolchain (#121829)" This reverts commit
eb31c42.
mysterymath added a commit to mysterymath/llvm-project that referenced this pull request Jun 17, 2025
…Baremetal toolchain (llvm#121829)"

This reverts the following stack of commits, due to them breaking the
Fuchsia toolchain and corresponding LLVM buildbot.

Revert "[Driver] Fix Arm/AArch64 Link Argument tests (llvm#144582)"
This reverts commit a79186c.

Revert "[Driver] Add option to force undefined symbols during linking in BareMetal toolchain object. (llvm#132807)"
This reverts commit 9cb7545.

Revert "[Driver] Fix link order of BareMetal toolchain object (llvm#132806)"
This reverts commit 31523de.

Revert "[Driver] Add support for crtbegin.o, crtend.o and libgloss lib to BareMetal toolchain object (llvm#121830)"
This reverts commit ec230aa.

Revert "[Driver] Add support for GCC installation detection in Baremetal toolchain (llvm#121829)"
This reverts commit eb31c42.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants