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
Cross compilation fixes [april 2020] #84415
Cross compilation fixes [april 2020] #84415
Conversation
- Need custom pkg-config setting - add wayland & libxkbcommon
@matthewbauer I just came about #83575 which suggests that |
# libvpx darwin targets include darwin version (ie. ARCH-darwinXX-gcc, XX being the darwin version) | ||
# See all_platforms: https://github.com/webmproject/libvpx/blob/master/configure | ||
# Darwin versions: 10.4=8, 10.5=9, 10.6=10, 10.7=11, 10.8=12, 10.9=13, 10.10=14 | ||
"--force-target=${stdenv.hostPlatform.config}${ | ||
"--force-target=${stdenv.hostPlatform.parsed.cpu.name}-${stdenv.hostPlatform.parsed.kernel.name}${ |
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.
Nice. I strugged with this one. I think so on aarch64 it is still incorrect because arm64
!= aarch64
.
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 was able to build for aarch64. I think they rewrite it here:
@@ -88,7 +90,7 @@ stdenv.mkDerivation { | |||
|
|||
makeFlags = [ | |||
"prefix=\${out}" | |||
"SHELL_PATH=${stdenv.shell}" | |||
"SHELL_PATH=${if (stdenv.hostPlatform != stdenv.buildPlatform) then "/bin/sh" else stdenv.shell}" |
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.
"SHELL_PATH=${if (stdenv.hostPlatform != stdenv.buildPlatform) then "/bin/sh" else stdenv.shell}" | |
"SHELL_PATH=${runtimeShell}" |
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.
Just read the commit message... The only pure alternative to your approach would be to replace stdenv.shell
with runtimeShell
in $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.
Otherwise if we have a sandbox build /bin/sh
is reasonable reproducible, could add the reasoning as a comment above for a future reader?
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.
We are referencing "/bin/sh"
in nixpkgs … oh 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.
Yeah if it is about the old vs new version of the code (stateful) I like to put in the commit message, but if it is about the new version of the code alone, I rather it be a comment.
Comments have a prayer of being edited to stay up to date :), but commit messages only describe a moment in time.
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 - patch-shebangs.sh bails out when the path is in the nix store.
I'll leave this change out of this set for now. Using /bin/sh is definitely not good, so some other fix is needed. Git will still build, you just can't run some of its shell scripts.
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.
🤔 isn't this a general problem with cross builds, for e.g. Python install scripts?
How about using a substitution set for buildDeps that should be replaced with runDeps? And maybe automatically testing for buildDeps that are referenced in the output but not specifically allowed?
[target."${toRustTarget stdenv.hostPlatform}"] | ||
"linker" = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc" | ||
EOF | ||
''; |
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.
Can we share this with the other places we 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.
Some setup hook would be nice if it is not possible to hard code this during compilation.
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 a better solution would be nice.
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 actually going to leave this out of this batch of cross fixes since there are a lot of questions on this (like why can't we do vala / gtk-doc / gobject-introspection when cross-compiling). These commits still exist on my other branch though:
- add glib to nativeBuildInputs - only update loaders cache on native builds
This is needed in cross where systemd is not in path.
Also set wayland-scanner to proper path
These should be runtime, not build time deps
Unfortunately, we need to emulate the system to get a real cache. Native version doesn’t know the right paths.
We can’t cross-compile the cache, so just skip it for now.
This prevents duplication in cross-compiled nixos machines. The bootstrapped glibc differs from the natively compiled one, so we get two glibc’s in the closure. To reduce closure size, just use stdenv.cc.libc where available.
fixes cross compilation
This fixes an evaluation error that occurs when we don’t have bluez.test. getOutput defaults to "out" in these cases.
9cdfaf8
to
c6ff360
Compare
In NixOS#84415, autoPatchelfHook was taught to use the correct path to the readelf binary when a crossSystem is specified. Unfortunately, the remainder of the functionality in the script depended on ldd, which only reads ELF files of its own architecture. It has the further unfortunate quality of not reporting any useful error, but rather that the file is not a dynamic executable. This change uses patchelf to directly analyze the DT_NEEDED tags in the target files instead, which correctly works across architectures. It also updates the use of objdump to be prefix-aware $OBJDUMP (which would have been required in the PR mentioned above, but we never made it that far into the script execution).
In NixOS#84415, autoPatchelfHook was taught to use the correct path to the readelf binary when a crossSystem is specified. Unfortunately, the remainder of the functionality in the script depended on ldd, which only reads ELF files of its own architecture. It has the further unfortunate quality of not reporting any useful error, but rather that the file is not a dynamic executable. This change uses patchelf to directly analyze the DT_NEEDED tags in the target files instead, which correctly works across architectures. It also updates the use of objdump to be prefix-aware $OBJDUMP (which would have been required in the PR mentioned above, but we never made it that far into the script execution). (cherry picked from commit b79483d)
In #84415, autoPatchelfHook was taught to use the correct path to the readelf binary when a crossSystem is specified. Unfortunately, the remainder of the functionality in the script depended on ldd, which only reads ELF files of its own architecture. It has the further unfortunate quality of not reporting any useful error, but rather that the file is not a dynamic executable. This change uses patchelf to directly analyze the DT_NEEDED tags in the target files instead, which correctly works across architectures. It also updates the use of objdump to be prefix-aware $OBJDUMP (which would have been required in the PR mentioned above, but we never made it that far into the script execution). (cherry picked from commit b79483d)
In NixOS#84415, autoPatchelfHook was taught to use the correct path to the readelf binary when a crossSystem is specified. Unfortunately, the remainder of the functionality in the script depended on ldd, which only reads ELF files of its own architecture. It has the further unfortunate quality of not reporting any useful error, but rather that the file is not a dynamic executable. This change uses patchelf to directly analyze the DT_NEEDED tags in the target files instead, which correctly works across architectures. It also updates the use of objdump to be prefix-aware $OBJDUMP (which would have been required in the PR mentioned above, but we never made it that far into the script execution). (cherry picked from commit b79483d)
In NixOS#84415, autoPatchelfHook was taught to use the correct path to the readelf binary when a crossSystem is specified. Unfortunately, the remainder of the functionality in the script depended on ldd, which only reads ELF files of its own architecture. It has the further unfortunate quality of not reporting any useful error, but rather that the file is not a dynamic executable. This change uses patchelf to directly analyze the DT_NEEDED tags in the target files instead, which correctly works across architectures. It also updates the use of objdump to be prefix-aware $OBJDUMP (which would have been required in the PR mentioned above, but we never made it that far into the script execution). (cherry picked from commit b79483d)
More cross-compilation fixes.
Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)