Skip to content

Commit ec65fbc

Browse files
committed
[gcc/fix-x32-mingw] gcc: use DWARF exception handling for i686-w64-mingw32
This is the default used by MSYS2[^1], ArchLinux[^2] and probably everyone else. This is required to compile Rust programs as it doesn't support SJLJ[^3]. [^1]: https://github.com/msys2/MINGW-packages/blob/725f262e9f6313e3ee04327a33c16614c970a110/mingw-w64-gcc/PKGBUILD#L185-L186 [^2]: https://gitlab.archlinux.org/archlinux/packaging/packages/mingw-w64-gcc/-/blob/14.2.0-3/PKGBUILD#L62 [^3]: rust-lang/rust#55444 (comment)
1 parent bf0bf76 commit ec65fbc

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

pkgs/development/compilers/gcc/common/configure-flags.nix

+4-14
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,6 @@
2828

2929
assert !enablePlugin -> disableGdbPlugin;
3030

31-
# Note [Windows Exception Handling]
32-
# sjlj (short jump long jump) exception handling makes no sense on x86_64,
33-
# it's forcably slowing programs down as it produces a constant overhead.
34-
# On x86_64 we have SEH (Structured Exception Handling) and we should use
35-
# that. On i686, we do not have SEH, and have to use sjlj with dwarf2.
36-
# Hence it's now conditional on x86_32 (i686 is 32bit).
37-
#
38-
# ref: https://stackoverflow.com/questions/15670169/what-is-difference-between-sjlj-vs-dwarf-vs-seh
39-
40-
4131
let
4232
inherit (stdenv)
4333
buildPlatform hostPlatform targetPlatform;
@@ -57,6 +47,10 @@ let
5747
"--with-as=${if targetPackages.stdenv.cc.bintools.isLLVM then binutils else targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as"
5848
"--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld"
5949
]
50+
++ lib.optionals (crossMingw && targetPlatform.isx86_32) [
51+
"--disable-sjlj-exceptions"
52+
"--with-dwarf2"
53+
]
6054
++ (if withoutTargetLibc then [
6155
"--disable-libssp"
6256
"--disable-nls"
@@ -80,10 +74,6 @@ let
8074
"--disable-nls"
8175
# To keep ABI compatibility with upstream mingw-w64
8276
"--enable-fully-dynamic-string"
83-
] ++ lib.optionals (crossMingw && targetPlatform.isx86_32) [
84-
# See Note [Windows Exception Handling]
85-
"--enable-sjlj-exceptions"
86-
"--with-dwarf2"
8777
] else [
8878
(if crossDarwin then "--with-sysroot=${lib.getLib libcCross}/share/sysroot"
8979
else "--with-headers=${lib.getDev libcCross}${libcCross.incdir or "/include"}")

0 commit comments

Comments
 (0)