[flang][AArch64] Always link compiler-rt to flang after libgcc (#144710)

This patch fixes an issue where the __trampoline_setup symbol is missing
with some programs compiled with flang. This symbol is present only in
compiler-rt and not in libgcc. This patch adds compiler-rt to the link
line after libgcc if libgcc is being used, so that only this symbol will
be picked from compiler-rt.

Fixes #141147
This commit is contained in:
David Truby
2025-06-24 11:08:13 +01:00
committed by GitHub
parent 594ebe6340
commit 049d61ad65
3 changed files with 23 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
! Check linker flags for AArch64 linux, since it needs both libgcc and
! compiler-rt, with compiler-rt second when -rtlib=libgcc.
! RUN: %flang -### -rtlib=libgcc --target=aarch64-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s
! CHECK-LABEL: "{{.*}}ld{{(\.exe)?}}"
! CHECK-SAME: "-lflang_rt.runtime" "-lm"
! CHECK-SAME: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
! CHECK-SAME: "--as-needed" "{{.*}}{{\\|/}}libclang_rt.builtins.a" "--no-as-needed"