Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 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>
- Loading branch information