-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
stdenv: don't set NIX_LIB*_IN_SELF_RPATH by default #223861
Conversation
Hey, thank you for the change, such changes triggers mass rebuilds, therefore you need to target staging, I will let you read carefully the CONTRIBUTING guide to understand how to do it without masspinging everyone, in the meantime, I will put this PR to draft. |
${lib.optionalString (system == "x86_64-linux") "NIX_LIB64_IN_SELF_RPATH=1"} | ||
${lib.optionalString (system == "mipsel-linux") "NIX_LIB32_IN_SELF_RPATH=1"} |
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'm afraid it's not that easy and depends on specific ports.
In theory non-multilib targets should just use lib
. In practice what is a multilib has a moot definition: for example x86_64-linux-glibc
is always multilib while x86_64-linux-musl
is (or, should be) never multilib.
You can see remnants of multilib in gcc
itself:
$ gcc -print-multi-os-directory
../lib64
Sometimes packages are diligent enough to have lib -> lib64
symlink (or the other way around). Sometimes they are not.
The question here is: What API do we expect for nixpkgs
to provide and packages to use for non-multilib? Is it always lib
or something else (lib64
)? Today we do both with lib64
being a canonical path.
This change effectively says lib64
is not considered anymore as a searchpath.
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 I follow, and quite possibly this change is too ambitious. My naïve thinking was that given the explicit dependencies of Nix, there shouldn't ever be multiple library search paths, only one set of paths per target.
However, assuming nixpkgs wants to keep the NIX_LIB*_IN_SELF_RPATH
API, this change also fixes what I consider a genuine bug: that NIX_LIB*_IN_SELF_RPATH
are set according to the build platform, not the target platform.
See #221350 for an example where the builder platform (x86_64-linux vs aarch64-linux) decides whether NIX_LIB*_IN_SELF_RPATH
is set, not the target platform which is the same (and non-multilib).
So, can I move the setting of NIX_LIB*_IN_SELF_RPATH
somewhere that depends on the target/host platform? pkgs/stdenv/linux/default.nix
is itself prefixed with
assert crossSystem == localSystem;
and thus cannot decide whether to set NIX_LIB*_IN_SELF_RPATH
. No?
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.
Cross-compilation case is a great point! I'll spend some time today to understand how nixpkgs
plumbs rpath
details there and get back.
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.
Is it fair to say NIX_LIB*_IN_SELF_RPATH
should only be set for multiStdenv
? If so, the variables could be set conditionally there.
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.
Is it fair to say NIX_LIB*_IN_SELF_RPATH should only be set for multiStdenv? If so, the variables could be set conditionally there.
Ideally (if non-multilib environment used lib
everywhere consistently) - yes. In practice I don't think we are there yet. We probably want both lib
and lib64
to still be pulled in. Normally I would expect NIX_LDFLAGS
to apply to host toolchains (and NIX_LDFLAGS_FOR_BUILD
/ NIX_LDFLAGS_FOR_TARGET
be disambiguating variables).
On the other hand looking at the history far back it was added before cross-compilation was a well-supported target: d9213df . It probably outlived it's purpose and we have many other ways to influence the driver.
Let's try your change as is and see if it works on multilib.
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.
Let's try your change as is and see if it works on multilib.
Nice, thank you.
It probably outlived it's purpose and we have many other ways to influence the driver.
By "other means to influence the driver", do you mean the corresponding (and only) users of the NIX_LIB*_IN_SELF_RPATH
,
nixpkgs/pkgs/stdenv/generic/setup.sh
Lines 314 to 319 in 2ba1f86
if [ -n "${NIX_LIB64_IN_SELF_RPATH:-}" ]; then | |
export NIX_LDFLAGS="-rpath $1/lib64 ${NIX_LDFLAGS-}" | |
fi | |
if [ -n "${NIX_LIB32_IN_SELF_RPATH:-}" ]; then | |
export NIX_LDFLAGS="-rpath $1/lib32 ${NIX_LDFLAGS-}" | |
fi |
should be removed as well?
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.
Yeah, let's remove those as well.
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.
Done.
451b831
to
02df378
Compare
@RaitoBezarius retargeted |
you nailed it :) |
${lib.optionalString (system == "x86_64-linux") "NIX_LIB64_IN_SELF_RPATH=1"} | ||
${lib.optionalString (system == "mipsel-linux") "NIX_LIB32_IN_SELF_RPATH=1"} |
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.
Is it fair to say NIX_LIB*_IN_SELF_RPATH should only be set for multiStdenv? If so, the variables could be set conditionally there.
Ideally (if non-multilib environment used lib
everywhere consistently) - yes. In practice I don't think we are there yet. We probably want both lib
and lib64
to still be pulled in. Normally I would expect NIX_LDFLAGS
to apply to host toolchains (and NIX_LDFLAGS_FOR_BUILD
/ NIX_LDFLAGS_FOR_TARGET
be disambiguating variables).
On the other hand looking at the history far back it was added before cross-compilation was a well-supported target: d9213df . It probably outlived it's purpose and we have many other ways to influence the driver.
Let's try your change as is and see if it works on multilib.
@ofborg build tests.cc-multilib-gcc |
02df378
to
3ecb6e1
Compare
The NIX_LIB64|32_IN_SELF_RPATH environment variables control whether to add lib64 and lib32 to rpaths. However, they're set depending on the build paltform, not the target platform and thus their values are incorrect for for cross-builds. On the other hand, setting them according to the build platform introduce pointless differences in build outputs; see NixOS#221350 for details. This change fixes the issues by boldly removes the NIX_LIB*_IN_SELF_RPATH facility altogether, in the hope that it is no longer necessary. They were introduced in 2009, long before nixpkgs had good support for cross-builds. Fixes NixOS#221350
3ecb6e1
to
88fd660
Compare
@ofborg build freshBootstrapTools.mips64el-linux-gnuabin32 |
Hey, I'm generally in favor of the goal here. I need a bit more time to review this; I recall from the last time I dealt with this stuff that it was hairy.
To test the effect of this deletion requires MIPS hardware (i.e. a native build) which Hydra doesn't have: nixpkgs/pkgs/stdenv/linux/default.nix Line 119 in 77c642a
I'm working on starting a build on one of my mips machines to confirm this. |
Alright, started on a mips64 host, which can native-compile mips32:
Needed #224325 (I thought I fixed the mips32-seccomp-sandbox-on-mips64-hosts situation, but I guess not... needed |
It's on the final (stage4) build of @trofi were you planning on merging this now or after the |
Waiting should be fine. |
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.
LGTM if we can wait until staging
branch-off on 2023-May-15.
Built on:
-
mipsel-linux
Thank you for the review! As I understand it, cache.nixos.org won't have packages with this PR applied in at least 40 days. |
Yeah, it's a bit unfortunate timing before a next major release preparation. Past history shows that we need to make sure toolchains are not too broken before we pull in major desktop environment updates right before NixOS release (like Note that I personally use Otherwise large-scale changes with many incremental steps might warrant a separate jobset on hydra to allow multiple iterations to get something into shape. This approach is usually used for |
I considered enabling content-adressing, however it's my understanding it won't help because this PR does change the binaries (in particular, |
Yeah, in this case it does change |
I suppose what you're saying is to keep working on reproducibility, ignoring this problem. That may work. However, I did see another indeterministic variation in binaries output by gcc that I suspect are caused by object files being different. |
Yup. Or use this change locally and keep getting world rebuilds. |
This is so cool; I really need to start doing it.
@eliasnaur I see you noticed the problem with that... |
Indeed. I hope to avoid some/all use of |
Similar to PR NixOS#223861 and the issue NixOS#221350, NIX_COREFOUNDATION_RPATH is set unconditionally in the darwin stdenv. This is wrong for cross- compiles and results in `rpaths` depending on the builder platform. This change makes another bold move and deletes the NIX_COREFOUNDATION_RPATH facility completely, in the hope it is no longer needed, or that any breakage is manageable. As an added bonus we can delete a darwin specific hack in glibc.
Can this be merged now that the branch-off date has passed? |
Now that the staging restrictions doesn't apply anymore, I believe this can proceed with standard reviewing as far as I know. |
Branch off is in 5 days though. |
Yeah, branch-off was an unfortunate label, sorry. I referred to the unrestricting of breaking changes to |
Let's pull it in. |
There doesn't seem to be a point in having separate /lib64 nor /lib32 directories in rpath in NixOS. Further, the setting of the environment variables
NIX_LIB64|32_IN_SELF_RPATH
depends on the build platform, not the target platform; see details in issues #221350.Fixes #221350
This change removes a Chesterton's Fence, and so is probably incomplete as is. I'm posting it anyway to start the discussion: only packages that need
NIX_LIB64|32_IN_SELF_RPATH
should define them, and only for the required target platforms. If possible, support forNIX_LIB64|32_IN_SELF_RPATH
should be removed altogether.Tested with
nix run .#hello
. I can test with a more representative package set once the approach is validated.Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)