-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
kismet: fix cross compilation #276038
kismet: fix cross compilation #276038
Conversation
@@ -39,6 +39,10 @@ stdenv.mkDerivation rec { | |||
--replace "-m 4550" "" | |||
''; | |||
|
|||
preConfigure = '' | |||
export PATH=${pkg-config}/bin/:$PATH |
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 adds the hostPlatform
pkgs-config
to PATH
, which (is most cases) is not runnable on buildPlatform
.
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 just want to clarify: Are you saying this breaks most builds or that this fixes most builds? Native builds are currently fine for the existing package on both aarch64 and x86_64 (probably most builds). Cross builds are currently broken (specifically x86_64 -> aarch64, but probably all cross-builds), which is what my pull request addresses.
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 not break native build, but still won't fix cross build. If it works for you, could be binfmt_misc interfering, please disable that and try again.
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.
A proper fix is to replace all hardcoded references to pkg-config
with $PKG_CONFIG
, which points to the pkg-config binary (something like aarch64-unknown-linux-gnu-pkg-config
) of the correct host/target platforms.
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 not break native build, but still won't fix cross build. If it works for you, could be binfmt_misc interfering, please disable that and try again.
Aw, you are right. Good catch. I've been emulating pkg-config and the protoc compilers without realizing it :-|. This does not work without qemu-user-static package on Debian based machines or boot.binfmt.emulatedSystems = [ "aarch64-linux" ] on NixOS. Still, this is the only way I have been able to semi-cross-compile on Non-NixOS machines.
I guess if this isn't really suitable for a merge, I can create an issue, and then submit this gist: https://gist.github.com/pete3n/4d997ee43277d31e2d7ee2a987018f5f as a solution to the issue? I just don't want other people to struggle the way I have to build this with pkgsCross.
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.
Sumitted an issue: #276165
That can be closed with either the provided git or possibly a revised version of this pull request. Obviously at your discretion. I just want to provide some workarounds to my cross-build issue.
Try this: --- a/pkgs/applications/networking/sniffers/kismet/default.nix
+++ b/pkgs/applications/networking/sniffers/kismet/default.nix
@@ -1,5 +1,6 @@
{ lib
, stdenv
+, autoreconfHook
, binutils
, elfutils
, fetchurl
@@ -20,7 +21,7 @@
, python3
, sqlite
, withNetworkManager ? false
-, withPython ? true
+, withPython ? stdenv.buildPlatform.canExecute stdenv.hostPlatform
, withSensors ? false
, zlib
}:
@@ -37,6 +38,8 @@ stdenv.mkDerivation rec {
postPatch = ''
substituteInPlace Makefile.in \
--replace "-m 4550" ""
+ substituteInPlace configure.ac \
+ --replace "pkg-config" "$PKG_CONFIG"
'';
postConfigure = ''
@@ -47,8 +50,13 @@ stdenv.mkDerivation rec {
-i Makefile
'';
+ strictDeps = true;
+
nativeBuildInputs = [
+ autoreconfHook
pkg-config
+ protobuf
+ protobufc
] ++ lib.optionals withPython [
python3
]; |
Nick,
This seems to have inverted the previous results. Now cross-compile builds run with pkgsCross succeed but native builds with pkgs throw the Python dependency error previously seen with the cross-builds. Buildsx86_64-linux NixOS 23.11 (no binfmt emulation)
x86_64-linux Debian 11 (no qemu-user-static)
aarch64-linux Ubuntu 22.04
|
This could be the |
That was it. I moved the conditional Python dependencies into the nativeBuildInputs and now all build scenarios are completing. I updated the PR with these changes. Thanks for your help. I'll be happy to see this get merged up. |
Result of 1 package built:
|
pkg-config | ||
protobuf | ||
protobufc | ||
] ++ lib.optionals withPython [ | ||
python3 |
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.
python3 |
This is redundant.
Also please squash the commits and fix the commit message, it should look like |
Update default.nix kismet: fix cross compilation
64cdbe7
to
898c9a7
Compare
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.
diff LGTM, future works could be re-enabling python support for cross compilation. Waiting for ofborg.
Changes to allow cross-compile builds with pkgsCross
See: https://gist.github.com/pete3n/4d997ee43277d31e2d7ee2a987018f5f
Description of changes
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.