[flang-commits] [flang] b52cf4c - [flang] Fix linker test on Windows.

Michael Kruse via flang-commits flang-commits at lists.llvm.org
Wed Mar 8 14:47:42 PST 2023


Author: Michael Kruse
Date: 2023-03-08T16:46:20-06:00
New Revision: b52cf4c41cd0f8c84e304c0e65efca85ccde30d7

URL: https://github.com/llvm/llvm-project/commit/b52cf4c41cd0f8c84e304c0e65efca85ccde30d7
DIFF: https://github.com/llvm/llvm-project/commit/b52cf4c41cd0f8c84e304c0e65efca85ccde30d7.diff

LOG: [flang] Fix linker test on Windows.

The linker-flags.f90 test checks for the linker command line. The `-target` indicates cross-compiling, the toolchain executables themselves are still running on the native platform. If it is Windows, the driver will try to fully resolve the path to `ld` which may include an `.exe` suffix.

In my case, it resolves to the MinGW installation (`"C:\\tools\\msys64\\usr\\bin\\ld.exe"`) found in `PATH`. The GNU ld that comes with the MSYS2 distribution does not support `elf64lppc` or MacOS emulation modes (`acosx_version_min`), but the test also does not require executing the linker.

Reviewed By: awarzynski

Differential Revision: https://reviews.llvm.org/D144592

Added: 
    

Modified: 
    flang/test/Driver/linker-flags.f90

Removed: 
    


################################################################################
diff  --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90
index 90c4a940c6d5f..e1350b74ae30a 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -17,20 +17,24 @@
 ! CHECK-SAME:  "-o" "[[object_file:.*\.o]]" {{.*}}Inputs/hello.f90
 
 ! Linker invocation to generate the executable
-! GNU-LABEL:  "{{.*}}ld" 
+! NOTE: Since we are cross-compiling, the host toolchain executables may
+!       run on any other platform, such as Windows that use a .exe
+!       suffix. Clang's driver will try to resolve the path to the ld
+!       executable and may find the GNU linker from MinGW or Cygwin.
+! GNU-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! GNU-SAME: "[[object_file]]"
 ! GNU-SAME: -lFortran_main
 ! GNU-SAME: -lFortranRuntime
 ! GNU-SAME: -lFortranDecimal
 ! GNU-SAME: -lm
 
-! DARWIN-LABEL:  "{{.*}}ld" 
+! DARWIN-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! DARWIN-SAME: "[[object_file]]"
 ! DARWIN-SAME: -lFortran_main
 ! DARWIN-SAME: -lFortranRuntime
 ! DARWIN-SAME: -lFortranDecimal
 
-! MINGW-LABEL:  "{{.*}}ld" 
+! MINGW-LABEL:  "{{.*}}ld{{(\.exe)?}}"
 ! MINGW-SAME: "[[object_file]]"
 ! MINGW-SAME: -lFortran_main
 ! MINGW-SAME: -lFortranRuntime


        


More information about the flang-commits mailing list