Skip to content

Instantly share code, notes, and snippets.

@tonytheodore
Created February 4, 2017 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonytheodore/0d5aec49cf86ed0c0faeb42c33b4b45e to your computer and use it in GitHub Desktop.
Save tonytheodore/0d5aec49cf86ed0c0faeb42c33b4b45e to your computer and use it in GitHub Desktop.
exceptions.diff
diff --git a/Makefile b/Makefile
index 727d21a..b92b3e8 100644
--- a/Makefile
+++ b/Makefile
@@ -87,8 +87,24 @@ MXE_CONFIGURE_OPTS = \
--disable-static --enable-shared ) \
$(MXE_DISABLE_DOC_OPTS)
+# GCC threads and exceptions
MXE_GCC_THREADS = \
- $(if $(findstring posix,$(TARGET)),posix,win32)
+ $(if $(findstring posix,$(or $(TARGET),$(1))),posix,win32)
+
+# allowed exception handling for targets
+# default (first item) and alternate, revisit if gcc/mingw-w64 change defaults
+i686-w64-mingw32_EH := sjlj dw2
+x86_64-w64-mingw32_EH := seh sjlj
+
+# functions to determine exception handling from user-specified target
+TARGET_EH_LIST = $($(firstword $(call split,.,$(or $(TARGET),$(1))))_EH)
+DEFAULT_EH = $(firstword $(TARGET_EH_LIST))
+GCC_EXCEPTIONS = \
+ $(lastword $(DEFAULT_EH) \
+ $(filter $(TARGET_EH_LIST),$(call split,.,$(or $(TARGET),$(1)))))
+MXE_GCC_EXCEPTION_OPTS = \
+ $(if $(call seq,sjlj,$(GCC_EXCEPTIONS)),--enable-sjlj-exceptions) \
+ $(if $(call seq,dw2,$(GCC_EXCEPTIONS)),--disable-sjlj-exceptions)
# Append these to the "make" and "make install" steps of autotools packages
# in order to neither build nor install unwanted binaries, manpages,
diff --git a/src/gcc.mk b/src/gcc.mk
index 31e8d28..236f492 100644
--- a/src/gcc.mk
+++ b/src/gcc.mk
@@ -37,6 +37,7 @@ define $(PKG)_CONFIGURE
--without-x \
--disable-win32-registry \
--enable-threads=$(MXE_GCC_THREADS) \
+ $(MXE_GCC_EXCEPTION_OPTS) \
--enable-libgomp \
--with-gmp='$(PREFIX)/$(BUILD)' \
--with-isl='$(PREFIX)/$(BUILD)' \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment