Unable to link to `CoreFoundation` symbols even though `CoreFoundation` framework is provided as `buildInput` (x86_64-darwin)

Hi folks,

I’ve been stuck on a linking issue with one of our Rust package outputs for the past couple of days and thought I’d reach out to see if anyone has any ideas.

When attempting to build the package output on x86_64-darwin under CI, I’m running into the following error:

2023-06-01T03:52:15.2368980Z forc> error: linking with `/nix/store/ahk80g4lqv6qh2jk2p0ggzq9rv4bn225-clang-wrapper-11.1.0/bin/cc` failed: exit status: 1
2023-06-01T03:52:15.2470450Z forc>   |
2023-06-01T03:52:15.2655270Z forc>   = note: "/nix/store/ahk80g4lqv6qh2jk2p0ggzq9rv4bn225-clang-wrapper-11.1.0/bin/cc" ..... # Omitted due to character limit
2023-06-01T03:52:15.2721490Z forc>   = note: Undefined symbols for architecture x86_64:
2023-06-01T03:52:15.2721870Z forc>             "_kCFURLVolumeAvailableCapacityForImportantUsageKey", referenced from:
2023-06-01T03:52:15.2783950Z forc>                 _$LT$sysinfo..apple..disk..Disk$u20$as$u20$sysinfo..traits..DiskExt$GT$::refresh::ha090b62f02761b2b in libsysinfo-bfbd6883445a3969.rlib(sysinfo-bfbd6883445a3969.sysinfo.4f5fc5ae-cgu.15.rcgu.o)
2023-06-01T03:52:15.2784960Z forc>                 sysinfo::apple::disk::get_disks::h63aaac400a8fb64f in libsysinfo-bfbd6883445a3969.rlib(sysinfo-bfbd6883445a3969.sysinfo.4f5fc5ae-cgu.15.rcgu.o)
2023-06-01T03:52:15.2785500Z forc>           ld: symbol(s) not found for architecture x86_64
2023-06-01T03:52:15.2786040Z forc>           clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
2023-06-01T03:52:15.2786330Z forc>           
2023-06-01T03:52:15.2786590Z forc> error: could not compile `forc` due to previous error
2023-06-01T03:52:19.3299700Z error: builder for '/nix/store/pjqri85igm1w3gmykvj982gldh8dlb4g-forc-0.39.1.drv' failed with exit code 101;

The linker note shortened due to character limit - see the full error with all linker flags here.

The error indicates a failure to link the _kCFURLVolumeAvailableCapacityForImportantUsageKey symbol. The docs show the symbol is provided by CoreFoundation, however I’m already including the CoreFoundation framework as a buildInput.

The flake providing the output is a little complex, so here’s the output of nix derivation show to show the derivation used for the build in question:

