summary refs log tree commit diff
diff options
context:
space:
mode:
authorMoritz Angermann <moritz.angermann@gmail.com>2020-06-08 12:40:38 +0800
committerGitHub <noreply@github.com>2020-06-08 12:40:38 +0800
commit58ffaee5d7d02058a1dd8644990b2f3b6c8a94ef (patch)
treedffe8f62bc0bdc935b62951581a56673f279d926
parente27e475f0d7292f1ecb64c4f40de2d417b46f45a (diff)
downloadnixpkgs-58ffaee5d7d02058a1dd8644990b2f3b6c8a94ef.tar
nixpkgs-58ffaee5d7d02058a1dd8644990b2f3b6c8a94ef.tar.gz
nixpkgs-58ffaee5d7d02058a1dd8644990b2f3b6c8a94ef.tar.bz2
nixpkgs-58ffaee5d7d02058a1dd8644990b2f3b6c8a94ef.tar.lz
nixpkgs-58ffaee5d7d02058a1dd8644990b2f3b6c8a94ef.tar.xz
nixpkgs-58ffaee5d7d02058a1dd8644990b2f3b6c8a94ef.tar.zst
nixpkgs-58ffaee5d7d02058a1dd8644990b2f3b6c8a94ef.zip
Update configure-flags.nix
-rw-r--r--pkgs/development/compilers/gcc/common/configure-flags.nix15
1 files changed, 12 insertions, 3 deletions
diff --git a/pkgs/development/compilers/gcc/common/configure-flags.nix b/pkgs/development/compilers/gcc/common/configure-flags.nix
index f38ce180b1f..0560fe0fda8 100644
--- a/pkgs/development/compilers/gcc/common/configure-flags.nix
+++ b/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
@@ -60,7 +70,9 @@ let
       "--disable-debug"
       "--disable-win32-registry"
     ] ++ 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"}")
@@ -87,9 +99,6 @@ let
       "--disable-nls"
       # To keep ABI compatibility with upstream mingw-w64
       "--enable-fully-dynamic-string"
-    ] ++ lib.optionals (crossMingw && targetPlatform.isx86_32) [
-      "--enable-sjlj-exceptions"
-      "--with-dwarf2"
     ] ++ lib.optional (targetPlatform.libc == "newlib") "--with-newlib"
       ++ lib.optional (targetPlatform.libc == "avrlibc") "--with-avrlibc"
     );