summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2009-04-19 19:59:26 +0200
committerBruno Haible <bruno@clisp.org>2009-04-19 19:59:26 +0200
commit9c3f20cc1cae69edbb237cb07dbc9e3a8cf93528 (patch)
treec6974187b04b295b5bdb9b72571f63db7039a6ec
parent46807f3e0bb828609aed0d561ede78fd6077c6fb (diff)
downloadlibunistring-9c3f20cc1cae69edbb237cb07dbc9e3a8cf93528.tar.gz
Don't use unreliable linker options on native Windows.
-rw-r--r--ChangeLog6
-rw-r--r--configure.ac2
-rw-r--r--m4/woe32-dll.m445
3 files changed, 53 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 33cc4d0..67573c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-04-19 Bruno Haible <bruno@clisp.org>
+
+ Don't use unreliable linker options on native Windows.
+ * m4/woe32-dll.m4: New file, from GNU gettext.
+ * configure.ac: Invoke gl_WOE32_DLL.
+
2008-04-11 Bruno Haible <bruno@clisp.org>
Limit the exported symbols through a config.h trick.
diff --git a/configure.ac b/configure.ac
index 08541a6..8bfd2b4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,6 +49,8 @@ AC_EXEEXT
dnl Check for build configuration.
+gl_WOE32_DLL
+
LT_INIT([win32-dll])
dnl Checks for types, header files, functions and declarations.
diff --git a/m4/woe32-dll.m4 b/m4/woe32-dll.m4
new file mode 100644
index 0000000..6b5a037
--- /dev/null
+++ b/m4/woe32-dll.m4
@@ -0,0 +1,45 @@
+# woe32-dll.m4 serial 2
+dnl Copyright (C) 2005-2006 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+# Add --disable-auto-import to the LDFLAGS if the linker supports it.
+# GNU ld has an --enable-auto-import option, and it is the default on Cygwin
+# since July 2005. But it has three fatal drawbacks:
+# - It produces executables and shared libraries with relocations in the
+# .text segment, defeating the principles of virtual memory.
+# - For some constructs such as
+# extern int var;
+# int * const b = &var;
+# it creates an executable that will give an error at runtime, rather
+# than either a compile-time or link-time error or a working executable.
+# (This is with both gcc and g++.) Whereas this code, not relying on
+# auto-import:
+# extern __declspec (dllimport) int var;
+# int * const b = &var;
+# gives a compile-time error with gcc and works with g++.
+# - It doesn't work in some cases (references to a member field of an
+# exported struct variable, or to a particular element of an exported
+# array variable), requiring code modifications. One platform
+# dictates code modifications on all platforms.
+AC_DEFUN([gl_WOE32_DLL],
+[
+ AC_REQUIRE([AC_CANONICAL_HOST])
+ case "$host_os" in
+ mingw* | cygwin*)
+ AC_MSG_CHECKING([for auto-import of symbols])
+ AC_CACHE_VAL([gl_cv_ld_autoimport], [
+ gl_save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -Wl,--disable-auto-import"
+ AC_TRY_LINK([], [], [gl_cv_ld_autoimport=yes], [gl_cv_ld_autoimport=no])
+ LDFLAGS="$gl_save_LDFLAGS"])
+ AC_MSG_RESULT([$gl_cv_ld_autoimport])
+ if test $gl_cv_ld_autoimport = yes; then
+ LDFLAGS="$LDFLAGS -Wl,--disable-auto-import"
+ fi
+ ;;
+ esac
+])