[flang] Add --gcc-toolchain and --gcc-install-dir options to flang. (#87360)
The `--gcc-toolchain` and `--gcc-install-dir` option were previously only visible to the Clang driver, but not Flang. These determine which assembler, linker, and libraries to use, e.g. for cross-compiling, and therefore are relevant for Flang as well. Tests are implemented using a mock GCC installation in `basic_cross_linux_tree` copied over from Clang's tests. The Clang driver already contains tests with `--driver-mode=flang` but `flang-new` is an entirely different executable (containing the `-fc1` stage) that should be tested as well. While not all files in `basic_cross_linux_tree` are strictly needed for testing those two driver flags, they will be necessarily needed for future added flags such as `--rtlib`. Also remove the entry `*.o` in flang's `.gitignore` since `crt*.o` files are needed in the GCC mock installation. Fixes #86729
This commit is contained in:
parent
aa6ba23235
commit
75e7e7d327
@ -802,9 +802,11 @@ def B : JoinedOrSeparate<["-"], "B">, MetaVarName<"<prefix>">,
|
||||
HelpText<"Search $prefix$file for executables, libraries, and data files. "
|
||||
"If $prefix is a directory, search $prefix/$file">;
|
||||
def gcc_install_dir_EQ : Joined<["--"], "gcc-install-dir=">,
|
||||
Visibility<[ClangOption, FlangOption]>,
|
||||
HelpText<"Use GCC installation in the specified directory. The directory ends with path components like 'lib{,32,64}/gcc{,-cross}/$triple/$version'. "
|
||||
"Note: executables (e.g. ld) used by the compiler are not overridden by the selected GCC installation">;
|
||||
def gcc_toolchain : Joined<["--"], "gcc-toolchain=">, Flags<[NoXarchOption]>,
|
||||
Visibility<[ClangOption, FlangOption]>,
|
||||
HelpText<"Specify a directory where Clang can find 'include' and 'lib{,32,64}/gcc{,-cross}/$triple/$version'. "
|
||||
"Clang will use the GCC installation with the largest version">;
|
||||
def gcc_triple_EQ : Joined<["--"], "gcc-triple=">,
|
||||
|
1
flang/.gitignore
vendored
1
flang/.gitignore
vendored
@ -5,7 +5,6 @@ build
|
||||
root
|
||||
tags
|
||||
TAGS
|
||||
*.o
|
||||
.nfs*
|
||||
*.sw?
|
||||
*~
|
||||
|
@ -0,0 +1 @@
|
||||
#!/bin/true
|
@ -0,0 +1 @@
|
||||
#!/bin/true
|
@ -0,0 +1 @@
|
||||
#!/bin/true
|
@ -0,0 +1 @@
|
||||
#!/bin/true
|
@ -0,0 +1 @@
|
||||
#!/bin/true
|
@ -0,0 +1 @@
|
||||
#!/bin/true
|
@ -0,0 +1 @@
|
||||
#!/bin/true
|
@ -0,0 +1 @@
|
||||
#!/bin/true
|
@ -0,0 +1 @@
|
||||
#!/bin/true
|
@ -0,0 +1 @@
|
||||
#!/bin/true
|
@ -0,0 +1 @@
|
||||
#!/bin/true
|
@ -0,0 +1 @@
|
||||
#!/bin/true
|
@ -0,0 +1 @@
|
||||
#!/bin/true
|
@ -0,0 +1 @@
|
||||
#!/bin/true
|
@ -0,0 +1 @@
|
||||
#!/bin/true
|
@ -0,0 +1 @@
|
||||
#!/bin/true
|
@ -104,6 +104,9 @@
|
||||
! CHECK-NEXT: -fversion-loops-for-stride
|
||||
! CHECK-NEXT: Create unit-strided versions of loops
|
||||
! CHECK-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
|
||||
! CHECK-NEXT: --gcc-install-dir=<value>
|
||||
! CHECK-NEXT: Use GCC installation in the specified directory. The directory ends with path components like 'lib{,32,64}/gcc{,-cross}/$triple/$version'. Note: executables (e.g. ld) used by the compiler are not overridden by the selected GCC installation
|
||||
! CHECK-NEXT: --gcc-toolchain=<value> Specify a directory where Clang can find 'include' and 'lib{,32,64}/gcc{,-cross}/$triple/$version'. Clang will use the GCC installation with the largest version
|
||||
! CHECK-NEXT: -gline-directives-only Emit debug line info directives only
|
||||
! CHECK-NEXT: -gline-tables-only Emit debug line number tables only
|
||||
! CHECK-NEXT: -gpulibc Link the LLVM C Library for GPUs
|
||||
|
@ -92,6 +92,9 @@
|
||||
! HELP-NEXT: -fversion-loops-for-stride
|
||||
! HELP-NEXT: Create unit-strided versions of loops
|
||||
! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
|
||||
! HELP-NEXT: --gcc-install-dir=<value>
|
||||
! HELP-NEXT: Use GCC installation in the specified directory. The directory ends with path components like 'lib{,32,64}/gcc{,-cross}/$triple/$version'. Note: executables (e.g. ld) used by the compiler are not overridden by the selected GCC installation
|
||||
! HELP-NEXT: --gcc-toolchain=<value> Specify a directory where Clang can find 'include' and 'lib{,32,64}/gcc{,-cross}/$triple/$version'. Clang will use the GCC installation with the largest version
|
||||
! HELP-NEXT: -gline-directives-only Emit debug line info directives only
|
||||
! HELP-NEXT: -gline-tables-only Emit debug line number tables only
|
||||
! HELP-NEXT: -gpulibc Link the LLVM C Library for GPUs
|
||||
|
21
flang/test/Driver/gcc-toolchain-install-dir.f90
Normal file
21
flang/test/Driver/gcc-toolchain-install-dir.f90
Normal file
@ -0,0 +1,21 @@
|
||||
!! Test that --gcc-toolchain and --gcc-install-dir options are working as expected.
|
||||
!! It does not test cross-compiling (--sysroot), so crtbegin.o, libgcc/compiler-rt, libc, libFortranRuntime, etc. are not supposed to be affected.
|
||||
!! PREFIX is captured twice because the driver escapes backslashes (occuring in Windows paths) in the -### output, but not on the "Selected GCC installation:" line.
|
||||
|
||||
! RUN: %flang 2>&1 -### -v -o %t %s -no-integrated-as -fuse-ld=ld --target=i386-unknown-linux-gnu --gcc-install-dir=%S/Inputs/basic_cross_linux_tree/usr/lib/gcc/i386-unknown-linux-gnu/10.2.0 | FileCheck %s --check-prefix=CHECK-I386
|
||||
! RUN: %flang 2>&1 -### -v -o %t %s -no-integrated-as -fuse-ld=ld --target=i386-unknown-linux-gnu --gcc-toolchain=%S/Inputs/basic_cross_linux_tree/usr | FileCheck %s --check-prefix=CHECK-I386
|
||||
! CHECK-I386: Selected GCC installation: [[PREFIX:[^"]+]]/Inputs/basic_cross_linux_tree/usr/lib/gcc/i386-unknown-linux-gnu/10.2.0
|
||||
! CHECK-I386: "-fc1" "-triple" "i386-unknown-linux-gnu"
|
||||
! CHECK-I386: "[[PREFIX:[^"]+]]/Inputs/basic_cross_linux_tree/usr/lib/gcc/i386-unknown-linux-gnu/10.2.0/../../../../i386-unknown-linux-gnu/bin{{/|\\\\}}as"
|
||||
! CHECK-I386: "[[PREFIX]]/Inputs/basic_cross_linux_tree/usr/lib/gcc/i386-unknown-linux-gnu/10.2.0/../../../../i386-unknown-linux-gnu/bin{{/|\\\\}}ld" {{.*}} "-m" "elf_i386"
|
||||
! CHECK-I386-SAME: "-L[[PREFIX]]/Inputs/basic_cross_linux_tree/usr/lib/gcc/i386-unknown-linux-gnu/10.2.0"
|
||||
! CHECK-I386-SAME: "-L[[PREFIX]]/Inputs/basic_cross_linux_tree/usr/lib/gcc/i386-unknown-linux-gnu/10.2.0/../../../../i386-unknown-linux-gnu/lib"
|
||||
|
||||
! RUN: %flang 2>&1 -### -v -o %t %s -no-integrated-as -fuse-ld=ld --target=x86_64-unknown-linux-gnu --gcc-install-dir=%S/Inputs/basic_cross_linux_tree/usr/lib/gcc/x86_64-unknown-linux-gnu/10.2.0 | FileCheck %s --check-prefix=CHECK-X86-64
|
||||
! RUN: %flang 2>&1 -### -v -o %t %s -no-integrated-as -fuse-ld=ld --target=x86_64-unknown-linux-gnu --gcc-toolchain=%S/Inputs/basic_cross_linux_tree/usr | FileCheck %s --check-prefix=CHECK-X86-64
|
||||
! CHECK-X86-64: Selected GCC installation: [[PREFIX:[^"]+]]/Inputs/basic_cross_linux_tree/usr/lib/gcc/x86_64-unknown-linux-gnu/10.2.0
|
||||
! CHECK-X86-64: "-fc1" "-triple" "x86_64-unknown-linux-gnu"
|
||||
! CHECK-X86-64: "[[PREFIX:[^"]+]]/Inputs/basic_cross_linux_tree/usr/lib/gcc/x86_64-unknown-linux-gnu/10.2.0/../../../../x86_64-unknown-linux-gnu/bin{{/|\\\\}}as" "--64"
|
||||
! CHECK-X86-64: "[[PREFIX]]/Inputs/basic_cross_linux_tree/usr/lib/gcc/x86_64-unknown-linux-gnu/10.2.0/../../../../x86_64-unknown-linux-gnu/bin{{/|\\\\}}ld" {{.*}} "-m" "elf_x86_64"
|
||||
! CHECK-X86-64-SAME: "-L[[PREFIX]]/Inputs/basic_cross_linux_tree/usr/lib/gcc/x86_64-unknown-linux-gnu/10.2.0"
|
||||
! CHECK-X86-64-SAME: "-L[[PREFIX]]/Inputs/basic_cross_linux_tree/usr/lib/gcc/x86_64-unknown-linux-gnu/10.2.0/../../../../x86_64-unknown-linux-gnu/lib"
|
Loading…
x
Reference in New Issue
Block a user