-
-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Static proot, wafHook cross compilation #58504
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
Conversation
this is necessary for talloc
These options are forcefully added by pkgsStatic but are not understood by waf.
waf does support --build and --host, but the only effect of these options is an error message telling to use --cross-compile instead. So we ignore these flags.
for this to work, wafHook must be in nativeBuildInputs.
if [[ | ||
# waf does not support these flags, but they are "blindly" added by the | ||
# pkgsStatic overlay, for example. | ||
$flag != "--enable-static" |
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.
Perhaps we should have some separate variable like "wafFlags" for this? waf supports a subset of the configure flags but not enough apparently.
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.
This would be a more invasive change. Would you prefer I change the PR to do this?
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.
It's okay as is for now. This is more a note on this.
substitutions = { | ||
inherit waf; | ||
crossFlags = lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) | ||
''--cross-compile "--cross-execute=${stdenv.targetPlatform.emulator pkgs}"''; |
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.
Note that this is pretty expensive to build. I'm not sure if waf is used enough for it to a problem though. I think it's okay since all waf scripts support it (not all need it though).
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.
If I understand correctly, this will only be built when one cross-builds a derivation using wafHook, so this is pretty optimal.
~/src/nixpkgs static-proot*
$ nix-store -qR $(nix-instantiate . -A pkgsCross.raspberryPi.talloc) | grep qemu
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
/nix/store/7s9kxar0nh6d6nzri342ynpfpxniwq1b-fix-qemu-ga.patch
/nix/store/pgkjdxzpglzfj5hpjim1p1m8bipx9hmj-qemu-3.1.0.tar.bz2.drv
/nix/store/3pjswv7hpf0z4avx11dp16rb9wfwpppg-qemu-3.1.0.drv
~/src/nixpkgs static-proot*
$ nix-store -qR $(nix-instantiate . -A talloc) | grep qemu
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
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 that's right. There might be a benefit to only adding it when you know a script will need to cross execute. But there's not a clean way to do that in Nixpkgs right now.
local flagsArray=( | ||
$configureFlags ${configureFlagsArray[@]} | ||
local flagsArray=(@crossFlags@); | ||
for flag in $configureFlags "${configureFlagsArray[@]}"; |
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.
Some more flags we might want to add are --bundled-libraries=NONE
and --disable-rpath-install
according to https://wiki.samba.org/index.php/Waf#controlling_rpath
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.
Makes sense, but this should probably go in another PR.
@matthewbauer Any reason not to merge this? I assume people who would have objections would have raised in the 11 days since your r+ :) |
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 should really change to use wafFlags
because ignoring flags is a hack and waf is not a build system with a defined set of flags, developers are free to define their own --enable-static
option. Keeping such hack would also mean that we need to maintain it with respect to all changes to pkgsStatic
.
|
Yes. I think it should be |
This avoids the potential conflict between autoconf flags and the waf flags. There is some overlap between the two but waf errors when it doesn’t recognize the flag.
@symphorien I pushed a commit to do this. Feel free to drop it if it's not helpful! |
Nice, thanks. It might warrant some release notes. I'll try to have a closer look on the week-end. |
@GrahamcOfBorg build proot |
@GrahamcOfBorg build talloc |
Motivation for this change
Have
pkgsStatic.proot.override {enablePython = false;}
compile.Things done
wafHook
use the vendored waf even if it is not located at./waf
wafHook
ignore--disable-shared
added by pkgsStaticwafHook
add the necessary configure flags for cross compilation transparentlyThings tested
Compilation of
tdb
,talloc
andproot
(with python disabled) inpkgs
,pkgsStatic
andpkgsCross.raspberryPi
.pkgsStatic.tdb
does not work because the waf script can only build a shared library.sandbox
innix.conf
on non-NixOS)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)cc @matthewbauer as the author of wafHook.