NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.64k stars 13.79k forks source link

pkgsCross.aarch64-embedded.llvmPackages_16.stdenv.mkDerivation failure #235675

Open benjaminmordaunt opened 1 year ago

benjaminmordaunt commented 1 year ago

Steps To Reproduce

Steps to reproduce the behaviour:

  1. Create a default.nix that tries to use cross LLVM 16 for aarch64:
    {
    pkgs ? import (fetchTarball {
    url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/23.05.tar.gz";
    }) {}
    }:
    pkgs.pkgsCross.aarch64-embedded.llvmPackages_16.stdenv.mkDerivation rec {
    # ...
    }

Build log

CMake Error at /nix/store/x27c0x6982aj1ycrywlr7pl7piz3cqjj-cmake-3.25.3/share/cmake-3.25/Modules/CMakeTestCCompiler.cmake:70 (message):
  The C compiler

    "/nix/store/fsq4m4kbm56zv6rnnksz3x7jp4ifvzny-aarch64-none-elf-clang-wrapper-16.0.1/bin/aarch64-none-elf-clang"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /tmp/nix-build-redacted-aarch64-none-elf-0.0.1-a0.drv-0/redacted/build/CMakeFiles/CMakeScratch/TryCompile-vO4Ibn

    Run Build Command(s):/nix/store/57q4yydmc8nfbfwhdgz091b1fs9k4af5-ninja-1.11.1/bin/ninja cmTC_9b97e && [1/2] Building C object CMakeFiles/cmTC_9b97e.dir/testCCompiler.c.obj
    [2/2] Linking C executable cmTC_9b97e
    FAILED: cmTC_9b97e
    : && /nix/store/fsq4m4kbm56zv6rnnksz3x7jp4ifvzny-aarch64-none-elf-clang-wrapper-16.0.1/bin/aarch64-none-elf-clang   CMakeFiles/cmTC_9b97e.dir/testCCompiler.c.obj -o cmTC_9b97e   && :
    clang-16: error: unable to execute command: Executable "ld.lld" doesn't exist!
    clang-16: error: ld.lld command failed with exit code 1 (use -v to see invocation)
    ninja: build stopped: subcommand failed.

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

Additional context

Seems that it cannot find ld.lld?

Notify maintainers

@dtzWill @Ericson2314 @lovek323

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"aarch64-darwin"`
 - host os: `Darwin 22.3.0, macOS 13.2.1`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.16.0`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`
Artturin commented 1 year ago

Reproducer

pkgs.pkgsCross.aarch64-embedded.hello.override { stdenv = pkgs.pkgsCross.aarch64-embedded.llvmPackages_16.stdenv; }

with --keep-failed config.log shows

clang-16: error: unable to execute command: Executable "ld.lld" doesn't exist!
clang-16: error: ld.lld command failed with exit code 1 (use -v to see invocation)
Artturin commented 1 year ago
{ pkgs ? import ./. { }, }:

let
  lStdenv = pkgs.pkgsCross.aarch64-embedded.llvmPackages_16.stdenv;
  llvmStdenvWithBintools = pkgs.overrideCC lStdenv (lStdenv.cc.override {
    bintools = pkgs.pkgsCross.aarch64-embedded.buildPackages.llvmPackages_16.bintools;
  });
in
pkgs.pkgsCross.aarch64-embedded.hello.override { stdenv = llvmStdenvWithBintools; }

Using llvm bintools gets us ld.lld.

the build still fails with a unrelated error lib/getprogname.c:287:4: error: "getprogname module not ported to this OS"