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
Make cross-compiling with the crossSystem argument work (v2) #21388
Make cross-compiling with the crossSystem argument work (v2) #21388
Conversation
- Fix the expressions for several derivations (gcc5, boehmgc, libffi, libxml2, readline, libtool, libiconv) so that their native derivations do not change when the top-level crossSystem argument is provided. - Don't use bootstrap tools to compile the cross-compilers, use the normal stdenv. To accomplish these goals, some new things were added: - stdenv.mkDerivationWithCrossArg - lib.overrideNativeDrv - lib.overrideNativeDrvs This commit was tested using the expression here: https://gist.github.com/DavidEGrayson/8f962b3ec6edf06365ecb0c70a88029f The tests passed, all the derivations were successfully built, and the rpiHello derivation was successfully run on a Raspberry Pi. This commit should not cause a mass rebuild of native derivations. Some future work that would be nice: - It would be nice to stop using the deprecated --with-headers option to configure GCC cross-compilers. - It would be nice to apply these GCC fixes to the GCC 6 expression. - Get cross-compiling working on Darwin too; this commit is mainly about getting it to work on Linux.
@DavidEGrayson, thanks for your PR! By analyzing the history of the files in this pull request, we identified @FRidh, @Ericson2314 and @edolstra to be potential reviewers. |
CC @shlevy and @bjornfor because they both asked for status updates on the previous pull request. Also @dezgeg because he helped make the previous pull request work. Also, @viric and @rasendubi. |
@DavidEGrayson you pinged me mentioning conflicts with my #21268 . Well besides the files changed there is a difference in approach. Currently in nixpkgs, as we both know, there is a only a very sloppy attempt to make nativeDrvs and crossDrvs. You clean that up with |
On a diffferent note, it would be amazing to get your tests into https://github.com/NixOS/nixpkgs/blob/master/pkgs/top-level/release-cross.nix so they (I think) will be tested by hydra. |
I posted this pull request one day before Christmas Eve. Now that the holidays are over, maybe a nixpkgs member would be interested in looking at it and merging it? There was a lot of interest on my previous attempt (#18386) and I thought people were gung-ho to get it merged in. A lot of this pull request is just fixing logic errors in the recipes for individual packages that are due to people misunderstanding how |
I currently have not a good understanding on how stdenv works.
This is the failing file: nixpkgs/pkgs/development/libraries/libxslt/default.nix
you changed in libxml2/default.nix -, pythonSupport ? (! stdenv ? cross) }:
+, pythonSupport ? null }: As I said don't know enough about stdenv and cross compilation in this context to know what the right fix in this case would be... |
@Mic92 Thanks, that would have to be fixed before this PR is merged. If you're looking for a quick solution, maybe just remove the assertion that is failing. For the longer term, I'd have to look into populating |
Unfortunately this is a mass-rebuild on NixOS. I currently do not have the resources locally to test this here. Probably someone with access to hydra could take a look at it. Because staging should be only used for changes, which are already expected to work, what is the appropriate action in this case @vcunat ? |
Hmmm, I have tests and code to try to make sure that this PR would not be a mass rebuild. What is the first derivation that is getting rebuilt for you when you try it out? |
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.
@DavidEGrayson Sorry for being slow. While I prefer the more general approach of my PR long term, that one is somewhat blocked on review. Also it would be nice to get cross into a better stage for my own comparing hashes in that one.
I don't want to penalize you for mine being blocked, so even though my PRs would mean undoing some of the work here, I'm now willing to merge this as soon as you
-
make these changes
-
make as many tests as possible part of
release-cross.nix
(recall my Improve release-cross tests #21414). For example, orrpiCrossSystem
is slightly different right? Maybe we want both variants in there? Maybe put the rest inmaintainers/scripts
(e.g. the HEAD, HEAD^ comparing ones)?
It would be great to get the green light from Travis too, but I understand that's often broken for silly reasons.
# crossStdenv adapter. | ||
# stdenvOverrides is used to avoid having multiple of versions | ||
# of certain dependencies that were used in bootstrapping the | ||
# standard environment. | ||
stdenvOverrides = self: super: |
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.
#21415 will imminently do half of this. See pkgs/stdenv/cross/default.nix
for dealing with the rest.
cross = crossSystem; | ||
crossStageStatic = false; | ||
noSysDirs = true; | ||
isl = isl_0_14; |
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.
Ok for now, but we should figure out why this can't be the default so this and the Linux stdenv don't need to special case.
cross = crossSystem; | ||
crossStageStatic = true; | ||
langCC = false; | ||
noSysDirs = true; | ||
isl = isl_0_14; |
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.
Ok for now, see isl
comment below
# standalone libiconv, just in case you want it. | ||
libiconv = | ||
let | ||
nativeDrv = if stdenv.isGlibc then stdenv.cc.libc |
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.
Please use glibcIconv
to strip unneeded
else if stdenv.isDarwin then darwin.libiconv | ||
else libiconvReal; | ||
crossDrv = | ||
if crossSystem.libc == "glibc" then libcCross |
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.
Similarly, please use glibcIconv
stdenv.mkDerivation ({ | ||
stdenv.mkDerivationWithCrossArg ( hostCrossSystem: | ||
let | ||
targetCrossSystem = if cross != null then cross else hostCrossSystem; |
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.
Please comment when targetCrossSystem
is non-null, I presume this is is a function of build
and host
and target
being equal or not equal in some combination.
|
||
stdenv.mkDerivationWithCrossArg(cross: | ||
let | ||
pythonSupportReally = if pythonSupport != null then pythonSupport |
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.
Please do something like pythonSupportReally
, matching the others, so the body of this stays the same.
@DavidEGrayson this would be the rebuild log, when doing |
I am closing this. @Ericson2314 is working hard to clean up cross-compiling in nixpkgs, so this pull request would probably just get in his way or be redundant. Instead of working on this stuff, I am pursuing a project called nixcrpkgs where I will make my own Nix expressions for cross-compiling and just use nixpkgs as the base platform for my build system. Since I don't need to worry about supporting a million different use cases, my expressions can be much cleaner and simpler than what has accumulated in nixpkgs over the years, especially when it comes to building a GCC cross-compiler. |
@DavidEGrayson Thanks, definitely watching that repo. I had opened #21471 which I hope your repo + my nixpkgs PRs will greatly accelerate. |
This is version 2 of my previous pull request (#18386). Compared to my previous pull request, this has a bit of a smaller scope: it does not add a
test
directory and it does not try to fix the deprecated--with-headers
option used to compile GCC cross-compilers. Also, it does not do as much fixing of the top-level logic, thanks to the merged pull request #19940 by @Ericson2314 which cleaned up a lot of the problems in that area.This pull request fixes several things about cross-compiling with the
crossSystem
argument:To accomplish these goals, some new things were added:
Motivation for this change
For motivation information, see my comment on the old pull request: #18386 (comment)
Things done to test
This pull request was tested using the expression here:
https://gist.github.com/DavidEGrayson/8f962b3ec6edf06365ecb0c70a88029f
The tests passed, all the derivations were successfully built, and the rpiHello derivation was successfully run on a Raspberry Pi. This pull request should not cause a mass rebuild of native derivations.
(nix.useSandbox on NixOS,
or option
build-use-sandbox
innix.conf
on non-NixOS)
nix-shell -p nox --run "nox-review wip"
./result/bin/
)Future work
Here are some similar things that could be done in the future:
stdenv.cross
, possibly removestdenv.cross
to prevent future errors.