-
-
Notifications
You must be signed in to change notification settings - Fork 194
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
wip: support using an existing clang installation #374
Conversation
This varies quite a bit among the components:
|
I have been testing @nolange's fork with I've only tested with these configurations and and I'm not building anything really complicated (but not just toy examples either) so it's not conclusive or anything, but I haven't had any issues:
I had hacked together my own much less elegant solution previously based on #59 using the same LLVM_VERSION strategy and had never encountered any compatibility problems with just the major version number matching the system llvm/clang version. |
Right - that avoids potential compatibility issues between the prebuilt clang/llvm and the runtimes - but it comes at the cost of risk of mismatches between the build scripts and the expectations in them, vs what works for the sources at the time. During the years, there's been quite a few different changes and cleanups in how the runtimes (in particular, libunwind+libcxxabi+libcxx) are built and configured. The build scripts generally should work with either the pinned version (the latest release or RC of LLVM) and the latest version from git (which is tested in nightly builds). But whenever I update the build scripts, if e.g. latest LLVM sources requires changing something, or if it allows making things cleaner/neater, I take that into use whenever I can (after updating the pinned version). A couple recent examples:
(There were lots of refactorings around the build of libcxx around 2020-2022, but I think the dust has mostly settled by now. But even still, things evolve all the time.) So going forward, if we'd have this functionality merged to be able to build with a prebuilt LLVM (sorry I haven't had time to actually look at the changes in the branch yet), the safest thing would probably be to check out a contempory version of llvm-mingw, matching the prebuilt LLVM/Clang (possibly overriding |
@mstorsjo thanks for the explanation I think ideally the compiler-rt builtins could be provided by the system clang, they only depend on mingw headers (and there likely some basic stuff like Picking the current supported LLVM version seems to be the most sane to me, but some options would be nice in the future:
Hope I will find some time next week |
# link the header directory, prevent modification | ||
ln -snf $resdir/include $PREFIX$clangres/include | ||
|
||
# Note: clang will detect the "InstalledDir" based on the path that was used to invoke the tools |
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.
Can you elaborate on this comment? In principle, won't this odd/unexpected feature essentially mean that the whole wrapper script that you generate below wouldn't be necessary? It would be good to make the comment clearer, to indicate that while this behaviour exists, we choose not to rely on it, because of reasons X and Y (which reasons?), and instead use a wrapper script. I guess the "This might still have some hidden effects" comments is that, somewhat, i.e. we could do that but choose not to since we don't know what implications it might have?
Just spelling it out a bit more explicitly would be helpful at least.
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.
The note is primary to myself, precisely because I dont know and cant explain if this might be an issue.
% clang -v
Debian clang version 17.0.2 (1~exp1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/12
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/12
Candidate multilib: .;@m64
Selected multilib: .;@m64
vs.
% /usr/lib/llvm-17/bin/clang -v
Debian clang version 17.0.2 (1~exp1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-17/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12
Candidate multilib: .;@m64
Selected multilib: .;@m64
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.
Left this open - anything to do here?
Its the way it is because I dont know better
Bwt. I managed to build via CI, but I am not used to Github: https://github.com/nolange/llvm-mingw/tree/wip Some pointers there? probably should copy or parameterize linux+asserts and try compiling ffmpeg? |
Hmm. It's probably easy to tweak some of the existing jobs to test this; not sure what the best way as a permanent place in the build graph would be... Most of the github actions build pipeline is built on one job producing a relocatable package, which is packed up and transferred to the next job, where it's unpacked and used. For a toolchain that is built to use the distro clang, that is much less of a redistributable package - although it practically works as long as both steps have e.g. the same version of Clang installed. Just building it and running |
add an option --host-clang which will skip building llvm, and instead provide symlinks and wrappers for clang and llvm tools. Currently the clang version is detected, but it does not affect the llvm version that will be downloaded and used.
Should've addressed all open points. some CI integration is in another branch: https://github.com/nolange/llvm-mingw/tree/wip |
Thanks! I think this looks good at this point. I tried doing a different kind of testing for it, by doing a build within docker, which allows controlling more exactly what files are available and what aren't, and a manual job that one can trigger to test building this within GHA, see https://github.com/mstorsjo/llvm-mingw/commits/system-clang. If you don't mind, I think I'll go ahead and merge it with this kind of testing setup in the near future. |
@mstorsjo: I certainly don't mind if this finds its way upstream, its self-contained enough so that changes can be done in future MRs. |
Ok, I've merged those patches now then, so I guess this PR can be closed. |
You could've just... you know... accepted the PR? |
Oh, right, indeed, sorry about that. At some point I considered if I wanted to tune some of the commits before merging, but I guess I could have done that by pushing to your branch and then merging the PR as well. Anyway, thanks for the contribution! |
add an option --host-clang which will skip building llvm, and instead provide symlinks and wrappers for clang and llvm tools.
Currently the clang version is detected, but it does not affect the llvm version that will be downloaded and used.
The functionality is so far only tested on debian 12 with a backported clang-17 from experimental. Unfortunately the default version is still clang-14.
To install the default clang for debian 12:
There exist still some issues I would want to resolve to make this a working "addon" using the system clang.
bin
for building llvm-mingw it doesnt matter much, but the final installation should be leaner.