-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Open
Labels
Description
I'm almost ready to package Flang on Gentoo. The remaining problem is that the driver hardcodes the lib directory for libflang_rt.a:
llvm-project/clang/lib/Driver/ToolChains/CommonArgs.cpp
Lines 1361 to 1370 in 6fde8fe
| void tools::addFortranRuntimeLibraryPath(const ToolChain &TC, | |
| const llvm::opt::ArgList &Args, | |
| ArgStringList &CmdArgs) { | |
| // Default to the <driver-path>/../lib directory. This works fine on the | |
| // platforms that we have tested so far. We will probably have to re-fine | |
| // this in the future. In particular, on some platforms, we may need to use | |
| // lib64 instead of lib. | |
| SmallString<256> DefaultLibPath = | |
| llvm::sys::path::parent_path(TC.getDriver().Dir); | |
| llvm::sys::path::append(DefaultLibPath, "lib"); |
This is problematic for two reasons:
- Gentoo is using
lib64for 64-bit libraries on platforms such on amd64, andlibfor 32-bit libraries, and installing a 64-bit library intolibis generally an error. - The forced use of a single library directory makes cross-compilation / multilib builds impossible. I haven't tested how well Flang works with that yet, but at least a dumb
flang --target=i686-pc-linux-gnu hello.f90seems to work, modulo trying to link a 64-bit runtime.
I've tried fiddling a fair bit, and unfortunately I don't see any good way of getting the correct lib* directory in that code. Perhaps the correct approach would be to include the architecture in the filename the way compiler-rt does — and perhaps move it to clang's resource directory while at it?