diff --git a/pkgs/development/libraries/gmp/6.x.nix b/pkgs/development/libraries/gmp/6.x.nix index 9093073cecff4..7bcc31e4fe8d0 100644 --- a/pkgs/development/libraries/gmp/6.x.nix +++ b/pkgs/development/libraries/gmp/6.x.nix @@ -2,6 +2,7 @@ , cxx ? !stdenv.hostPlatform.useAndroidPrebuilt && !stdenv.hostPlatform.isWasm , buildPackages , withStatic ? stdenv.hostPlatform.isStatic +, autoreconfHook }: # Note: this package is used for bootstrapping fetchurl, and thus @@ -29,7 +30,7 @@ let self = stdenv.mkDerivation rec { passthru.static = self.out; depsBuildBuild = [ buildPackages.stdenv.cc ]; - nativeBuildInputs = [ m4 ]; + nativeBuildInputs = [ m4 ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ autoreconfHook ]; configureFlags = [ "--with-pic" diff --git a/pkgs/development/libraries/isl/generic.nix b/pkgs/development/libraries/isl/generic.nix index eb6fe5f9cd69a..5a82fdfd6ab3e 100644 --- a/pkgs/development/libraries/isl/generic.nix +++ b/pkgs/development/libraries/isl/generic.nix @@ -6,6 +6,7 @@ }: { lib, stdenv, fetchurl, gmp +, autoreconfHook }: stdenv.mkDerivation { @@ -17,6 +18,8 @@ stdenv.mkDerivation { inherit patches; + nativeBuildInputs = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ autoreconfHook ]; + buildInputs = [ gmp ]; inherit configureFlags; diff --git a/pkgs/development/libraries/libmpc/default.nix b/pkgs/development/libraries/libmpc/default.nix index 2dede1f976d22..d4c575a194349 100644 --- a/pkgs/development/libraries/libmpc/default.nix +++ b/pkgs/development/libraries/libmpc/default.nix @@ -1,5 +1,6 @@ { lib, stdenv, fetchurl , gmp, mpfr +, fixPathToUsrBinFileInConfigureScript }: # Note: this package is used for bootstrapping fetchurl, and thus @@ -16,7 +17,7 @@ stdenv.mkDerivation rec { sha256 = "0n846hqfqvmsmim7qdlms0qr86f1hck19p12nq3g3z2x74n3sl0p"; }; - buildInputs = [ gmp mpfr ]; + buildInputs = [ gmp mpfr ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ fixPathToUsrBinFileInConfigureScript ]; doCheck = true; # not cross; diff --git a/pkgs/development/libraries/mpfr/default.nix b/pkgs/development/libraries/mpfr/default.nix index fc7eeeab94206..88a3bda8a8f01 100644 --- a/pkgs/development/libraries/mpfr/default.nix +++ b/pkgs/development/libraries/mpfr/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchurl, gmp }: +{ lib, stdenv, fetchurl, gmp, fixPathToUsrBinFileInConfigureScript }: # Note: this package is used for bootstrapping fetchurl, and thus # cannot use fetchpatch! All mutable patches (generated by GitHub or @@ -22,6 +22,9 @@ stdenv.mkDerivation rec { # mpfr.h requires gmp.h propagatedBuildInputs = [ gmp ]; + # autoreconf with latest autotools will break mpfr + nativeBuildInputs = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ fixPathToUsrBinFileInConfigureScript ]; + configureFlags = lib.optional stdenv.hostPlatform.isSunOS "--disable-thread-safe" ++ lib.optional stdenv.hostPlatform.is64bit "--with-pic"; diff --git a/pkgs/development/libraries/pcre/default.nix b/pkgs/development/libraries/pcre/default.nix index 5fc8d496ba914..d8204f7a79620 100644 --- a/pkgs/development/libraries/pcre/default.nix +++ b/pkgs/development/libraries/pcre/default.nix @@ -1,5 +1,6 @@ { lib, stdenv, fetchurl , pcre, windows ? null +, autoreconfHook , variant ? null }: @@ -20,6 +21,8 @@ stdenv.mkDerivation rec { outputs = [ "bin" "dev" "out" "doc" "man" ]; + nativeBuildInputs = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ autoreconfHook ]; + # Disable jit on Apple Silicon, https://github.com/zherczeg/sljit/issues/51 configureFlags = optional (!stdenv.hostPlatform.isRiscV && !(stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)) "--enable-jit" ++ [ "--enable-unicode-properties" diff --git a/pkgs/development/tools/misc/libtool/libtool2.nix b/pkgs/development/tools/misc/libtool/libtool2.nix index 44e4c8665c839..109bdd704088f 100644 --- a/pkgs/development/tools/misc/libtool/libtool2.nix +++ b/pkgs/development/tools/misc/libtool/libtool2.nix @@ -1,4 +1,5 @@ { lib, stdenv, fetchurl, fetchpatch, autoconf, automake, m4, perl, help2man +, buildPackages }: # Note: this package is used for bootstrapping fetchurl, and thus @@ -36,6 +37,25 @@ stdenv.mkDerivation rec { popd ''; + # When detecting the `LD` (linker) command and flags for cross + # compiling, libtool.m4 expects to be able to use "/usr/bin/file" to + # detect host details like ABI and linker flags. Unfortunately this + # detection code hardwires the path to /usr/bin/file, which is + # inaccessible for sandboxed builds. This causes the `LD` flag to + # be detected incorrectly when cross-compiling to the following + # hostPlatforms: {x86_64, powerpc, s390, sparc, mips64*}-linux, + # x86_64-kfreebsd, *-solaris, *-irix, and *-hpux. + # + # This substitution is performed only for cross-compilation in order + # to avoid a mass-rebuild. A separate PR will be submitted to + # staging, not to be merged until after nixpkgs-22.05 branch-off, + # which deletes this conditional and this comment. + # + preBuild = if stdenv.buildPlatform == stdenv.targetPlatform + then null + else ''substituteInPlace m4/libtool.m4 \ + --replace "/usr/bin/file" "${buildPackages.file}/bin/file"''; + nativeBuildInputs = [ perl help2man m4 ] ++ [ autoconf automake ]; propagatedBuildInputs = [ m4 ]; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 5d52bf43efcb7..38f30f5a0f8f8 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -179,6 +179,17 @@ with pkgs; } ''); + # libtool.m4 invokes "/usr/bin/file", and is vendored into many ./configure scripts + fixPathToUsrBinFileInConfigureScript = makeSetupHook {} + (writeScript "fix-path-to-user-bin-file.sh" '' + postUnpackHooks+=(_fixPathToUserBinFile) + _fixPathToUserBinFile() { + if [ -e $sourceRoot/configure ]; then + substituteInPlace $sourceRoot/configure --replace /usr/bin/file ${buildPackages.file}/bin/file + fi + } + ''); + addOpenGLRunpath = callPackage ../build-support/add-opengl-runpath { }; quickemu = callPackage ../development/quickemu { };