this is a follow-up of #2111, where it became clear that the currently supported clang[-X] does not work with clang-cl by simply overwriting the environment like make GXX="clang-cl" CXXFLAGS="/EHsc ..." ...
It will allow to build Visual C++ codes, especially those that make direct use of Microsoft CRT and Windows SDK (which can be installed on Linux using xwin).
What might be a solution?
The main problem with clang-cl and its linker lld-link is their command line options dont work the same way as the g++ and ld duo. Specifically:
In order to link against CRT and SDK things one needs to 1) tell clang-cl to use lld-link instead of the GNU ld and 2) pass their installation paths down to lld-link, for example like so:
This however does not work cause the /link parameter (of lld-link) must be the very last thing of the command constructed, since everyting after /link gets passed to the linker. This does not happen the way linking is currently done in GNU style by constructing a command like $CXX $LDFLAGS ... <objects> -o <lib or exe>
I see two possible solutions:
1) construct a link command that respects /link with everything thereafter being last
2) link more Windows style by constructing a linker command from $LD, in which case the -fuse-ld=lld-link param would not be necessary and it would still need to respect the position of /link ...
(right now $LD does not appear to me supported at all by the generated makefiles)
What other alternatives have you already considered?
There are none as far I see and tried; its ether supported or its not.
Anything else we should know?
Distributions like Ubuntu package clang-cl with version numbers; which means the actual commands are clang-cl-14 or clang-cl-12 and lld-link-14 or lld-link-12 or whatever version the user installed. So a optional version number should be supported, same way as the current clang toolset does (when #2113 is released).
this is a follow-up of #2111, where it became clear that the currently supported
clang[-X]
does not work withclang-cl
by simply overwriting the environment likemake GXX="clang-cl" CXXFLAGS="/EHsc ..." ...
this is due to the nature of clang-cl being a LLVM frontend specifically compatible to Microsofts Visual C++ compiler, see https://clang.llvm.org/docs/UsersManual.html#clang-cl.
What problem will this solve?
It will allow to build Visual C++ codes, especially those that make direct use of Microsoft CRT and Windows SDK (which can be installed on Linux using xwin).
What might be a solution?
The main problem with
clang-cl
and its linkerlld-link
is their command line options dont work the same way as theg++
andld
duo. Specifically:In order to link against CRT and SDK things one needs to 1) tell clang-cl to use
lld-link
instead of the GNUld
and 2) pass their installation paths down tolld-link
, for example like so:This however does not work cause the
/link
parameter (oflld-link
) must be the very last thing of the command constructed, since everyting after/link
gets passed to the linker. This does not happen the way linking is currently done in GNU style by constructing a command like$CXX $LDFLAGS ... <objects> -o <lib or exe>
I see two possible solutions:
1) construct a link command that respects
/link
with everything thereafter being last2) link more Windows style by constructing a linker command from $LD, in which case the
-fuse-ld=lld-link
param would not be necessary and it would still need to respect the position of/link ...
(right now $LD does not appear to me supported at all by the generated makefiles)What other alternatives have you already considered?
There are none as far I see and tried; its ether supported or its not.
Anything else we should know?
Distributions like Ubuntu package clang-cl with version numbers; which means the actual commands are
clang-cl-14
orclang-cl-12
andlld-link-14
orlld-link-12
or whatever version the user installed. So a optional version number should be supported, same way as the currentclang
toolset does (when #2113 is released).