-
Notifications
You must be signed in to change notification settings - Fork 26
Add option to build with a LLVM prefix or LLVM with suffix instead of system LLVM/in-tree LLVM #61
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
base: master
Are you sure you want to change the base?
Conversation
This patch allows the use of a LLVM prefix instead of system or built in-tree LLVM, this is part of the effort to distribute gnat-llvm in alire.
8c6ebbe to
4481069
Compare
|
Thanks for working on the Alire integration! If I understand correctly, you're adding a new way to locate LLVM by specifying a path in |
To be honest, it might be the case I was frustrated because of the many issues I was having with system llvm, and missed that, I would say that just the bit about |
It may even already be possible to do that by setting both |
|
I attempted to override the variables via env, and that much I'm sure wasn't working as there's the if that checks if |
ifneq ($(wildcard $(LLVM_BUILD_DIR)/bin/llvm-config),)
LLVM_CONFIG=$(LLVM_BUILD_DIR)/bin/llvm-config
LLVM_SRC=$(shell cd `$(LLVM_CONFIG) --includedir`/../..;pwd)
CLANG_CXXFLAGS=-I$(LLVM_BUILD_DIR)/tools/clang/include -I$(LLVM_SRC)/clang/include
else
...this if to be precise |
|
Sorry, environment was the wrong word; I usually set them via the command like, as in |
|
I guess what I'm trying to say is if you have LLVM installed in |
|
yeah, |
|
Oh, now I get it, sorry - |
|
I'm just trying to see if there's a way to avoid the duplication between the |
I can look into making it that way, you have a good point on this. |
|
And then the "default" way of building would change to always be |
|
That's what I was thinking, yes. Or we could default to I think this should do it: LLVM_CONFIG=$(pwd)/../llvm/llvm-obj/bin/llvm-config
CLANG_CXXFLAGS=-I$(shell $(LLVM_CONFIG) --prefix)/tools/clang/include -I$(shell cd `$(LLVM_CONFIG) --includedir`/../..;pwd)/clang/includeReplacing all the checks... |
|
I think the default of in tree llvm is less effort for everyday development and if you then need to make proper binaries with out of tree llvm there's a clear path, I guess it's adacore's team choice on this one. |
|
To be honest, most of us don't use the in-tree LLVM but instead get the latest LLVM artifacts from the internal build servers and activate them via There's a minor inconvenience still: We always need |
I'm not sure I get what you mean by |
|
Also, I uderstood your opt comment, forgot there's an llvm binary named opt 🤦🏻. edit: I looked at the Makefiles but there's not really a call to |
This doesn't work because the root makefile calls the other makefiles, and this was breaking passing it as a make parameter, I had to make a change so it uses an envvar, check the patch as to how it ended up looking. |
|
Also, should I update the readme with new build instructions or do you want to do it on your end? |
I may be misunderstanding, but doesn't Make forward all its variables to child instances? When I run my |
Interestingly, for me it fails if I use the patch exactly as you proposed, but with the if I re-inserted it works and builds from the project root 🤷🏻♂️. |
|
Would you mind sharing the build output when it fails despite the parameter? I'm curious why it should fail 😊 |
make clean
make LLVM_CONFIG=$HOME/.local/opt/llvm-19.1.7/bin/llvm-config -jstderr: from what I can tell it is breaking at linking for some weird reason. |
|
Which include paths does it pass to the compiler at the very beginning of the log, when we build Also, the first line of your log is a complaint that |
I will check too, but if you are interested, here is the full output edit: |
|
And for debug sake, here is a success build: LLVM_CONFIG=$HOME/.local/opt/llvm-19.1.7/bin/llvm-config makeedit: looking at this log the same issue with |
|
I tried to compare the build commands for |
I made sure to run make clean between builds, but to make sure here is the command: make clean; LLVM_CONFIG=$HOME/.local/opt/llvm-19.1.7/bin/llvm-config make 2>&1 | tee good.logand the log |
|
The build command for
As for why the build with the Make parameter failed, I now suspect that it's something unrelated: We've occasionally seen race conditions somewhere in the build system when it's run with |
I will try without '-j', and no the second path is wrong, I will double check the makefile and the paths. |
|
|
|
There this should be a good final version of the patch, it builds reliably and I also fixed the include paths. |
|
I'm not sure about the include paths: CLANG_CXXFLAGS=-I$(shell `$(LLVM_CONFIG) --includedir`)/clangWhen I run a build locally, this line gets the include dir from llvm-config but then tries to interpret it as a shell command: I think the reason why the build still works is that the directory layout differs between LLVM installations and build trees:
If you confirm that your build works with an LLVM installation even with empty |
Hey, yeah, it works, with |
|
Also do you want to put that in a separate patchset or keep it in this one? |
|
I think we'll have to fix it as part of this one because the old code worked with a build tree, whereas the proposed new version doesn't. I'm not sure that we actually need to detect build trees specifically. Since the installation case works without any special flags, we could assume a build tree and set |
Ok, I will look into it tomorrow :) |
|
I think this should work (in addition to your changes in the other files): LLVM_CONFIG ?= llvm-config
# If llvm-config belongs to an installation of LLVM, then its include directory
# is going to contain everything we need. Otherwise, if llvm-config belongs to a
# _build tree_, we need to add an extra directory because the Clang headers
# won't be in `llvm-config --includedir`.
CLANG_CXXFLAGS :=
CLANG_INCLUDE_DIR := $(abspath $(shell $(LLVM_CONFIG) --includedir)/../../clang/include)
ifneq ($(wildcard $(CLANG_INCLUDE_DIR)/.),)
CLANG_CXXFLAGS := -I$(CLANG_INCLUDE_DIR) -I$(abspath $(shell $(LLVM_CONFIG) --obj-root)/tools/clang/include)
endifIt turned out that we do need I tried this with both an LLVM installation and a build tree, setting only |
|
Hey, I didn't have much spare time this week, I will look during the weekend
…On Fri, Jan 16, 2026 at 10:19 PM Sebastian Poeplau ***@***.***> wrote:
*sebastianpoeplau* left a comment (AdaCore/gnat-llvm#61)
<#61 (comment)>
I think this should work (in addition to your changes in the other files):
LLVM_CONFIG ?= llvm-config
# If llvm-config belongs to an installation of LLVM, then its include directory# is going to contain everything we need. Otherwise, if llvm-config belongs to a# _build tree_, we need to add an extra directory because the Clang headers# won't be in `llvm-config --includedir`.CLANG_CXXFLAGS :=CLANG_INCLUDE_DIR := $(abspath $(shell $(LLVM_CONFIG) --includedir)/../../clang/include)
ifneq ($(wildcard $(CLANG_INCLUDE_DIR)/.),)
CLANG_CXXFLAGS := -I$(CLANG_INCLUDE_DIR) -I$(abspath $(shell $(LLVM_CONFIG) --obj-root)/tools/clang/include)endif
It turned out that we do need <build_dir>/tools/clang/include because it
contains clang/Basic/DiagnosticGroups.inc, a transitive dependency of our
C++ code.
I tried this with both an LLVM installation and a build tree, setting only
LLVM_CONFIG. The variable can be set via the command line or the
environment. Would you mind checking whether it works in your setup too?
—
Reply to this email directly, view it on GitHub
<#61 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABD5R2WE3EFNKT2J2DZPI7T4HFIW3AVCNFSM6AAAAACQO4HXXOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTONRRHA2DQMJRHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
This patch allows the use of a LLVM prefix instead of system or built in-tree LLVM, this is part of the effort to distribute gnat-llvm in alire.