-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix ninja cannot find the library when libraries contain symlinks. #12808
Conversation
What exactly is the purpose of such a symlink, anyway? |
glibc is installed to /lib64/lp64d or /lib64/ilp32 by default on RISC-V, instead of the common /lib64 |
That doesn't tell me the purpose of the symlink... It sounds like a Fedora bug, frankly. |
The symlink is weird, but the path is perfectly correct and resolvable:
It's just generated as a side effect of how GCC concatenates its directory paths. Combined with the fact that on RISC-V (any Linux distro) GCC uses subdirectories for each RISC-V subarch, but Linux distros want to put their libraries in The same thing could happen on any platform that uses a particular type of symbolic link in GCC search paths, so it's clearly a meson bug that it cannot resolve this type of symlink. Note also libtool, cmake, etc (in fact every other build system that Linux uses) has no problem here. |
"A particular type of symbolic link" is definitely one way to describe an infinite symlink loop. Not sure I agree with the "perfectly correct" part though. |
This is a valid symlink, The symlink exist so that we could have both |
It's not an infinite symlink loop. |
Looking at the current (pre-patch) code:
what is it that can raise Since we are expecting all these paths to exist, why not just resolve them all using |
I confirmed by testing it that the patch posted by @U2FsdGVkX1 does fix the issue on Fedora/RISC-V. (I'm not claiming it's the best or only way to fix the problem though, as I'm still not quite sure I understand what that function is doing.) |
It was claimed above, that the following is a symlink:
The answer is, as with all good answers, "it depends". Perhaps if you check the date the code was added it can provide a hint. |
An infinite loop symlink points to itself, eg:
This symlink does not point to itself, and realpath is able to resolve it without loops.
It was added in aa20c91 (2018) and in Python 3.6 the strict default was changed. So that indicates meson should have added
@U2FsdGVkX1: The patch needs to be updated to deal with this. |
I have updated the patch and it also fixed the symlink issue |
try: | ||
resolved = pathlib.Path(p).resolve().as_posix() | ||
resolved = pobj.resolve(True).as_posix() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this won't work on Python 3.5 as it won't be expecting the strict
argument to be present at all. Not sure how to solve that except by bumping the minimum version or introspecting somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this won't work on Python 3.5 as it won't be expecting the
strict
argument to be present at all. Not sure how to solve that except by bumping the minimum version or introspecting somehow.
meson now requires Python 3.7 minimum version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed you are right - I still had an old branch checked out while I was looking for the commit above. So yes, this should be fine.
If there're weird symlinks in the system like Fedora RISC-V
/lib64/lp64d -> /lib64
and glibc is installed to /lib64/lp64d
When calling cxx.find_library, it will first search for /lib64/lp64d/../lib64/lp64d/
meson/mesonbuild/compilers/mixins/clike.py
Line 205 in 2fbc7b5
meson/mesonbuild/compilers/mixins/gnu.py
Line 475 in 2fbc7b5
Then generate linkargs ['/lib64/lp64d/../lib64/lp64d/libbz2.so']
which will cause ninja build fail: ninja-build/ninja#1330
Here is a simple example
According to the commit history, the issue was introduced in this commit that inserts the unresolved variable to paths to avoid systemd test fail.
I don't know if the workaround mentioned above is still required now, so I temporarily adjusted the priority in my patch for compatibility.
CC: @rwmjones @davidlt