diff options
Diffstat (limited to 'nixpkgs/pkgs/development/compilers/gcc/common')
3 files changed, 62 insertions, 11 deletions
diff --git a/nixpkgs/pkgs/development/compilers/gcc/common/configure-flags.nix b/nixpkgs/pkgs/development/compilers/gcc/common/configure-flags.nix index be7f3df42de..7e0d691412b 100644 --- a/nixpkgs/pkgs/development/compilers/gcc/common/configure-flags.nix +++ b/nixpkgs/pkgs/development/compilers/gcc/common/configure-flags.nix @@ -27,6 +27,16 @@ assert cloog != null -> stdenv.lib.versionOlder version "5"; assert langJava -> stdenv.lib.versionOlder version "7"; +# Note [Windows Exception Handling] +# sjlj (short jump long jump) exception handling makes no sense on x86_64, +# it's forcably slowing programs down as it produces a constant overhead. +# On x86_64 we have SEH (Structured Exception Handling) and we should use +# that. On i686, we do not have SEH, and have to use sjlj with dwarf2. +# Hence it's now conditional on x86_32 (i686 is 32bit). +# +# ref: https://stackoverflow.com/questions/15670169/what-is-difference-between-sjlj-vs-dwarf-vs-seh + + let inherit (stdenv) buildPlatform hostPlatform targetPlatform @@ -58,8 +68,16 @@ let "--with-gnu-as" "--with-gnu-ld" "--disable-debug" - "--enable-sjlj-exceptions" "--disable-win32-registry" + "--enable-hash-synchronization" + "--enable-libssp" + "--disable-nls" + # To keep ABI compatibility with upstream mingw-w64 + "--enable-fully-dynamic-string" + ] ++ lib.optionals (crossMingw && targetPlatform.isx86_32) [ + # See Note [Windows Exception Handling] + "--enable-sjlj-exceptions" + "--with-dwarf2" ] else [ (if crossDarwin then "--with-sysroot=${lib.getLib libcCross}/share/sysroot" else "--with-headers=${lib.getDev libcCross}${libcCross.incdir or "/include"}") @@ -80,14 +98,6 @@ let ] ++ lib.optionals (targetPlatform.libc == "musl") [ # musl at least, disable: https://git.buildroot.net/buildroot/commit/?id=873d4019f7fb00f6a80592224236b3ba7d657865 "--disable-libmpx" - ] ++ lib.optionals crossMingw [ - "--enable-sjlj-exceptions" - "--enable-hash-synchronization" - "--enable-libssp" - "--disable-nls" - "--with-dwarf2" - # To keep ABI compatibility with upstream mingw-w64 - "--enable-fully-dynamic-string" ] ++ lib.optional (targetPlatform.libc == "newlib") "--with-newlib" ++ lib.optional (targetPlatform.libc == "avrlibc") "--with-avrlibc" ); diff --git a/nixpkgs/pkgs/development/compilers/gcc/common/extra-target-flags.nix b/nixpkgs/pkgs/development/compilers/gcc/common/extra-target-flags.nix index 62d9818ca95..0a5a7a1bc1c 100644 --- a/nixpkgs/pkgs/development/compilers/gcc/common/extra-target-flags.nix +++ b/nixpkgs/pkgs/development/compilers/gcc/common/extra-target-flags.nix @@ -8,7 +8,7 @@ in # For non-cross builds these flags are currently assigned in builder.sh. # It would be good to consolidate the generation of makeFlags # ({C,CXX,LD}FLAGS_FOR_{BUILD,TARGET}, etc...) at some point. - EXTRA_TARGET_FLAGS = let + EXTRA_FLAGS_FOR_TARGET = let mkFlags = dep: langD: lib.optionals (targetPlatform != hostPlatform && dep != null && !langD) ([ "-O2 -idirafter ${lib.getDev dep}${dep.incdir or "/include"}" ] ++ stdenv.lib.optionals (! crossStageStatic) [ @@ -18,7 +18,7 @@ in ++ lib.optionals (!crossStageStatic) (mkFlags threadsCross langD) ; - EXTRA_TARGET_LDFLAGS = let + EXTRA_LDFLAGS_FOR_TARGET = let mkFlags = dep: lib.optionals (targetPlatform != hostPlatform && dep != null) ([ "-Wl,-L${lib.getLib dep}${dep.libdir or "/lib"}" ] ++ (if crossStageStatic then [ diff --git a/nixpkgs/pkgs/development/compilers/gcc/common/pre-configure.nix b/nixpkgs/pkgs/development/compilers/gcc/common/pre-configure.nix index 85b854e19b9..1c65b4a8ba6 100644 --- a/nixpkgs/pkgs/development/compilers/gcc/common/pre-configure.nix +++ b/nixpkgs/pkgs/development/compilers/gcc/common/pre-configure.nix @@ -2,6 +2,7 @@ , gnatboot ? null , langAda ? false , langJava ? false +, langJit ? false , langGo }: assert langJava -> lib.versionOlder version "7"; @@ -17,3 +18,43 @@ lib.optionalString (hostPlatform.isSunOS && hostPlatform.is64bit) '' '' + lib.optionalString langAda '' export PATH=${gnatboot}/bin:$PATH '' + +# NOTE 2020/3/18: This environment variable prevents configure scripts from +# detecting the presence of aligned_alloc on Darwin. There are many facts that +# collectively make this fix necessary: +# - Nix uses a fixed set of standard library headers on all MacOS systems, +# regardless of their actual version. (Nix uses version 10.12 headers.) +# - Nix uses the native standard library binaries for the build system. That +# means the standard library binaries may not exactly match the standard +# library headers. +# - The aligned_alloc procedure is present in MacOS 10.15 (Catalina), but not +# in earlier versions. Therefore on Catalina systems, aligned_alloc is +# linkable (i.e. present in the binary libraries) but not present in the +# headers. +# - Configure scripts detect a procedure's existence by checking whether it is +# linkable. They do not check whether it is present in the headers. +# - GCC throws an error during compilation because aligned_alloc is not +# defined in the headers---even though the linker can see it. +# +# This fix would not be necessary if ANY of the above were false: +# - If Nix used native headers for each different MacOS version, aligned_alloc +# would be in the headers on Catalina. +# - If Nix used the same libary binaries for each MacOS version, aligned_alloc +# would not be in the library binaries. +# - If Catalina did not include aligned_alloc, this wouldn't be a problem. +# - If the configure scripts looked for header presence as well as +# linkability, they would see that aligned_alloc is missing. +# - If GCC allowed implicit declaration of symbols, it would not fail during +# compilation even if the configure scripts did not check header presence. +# ++ lib.optionalString (hostPlatform.isDarwin) '' + export ac_cv_func_aligned_alloc=no +'' + +# In order to properly install libgccjit on macOS Catalina, strip(1) +# upon installation must not remove external symbols, otherwise the +# install step errors with "symbols referenced by indirect symbol +# table entries that can't be stripped". ++ lib.optionalString (hostPlatform.isDarwin && langJit) '' + export STRIP='strip -x' +'' |