-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
[Flang] Driver hardcodes lib/libflang_rt.a
path that is incorrect on lib64
systems, and does not permit multilib
#127538
Comments
Oh, and for completeness: we are installing the whole LLVM into per-version prefixes, so that different versions can be used simultaneously. So we can't just rely on the linker picking up the library from |
@llvm/issue-subscribers-flang-driver Author: Michał Górny (mgorny)
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
This is problematic for two reasons:
I've tried fiddling a fair bit, and unfortunately I don't see any good way of getting the correct |
It looks like gcc installs libgfortran and libstdc++ to its equivalent of a resource directory. It seems like a reasonable place to put it. But we should try to be consistent with libc++, which is the closest equivalent in the LLVM project. |
Is flang_rt compatible across different Flang versions? I.e. is it fine to, say, use |
I am not sure. Perhaps someone more knowledgeable about the runtime can give you a more definitive answer, @klausler @kiranchandramohan @jeanPerier @clementval |
There is no such guarantee. The runtime API do evolve from time to time and some may be removed/modified. The Fortran runtime is not a "standard library", it is tightly connected to the compiler, so it is more similar to compiler-rt in terms of compiler/runtime interaction, even though its features are comparable to libc++. |
Yeah, so I think clang resource dir would work best. FWICS the standalone runtimes build already attempts installing it somewhere like that, except that I don't think the driver actually checks that location. |
At the moment flang does not support cross-compilation. Even if flang accepts #110217 ( I see you also opened #127345, the library where libflang_rt.runtime.a and the driver searches for them must be in-sync, ideally also with clang/compiler-rt. Unfortantely, it's total chaos (together with |
To elaborate, this is the reason why |
Just to add a bit of context; flang does support cross compilation in practice between "similar" targets, ie 64 bit targets where the sizes of the types are the same. I've used it myself to cross compile from x86_64-linux to aarch64-linux, as well as from aarch64-linux to aarch64-win32, and it has worked well in those cases. It's certainly under tested though, and you have to hope that the platforms you're using have the same eg integer widths. I'm also not aware of anyone having tested flang on any kind of 32 bit architecture. It's almost certainly impossible to do a build of flang itself in 32 bit because of memory requirements; I suppose you could cross compile it (it's just a C++ programme after all) but I'm not aware of that having been tested by anyone. I don't think any of this should be a mark against a distributor's desire to have lib only contain 32 bit libraries and lib64 contain only 64 bit binaries though. It does sound to me like taking the same approach as clang takes for compiler-rt would be the best path forward. Would we be able to invent a flang resource dir using the same logic as clang uses for its equivalent, and use that as the location for libflang-rt? |
Not just type widths, but also alignment rules, which causes structs to have different sizes etc. x86_64 and aarch64 might mostly work, since both are LP64 ( I don't think we should claim any level of "supported" as long as there are such known miscompilation issues. Otherwise users/clients will use it, their program crashes unexpectedly, nobody can reproduce it until we're told that they were cross-compiling, and rightfully blame us for it. At least I want to tell them they were not supposed to do cross-compilation. |
For 32 bits the doc is pretty clear.
For cross compilation to other 64bits target nobody ever claimed that is was implemented and/or tested so I would not use it in production until somebody spend the time to make the adjustment to make it work 100%. |
Yeah, I wasn't trying to suggest that anyone should use it in production as of yet, only that it does work in some cases, and that we should try not to put any more blockers in place for when we do want to make it work in more/all cases. |
Well, that's pretty much what multilib is about, but I didn't plan on doing that. At this point, I'd like to see 32-bit platform support fixed in MLIR first (but can't really find time to look into it), as it's going to be required for ClangIR. That said, the memory requirements are a problem on 64-bit platforms as well. With 32G RAM here, I have to build Flang with |
I'm seeing an error on macOS that seems related to this issue:
Adding
I can work around it by explicitly passing the directory where
It's interesting that |
See #127364 |
I didn't go through all the comment, but PR #134362 may fix this. The driver will search for the full path to |
I'm almost ready to package Flang on Gentoo. The remaining problem is that the driver hardcodes the
lib
directory forlibflang_rt.a
:llvm-project/clang/lib/Driver/ToolChains/CommonArgs.cpp
Lines 1361 to 1370 in 6fde8fe
This is problematic for two reasons:
lib64
for 64-bit libraries on platforms such on amd64, andlib
for 32-bit libraries, and installing a 64-bit library intolib
is generally an error.flang --target=i686-pc-linux-gnu hello.f90
seems 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?The text was updated successfully, but these errors were encountered: