Skip to content

lp_solve: fix cross-compilation#419322

Merged
uninsane merged 1 commit intoNixOS:masterfrom
synalice-forks:lp_solve-fix-cross-comp
Jul 2, 2025
Merged

lp_solve: fix cross-compilation#419322
uninsane merged 1 commit intoNixOS:masterfrom
synalice-forks:lp_solve-fix-cross-comp

Conversation

@synalice
Copy link
Contributor

@synalice synalice commented Jun 23, 2025

Fixed failing cross-compilation. Closes #419102.

Tested with:

x86_64-linux > x86_64-linux

nix-build -I nixpkgs=channel:nixos-unstable -E 'with import <nixpkgs> {}; callPackage ./pkgs/applications/science/math/lp_solve/default.nix { inherit (darwin) autoSignDarwinBinariesHook; }'

x86_64-linux > aarch64-unknown-linux-gnu

nix-build -I nixpkgs=channel:nixos-unstable -E 'with import <nixpkgs> { crossSystem = { config = "aarch64-unknown-linux-gnu"; }; }; callPackage ./pkgs/applications/science/math/lp_solve/default.nix { inherit (darwin) autoSignDarwinBinariesHook; }'

I also tried armv7l-unknown-linux-gnueabi and riscv64-linux, but there was no gcc and it tried building armv7l-unknown-linux-gnueabi-nolibc-gcc-14.3.0 which I assume is a lost cause (I don't have 8 hours to build gcc 💀).

Is there any way I can check what architectures/channels have a precompiled gcc toolchain?

  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage

The only failing package is shogun-6.1.4, but it has nothing to do with my change — #419311.

Besides that I think everything else was rebuilding successfully. Unfortunately my laptop ran out of all 32 GB of memory while trying to build libreoffice, so I could not complete the whole process, lol.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • Nixpkgs 25.11 Release Notes (or backporting 24.11 and 25.05 Nixpkgs Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
  • NixOS 25.11 Release Notes (or backporting 24.11 and 25.05 NixOS Release notes)
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other contributing documentation in corresponding paths.

Add a 👍 reaction to pull requests you find important.

@ofborg ofborg bot added the 6.topic: cross-compilation Building packages on a different platform than they will be used on label Jun 23, 2025
@github-actions github-actions bot added 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. labels Jun 23, 2025
@nix-owners nix-owners bot requested a review from sergei-mironov June 23, 2025 16:52
@synalice synalice force-pushed the lp_solve-fix-cross-comp branch from 9e83db9 to bf7ea31 Compare June 23, 2025 17:01
@synalice
Copy link
Contributor Author

Btw, I have some concerns about having to launch an emulator during build time. Is it a good approach in general? And would x86_64-linux > x86_64-linux non-cross build launch it?

Also, is it okay to declare and export env variables like I did? How idiomatic is it? I've seen makeFlags, but it only works with Make.

@uninsane
Copy link
Contributor

Btw, I have some concerns about having to launch an emulator during build time. Is it a good approach in general? And would x86_64-linux > x86_64-linux non-cross build launch it?

$ nix eval --impure --expr 'with import <nixpkgs> {}; stdenv.hostPlatform.emulator buildPackages'
"/nix/store/wjq0dhc78n818mmcl7lg7da64ds3iai3-exec/bin/exec"

when the buildPlatform can natively execute the hostPlatform then the "emulator" just exec's its command. it's a fine thing to do.

Also, is it okay to declare and export env variables like I did? How idiomatic is it? I've seen makeFlags, but it only works with Make.

for this specific case, you can use replaceVars, like this

@synalice synalice force-pushed the lp_solve-fix-cross-comp branch from bf7ea31 to df9c2d9 Compare June 28, 2025 11:50
@synalice
Copy link
Contributor Author

Btw, turn out that Nix automatically sets env variables for all binutils binaries, so there is no need to manually set them.

when the buildPlatform can natively execute the hostPlatform then the "emulator" just exec's its command. it's a fine thing to do.

Good to know, thanks!

for this specific case, you can use replaceVars, like this

Nice, I like that more than export statements.

@synalice synalice force-pushed the lp_solve-fix-cross-comp branch from df9c2d9 to c598b21 Compare June 28, 2025 11:55
Copy link
Contributor

@uninsane uninsane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

the emulator stuff is pretty specific to us, but upstream would probably be interested in taking the CC, AR and RANLIB changes if you get an extra moment to submit those. looks like development has migrated to Github (CC @sergei-mironov if you want to check the validity of that post & update our sources for lp_solve if it's accurate).

@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Jun 29, 2025
@synalice
Copy link
Contributor Author

synalice commented Jun 30, 2025

upstream would probably be interested in taking the CC, AR and RANLIB changes

In that case do you want me to rewrite that patch so that it defaults back to cc is $CC isn't set (same with AR and RANLIB)? Like this:

c="${CC:-cc}"

@uninsane uninsane merged commit 375eb81 into NixOS:master Jul 2, 2025
27 of 28 checks passed
@synalice synalice deleted the lp_solve-fix-cross-comp branch July 23, 2025 15:50
@wegank wegank mentioned this pull request Oct 18, 2025
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: cross-compilation Building packages on a different platform than they will be used on 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build failure: lp_solve (cross-compilation)

3 participants