Skip to content
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

Static proot, wafHook cross compilation #58504

Merged
merged 7 commits into from Apr 13, 2019
Merged

Conversation

symphorien
Copy link
Member

Motivation for this change

Have pkgsStatic.proot.override {enablePython = false;} compile.

Things done
  • Let wafHook use the vendored waf even if it is not located at ./waf
  • Make wafHook ignore --disable-shared added by pkgsStatic
  • Make wafHook add the necessary configure flags for cross compilation transparently
  • adapt tdb and talloc to these modifications
  • fix cross compilation of proot
Things tested

Compilation of tdb, talloc and proot (with python disabled) in pkgs, pkgsStatic and pkgsCross.raspberryPi. pkgsStatic.tdb does not work because the waf script can only build a shared library.

  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

cc @matthewbauer as the author of wafHook.

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"
Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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}"'';
Copy link
Member

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).

Copy link
Member Author

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

Copy link
Member

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[@]}";
Copy link
Member

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

Copy link
Member Author

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.

@Ekleog
Copy link
Member

Ekleog commented Apr 8, 2019

@matthewbauer Any reason not to merge this? I assume people who would have objections would have raised in the 11 days since your r+ :)

Copy link
Member

@veprbl veprbl left a 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.

@symphorien
Copy link
Member Author

wafFlags is already taken for build flags, shall I go withwafConfigureFlags?

@veprbl
Copy link
Member

veprbl commented Apr 9, 2019

Yes. I think it should be wafConfigureFlags, wafBuildFlags and wafInstallFlags for each phase. Since wafHook is relatively new and it is not a part of any released nixpkgs yet, I think it's okay to break some backward compatibility to make things right.

@veprbl veprbl added this to the 19.03 milestone Apr 9, 2019
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.
@matthewbauer
Copy link
Member

@symphorien I pushed a commit to do this. Feel free to drop it if it's not helpful!

@veprbl veprbl added the 9.needs: port to stable A PR needs a backport to the stable release. label Apr 10, 2019
@symphorien
Copy link
Member Author

Nice, thanks. It might warrant some release notes. I'll try to have a closer look on the week-end.

@veprbl
Copy link
Member

veprbl commented Apr 10, 2019

@GrahamcOfBorg build proot

@veprbl
Copy link
Member

veprbl commented Apr 11, 2019

@GrahamcOfBorg build talloc

@veprbl veprbl merged commit 59c8116 into NixOS:master Apr 13, 2019
@veprbl veprbl added 8.has: port to stable A PR already has a backport to the stable release. and removed 9.needs: port to stable A PR needs a backport to the stable release. labels Apr 17, 2019
@symphorien symphorien deleted the static-proot branch May 18, 2019 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants