configure: use subarch instead of arch to create .def files on mingw

Message ID 20171116020719.3096-1-jamrial@gmail.com
State New
Headers show

Commit Message

James Almer Nov. 16, 2017, 2:07 a.m.
arch is "x86" regardless of target being x86_32 or x86_64, and if
configuring with asm disabled it's "c" instead.
Using subarch (Always either "x86_32" or "x86_64") and adapting
makedef makes sure the symbols are always detected correctly on
x86_32.
---
 compat/windows/makedef | 2 +-
 configure              | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

Comments

Martin Storsjö Nov. 16, 2017, 7:07 a.m. | #1
On Wed, 15 Nov 2017, James Almer wrote:

> arch is "x86" regardless of target being x86_32 or x86_64, and if
> configuring with asm disabled it's "c" instead.
> Using subarch (Always either "x86_32" or "x86_64") and adapting
> makedef makes sure the symbols are always detected correctly on
> x86_32.
> ---
> compat/windows/makedef | 2 +-
> configure              | 3 ++-
> 2 files changed, 3 insertions(+), 2 deletions(-)

Probably ok, although I think I've got an even better idea:

What about ditching the prefix guessing from makedef altogether? We 
already know it (in extern_prefix) within configure, so we could just pass 
that along to makedef instead of passing ARCH and guessing from that, or 
by running dumpbin -headers and trying to find the arch from there.

// Martin

Patch

diff --git a/compat/windows/makedef b/compat/windows/makedef
index 0cd169c15c..9e88611cc8 100755
--- a/compat/windows/makedef
+++ b/compat/windows/makedef
@@ -63,7 +63,7 @@  IFS='
 prefix=""
 if [ -n "$NM" ]; then
     case $ARCH in
-    *86)
+    x86_32)
         prefix="_"
         ;;
     *)
diff --git a/configure b/configure
index e608d26608..df179fc3fb 100755
--- a/configure
+++ b/configure
@@ -3901,7 +3901,7 @@  case $target_os in
         SLIB_INSTALL_LINKS=
         SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
         SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
-        SLIB_CREATE_DEF_CMD='ARCH="$(ARCH)" AR="$(AR_CMD)" NM="$(NM_CMD)" $(SRC_PATH)/compat/windows/makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)'
+        SLIB_CREATE_DEF_CMD='ARCH="$(SUBARCH)" AR="$(AR_CMD)" NM="$(NM_CMD)" $(SRC_PATH)/compat/windows/makedef $(SUBDIR)lib$(NAME).ver $(OBJS) > $$(@:$(SLIBSUF)=.def)'
         SHFLAGS='-shared -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-auto-image-base $$(@:$(SLIBSUF)=.def)'
         enabled x86_64 && objformat="win64" || objformat="win32"
         ranlib=:
@@ -5212,6 +5212,7 @@  MANDIR=\$(DESTDIR)$mandir
 SRC_PATH=$source_path
 CC_IDENT=$cc_ident
 ARCH=$arch
+SUBARCH=$subarch
 INTRINSICS=$intrinsics
 CC=$cc
 AS=$as