nixpkgs/pkgs/stdenv/generic
Artturin c25f7f894f stdenv: Add hack to fix cmake canExecute cross-compilation
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 30435a9d0f/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>
2023-08-29 22:12:06 +03:00
..
builder.sh Revert "Merge remote-tracking branch 'origin/python-unstable' into staging-next" 2021-09-05 15:02:25 +02:00
check-meta.nix stdenv: factor out meta attr augmentation for reusability 2023-05-01 20:18:11 +03:00
common-path.nix stdenv/common-path.nix: move to stdenv/generic/ 2022-07-29 18:24:00 -04:00
default-builder.sh stdenv: support opt-in __structuredAttrs 2022-12-08 06:13:19 +02:00
default.nix Revert "stdenv: use improved strip.sh for aarch64-linux" 2023-07-31 11:20:15 +02:00
make-derivation.nix stdenv: Add hack to fix cmake canExecute cross-compilation 2023-08-29 22:12:06 +03:00
setup.sh stdenv: Print _allFlags debug output to stderr 2023-08-10 17:35:07 +03:00