[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gettext] [PATCH] Determine Woe32 C symbol prefix at configure time.
From: |
Daiki Ueno |
Subject: |
[bug-gettext] [PATCH] Determine Woe32 C symbol prefix at configure time. |
Date: |
Thu, 27 Dec 2012 18:28:16 +0900 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
See <http://savannah.gnu.org/bugs/?29946>.
Because of my poor understanding of Woe32 platforms, the mingw w64
patch[1] applied to 0.18.2 was too ad-hoc, as it hard-codes C prefix
as "__imp_" when _WIN64 is defined.
On the above issue, Evgeny kindly explaind the background and suggested
to detect the prefix at configure time. Here is the proposed patch.
Footnotes:
[1] http://lists.gnu.org/archive/html/bug-gettext/2012-12/msg00049.html
---
gettext-runtime/ChangeLog | 5 +++++
gettext-runtime/configure.ac | 29 +++++++++++++++++++++++++++++
gettext-runtime/intl/ChangeLog | 7 +++++++
gettext-runtime/intl/intl-exports.c | 9 +++------
gettext-tools/ChangeLog | 10 ++++++++++
gettext-tools/configure.ac | 6 ++++++
gettext-tools/src/ChangeLog | 5 +++++
gettext-tools/src/Makefile.am | 3 +++
gettext-tools/woe32dll/export.h | 9 +++------
gnulib-local/ChangeLog | 5 +++++
gnulib-local/modules/gettext-runtime-misc | 5 +++++
11 files changed, 81 insertions(+), 12 deletions(-)
diff --git a/gettext-runtime/ChangeLog b/gettext-runtime/ChangeLog
index 4c9c283..b523cfd 100644
--- a/gettext-runtime/ChangeLog
+++ b/gettext-runtime/ChangeLog
@@ -1,3 +1,8 @@
+2012-12-27 Daiki Ueno <address@hidden>
+
+ * configure.ac (WOE32DLL): New conditional.
+ (INTL_EXPORTS_FLAGS): New substituted variable.
+
2012-12-25 Daiki Ueno <address@hidden>
* gettext-0.18.2 released.
diff --git a/gettext-runtime/configure.ac b/gettext-runtime/configure.ac
index 745caf6..e300c73 100644
--- a/gettext-runtime/configure.ac
+++ b/gettext-runtime/configure.ac
@@ -106,6 +106,35 @@ AH_BOTTOM([
#endif
])
+dnl Compilation on mingw and Cygwin needs special Makefile rules, because
+dnl 1. when we install a shared library, we must arrange to export
+dnl auxiliary pointer variables for every exported variable,
+dnl 2. when we install a shared library and a static library simultaneously,
+dnl the include file specifies __declspec(dllimport) and therefore we
+dnl must arrange to define the auxiliary pointer variables for the
+dnl exported variables _also_ in the static library.
+if test "$enable_shared" = yes; then
+ case "$host_os" in
+ mingw* | cygwin*) is_woe32dll=yes ;;
+ *) is_woe32dll=no ;;
+ esac
+else
+ is_woe32dll=no
+fi
+AM_CONDITIONAL([WOE32DLL], [test $is_woe32dll = yes])
+if test $is_woe32dll = yes; then
+ AC_DEFINE([WOE32DLL], [1],
+ [Define when --enable-shared is used on mingw or Cygwin.])
+fi
+
+INTL_EXPORTS_FLAGS=
+dnl 64-bit mingw does not prepend an underscore to C symbols.
+dnl USER_LABEL_PREFIX is set by gl_ASM_SYMBOL_PREFIX, inside gl_INIT.
+if test "$USER_LABEL_PREFIX" = _; then
+ INTL_EXPORTS_FLAGS="-DUSER_LABEL_PREFIX_UNDERSCORE $INTL_EXPORTS_FLAGS"
+fi
+AC_SUBST([INTL_EXPORTS_FLAGS])
+
dnl Check for tools needed for formatting the documentation.
ac_aux_dir_abs=`cd $ac_aux_dir && pwd`
AC_PATH_PROG([PERL], [perl], [$ac_aux_dir_abs/missing perl])
diff --git a/gettext-runtime/intl/ChangeLog b/gettext-runtime/intl/ChangeLog
index 8fe8f3d..0837d38 100644
--- a/gettext-runtime/intl/ChangeLog
+++ b/gettext-runtime/intl/ChangeLog
@@ -1,3 +1,10 @@
+2012-12-27 Daiki Ueno <address@hidden>
+
+ Determine imported C symbol prefix at configure time.
+ Suggested by Evgeny Grin in <http://savannah.gnu.org/bugs/?29946>.
+ * intl-exports.c (IMP): Define depending on the result of the
+ configure run.
+
2012-12-25 Daiki Ueno <address@hidden>
* gettext-0.18.2 released.
diff --git a/gettext-runtime/intl/intl-exports.c
b/gettext-runtime/intl/intl-exports.c
index 4a5126b..891c25e 100644
--- a/gettext-runtime/intl/intl-exports.c
+++ b/gettext-runtime/intl/intl-exports.c
@@ -16,13 +16,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* IMP(x) is a symbol that contains the address of x. */
-#if defined _WIN64 && defined __MINGW32__
- /* mingw W64 started using __imp_ prefix for MSVC compatibility since
- 2010. Ideally we should check the prefix in configure though,
- we assume __imp_ on mingw W64 for the time being. */
-# define IMP(x) __imp_##x
-#else
+#if USER_LABEL_PREFIX_UNDERSCORE
# define IMP(x) _imp__##x
+#else
+# define IMP(x) __imp_##x
#endif
/* Ensure that the variable x is exported from the library, and that a
diff --git a/gettext-tools/ChangeLog b/gettext-tools/ChangeLog
index 167d6a6..123c114 100644
--- a/gettext-tools/ChangeLog
+++ b/gettext-tools/ChangeLog
@@ -1,3 +1,13 @@
+2012-12-27 Daiki Ueno <address@hidden>
+
+ Determine imported C symbol prefix at configure time.
+ Suggested by Evgeny Grin in <http://savannah.gnu.org/bugs/?29946>.
+ * woe32dll/export.h (IMP): Define depending on the result of the
+ configure run.
+ * configure.ac (GETTEXTLIB_EXPORTS_FLAGS): Add
+ -DUSER_LABEL_PREFIX_UNDERSCORE if imported C symbol has
+ underscore prefix.
+
2012-12-25 Daiki Ueno <address@hidden>
* gettext-0.18.2 released.
diff --git a/gettext-tools/configure.ac b/gettext-tools/configure.ac
index 6392756..373d3cc 100644
--- a/gettext-tools/configure.ac
+++ b/gettext-tools/configure.ac
@@ -235,6 +235,12 @@ dnl gl_ERROR, inside gl_INIT.
if test "$ac_cv_lib_error_at_line" = no; then
GETTEXTLIB_EXPORTS_FLAGS="-DGNULIB_DEFINED_ERROR $GETTEXTLIB_EXPORTS_FLAGS"
fi
+
+dnl 64-bit mingw does not prepend an underscore to C symbols.
+dnl USER_LABEL_PREFIX is set by gl_ASM_SYMBOL_PREFIX, inside gl_INIT.
+if test "$USER_LABEL_PREFIX" = _; then
+ GETTEXTLIB_EXPORTS_FLAGS="-DUSER_LABEL_PREFIX_UNDERSCORE
$GETTEXTLIB_EXPORTS_FLAGS"
+fi
AC_SUBST([GETTEXTLIB_EXPORTS_FLAGS])
dnl Tell the source files that the error facility is replaced by
diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog
index 2ab9c53..07de373 100644
--- a/gettext-tools/src/ChangeLog
+++ b/gettext-tools/src/ChangeLog
@@ -1,3 +1,8 @@
+2012-12-27 Daiki Ueno <address@hidden>
+
+ * Makefile.am (libgettextsrc_la_CPPFLAGS): Define to specify Woe32
+ DLL export flags.
+
2012-12-25 Daiki Ueno <address@hidden>
* gettext-0.18.2 released.
diff --git a/gettext-tools/src/Makefile.am b/gettext-tools/src/Makefile.am
index 87cc358..aea01e6 100644
--- a/gettext-tools/src/Makefile.am
+++ b/gettext-tools/src/Makefile.am
@@ -240,10 +240,13 @@ libgettextsrc_la_LDFLAGS = \
-release @VERSION@ \
../gnulib-lib/libgettextlib.la $(LTLIBUNISTRING) @LTLIBINTL@ @LTLIBICONV@
-lc -no-undefined
+libgettextsrc_la_CPPFLAGS = $(AM_CPPFLAGS)
+
# Tell the mingw or Cygwin linker which symbols to export.
if WOE32DLL
libgettextsrc_la_SOURCES += ../woe32dll/gettextsrc-exports.c
libgettextsrc_la_LDFLAGS += -Wl,--export-all-symbols
+libgettextsrc_la_CPPFLAGS += $(GETTEXTLIB_EXPORTS_FLAGS)
endif
# No need to install libgettextsrc.a, except on AIX.
diff --git a/gettext-tools/woe32dll/export.h b/gettext-tools/woe32dll/export.h
index 68e9bcc..8bd1566 100644
--- a/gettext-tools/woe32dll/export.h
+++ b/gettext-tools/woe32dll/export.h
@@ -94,13 +94,10 @@
#if defined __GNUC__ /* GCC compiler, GNU toolchain */
/* IMP(x) is a symbol that contains the address of x. */
-#if defined _WIN64 && defined __MINGW32__
- /* mingw W64 started using __imp_ prefix for MSVC compatibility since
- 2010. Ideally we should check the prefix in configure though,
- we assume __imp_ on mingw W64 for the time being. */
-# define IMP(x) __imp_##x
-#else
+#if USER_LABEL_PREFIX_UNDERSCORE
# define IMP(x) _imp__##x
+#else
+# define IMP(x) __imp_##x
#endif
/* Ensure that the variable x is exported from the library, and that a
diff --git a/gnulib-local/ChangeLog b/gnulib-local/ChangeLog
index f48a62b..fe80bb8 100644
--- a/gnulib-local/ChangeLog
+++ b/gnulib-local/ChangeLog
@@ -1,3 +1,8 @@
+2012-12-27 Daiki Ueno <address@hidden>
+
+ * modules/gettext-runtime-misc (AM_CPPFLAGS): Augment by
+ INTL_EXPORTS_FLAGS.
+
2012-12-25 Daiki Ueno <address@hidden>
* gettext-0.18.2 released.
diff --git a/gnulib-local/modules/gettext-runtime-misc
b/gnulib-local/modules/gettext-runtime-misc
index 4cad86d..de358b6 100644
--- a/gnulib-local/modules/gettext-runtime-misc
+++ b/gnulib-local/modules/gettext-runtime-misc
@@ -15,6 +15,11 @@ AM_CPPFLAGS += -I$(top_builddir)/intl -I$(top_srcdir)/intl
# Parametrization of the 'relocatable' module.
AM_CPPFLAGS += -DDEPENDS_ON_LIBICONV=1 -DDEPENDS_ON_LIBINTL=1
+# Tell the mingw or Cygwin linker which symbols to export.
+if WOE32DLL
+AM_CPPFLAGS += @INTL_EXPORTS_FLAGS@
+endif
+
Include:
License:
--
1.7.11.7
- [bug-gettext] [PATCH] Determine Woe32 C symbol prefix at configure time.,
Daiki Ueno <=