Unverified Commit ccc56d1a authored by Luna Nova's avatar Luna Nova
Browse files

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.
parent 58b0870c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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"
    ]
+2 −0
Original line number Diff line number Diff line
@@ -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
+1 −0
Original line number Diff line number Diff line
@@ -193,6 +193,7 @@ stdenv.mkDerivation (finalAttrs: {
    "--disable-multilib"
    "--disable-nls"
    "--disable-shared"
    "--enable-default-pie"
    "--enable-languages=${
      lib.concatStrings (
        lib.intersperse "," (
+4 −3
Original line number Diff line number Diff line
@@ -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"
+5 −0
Original line number Diff line number Diff line
@@ -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: {