Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
nix: use clang11Stdenv for shell and host clang for bazel on macos (#…
Browse files Browse the repository at this point in the history
…59825)

Host clang for bazel reason:
```
ERROR: /Users/noah/Sourcegraph/sourcegraph/BUILD.bazel:305:5: GoLink sg_nogo_actual_/sg_nogo_actual [for tool] failed: (Exit 1): builder failed: error executing GoLink command (from target //:sg_nogo_actual) bazel-out/darwin_arm64-opt-exec-ST-1a88b5d644a4/bin/external/go_sdk/builder_reset/builder '-param=bazel-out/darwin_arm64-opt-exec-ST-1a88b5d644a4/bin/sg_nogo_actual_/sg_nogo_actual-0.params' -- -extld ... (remaining 6 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
external/go_sdk/pkg/tool/darwin_arm64/link: running external/local_config_cc/cc_wrapper.sh failed: exit status 1
ld: framework not found CoreFoundation
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

clang 11 for shell reason: NixOS/nixpkgs#166205


## Test plan

`./dev/scip-ctags-install.sh` and `bazel build //:gazelle`
  • Loading branch information
Strum355 authored Jan 24, 2024
1 parent 39ea8a0 commit da169dc
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let
# Additionally bazel seems to break when CC and CXX is set to a nix managed
# compiler on darwin. So the script unsets those.
bazel-wrapper = writeShellScriptBin "bazel" (if hostPlatform.isMacOS then ''
unset CC CXX
export CC=/usr/bin/clang
exec ${pkgs.bazelisk}/bin/bazelisk "$@"
'' else ''
unset TMPDIR TMP
Expand All @@ -33,7 +33,7 @@ let
exec ${pkgs.bazel_7}/bin/bazel "$@"
'');
bazel-watcher = writeShellScriptBin "ibazel" ''
${lib.optionalString hostPlatform.isMacOS "unset CC CXX"}
${lib.optionalString hostPlatform.isMacOS "export CC=/usr/bin/clang"}
exec ${pkgs.bazel-watcher}/bin/ibazel \
${lib.optionalString hostPlatform.isLinux "-bazel_path=${bazel-fhs}/bin/bazel"} "$@"
'';
Expand Down Expand Up @@ -65,7 +65,7 @@ let
# the binary for GNU sed.
gsed = pkgs.writeShellScriptBin "gsed" ''exec ${pkgs.gnused}/bin/sed "$@"'';
in
mkShell {
mkShell.override { stdenv = if hostPlatform.isMacOS then pkgs.clang11Stdenv else pkgs.stdenv; } {
name = "sourcegraph-dev";

# The packages in the `buildInputs` list will be added to the PATH in our shell
Expand Down Expand Up @@ -118,7 +118,7 @@ mkShell {
bazel-fhs
bazel-watcher
bazel-buildtools
]);
]) ++ lib.optional hostPlatform.isMacOS [ bazel-wrapper ];

# Startup postgres, redis & set nixos specific stuff
shellHook = ''
Expand All @@ -143,6 +143,7 @@ mkShell {
# bazel complains when the bazel version differs even by a patch version to whats defined in .bazelversion,
# so we tell it to h*ck off here.
# https://sourcegraph.com/github.com/bazelbuild/bazel@1a4da7f331c753c92e2c91efcad434dc29d10d43/-/blob/scripts/packages/bazel.sh?L23-28
USE_BAZEL_VERSION =
if hostPlatform.isMacOS then "" else pkgs.bazel_7.version;
USE_BAZEL_VERSION = if hostPlatform.isMacOS then "" else pkgs.bazel_7.version;

LIBTOOL = if hostPlatform.isMacOS then "${pkgs.libtool}" else "";
}

0 comments on commit da169dc

Please sign in to comment.