From 060cb6348506e82f6ee585c3c582c7249cdaa1f3 Mon Sep 17 00:00:00 2001 From: js6pak Date: Mon, 23 Dec 2024 03:51:45 +0100 Subject: [PATCH] [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]: https://github.com/rust-lang/rust/pull/55444#issuecomment-434044002 --- .../compilers/gcc/common/configure-flags.nix | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/pkgs/development/compilers/gcc/common/configure-flags.nix b/pkgs/development/compilers/gcc/common/configure-flags.nix index 25d4f1f53bae9c..eb2d363015bdd3 100644 --- a/pkgs/development/compilers/gcc/common/configure-flags.nix +++ b/pkgs/development/compilers/gcc/common/configure-flags.nix @@ -28,16 +28,6 @@ assert !enablePlugin -> disableGdbPlugin; -# 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; @@ -57,6 +47,10 @@ let "--with-as=${if targetPackages.stdenv.cc.bintools.isLLVM then binutils else targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" ] + ++ lib.optionals (crossMingw && targetPlatform.isx86_32) [ + "--disable-sjlj-exceptions" + "--with-dwarf2" + ] ++ (if withoutTargetLibc then [ "--disable-libssp" "--disable-nls" @@ -80,10 +74,6 @@ let "--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"}")