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

Diana Picus via Phabricator via flang-commits flang-commits at lists.llvm.org
Wed Jun 1 01:37:39 PDT 2022


rovka added a comment.

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

> In D126291#3547023 <https://reviews.llvm.org/D126291#3547023>, @rovka wrote:
>
>> With this patch in place, we still need to add `-Xlinker -subsystem:console' in order to compile a simple 'Hello World' to run from the console.
>
> Is this behavior consistent with "clang.exe"? Also, any clue why is this needed? Some documentation here <https://docs.microsoft.com/en-us/cpp/build/reference/subsystem-specify-subsystem?view=msvc-170>. I've scanned it and am no wiser :/

Yep, it is consistent with clang. I tried running both `clang-cl.exe` and `clang.exe` on a `hello.cpp` and in both cases I get a civilized error from lld saying "lld-link: error: subsystem must be defined". 
I've read those docs too and I think the main takeaway is that it sets the entry point for the program. There's a nice table <https://docs.microsoft.com/en-us/cpp/build/reference/entry-entry-point-symbol?view=msvc-170#remarks> that suggests that passing in `/subsystem:console` ultimately leads to `main` being called, which is definitely what we want, since that's what we're linking in via `Fortran_main`.
Now, it could be the case that for Fortran we could hardcode the subsystem since people probably (?!) don't write kernel mode drivers or boot applications in Fortran, but I'm not so sure about the GUI stuff (i.e. the windows subsystem). Since I don't know enough about these things, I'd rather leave users the option to use whatever subsystem they like (and hope things won't break just because we're linking in `Fortran_main.lib`). I'd love to hear more opinions though.


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

https://reviews.llvm.org/D126291



More information about the flang-commits mailing list