Ld: framework not found System

After prematurely posting my last question I’m now facing an issue I really can’t solve. I’m trying to package the Solana CLI and you can find my current efforts here GitHub - cideM/solana-nix: The Solana CLI tools packaged up with Nix

I’m on a MacBook.

If I run nix build I get

   Compiling serde_derive v1.0.130
   Compiling serde v1.0.130
   Compiling memchr v2.4.0
   Compiling spin v0.5.2
error: linking with `/nix/store/jgaarpq3rdfk7gbm0gm3xlh8hhbw15ay-clang-wrapper-11.1.0/bin/cc` fai
  |
  = note: "/nix/store/jgaarpq3rdfk7gbm0gm3xlh8hhbw15ay-clang-wrapper-11.1.0/bin/cc" "-arch" "arm6
  = note: ld: framework not found System
          clang-11: error: linker command failed with exit code 1 (use -v to see invocation)


error: linking with `/nix/store/jgaarpq3rdfk7gbm0gm3xlh8hhbw15ay-clang-wrapper-11.1.0/bin/cc` fai
  |
  = note: "/nix/store/jgaarpq3rdfk7gbm0gm3xlh8hhbw15ay-clang-wrapper-11.1.0/bin/cc" "-arch" "arm6
  = note: ld: framework not found System
          clang-11: error: linker command failed with exit code 1 (use -v to see invocation)


error: linking with `/nix/store/jgaarpq3rdfk7gbm0gm3xlh8hhbw15ay-clang-wrapper-11.1.0/bin/cc` fai
  |
  = note: "/nix/store/jgaarpq3rdfk7gbm0gm3xlh8hhbw15ay-clang-wrapper-11.1.0/bin/cc" "-arch" "arm6
  = note: ld: framework not found System
          clang-11: error: linker command failed with exit code 1 (use -v to see invocation)


error: aborting due to previous error

error: aborting due to previous error

error: aborting due to previous error

error: could not compile `proc-macro2`

I’ve already read most issues and PRs on that topic and so far I have this in the flake:

            nativeBuildInputs = [
              pkgs.hidapi
              pkgs.llvmPackages.clang
              pkgs.llvm
              pkgs.rustfmt
              pkgs.darwin.apple_sdk.frameworks.System
              pkgs.llvmPackages.libclang
              pkgs.pkg-config
            ];

            buildInputs = [
              pkgs.hidapi
              pkgs.llvm
              pkgs.llvmPackages.libclang
              pkgs.rustfmt
              pkgs.darwin.apple_sdk.frameworks.System
              pkgs.openssl
              # pkgs.udev
              pkgs.zlib
            ];

            preBuild = ''
              export LLVM_CONFIG_PATH="${pkgs.llvm}/bin/llvm-config";
              export LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib";
            '';

            preConfigure = ''
              export NIX_LDFLAGS="-F${pkgs.darwin.apple_sdk.frameworks.System}/Library/Frameworks -framework System $NIX_LDFLAGS";
            '';

so as you can see I already have the frameworks.System and I’m passing it via NIX_LDFLAGS but it doesn’t change the error in any way.

The solution to this issue is to make sure that whatever application you are linking/compiling is not linking to System.

The System framework should never be used according to Apple: https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/OSX_Technology_Overview/SystemFrameworks/SystemFrameworks.html

So the best thing to do is to patch the software.

I had this issue with compiling a Rust project. It is definitely a Nix-Darwin thing. I had no problem compiling the project with cargo build in my system. I also had no problem using nix-build inside a docker image with aarch-unknown-linux-gnu

Did anyone find a solution to this? I’m getting what I assume is a related problem, but with SystemConfiguration when trying to add datafusion-cli:

   >   = note: ld: framework not found SystemConfiguration
   >           clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
   >           
   >
   > error: could not compile `datafusion-cli` (bin "datafusion-cli") due to 1 previous error

with the following in my flake.nix:

      buildInputs = [
          openssl
          pkg-config
          cargo-dist
          llvmPackages_latest.llvm
          llvmPackages_latest.bintools
          zlib.out
          llvmPackages_latest.lld
          darwin.apple_sdk.frameworks.Security
          darwin.apple_sdk.frameworks.SystemConfiguration
          datafusion-cli
          (rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override {
            extensions = [ "rust-src" "rust-analyzer" ];
          }))
        ];

        shellHook = ''
          export NIX_LDFLAGS="-F${pkgs.darwin.apple_sdk.frameworks.SystemConfiguration}/Library/Frameworks -framework SystemConfiguration $NIX_LDFLAGS"
          alias ls=exa
          alias find=fd
          alias grep=ripgrep
        '';

Facing similar issue

  = note: ld: framework not found SystemConfiguration
          clang-16: error: linker command failed with exit code 1 (use -v to see invocation)


error: could not compile `prisma-cli` (bin "prisma-cli") due to 1 previous error