mstorsjo added a comment.

In D137024#3901342 <https://reviews.llvm.org/D137024#3901342>, @mgorny wrote:

> Thanks! Let's hope it works this time.

FYI, this broke builds of mine 
(https://github.com/mstorsjo/llvm-mingw/actions/runs/3382275510/jobs/5617040099),
 but I just need to change/add a workaround so I don't think we need to revert 
it due to that.

My setup is that I'm building LLVM with `-DLLVM_INSTALL_TOOLCHAIN_ONLY=TRUE`, 
so it only installs toolchain binaries, but not files like LLVMConfig.cmake or 
the individual LLVM libraries. I then use this new toolchain to (cross-)build 
compiler-rt (and all other runtimes), to bootstrap new cross-sysroots.

Previously, the compiler-rt cmake files would pick up a distro-installed 
`llvm-config` and due to that, add systemwide install directories into the mix 
when building compiler-rt (for a potential cross target!). I worked around that 
by passing `-DLLVM_CONFIG_PATH=""` to make sure that it doesn't pick up an 
unrelated `llvm-config` binary. 
(https://github.com/mstorsjo/llvm-mingw/commit/3b96433cdf89e8ef444c6669254b386229dbddd9)
 Now after this change, it can again find unrelated `LLVMConfig.cmake` from the 
surrounding distribution, which ends up adding unexpected include directories. 
This time I'm working around it with 
https://github.com/mstorsjo/llvm-mingw/commit/486dcf32274ae6c3e0ea7916fd1e88a58742b7ca,
 by adding `-DCMAKE_FIND_ROOT_PATH=$PREFIX/$arch-w64-mingw32 
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY`, so that cmake won't find unrelated 
cmake files.

These workarounds are fine for me, but I wonder if it would be useful with a 
more direct cmake option to tell it not look for these files at all. I'm 
building out of the git monorepo checkout, so whatever source files and cmake 
scripts can be found there, but other LLVM build products (individual libraries 
etc) aren't available, and cmake shouldn't try to venture out on its own to 
find them in unexpected places.

@phosek - How does this work for general cross compilation of compiler-rt btw - 
when building compiler-rt for a cross target, but it finds `LLVMConfig.cmake` 
for the current host, and ends up including headers (and possibly more) from 
there? (If the include directory added from `LLVMConfig.cmake` is something 
like `/usr/include/llvm-15` it's probably benign, but in the msys2 cases, the 
llvm headers are installed in the toplevel include directory, so it ended up 
adding the equivalent of `-I/usr/include` in something which is supposed to be 
a cross build.) I can manually mitigate this with the `-DCMAKE_FIND_ROOT_PATH*` 
options in my case, but I don't see e.g. `llvm-project/llvm/runtimes` doing 
this anywhere?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137024/new/

https://reviews.llvm.org/D137024

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to