Closed YorikSar closed 2 years ago
% /nix/store/1q1yvxiirik8azmllr27h5wkf1320qhb-bazel-nixpkgs-cc/bin/cc -v clang version 7.1.0 (tags/RELEASE_710/final) Target: x86_64-apple-darwin Thread model: posix InstalledDir: /nix/store/zfh3npfhfjjgwi0dqpriklip5k15ppmj-clang-7.1.0/bin "/nix/store/gsfxxazc51sx6vjdrz6cq8s19x7h5mwh-clang-wrapper-7.1.0/bin/ld" -demangle -lto_library /nix/store/zfh3npfhfjjgwi0dqpriklip5k15ppmj-clang-7.1.0/lib/libLTO.dylib -dynamic -arch x86_64 -macosx_version_min 10.12.0 -o a.out -L/nix/store/5ygwml3yjcdvv5y35c2p9z4qavknfs0i-libcxx-7.1.0/lib -L/nix/store/a1sp2lg1lc67kwgcq5iw6ar2wdjfqqcc-objc4-709.1/lib -L/nix/store/1vp7fr7dm20khrz9zhzbwq8h9k37phhc-Libsystem-1238.60.2/lib -L/nix/store/66crk4qirnyz08zw91nhlz4x8lrxprc0-clang-7.1.0-lib/lib -L/nix/store/5ygwml3yjcdvv5y35c2p9z4qavknfs0i-libcxx-7.1.0/lib -no_uuid -arch x86_64 -lSystem /nix/store/gsfxxazc51sx6vjdrz6cq8s19x7h5mwh-clang-wrapper-7.1.0/resource-root/lib/darwin/libclang_rt.osx.a -F/nix/store/nvn3ldqg86k6x05pbq6yblg39p469rfd-apple-framework-CoreFoundation/Library/Frameworks -F/nix/store/8qc9kz9h8paijgxnhap7gslvvsyvry0f-apple-framework-CoreServices/Library/Frameworks -F/nix/store/f64r0ps4phxl3cnar09gi9y4pp1q5n7h-apple-framework-Security/Library/Frameworks -F/nix/store/pk9s46a3pi32h6x99k6ipyj8qy5gvrzj-apple-framework-Foundation/Library/Frameworks Undefined symbols for architecture x86_64: "_main", referenced from: implicit entry/start for main executable ld: symbol(s) not found for architecture x86_64 clang-7: error: linker command failed with exit code 1 (use -v to see invocation)
I recognize this error, I've seen this in the context of rules_haskell on M1. Defining the cc toolchain like this avoided the issue in that context.
This was fixed by https://github.com/tweag/rules_nixpkgs/pull/216
Describe the bug On macOS toolchain created by
nixpkgs_cc_configure
is misidentified as not being Clang.To Reproduce
Expected behavior On Darwin this toolchain uses Clang, so
IS_CLANG
should beTrue
.Environment
Additional context It looks like the script that generates
CC_TOOLCHAIN_INFO
tries running.../bin/cc -v
which fails because of the wrapper created by rules_nixpkgs:But if we try running it directly from the wrapper generated by nixpkgs, it works fine:
Since the decision is made based on the return value of the
${cc}/bin/cc -v 2>&1 | grep -q clang
pipeline, this failure leads toFalse
.