diff options
author | Matthew Bauer <mjbauer95@gmail.com> | 2020-08-28 15:10:59 -0500 |
---|---|---|
committer | Matthew Bauer <mjbauer95@gmail.com> | 2020-08-28 15:10:59 -0500 |
commit | 27fb2091943966748d02b12bfa07fb6401feaa69 (patch) | |
tree | bfe4b3396684c0a0e1a58251dd629ce1c44a824c /pkgs/build-support | |
parent | 5bd2c3719a5af1a4a8d430e5e33ba3092bdb9f7e (diff) | |
download | nixpkgs-27fb2091943966748d02b12bfa07fb6401feaa69.tar nixpkgs-27fb2091943966748d02b12bfa07fb6401feaa69.tar.gz nixpkgs-27fb2091943966748d02b12bfa07fb6401feaa69.tar.bz2 nixpkgs-27fb2091943966748d02b12bfa07fb6401feaa69.tar.lz nixpkgs-27fb2091943966748d02b12bfa07fb6401feaa69.tar.xz nixpkgs-27fb2091943966748d02b12bfa07fb6401feaa69.tar.zst nixpkgs-27fb2091943966748d02b12bfa07fb6401feaa69.zip |
build-bazel-package: add dontAddBazelOpts arg
This adds an option to skip adding --copt and --linkopt to Bazel flags. In some cases, Bazel doesn’t like these flags, like when a custom toolchain is being used (as opposed to the builtin one. The compiler can still get the dependencies since it is invoked through gcc wrapper and picks up the NIX_CFLAGS_COMPILE / NIX_LDFLAGS.
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/build-bazel-package/default.nix | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/pkgs/build-support/build-bazel-package/default.nix b/pkgs/build-support/build-bazel-package/default.nix index bbcbc4e2e11..4d22a329e41 100644 --- a/pkgs/build-support/build-bazel-package/default.nix +++ b/pkgs/build-support/build-bazel-package/default.nix @@ -37,6 +37,12 @@ args@{ # Debian-specific /usr/share/java paths, but doesn't in the configured build). , fetchConfigured ? false +# Don’t add Bazel --copt and --linkopt from NIX_CFLAGS_COMPILE / +# NIX_LDFLAGS. This is necessary when using a custom toolchain which +# Bazel wants all headers / libraries to come from, like when using +# CROSSTOOL. Weirdly, we can still get the flags through the wrapped +# compiler. +, dontAddBazelOpts ? false , ... }: @@ -170,6 +176,8 @@ in stdenv.mkDerivation (fBuildAttrs // { done '' + fBuildAttrs.preConfigure or ""; + inherit dontAddBazelOpts; + buildPhase = fBuildAttrs.buildPhase or '' runHook preBuild @@ -181,20 +189,22 @@ in stdenv.mkDerivation (fBuildAttrs // { # copts=() host_copts=() - for flag in $NIX_CFLAGS_COMPILE; do - copts+=( "--copt=$flag" ) - host_copts+=( "--host_copt=$flag" ) - done - for flag in $NIX_CXXSTDLIB_COMPILE; do - copts+=( "--copt=$flag" ) - host_copts+=( "--host_copt=$flag" ) - done linkopts=() host_linkopts=() - for flag in $NIX_LDFLAGS; do - linkopts+=( "--linkopt=-Wl,$flag" ) - host_linkopts+=( "--host_linkopt=-Wl,$flag" ) - done + if [ -z "''${dontAddBazelOpts:-}" ]; then + for flag in $NIX_CFLAGS_COMPILE; do + copts+=( "--copt=$flag" ) + host_copts+=( "--host_copt=$flag" ) + done + for flag in $NIX_CXXSTDLIB_COMPILE; do + copts+=( "--copt=$flag" ) + host_copts+=( "--host_copt=$flag" ) + done + for flag in $NIX_LDFLAGS; do + linkopts+=( "--linkopt=-Wl,$flag" ) + host_linkopts+=( "--host_linkopt=-Wl,$flag" ) + done + fi BAZEL_USE_CPP_ONLY_TOOLCHAIN=1 \ USER=homeless-shelter \ |