Skip to content

Check for "$ENV{NIX_CC}", with quotes, not without #194929

@poliorcetics

Description

@poliorcetics

In this commit: 871cf9f#diff-ff2a2145cf58008275b3e5299c8bdcd31a88541c74f23127aa4f5468de69b80eR25, the code IS_DIRECTORY ${ENV(NIX_CC} checks the env var without quotes, which means an unset or empty variables can cause build errors, eg this one for the boring-sys Rust crate in a nix shell:

      "IS_DIRECTORY" "AND" "EXISTS" "/nix-support/orig-libc" "AND" "EXISTS" "/nix-support/orig-libc-dev"
                    ^
                    Nothing here, should have at least an empty string

I'm not sure it's missing quotes though, I don't know how CMake works in this situation, but since that looks like a bash-inspired syntax, I suppose it has bash-inspired bugs too


Full error:

  running: "cmake" "[CARGO_HOME]/registry/src/github.com-1ecc6299db9ec823/boring-sys-2.1.0/deps/boringssl" "-G" "Ninja" "-DCMAKE_TOOLCHAIN_FILE=/nix/store/x25lgahqpdygym97i6kqcy82bif2f89n-macos.arm64.cmake" "-DCMAKE_INSTALL_PREFIX=[CWD]/target/aarch64-apple-darwin/debug/build/boring-sys-400f6fa962fd5ab3/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin" "-DCMAKE_BUILD_TYPE=Debug"
  -- The C compiler identification is Clang 14.0.6
  -- The CXX compiler identification is Clang 14.0.6
  -- Configuring incomplete, errors occurred!
  See also "[CWD]/target/aarch64-apple-darwin/debug/build/boring-sys-400f6fa962fd5ab3/out/build/CMakeFiles/CMakeOutput.log".

  --- stderr
  CMake Error at /nix/store/dz5jcmsfmi4hi6lkajvdfcv8g9dcnvds-cmake-3.24.1/share/cmake-3.24/Modules/Platform/UnixPaths.cmake:51 (if):
    if given arguments:

      "IS_DIRECTORY" "AND" "EXISTS" "/nix-support/orig-libc" "AND" "EXISTS" "/nix-support/orig-libc-dev"

    Unknown arguments specified
  Call Stack (most recent call first):
    /nix/store/dz5jcmsfmi4hi6lkajvdfcv8g9dcnvds-cmake-3.24.1/share/cmake-3.24/Modules/Platform/Darwin.cmake:241 (include)
    /nix/store/dz5jcmsfmi4hi6lkajvdfcv8g9dcnvds-cmake-3.24.1/share/cmake-3.24/Modules/CMakeSystemSpecificInformation.cmake:37 (include)
    CMakeLists.txt:9 (project)


  thread 'main' panicked at '
  command did not execute successfully, got: exit status: 1

  build script failed, must exit now', [CARGO_HOME]/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.48/src/lib.rs:975:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Temporary workaround:

Set NIX_CC to garbage, like /does-not-exists, and it will build and run correctly

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions