NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.4k stars 14.35k forks source link

Cmake assumes /bin/sh to be present when checking for working C compiler #124734

Closed tim-hilt closed 3 years ago

tim-hilt commented 3 years ago

Describe the bug

When compiling anything via cmake with gcc, cmake will try to compile a simple test-program. However this will fail because it assumes /bin/sh to be present (instead of for example /usr/bin/env sh, which would work).

Build log:

@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/gim14h2wkwbj7mzqffpv9f4zm436av9z-gpj7w0a2xiw28drsk8kb8xz4zqx2iwlf-source
source root is gpj7w0a2xiw28drsk8kb8xz4zqx2iwlf-source
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
applying patch /nix/store/jnp9n2x9cdvl47da3656illrd3p2qvb5-system_rplugin_manifest.patch
patching file runtime/autoload/remote/host.vim
patching file runtime/plugin/rplugin.vim
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
cmake flags: -DCMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY=OFF -DCMAKE_FIND_USE_PACKAGE_REGISTRY=OFF -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_SKIP_BUILD_RPATH=ON -DBUILD_TESTIN>
-- The C compiler identification is GNU 10.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /nix/store/35pnk5kwi26m3ph2bc7dxwjnavpzl8cn-gcc-wrapper-10.3.0/bin/gcc
-- Check for working C compiler: **/nix/store/35pnk5kwi26m3ph2bc7dxwjnavpzl8cn-gcc-wrapper-10.3.0/bin/gcc - broken**
CMake Error at /nix/store/zzqzl5lm59mc04fd8f1wbwl7nmxvv1bb-cmake-3.19.7/share/cmake-3.19/Modules/CMakeTestCCompiler.cmake:66 (message):
  The C compiler

    "/nix/store/35pnk5kwi26m3ph2bc7dxwjnavpzl8cn-gcc-wrapper-10.3.0/bin/gcc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /build/gpj7w0a2xiw28drsk8kb8xz4zqx2iwlf-source/build/CMakeFiles/CMakeTmp

    Run Build Command(s):/nix/store/g2fna66r9m081w1h1zj857j06jigx6cq-gnumake-4.3/bin/make cmTC_28834/fast && /nix/store/g2fna66r9m081w1h1zj857j06jigx6cq-gnumake-4.3/bin/make  -f CMakeFiles/cmTC_28834.dir>
    make[1]: Entering directory '/build/gpj7w0a2xiw28drsk8kb8xz4zqx2iwlf-source/build/CMakeFiles/CMakeTmp'
    make[1]: **/bin/sh: No such file or directory**
    make[1]: *** [CMakeFiles/cmTC_28834.dir/build.make:84: CMakeFiles/cmTC_28834.dir/testCCompiler.c.o] Error 127
    make[1]: Leaving directory '/build/gpj7w0a2xiw28drsk8kb8xz4zqx2iwlf-source/build/CMakeFiles/CMakeTmp'
    make: *** [Makefile:140: cmTC_28834/fast] Error 2

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:7 (project)

-- Configuring incomplete, errors occurred!
See also "/build/gpj7w0a2xiw28drsk8kb8xz4zqx2iwlf-source/build/CMakeFiles/CMakeOutput.log".
See also "/build/gpj7w0a2xiw28drsk8kb8xz4zqx2iwlf-source/build/CMakeFiles/CMakeError.log".

To Reproduce Steps to reproduce the behavior:

  1. Include something, that will build with cmake in your configuration.nix or flake.nix
  2. `nixos-rebuild switch

Expected behavior

Correct compilation resulting in a usable program

Notify maintainers @tteggel @LnL7

wiltaylor commented 3 years ago

I am getting something similar with xorg font packages:

@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/w1hzp0nsyskhgzbipx3l8r3ncxg6dkpb-font-bh-lucidatypewriter-100dpi-1.0.3.tar.bz2
source root is font-bh-lucidatypewriter-100dpi-1.0.3
setting SOURCE_DATE_EPOCH to timestamp 1289851816 of file font-bh-lucidatypewriter-100dpi-1.0.3/INSTALL
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
configure flags: --disable-dependency-tracking --prefix=/nix/store/j12wlka8vvl4f60ilvzly23scq6qpxa7-font-bh-lucidatypewriter>
/nix/store/qg8qhrxiab3r87xmaxbq565g1g8bnl57-stdenv-linux/setup: ./configure: /bin/sh: bad interpreter: No such file or direc>
nixos-discourse commented 3 years ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/include-custom-package-in-flake-configuration-with-flake-utils-plus/13311/3

teto commented 3 years ago

duplicate of https://github.com/NixOS/nixpkgs/issues/124372 ?

tim-hilt commented 3 years ago

Possibly. I can confirm it when I find out how to delete the store-path-line from /etc/nix/nix.conf.

tim-hilt commented 3 years ago

Confirmed this is a duplicate of #124372. Closing.