[PATCH] D126291: [flang][Driver] Update link job on windows

Michael Kruse via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 6 16:00:52 PDT 2022


Meinersbur added a comment.

I looked into Google Benchmark because it also has its main in a .lib library and how it handles it. Turns out it is using cmake which by default always adds `/subsystem:console` unless setting 
 WIN32_EXECUTABLE <https://cmake.org/cmake/help/latest/prop_tgt/WIN32_EXECUTABLE.html#prop_tgt:WIN32_EXECUTABLE>=ON.

I tested the updated patch again it is failing:

  $ ":" "RUN: at line 16"
  $ "c:\users\meinersbur\build\llvm-project\release\bin\flang-new.exe" "-###" "-flang-experimental-exec" "--ld-path=/usr/bin/ld" "C:\Users\meinersbur\src\llvm-project\flang\test\Driver/Inputs/hello.f90"
  $ "c:\users\meinersbur\build\llvm-project\release\bin\filecheck.exe" "C:\Users\meinersbur\src\llvm-project\flang\test\Driver\linker-flags.f90"
  # command stderr:
  C:\Users\meinersbur\src\llvm-project\flang\test\Driver\linker-flags.f90:26:16: error: CHECK-LABEL: expected string not found in input
  ! CHECK-LABEL: "/usr/bin/ld"
                 ^
  <stdin>:7:136: note: scanning from here
   "c:\\users\\meinersbur\\build\\llvm-project\\release\\bin\\flang-new" "-fc1" "-triple" "x86_64-pc-windows-msvc19.32.31329" "-emit-obj" "-o" "C:\\Users\\MEINER~1\\AppData\\Local\\Temp\\lit-tmp-0rwi220l\\hello-bbdcc9.o" "C:\\Users\\meinersbur\\src\\llvm-project\\flang\\test\\Driver/Inputs/hello.f90"

Presumably the feature 'windows-msvc' is not registered. `print(config.available_features)` results in:

  {'asserts', 'x86-registered-target', 'nvptx-registered-target', 'system-windows'}



In D126291#3555639 <https://reviews.llvm.org/D126291#3555639>, @awarzynski wrote:

> In D126291#3555591 <https://reviews.llvm.org/D126291#3555591>, @mmuetzel wrote:
>
>> ISTR, I somewhere read that Windows isn't a supported host currently. Is this no longer the case?)
>
> Windows is supported: https://lab.llvm.org/buildbot/#/builders/172 :)

The bot just compiles flang and runs the unit-test, none of which actually try to compile, link & run a Fortan program. Until recently the flang driver would not compile itself, but delegate it to gfortran anyway.



================
Comment at: clang/lib/Driver/ToolChains/MSVC.cpp:140
+    // defined in flang's runtime libraries.
+    if (TC.getTriple().isKnownWindowsMSVCEnvironment())
+      CmdArgs.push_back("/subsystem:console");
----------------
mmuetzel wrote:
> awarzynski wrote:
> > mmuetzel wrote:
> > > Is the MSVC toolchain used anywhere else but on Windows?
> > No: https://github.com/llvm/llvm-project/blob/5fee1799f4d8da59c251e2d04172fc2f387cbe54/llvm/include/llvm/ADT/Triple.h#L576-L578 ;-) 
> In that case, this argument could probably be added unconditionally.
How do you mean this? `/subsystem:console` is a `link.exe` flag, also supported by `lld-link.exe` sind it tries to be an msvc-compatible wrapper. It is not a valid flag for eg GNU ld even in msys.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126291/new/

https://reviews.llvm.org/D126291



More information about the cfe-commits mailing list