-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
linkers: don't include absolue RPATH on cross-compiling #15110
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
base: master
Are you sure you want to change the base?
Conversation
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.
On top of this on cross-compilation on 99% of the scenario, it's not really possible to run the just built tool for build usage as it probably target a different arch.
Assuming that nobody falls into the 1% case is an absolute deal breaker. At minimum, this PR cannot even be considered unless it continues to use rpaths when cross compiling but the resulting executables are runnable.
More generally, Meson was explicitly designed to support this use case via exe_wrapper set in your cross file, and APIs such as meson.can_run_host_binaries()
.
It is absolutely vital to have such support, if one wishes to allow users to for example run testsuites during cross builds. It also allows things such as running cross-built compiletests (cc.run()
and suchlike).
While I would like to aid reproducibility too, it is NEVER acceptable to prevent a subset of users from being able to build at all, just for the sake of a different subset benefiting from reproducible builds.
The environment object tracks both the need for, and the presence of, an exe wrapper. See e.g. meson/mesonbuild/interpreter/mesonmain.py Lines 267 to 275 in 019d960
We could use that to narrow the impact of this change to an acceptable level. I'm still interested in opinions from other team members regarding whether it feels right to use different compile arguments based on this, though. |
@eli-schwartz thanks a lot for the comments. The alternative might be to introduce a toggle to disable adding the RPATH in build stage but I don't want to follow that path... Thanks for pointing out _can_run_host_binaries_impl In the meantime I will update this to use that instead of the simple is_cross_build(). I honestly think it's a good compromise for this. |
Right, this would allow every person building something to make a personal decision "do I want tests to work or do I want to avoid build time rpaths". But the downside is that people have to choose. :D I know that @jpakkane is nervous to add too many built-in options as it tends to clutter up the |
6d38993
to
505653c
Compare
To permit usage of can_run_host_binaries() in other location, move it to environment. This will be needed in linker to decide if external library should be included in RPATH entry. Signed-off-by: Christian Marangi <[email protected]>
There is currently a reproducible problem when cross-compiling with the inclusion of external shared library RPATH entry. Meson normally includes RPATH entry to permit the usage of the tool in the build process and later removes it on the intall phase. This might be ok and permits creating reproducible build to some degree when building on host (as we can expect the shared library are always placed on a standard directory path and have a consistent RPATH) This doesn't apply for cross-compilation scenario where the shared library might be provided from an arbritrary directory to be later packed in the final system (for example a squashfs image) On top of this on cross-compilation on 99% of the scenario, it's not really possible to run the just built tool for build usage as it probably target a different arch (unless the project provide an exe_wrapper). To permit building REAL reproducible binary, add extra logic to skip the inclusion of such library path in RPATH if we detect a cross-compilation scenario and limit the inclusion of library path in RPATH only to relative path (expected to be the ones specific to the building binary/internal shared library) if we detect the binaries can't be run on the host system (by the use of can_run_host_binaries() API). Signed-off-by: Christian Marangi <[email protected]>
505653c
to
432a43a
Compare
@eli-schwartz I updated the thing to use the helper (I also had to move it) What do you think? |
There is currently a reproducible problem when cross-compiling with the inclusion of external shared library RPATH entry. Meson normally includes RPATH entry to permit the usage of the tool in the build process and later removes it on the intall phase. This might be ok and permits creating reproducible build to some degree when building on host (as we can expect the shared library are always placed on a standard directory path and have a consistent RPATH)
This doesn't apply for cross-compilation scenario where the shared library might be provided from an arbritrary directory to be later packed in the final system (for example a squashfs image)
On top of this on cross-compilation on 99% of the scenario, it's not really possible to run the just built tool for build usage as it probably target a different arch.
To permit building REAL reproducible binary, add extra logic to skip the inclusion of such library path in RPATH if we detect a cross-compilation scenario and limit the inclusion of library path in RPATH only to relative path (expected to be the ones specific to the building binary/internal shared library)