gcc: build with --enable-default-pie configure option
Rather than implementing this at the wrapper level (which has been attempted but not merged in # 252310 and # 205031), configuring GCC directly with --enable-default-pie is simple and matches mainstream distribution practices. Packages that cannot build with PIE can explicitly pass -no-pie when needed, and mostly already do due to the prevalence of GCCs built with this flag. Requires followup to decide what to do with "pie" flag.
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
enablePlugin,
|
enablePlugin,
|
||||||
disableGdbPlugin ? !enablePlugin,
|
disableGdbPlugin ? !enablePlugin,
|
||||||
enableShared,
|
enableShared,
|
||||||
|
enableDefaultPie,
|
||||||
targetPrefix,
|
targetPrefix,
|
||||||
|
|
||||||
langC,
|
langC,
|
||||||
@@ -279,6 +280,9 @@ let
|
|||||||
"libat_cv_have_ifunc=no"
|
"libat_cv_have_ifunc=no"
|
||||||
"--disable-gnu-indirect-function"
|
"--disable-gnu-indirect-function"
|
||||||
]
|
]
|
||||||
|
++ lib.optionals enableDefaultPie [
|
||||||
|
"--enable-default-pie"
|
||||||
|
]
|
||||||
++ lib.optionals langJit [
|
++ lib.optionals langJit [
|
||||||
"--enable-host-shared"
|
"--enable-host-shared"
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
cargo,
|
cargo,
|
||||||
staticCompiler ? false,
|
staticCompiler ? false,
|
||||||
enableShared ? stdenv.targetPlatform.hasSharedLibraries,
|
enableShared ? stdenv.targetPlatform.hasSharedLibraries,
|
||||||
|
enableDefaultPie ? true,
|
||||||
enableLTO ? stdenv.hostPlatform.hasSharedLibraries,
|
enableLTO ? stdenv.hostPlatform.hasSharedLibraries,
|
||||||
texinfo ? null,
|
texinfo ? null,
|
||||||
perl ? null, # optional, for texi2pod (then pod2man)
|
perl ? null, # optional, for texi2pod (then pod2man)
|
||||||
@@ -137,6 +138,7 @@ let
|
|||||||
darwin
|
darwin
|
||||||
disableBootstrap
|
disableBootstrap
|
||||||
disableGdbPlugin
|
disableGdbPlugin
|
||||||
|
enableDefaultPie
|
||||||
enableLTO
|
enableLTO
|
||||||
enableMultilib
|
enableMultilib
|
||||||
enablePlugin
|
enablePlugin
|
||||||
|
|||||||
@@ -193,6 +193,7 @@ stdenv.mkDerivation (finalAttrs: {
|
|||||||
"--disable-multilib"
|
"--disable-multilib"
|
||||||
"--disable-nls"
|
"--disable-nls"
|
||||||
"--disable-shared"
|
"--disable-shared"
|
||||||
|
"--enable-default-pie"
|
||||||
"--enable-languages=${
|
"--enable-languages=${
|
||||||
lib.concatStrings (
|
lib.concatStrings (
|
||||||
lib.intersperse "," (
|
lib.intersperse "," (
|
||||||
|
|||||||
@@ -54,9 +54,10 @@ stdenv.mkDerivation (finalAttrs: {
|
|||||||
# Drop in libiberty, as external builds are not expected
|
# Drop in libiberty, as external builds are not expected
|
||||||
cd "$buildRoot"
|
cd "$buildRoot"
|
||||||
(
|
(
|
||||||
mkdir -p build-${stdenv.buildPlatform.config}/libiberty/
|
mkdir -p "build-${stdenv.buildPlatform.config}/libiberty/pic"
|
||||||
cd build-${stdenv.buildPlatform.config}/libiberty/
|
cd "build-${stdenv.buildPlatform.config}/libiberty/"
|
||||||
ln -s ${buildPackages.libiberty}/lib/libiberty.a ./
|
ln -s "${buildPackages.libiberty}/lib/libiberty.a" ./
|
||||||
|
ln -s "${buildPackages.libiberty}/lib/libiberty_pic.a" pic/libiberty.a
|
||||||
)
|
)
|
||||||
mkdir -p "$buildRoot/gcc"
|
mkdir -p "$buildRoot/gcc"
|
||||||
cd "$buildRoot/gcc"
|
cd "$buildRoot/gcc"
|
||||||
|
|||||||
@@ -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:
|
# ...-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
|
# error loading plugin: ...-bootstrap-tools/lib/libpthread.so.0: undefined symbol: __libc_vfork, version GLIBC_PRIVATE
|
||||||
enableLTO = false;
|
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
|
)).overrideAttrs
|
||||||
(a: {
|
(a: {
|
||||||
|
|||||||
Reference in New Issue
Block a user