Skip to content

Commit 7647174

Browse files
authored
[flang] Add -rtlib flag (#99058)
This patch allows the -rtlib flag with flang-new to select between the libgcc_s and compiler-rt runtimes. The behaviour is identical to the same flag with clang.
1 parent 07f8a65 commit 7647174

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5622,7 +5622,7 @@ def resource_dir_EQ : Joined<["-"], "resource-dir=">, Flags<[NoXarchOption]>,
56225622
Alias<resource_dir>;
56235623
def rpath : Separate<["-"], "rpath">, Flags<[LinkerInput]>, Group<Link_Group>,
56245624
Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>;
5625-
def rtlib_EQ : Joined<["-", "--"], "rtlib=">, Visibility<[ClangOption, CLOption]>,
5625+
def rtlib_EQ : Joined<["-", "--"], "rtlib=">, Visibility<[ClangOption, CLOption, FlangOption]>,
56265626
HelpText<"Compiler runtime library to use">;
56275627
def frtlib_add_rpath: Flag<["-"], "frtlib-add-rpath">, Flags<[NoArgumentUnused]>,
56285628
Visibility<[ClangOption, FlangOption]>,

flang/test/Driver/linker-flags.f90

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib
1212
! RUN: %flang -### --target=x86_64-unknown-haiku %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,HAIKU,HAIKU-F128%f128-lib
1313
! RUN: %flang -### --target=x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,MINGW,MINGW-F128%f128-lib
14+
! RUN: %flang -### -rtlib=compiler-rt --target=aarch64-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,COMPILER-RT
1415

1516
! NOTE: Clang's driver library, clangDriver, usually adds 'oldnames' on Windows,
1617
! but it is not needed when compiling Fortran code and they might bring in
@@ -33,6 +34,7 @@
3334
! UNIX-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "--as-needed" "-lquadmath" "--no-as-needed"
3435
! SOLARIS-F128LIBQUADMATH-SAME: "-lFortranFloat128Math" "-z" "ignore" "-lquadmath" "-z" "record"
3536
! UNIX-SAME: "-lFortranRuntime" "-lFortranDecimal" "-lm"
37+
! COMPILER-RT: "{{.*}}{{\\|/}}libclang_rt.builtins.a"
3638

3739
! DARWIN-LABEL: "{{.*}}ld{{(\.exe)?}}"
3840
! DARWIN-SAME: "[[object_file]]"
@@ -61,3 +63,6 @@
6163
! MSVC-LABEL: link
6264
! MSVC-SAME: /subsystem:console
6365
! MSVC-SAME: "[[object_file]]"
66+
67+
! COMPILER-RT-NOT: "-lgcc"
68+
! COMPILER-RT-NOT: "-lgcc_s"

0 commit comments

Comments
 (0)