$ nix derivation show --system x86_64-darwin .#forc-nightly
{
  "/nix/store/5iwi1s5mq5l60ppk2x43lavwnv52hfzj-forc-0.39.1.drv": {
    "args": [
      "-e",
      "/nix/store/6xg259477c90a229xwmb53pdfkn6ig3g-default-builder.sh"
    ],
    "builder": "/nix/store/1icxmg6cq1xcv7mkry7ra1i21x8k9cjf-bash-5.2-p15/bin/bash",
    "env": {
      "PKG_CONFIG_ALLOW_CROSS": "0",
      "__darwinAllowLocalNetworking": "",
      "__impureHostDeps": "/bin/sh /usr/lib/libSystem.B.dylib /usr/lib/system/libunc.dylib /dev/zero /dev/random /dev/urandom /bin/sh",
      "__propagatedImpureHostDeps": "",
      "__propagatedSandboxProfile": "",
      "__sandboxProfile": "",
      "__structuredAttrs": "",
      "buildAndTestSubdir": "forc",
      "buildInputs": "/nix/store/5yk3w875qvbcjny91b5jvvmkbszd1jca-apple-framework-CoreFoundation /nix/store/1b4zhsk7n287pdpyd8pwb8aj73hlmg6r-apple-framework-Security /nix/store/aph2cwrvcnr5s4xfmg56fabg2pa25m6b-apple-framework-SystemConfiguration /nix/store/219azlfqflil2b4jabs1g55hhgw7ar1p-apple-framework-CoreServices /nix/store/yfni0piv84nnqsm6kz8sn7s1hbwdjh0r-libiconv-50",
      "builder": "/nix/store/1icxmg6cq1xcv7mkry7ra1i21x8k9cjf-bash-5.2-p15/bin/bash",
      "cargoBuildFeatures": "",
      "cargoBuildNoDefaultFeatures": "",
      "cargoBuildType": "release",
      "cargoCheckFeatures": "",
      "cargoCheckNoDefaultFeatures": "",
      "cargoCheckType": "release",
      "cargoDeps": "/nix/store/l9bbmb2gir6hc1vrils511b7b5j80vc3-cargo-vendor-dir",
      "cmakeFlags": "",
      "configureFlags": "",
      "configurePhase": "runHook preConfigure\nrunHook postConfigure\n",
      "date": "2023-05-31",
      "depsBuildBuild": "",
      "depsBuildBuildPropagated": "",
      "depsBuildTarget": "",
      "depsBuildTargetPropagated": "",
      "depsHostHost": "",
      "depsHostHostPropagated": "",
      "depsTargetTarget": "",
      "depsTargetTargetPropagated": "",
      "doCheck": "",
      "doInstallCheck": "",
      "mesonFlags": "",
      "name": "forc-0.39.1",
      "nativeBuildInputs": "/nix/store/6rsg4fzyahmw1l93yac0px435228a757-perl-5.36.0 /nix/store/i10dnzwn79y48zda0qjfpnyp71c6s6z9-pkg-config-wrapper-0.29.2 /nix/store/fjyp6k0clgsz4r2yghjb0s28gjbv33hv-nss-cacert-3.86 /nix/store/sn6y1pfj8ybfgf5g9h891ljfwfqmy8zj-cargo-build-hook.sh /nix/store/2lk21iizcrkp3qj5bibrkwwfbh3pmqfw-cargo-check-hook.sh /nix/store/84nwdfvc4z78kzmlgrfyhqrws6qwhbdz-cargo-install-hook.sh /nix/store/qa1rl1s0skr57lpiwbap5ynmnfpqv535-cargo-setup-hook.sh /nix/store/46cpzwz2vbcda3r0jrpqzaicgcmb9y25-rust-default-1.67.0",
      "out": "/nix/store/svg4d4k48i2jmn5mnw49c1vngrcn372x-forc-0.39.1",
      "outputs": "out",
      "patchRegistryDeps": "/nix/store/nk6b2ckznjic5wj8ddw0wgdrn4mbz3lg-patch-registry-deps",
      "patches": "",
      "pname": "forc",
      "postUnpack": "eval \"$cargoDepsHook\"\n\nexport RUST_LOG=\n",
      "propagatedBuildInputs": "",
      "propagatedNativeBuildInputs": "",
      "rust": "/nix/store/46cpzwz2vbcda3r0jrpqzaicgcmb9y25-rust-default-1.67.0",
      "src": "/nix/store/nqdknlmhpaxkikal1zj8v95zrai8l78f-sway-08c5bc1",
      "stdenv": "/nix/store/ibgiw134amh5hj4znpay84s7dlb550yj-stdenv-darwin",
      "strictDeps": "1",
      "system": "x86_64-darwin",
      "version": "0.39.1"
    },
    "inputDrvs": {
      "/nix/store/19vypv62ka5dcz0qbwc35xr9idv885vq-stdenv-darwin.drv": [
        "out"
      ],
      "/nix/store/6wpbp2qsh9cjqal2v12djnkpg1pfpi0l-rust-default-1.67.0.drv": [
        "out"
      ],
      "/nix/store/7v41jw8kdrwghk7yj45c6lxgz7v5naym-apple-framework-Security.drv": [
        "out"
      ],
      "/nix/store/7yakz0g23q7xhabxzqiwrrpni9j9ykzq-libiconv-50.drv": [
        "out"
      ],
      "/nix/store/951m6kcvryni7shrav389269va64xv5p-perl-5.36.0.drv": [
        "out"
      ],
      "/nix/store/c42r69rd7iv7hngq1q46hzdjcazi18cr-apple-framework-CoreFoundation.drv": [
        "out"
      ],
      "/nix/store/f5bk1gbp80k5qk10jkwvlphqw9z817hn-cargo-install-hook.sh.drv": [
        "out"
      ],
      "/nix/store/fsrpw8dwp1s66b45dwcdngzifrr27j6n-bash-5.2-p15.drv": [
        "out"
      ],
      "/nix/store/hka8ahlmdh5d55zbak0dy8mqm6rl2cs2-cargo-check-hook.sh.drv": [
        "out"
      ],
      "/nix/store/iars4wncfk6fl4cwmq8qbngvg06igh9y-apple-framework-CoreServices.drv": [
        "out"
      ],
      "/nix/store/jhhqdbynqc64b4n41l692vqb0gaqqsss-cargo-setup-hook.sh.drv": [
        "out"
      ],
      "/nix/store/m72cs98plfg1z529dilzm12y3d3ag92k-cargo-build-hook.sh.drv": [
        "out"
      ],
      "/nix/store/qxn2m1m4h5dsisgq3lzkgk5mwam0ca24-sway-08c5bc1.drv": [
        "out"
      ],
      "/nix/store/r9vq9js5pyja2zw53ffijya0mfj15x0i-pkg-config-wrapper-0.29.2.drv": [
        "out"
      ],
      "/nix/store/s5x752km2gaml3fmc80khrzg580bycbi-apple-framework-SystemConfiguration.drv": [
        "out"
      ],
      "/nix/store/v1m97f2cdwa9lic3kvwai8pxnp747dbq-nss-cacert-3.86.drv": [
        "out"
      ],
      "/nix/store/xhbjb22m6d8m2kx1vi6sdbwdjwbmz8hn-cargo-vendor-dir.drv": [
        "out"
      ]
    },
    "inputSrcs": [
      "/nix/store/6xg259477c90a229xwmb53pdfkn6ig3g-default-builder.sh",
      "/nix/store/nk6b2ckznjic5wj8ddw0wgdrn4mbz3lg-patch-registry-deps"
    ],
    "name": "forc-0.39.1",
    "outputs": {
      "out": {
        "path": "/nix/store/svg4d4k48i2jmn5mnw49c1vngrcn372x-forc-0.39.1"
      }
    },
    "system": "x86_64-darwin"
  }
}

For those curious, here’s the issue where we’re tracking the failure.

Any ideas on what I might be missing here would be greatly appreciated!

1 Like