diff options
author | Alyssa Ross <hi@alyssa.is> | 2021-11-03 16:57:34 +0000 |
---|---|---|
committer | Jonathan Ringer <jonringer@users.noreply.github.com> | 2021-12-02 16:11:43 -0800 |
commit | 801078806b8664c8c5aa90587dcabf8b285e9269 (patch) | |
tree | 1bee0736218441f79458eb378e5202602f439978 | |
parent | 2e6fadac4ed52857ad0baf664c38f3f95819d8f3 (diff) | |
download | nixpkgs-801078806b8664c8c5aa90587dcabf8b285e9269.tar nixpkgs-801078806b8664c8c5aa90587dcabf8b285e9269.tar.gz nixpkgs-801078806b8664c8c5aa90587dcabf8b285e9269.tar.bz2 nixpkgs-801078806b8664c8c5aa90587dcabf8b285e9269.tar.lz nixpkgs-801078806b8664c8c5aa90587dcabf8b285e9269.tar.xz nixpkgs-801078806b8664c8c5aa90587dcabf8b285e9269.tar.zst nixpkgs-801078806b8664c8c5aa90587dcabf8b285e9269.zip |
pkg-config: always pass --static in static builds
By default, pkg-config output will not include Requires.private dependencies (which specify dependencies that only apply when building statically). It will only do this when passed --static. In pkgsStatic, let's ensure pkg-config is always operating in static mode, because pkgsStatic will ensure that any libraries pkg-config might find will always be static, and so will always need their Requires.private dependencies. This is very useful for Meson builds, because otherwise Meson will only pass --static to pkg-config if the dependency was explicitly "static : true", which is not likely to be the case for most stuff we're building. An alternative proposal was to patch Meson to add a special environment variable to force dependencies to be "static : true". I feel that the approach I've taken here is less invasive.
-rw-r--r-- | pkgs/build-support/pkg-config-wrapper/default.nix | 3 | ||||
-rw-r--r-- | pkgs/build-support/pkg-config-wrapper/pkg-config-wrapper.sh | 2 |
2 files changed, 5 insertions, 0 deletions
diff --git a/pkgs/build-support/pkg-config-wrapper/default.nix b/pkgs/build-support/pkg-config-wrapper/default.nix index bbc49d6728c..aa8f57ffb04 100644 --- a/pkgs/build-support/pkg-config-wrapper/default.nix +++ b/pkgs/build-support/pkg-config-wrapper/default.nix @@ -47,6 +47,9 @@ stdenv.mkDerivation { dontBuild = true; dontConfigure = true; + # Additional flags passed to pkg-config. + addFlags = lib.optional stdenv.targetPlatform.isStatic "--static"; + unpackPhase = '' src=$PWD ''; diff --git a/pkgs/build-support/pkg-config-wrapper/pkg-config-wrapper.sh b/pkgs/build-support/pkg-config-wrapper/pkg-config-wrapper.sh index a5a44271668..9d0f7b028d8 100644 --- a/pkgs/build-support/pkg-config-wrapper/pkg-config-wrapper.sh +++ b/pkgs/build-support/pkg-config-wrapper/pkg-config-wrapper.sh @@ -12,6 +12,8 @@ if [ -z "${NIX_PKG_CONFIG_WRAPPER_FLAGS_SET_@suffixSalt@:-}" ]; then source @out@/nix-support/add-flags.sh fi +set -- "$@" @addFlags@ + if (( ${#role_suffixes[@]} > 0 )); then # replace env var with nix-modified one PKG_CONFIG_PATH=$PKG_CONFIG_PATH_@suffixSalt@ exec @prog@ "$@" |