Skip to content

Commit

Permalink
bazel_7: fix darwin compilation with CLang 16 & recent nixpkgs/master
Browse files Browse the repository at this point in the history
Workaround for #166205 similar to
51451ac

And warning fix similar to `bazel_6` fix for
```
external/upb~0.0.0-20220923-a547704/upb/mini_table.c:634:14: error: defining a type within '__builtin_offsetof' is a Clang extension [-Werror,-Wgnu-offsetof-extensions]
  UPB_ASSERT(UPB_ALIGN_OF(upb_StringView) ==
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
  • Loading branch information
boltzmannrain authored and layus committed Dec 13, 2023
1 parent 4d54ca8 commit 306e8ea
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ stdenv.mkDerivation rec {

postPatch =
let
# Workaround for https://github.com/NixOS/nixpkgs/issues/166205
nixpkgs166205ldflag = lib.optionalString stdenv.cc.isClang "-l${stdenv.cc.libcxx.cxxabi.libName}";
darwinPatches = ''
bazelLinkFlags () {
eval set -- "$NIX_LDFLAGS"
Expand All @@ -284,11 +286,13 @@ stdenv.mkDerivation rec {
# Framework search paths aren't added by bintools hook
# https://github.com/NixOS/nixpkgs/pull/41914
export NIX_LDFLAGS+=" -F${CoreFoundation}/Library/Frameworks -F${CoreServices}/Library/Frameworks -F${Foundation}/Library/Frameworks -F${IOKit}/Library/Frameworks"
export NIX_LDFLAGS+=" -F${CoreFoundation}/Library/Frameworks -F${CoreServices}/Library/Frameworks -F${Foundation}/Library/Frameworks -F${IOKit}/Library/Frameworks ${nixpkgs166205ldflag}"
# libcxx includes aren't added by libcxx hook
# https://github.com/NixOS/nixpkgs/pull/41589
export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem ${lib.getDev libcxx}/include/c++/v1"
# for CLang 16 compatibility in external/upb dependency
export NIX_CFLAGS_COMPILE+=" -Wno-gnu-offsetof-extensions"
# This variable is used by bazel to propagate env vars for homebrew,
# which is exactly what we need too.
Expand Down

0 comments on commit 306e8ea

Please sign in to comment.