Skip to content

Commit 4c39db4

Browse files
committed
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 b024ced commit 4c39db4

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

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

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,6 @@
3636

3737
assert !enablePlugin -> disableGdbPlugin;
3838

39-
# Note [Windows Exception Handling]
40-
# sjlj (short jump long jump) exception handling makes no sense on x86_64,
41-
# it's forcably slowing programs down as it produces a constant overhead.
42-
# On x86_64 we have SEH (Structured Exception Handling) and we should use
43-
# that. On i686, we do not have SEH, and have to use sjlj with dwarf2.
44-
# Hence it's now conditional on x86_32 (i686 is 32bit).
45-
#
46-
# ref: https://stackoverflow.com/questions/15670169/what-is-difference-between-sjlj-vs-dwarf-vs-seh
47-
4839
let
4940
inherit (stdenv)
5041
buildPlatform
@@ -71,6 +62,10 @@ let
7162
}/bin/${targetPlatform.config}-as"
7263
"--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld"
7364
]
65+
++ lib.optionals (crossMingw && targetPlatform.isx86_32) [
66+
"--disable-sjlj-exceptions"
67+
"--with-dwarf2"
68+
]
7469
++ (
7570
if withoutTargetLibc then
7671
[
@@ -98,11 +93,6 @@ let
9893
# To keep ABI compatibility with upstream mingw-w64
9994
"--enable-fully-dynamic-string"
10095
]
101-
++ lib.optionals (crossMingw && targetPlatform.isx86_32) [
102-
# See Note [Windows Exception Handling]
103-
"--enable-sjlj-exceptions"
104-
"--with-dwarf2"
105-
]
10696
else
10797
[
10898
(

0 commit comments

Comments
 (0)