mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-28 22:32:58 +03:00
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.
This commit is contained in:
parent
5bd2c3719a
commit
27fb209194
@ -37,6 +37,12 @@ args@{
|
|||||||
# Debian-specific /usr/share/java paths, but doesn't in the configured build).
|
# Debian-specific /usr/share/java paths, but doesn't in the configured build).
|
||||||
, fetchConfigured ? false
|
, 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
|
done
|
||||||
'' + fBuildAttrs.preConfigure or "";
|
'' + fBuildAttrs.preConfigure or "";
|
||||||
|
|
||||||
|
inherit dontAddBazelOpts;
|
||||||
|
|
||||||
buildPhase = fBuildAttrs.buildPhase or ''
|
buildPhase = fBuildAttrs.buildPhase or ''
|
||||||
runHook preBuild
|
runHook preBuild
|
||||||
|
|
||||||
@ -181,6 +189,9 @@ in stdenv.mkDerivation (fBuildAttrs // {
|
|||||||
#
|
#
|
||||||
copts=()
|
copts=()
|
||||||
host_copts=()
|
host_copts=()
|
||||||
|
linkopts=()
|
||||||
|
host_linkopts=()
|
||||||
|
if [ -z "''${dontAddBazelOpts:-}" ]; then
|
||||||
for flag in $NIX_CFLAGS_COMPILE; do
|
for flag in $NIX_CFLAGS_COMPILE; do
|
||||||
copts+=( "--copt=$flag" )
|
copts+=( "--copt=$flag" )
|
||||||
host_copts+=( "--host_copt=$flag" )
|
host_copts+=( "--host_copt=$flag" )
|
||||||
@ -189,12 +200,11 @@ in stdenv.mkDerivation (fBuildAttrs // {
|
|||||||
copts+=( "--copt=$flag" )
|
copts+=( "--copt=$flag" )
|
||||||
host_copts+=( "--host_copt=$flag" )
|
host_copts+=( "--host_copt=$flag" )
|
||||||
done
|
done
|
||||||
linkopts=()
|
|
||||||
host_linkopts=()
|
|
||||||
for flag in $NIX_LDFLAGS; do
|
for flag in $NIX_LDFLAGS; do
|
||||||
linkopts+=( "--linkopt=-Wl,$flag" )
|
linkopts+=( "--linkopt=-Wl,$flag" )
|
||||||
host_linkopts+=( "--host_linkopt=-Wl,$flag" )
|
host_linkopts+=( "--host_linkopt=-Wl,$flag" )
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
BAZEL_USE_CPP_ONLY_TOOLCHAIN=1 \
|
BAZEL_USE_CPP_ONLY_TOOLCHAIN=1 \
|
||||||
USER=homeless-shelter \
|
USER=homeless-shelter \
|
||||||
|
Loading…
Reference in New Issue
Block a user