-
Notifications
You must be signed in to change notification settings - Fork 32
Improve support of clang #158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
b4a33c4
to
52775f6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, it's a slightly nitty set of review comments - overall, I unsurprisingly like being able to add support for clang
!
I'm mechanically suggesting to capture the basename of the command - i.e. make it snapshot the fact its gcc
, cl
, clang
, etc., but don't ever allow the full path to be embedded). Given that flexlink
is essentially built as part of the compiler these days, I think it's OK to be doing it this way, rather than adding "never to be used" mechanisms for specifying the compiler on the command line (which I think we may have already talked about offline?)
Makefile
Outdated
echo 'let cygwin64 = "$(subst ",\",$(subst \,\\,$(CYG64CC)))"' >> $@ | ||
echo 'let mingw = "$(subst ",\",$(subst \,\\,$(MINCC)))"' >> $@ | ||
echo 'let mingw64 = "$(subst ",\",$(subst \,\\,$(MIN64CC)))"' >> $@ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in practice these should never end up with anything other than a compiler name, so perhaps the subst
can be omitted?
Makefile
Outdated
echo 'let msvc = "$(subst ",\",$(subst \,\\,$(MSVCC)))"' >> $@ | ||
echo 'let msvc64 = "$(subst ",\",$(subst \,\\,$(MSVCC64)))"' >> $@ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the intention - but, for example, it's not hardened against a path with an apostrophe - which is a legal character in a directory name - while quoting double-quotes, which are not. However - I think $(notdir $(MSVCC))
gets us enough?
reloc.ml
Outdated
let separator, run_through_cygpath = | ||
if Sys.win32 then | ||
if dir_exists_no_cygpath install then | ||
if install = None (* clang *) || dir_exists_no_cygpath (Option.get install) then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if install = None (* clang *) || dir_exists_no_cygpath (Option.get install) then | |
if Option.fold ~none:true ~some:dir_exists_no_cygpath install then |
(I think Option.get
then isn't needed)
Makefile
Outdated
@@ -239,6 +240,15 @@ flexdll_initer_gnat.o: flexdll_initer.c | |||
flexdll_initer_mingw64.o: flexdll_initer.c | |||
$(MIN64CC) $(GCC_FLAGS) -c -o $@ $< | |||
|
|||
build_config.ml: Makefile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, just update version.ml with the extra definitions (as things stand, you've not build_config.ml
to the clean
target but as version.ml
already had the mingw ones there 🤷♀️)
52775f6
to
75a6fcc
Compare
I've applied your suggestions, thanks! |
Record the compiler used during FlexDLL's build in a new module. In the case of MINGW* and CYGWIN64 toolchains, this allows using alternative compilers such as clang. Otherwise, FlexDLL would default to querying GCC, which may report different path list than clang. In the case of MSVC and MSVC64 toolchains, this allows using alternative compilers such as clang-cl. Otherwise, FlexDLL would default to using cl.exe, which may not be desired or even available.
`clang -print-search-dirs` doesn't print an `install` field and its `libraries` path list is already in mixed-style (Windows path with forward slashes separated by semicolons). This happens when using clang in both MSYS2 MINGW64 or CLANG64 environments. The `libraries` path list may also contain empty paths, strip them.
75a6fcc
to
f37b539
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
I'm trying to use clang everywhere. The MSYS2 CLANG64 environment uses UCRT, but we're missing bits to link with it right now. It is however possible to use clang with MSYS2 MINGW64 environment, or with Cygwin+mingw, or with the MSYS2 MSYS and Cygwin+cygwin1.dll environments (although in this last two cases clang packages are currently unmaintained).
It is also possible to use clang-cl instead of MSVC.
This PR makes sure that flexlink doesn't default to GCC or MSVC when clang is desired instead.
The first step is to retain the compilers used when building for searching library directories. This allows using alternative compilers, otherwise, FlexDLL would default to querying GCC, which may report different path list than clang.
The second step teaches FlexDLL to parse clang's output.
clang.exe -print-search-dirs
doesn't print aninstall
field and itslibraries
path list is already in mixed-style (Windows path with forward slashes separated by semicolons). This happens when using clang in both MSYS2 MINGW64 or CLANG64 environments.