diff --git a/pkgs/development/compilers/gcc/common/configure-flags.nix b/pkgs/development/compilers/gcc/common/configure-flags.nix index 17d32f60d6cd..a633d1f4d47d 100644 --- a/pkgs/development/compilers/gcc/common/configure-flags.nix +++ b/pkgs/development/compilers/gcc/common/configure-flags.nix @@ -20,6 +20,7 @@ enablePlugin, disableGdbPlugin ? !enablePlugin, enableShared, + enableDefaultPie, targetPrefix, langC, @@ -279,6 +280,9 @@ let "libat_cv_have_ifunc=no" "--disable-gnu-indirect-function" ] + ++ lib.optionals enableDefaultPie [ + "--enable-default-pie" + ] ++ lib.optionals langJit [ "--enable-host-shared" ] diff --git a/pkgs/development/compilers/gcc/default.nix b/pkgs/development/compilers/gcc/default.nix index 3e78d7946b5d..03ee925908f4 100644 --- a/pkgs/development/compilers/gcc/default.nix +++ b/pkgs/development/compilers/gcc/default.nix @@ -19,6 +19,7 @@ cargo, staticCompiler ? false, enableShared ? stdenv.targetPlatform.hasSharedLibraries, + enableDefaultPie ? true, enableLTO ? stdenv.hostPlatform.hasSharedLibraries, texinfo ? null, perl ? null, # optional, for texi2pod (then pod2man) @@ -137,6 +138,7 @@ let darwin disableBootstrap disableGdbPlugin + enableDefaultPie enableLTO enableMultilib enablePlugin diff --git a/pkgs/development/compilers/gcc/ng/common/gcc/default.nix b/pkgs/development/compilers/gcc/ng/common/gcc/default.nix index fe4688a96beb..3a8250b6a2c7 100644 --- a/pkgs/development/compilers/gcc/ng/common/gcc/default.nix +++ b/pkgs/development/compilers/gcc/ng/common/gcc/default.nix @@ -193,6 +193,7 @@ stdenv.mkDerivation (finalAttrs: { "--disable-multilib" "--disable-nls" "--disable-shared" + "--enable-default-pie" "--enable-languages=${ lib.concatStrings ( lib.intersperse "," ( diff --git a/pkgs/development/libraries/gcc/libgcc/default.nix b/pkgs/development/libraries/gcc/libgcc/default.nix index 78ecc8f45523..1085e9b301f6 100644 --- a/pkgs/development/libraries/gcc/libgcc/default.nix +++ b/pkgs/development/libraries/gcc/libgcc/default.nix @@ -54,9 +54,10 @@ stdenv.mkDerivation (finalAttrs: { # Drop in libiberty, as external builds are not expected cd "$buildRoot" ( - mkdir -p build-${stdenv.buildPlatform.config}/libiberty/ - cd build-${stdenv.buildPlatform.config}/libiberty/ - ln -s ${buildPackages.libiberty}/lib/libiberty.a ./ + mkdir -p "build-${stdenv.buildPlatform.config}/libiberty/pic" + cd "build-${stdenv.buildPlatform.config}/libiberty/" + ln -s "${buildPackages.libiberty}/lib/libiberty.a" ./ + ln -s "${buildPackages.libiberty}/lib/libiberty_pic.a" pic/libiberty.a ) mkdir -p "$buildRoot/gcc" cd "$buildRoot/gcc" diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index 6287a3877b41..77906d1ca425 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -425,6 +425,11 @@ assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check # ...-binutils-patchelfed-ld-2.40/bin/ld: ...-xgcc-13.0.0/libexec/gcc/x86_64-unknown-linux-gnu/13.0.1/liblto_plugin.so: # error loading plugin: ...-bootstrap-tools/lib/libpthread.so.0: undefined symbol: __libc_vfork, version GLIBC_PRIVATE enableLTO = false; + + # relocatable libs may not be available in the bootstrap + # which will cause compilation to fail with + # configure: error: C compiler cannot create executables + enableDefaultPie = false; } )).overrideAttrs (a: {