-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
stdenv: Add hack to fix cmake canExecute cross-compilation #251853
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Artturin
added
the
6.topic: cross-compilation
Building packages on a different platform than they will be used on
label
Aug 27, 2023
12 tasks
Fixes `pkgsCross.musl64.llvmPackages_16.clang.cc` on `x86_64-linux`, which used to fail with `/bin/sh: clang-tblgen: not found`. Same hack is used in other projects: https://github.com/search?q=%2FCMAKE_CROSSCOMPILING_EMULATOR.%2B%5C%2Fusr%5C%2Fbin%5C%2Fenv%2F+NOT+is%3Afork&type=code Comment from https://github.com/vsrinivas/fuchsia/blob/30435a9d0f0b67c94e3c70760b522c9f7fbbd6be/build/cmake/HostLinuxToolchain.cmake#L64 > Required to run host Linux executables during the build itself. > An example would be https://gitub.com/KhronosGroup/Vulkan-Loader and > its "asm_offset" program. > > NOTE: Alternatives have been tried unsuccessfully, i.e.: > > With $(set CMAKE_CROSSCOMPILING_EMULATOR), the build fails because > the CMake ninja/Make script tries to find the executable in the current > path, as in: > > [3/16] Generating gen_defines.asm > FAILED: loader/gen_defines.asm > cd /tmp/cc/build-Vulkan-Loader/loader && asm_offset GAS > /bin/sh: asm_offset: command not found > ninja: build stopped: subcommand failed. > > With $(set CMAKE_CROSSCOMPILING_EMULATOR ""), the build fails because > the shell cannot find the "" program as in: > > [3/16] Generating gen_defines.asm > FAILED: loader/gen_defines.asm > cd /tmp/cc/build-Vulkan-Loader/loader && "" /tmp/cc/build-Vulkan-Loader/loader/asm_offset GAS > /bin/sh: : command not found > ninja: build stopped: subcommand failed. > > It seems that the root of the problem comes from how the CMake function > cmCustomCommandGenerator::GetArgc0Location() computes the target > executable's location. At this point it's unclear whether this is a CMake > bug or a feature. Risicle discovered this hack. Co-authored-by: Robert Scott <code@humanleg.org.uk>
Mindavi
approved these changes
Sep 1, 2023
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.
Let's try it out and see
Tests are failing now: |
13 tasks
alyssais
added a commit
to alyssais/nixpkgs
that referenced
this pull request
Feb 2, 2024
Fixes e.g. pkgsStatic.libjpeg_turbo. Link: NixOS#251853 (comment)
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
6.topic: stdenv
Standard environment
10.rebuild-darwin: 1-10
10.rebuild-darwin: 1
10.rebuild-linux: 101-500
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes
pkgsCross.musl64.llvmPackages_16.clang.cc
onx86_64-linux
, which used to fail with/bin/sh: clang-tblgen: not found
.Same hack is used in other projects:
https://github.com/search?q=%2FCMAKE_CROSSCOMPILING_EMULATOR.%2B%5C%2Fusr%5C%2Fbin%5C%2Fenv%2F+NOT+is%3Afork&type=code
Comment from https://github.com/vsrinivas/fuchsia/blob/30435a9d0f0b67c94e3c70760b522c9f7fbbd6be/build/cmake/HostLinuxToolchain.cmake#L64
Risicle discovered this hack.
Description of changes
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)