[llvm] [Bazel] Make LLVM and Clang config headers configurable (PR #126729)
Jordan Rupprecht via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 14 20:44:59 PST 2025
rupprecht wrote:
We tried to do something like this a couple years ago and it landed as e2ee8bf9818189b900e65d6ea8f1ae6fc75455ce, but was reverted as 17296607a761086b2c0e6518ceaa16415dceb55b. I looked at the internal bug and it seems the need to revert no longer applies so much, but we never got around to relanding it.
It's honestly impressive you got this working in bazel at all, because the language is extremely limited for this kind of thing. AFAIK there isn't a way to have bazel itself open a file and process it, it can just do expand_template with a dict. That's why you have to manually specify `ENABLE_BACKTRACES` with the `cmakedefine01` helper, but `HAVE_BACKTRACE` with the different `cmakedefine` helper; whereas with something that shells out to a script can just pass `["ENABLE_BACKTRACES=1", "HAVE_BACKTRACE=1"]` and let the script take care of the difference between `#cmakedefine01` and `#cmakedefine` in the config.h.cmake template.
By default, llvm/utils/gn/build/write_cmake_config.py is a reasonable first pick for such a script, but it doesn't need to be -- we could write a new one, or even `cmake -P` kinda works, if we can rely on cmake existing on the build host.
https://github.com/llvm/llvm-project/pull/126729
More information about the llvm-commits
mailing list