Skip to content

Commit

Permalink
It turns out that, in gnustep-make the mingw64 support was incomplete,
Browse files Browse the repository at this point in the history
so when we correctly detect mingw64 rather than mingw32 we actually
broke building of Gorm on mingw64.  Additionally, examination of the
cases where we do differentiate between mingw32 and mingw64, in all but
one of them we do the same thing for both.  That being the case, it
makes more sense to scrap the code to differentiate between the two
systems (except in the one case in target.make where we need to be aware
that the two systems prefix class names differently in the object
files), and adopt the triplet used by the mingw-w64 project (where os is
always mingw32 and we differentaiate 64bit windows using the vendor part
of the triplet) rather than the one returned by autoconf (config.guess).
  • Loading branch information
rfm committed Mar 6, 2021
1 parent 04ce555 commit 2270671
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 192 deletions.
2 changes: 0 additions & 2 deletions Instance/application.make
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ endif
# when linking applications.
ifeq ($(findstring mingw32, $(GNUSTEP_TARGET_OS)), mingw32)
ALL_LDFLAGS += -Wl,-subsystem,windows
else ifeq ($(findstring mingw64, $(GNUSTEP_TARGET_OS)), mingw32)
ALL_LDFLAGS += -Wl,-subsystem,windows
endif

$(APP_FILE): $(OBJ_FILES_TO_LINK)
Expand Down
71 changes: 33 additions & 38 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -4393,6 +4393,20 @@ $as_echo "$cc_bundle" >&6; }



#--------------------------------------------------------------------
# config.guess returns mingw64 and pc as the os and vendor, but the
# mingw-w64 project chose to use mingw32 and w64 respectively. We
#need to standardise on one.
#--------------------------------------------------------------------
if test "$host_os" = mingw64; then
host_os=mingw32
host_vendor=w64
fi
if test "$target_os" = mingw64; then
target_os=mingw32
target_vendor=w64
fi

#--------------------------------------------------------------------
# specific target_os options
#--------------------------------------------------------------------
Expand All @@ -4402,52 +4416,33 @@ case "$target_os" in
LIB_DIR="$LIB_DIR -L/usr/local/lib";;
netbsd*) INCLUDES="$INCLUDES -I/usr/pkg/include"
LIB_DIR="$LIB_DIR -Wl,-R/usr/pkg/lib -L/usr/pkg/lib";;
*mingw32* )
# NB. autoconf expects the triplet (cpu-vendor-os) to have mingw32 or
# mingw64 as the os part, but the mingw-w64 project chose a different
# triplet (cpu-w64-mingw32) which looks like mingw32. To handle that
# we convert the triplet back to the standard form.
if test "$target_vendor" = w64; then
target_vendor=pc
target_os=mingw64
fi;;
esac

#--------------------------------------------------------------------
# Determine the host, build, and target systems
#--------------------------------------------------------------------
case $host_os in
*cygwin* )
MINGW32=no
MINGW64=no
CYGWIN=yes
MSWIND=yes;;
MINGW32=no
MINGW64=no
CYGWIN=yes
MSWIND=yes;;
*mingw32* )
if test "$host_vendor" = w64; then
# NB. autoconf expects the triplet (cpu-vendor-os) to have mingw32 or
# mingw64 as the os part, but the mingw-w64 project chose a different
# triplet (cpu-w64-mingw32) which looks like mingw32. To handle that
# we convert the triplet back to the standard form.
host_vendor=pc
host_os=mingw64
MINGW32=no
MINGW64=yes
else
MINGW32=yes
MINGW64=no
fi
CYGWIN=no
MSWIND=yes;;
*mingw64* )
MINGW32=no
MINGW64=yes
CYGWIN=no
MSWIND=yes;;
* )
MINGW32=no
MINGW64=no
CYGWIN=no
MSWIND=no;;
if test $host_vendor = pc
then
MINGW32=yes
MINGW64=no
else
MINGW32=no
MINGW64=yes
fi
CYGWIN=no
MSWIND=yes;;
* )
MINGW32=no
MINGW64=no
CYGWIN=no
MSWIND=no;;
esac


Expand Down
71 changes: 33 additions & 38 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,20 @@ AC_MSG_RESULT($cc_bundle)
AC_SUBST(cc_cppprecomp)
AC_SUBST(cc_bundle)

#--------------------------------------------------------------------
# config.guess returns mingw64 and pc as the os and vendor, but the
# mingw-w64 project chose to use mingw32 and w64 respectively. We
#need to standardise on one.
#--------------------------------------------------------------------
if test "$host_os" = mingw64; then
host_os=mingw32
host_vendor=w64
fi
if test "$target_os" = mingw64; then
target_os=mingw32
target_vendor=w64
fi

#--------------------------------------------------------------------
# specific target_os options
#--------------------------------------------------------------------
Expand All @@ -117,52 +131,33 @@ case "$target_os" in
LIB_DIR="$LIB_DIR -L/usr/local/lib";;
netbsd*) INCLUDES="$INCLUDES -I/usr/pkg/include"
LIB_DIR="$LIB_DIR -Wl,-R/usr/pkg/lib -L/usr/pkg/lib";;
*mingw32* )
# NB. autoconf expects the triplet (cpu-vendor-os) to have mingw32 or
# mingw64 as the os part, but the mingw-w64 project chose a different
# triplet (cpu-w64-mingw32) which looks like mingw32. To handle that
# we convert the triplet back to the standard form.
if test "$target_vendor" = w64; then
target_vendor=pc
target_os=mingw64
fi;;
esac

#--------------------------------------------------------------------
# Determine the host, build, and target systems
#--------------------------------------------------------------------
case $host_os in
*cygwin* )
MINGW32=no
MINGW64=no
CYGWIN=yes
MSWIND=yes;;
MINGW32=no
MINGW64=no
CYGWIN=yes
MSWIND=yes;;
*mingw32* )
if test "$host_vendor" = w64; then
# NB. autoconf expects the triplet (cpu-vendor-os) to have mingw32 or
# mingw64 as the os part, but the mingw-w64 project chose a different
# triplet (cpu-w64-mingw32) which looks like mingw32. To handle that
# we convert the triplet back to the standard form.
host_vendor=pc
host_os=mingw64
MINGW32=no
MINGW64=yes
else
MINGW32=yes
MINGW64=no
fi
CYGWIN=no
MSWIND=yes;;
*mingw64* )
MINGW32=no
MINGW64=yes
CYGWIN=no
MSWIND=yes;;
* )
MINGW32=no
MINGW64=no
CYGWIN=no
MSWIND=no;;
if test $host_vendor = pc
then
MINGW32=yes
MINGW64=no
else
MINGW32=no
MINGW64=yes
fi
CYGWIN=no
MSWIND=yes;;
* )
MINGW32=no
MINGW64=no
CYGWIN=no
MSWIND=no;;
esac
AC_SUBST(CYGWIN)

Expand Down
2 changes: 0 additions & 2 deletions jni.make
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ endif
# Windows
ifeq ($(findstring mingw32, $(GNUSTEP_TARGET_OS)), mingw32)
JAVA_OS = win32
else ifeq ($(findstring mingw64, $(GNUSTEP_TARGET_OS)), mingw64)
JAVA_OS = win32
endif

# Add more platforms here
Expand Down
8 changes: 0 additions & 8 deletions rules.make
Original file line number Diff line number Diff line change
Expand Up @@ -572,14 +572,6 @@ ifeq ($(findstring mingw32, $(GNUSTEP_TARGET_OS)), mingw32)
# Add the .rc suffix on Windows.
.SUFFIXES: .rc

# A rule to generate a .o file from the .rc file.
$(GNUSTEP_OBJ_INSTANCE_DIR)/%.rc$(OEXT): %.rc
$(ECHO_COMPILING)windres $< $@$(END_ECHO)

else ifeq ($(findstring mingw64, $(GNUSTEP_TARGET_OS)), mingw64)
# Add the .rc suffix on Windows.
.SUFFIXES: .rc

# A rule to generate a .o file from the .rc file.
$(GNUSTEP_OBJ_INSTANCE_DIR)/%.rc$(OEXT): %.rc
$(ECHO_COMPILING)windres $< $@$(END_ECHO)
Expand Down
109 changes: 5 additions & 104 deletions target.make
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ ifeq ($(findstring mingw32, $(GNUSTEP_TARGET_OS)), mingw32)
TARGET_SYSTEM_LIBS = $(CONFIG_SYSTEM_LIBS) \
-lws2_32 -ladvapi32 -lcomctl32 -luser32 -lcomdlg32 \
-lmpr -lnetapi32 -lm -I. # the -I is a dummy to avoid -lm^M
else ifeq ($(findstring mingw64, $(GNUSTEP_TARGET_OS)), mingw64)
TARGET_SYSTEM_LIBS = $(CONFIG_SYSTEM_LIBS) \
-lws2_32 -ladvapi32 -lcomctl32 -luser32 -lcomdlg32 \
-lmpr -lnetapi32 -lm -I. # the -I is a dummy to avoid -lm^M
else ifeq ($(GNUSTEP_TARGET_OS), windows)
TARGET_SYSTEM_LIBS = $(CONFIG_SYSTEM_LIBS) \
-lws2_32 -ladvapi32 -lcomctl32 -luser32 -lcomdlg32 \
Expand Down Expand Up @@ -881,113 +877,18 @@ endif
ADDITIONAL_LDFLAGS += -Wl,--enable-auto-import
ADDITIONAL_FLAGS += -fno-omit-frame-pointer

# On Mingw32, it looks like the class name symbols start with '___' rather
# than '__'
# On 32bit Mingw32, it looks like the class name symbols start with an extra
# underscore.

ifeq ($(findstring pc, $(GNUSTEP_TARGET_VENDOR)), pc)
EXTRACT_CLASS_NAMES_COMMAND = $(NM) -Pg $$object_file | sed -n -e '/^.__OBJC_CLASS_[A-Za-z0-9_.]* [^U]/ {s/^.__OBJC_CLASS_\([A-Za-z0-9_.]*\) [^U].*/\1/p;}' -e '/^___objc_class_name_[A-Za-z0-9_.]* [^U]/ {s/^___objc_class_name_\([A-Za-z0-9_.]*\) [^U].*/\1/p;}'

endif

# end Mingw32
#
####################################################

####################################################
#
# Mingw64
#
ifeq ($(findstring mingw64, $(GNUSTEP_TARGET_OS)), mingw64)
shared = yes
HAVE_SHARED_LIBS = yes

# There's some sort of gcc bug that -pthread doesn't work on windows
# so we need to reset the variables which use it.
INTERNAL_CFLAGS =
INTERNAL_OBJCFLAGS =
INTERNAL_LDFLAGS =
SHARED_CFLAGS =

# This command links the library, generates automatically the list of
# symbols to export, creates the DLL (eg, obj/gnustep-base-1_13.dll)
# and the import library (eg, obj/libgnustep-base.dll.a). We pass
# --export-all-symbols to make sure it is always used. Otherwise,
# while it is the default, it might silently get disabled if a symbol
# gets manually exported (eg, because a header of a library we include
# exports a symbol by mistake).
ifneq ($(CLANG_CC), yes)
SHARED_LIB_LINK_CMD = \
$(LD) $(SHARED_LD_PREFLAGS) -shared \
-Wl,--enable-auto-image-base \
-Wl,--export-all-symbols \
-Wl,--out-implib,$(LIB_LINK_OBJ_DIR)/$(LIB_LINK_VERSION_FILE) \
$(ALL_LDFLAGS) -o $(LIB_LINK_OBJ_DIR)/$(LIB_LINK_DLL_FILE) $^ \
$(INTERNAL_LIBRARIES_DEPEND_UPON) \
$(SHARED_LD_POSTFLAGS)
else
SHARED_LIB_LINK_CMD = \
$(LD) $(SHARED_LD_PREFLAGS) -shared \
-Wl,--enable-auto-image-base \
-Wl,--export-all-symbols \
-Wl,--out-implib,$(LIB_LINK_OBJ_DIR)/$(LIB_LINK_VERSION_FILE) \
-o $(LIB_LINK_OBJ_DIR)/$(LIB_LINK_DLL_FILE) \
-Wl,--whole-archive $^ $(ALL_LDFLAGS) -Wl,--no-whole-archive \
$(INTERNAL_LIBRARIES_DEPEND_UPON) \
$(SHARED_LD_POSTFLAGS)
endif

AFTER_INSTALL_SHARED_LIB_CMD =
AFTER_INSTALL_SHARED_LIB_CHOWN =

BUILD_DLL = yes
LIBEXT = .a
# Technically, in this Unix-inspired building system, a DLL is
# composed of a .dll file which goes in the executable path and is the
# one which is loaded at runtime, and a .dll.a file which goes in the
# library path and which is linked into the application in order to
# enable it use the .dll. Anything in gnustep-make which is looking
# for shared libs should detect / look for the .dll.a as that's what
# we link applications against.
SHARED_LIBEXT = .dll.a
DLL_LIBEXT = .dll
#SHARED_CFLAGS +=

ifneq ($(CLANG_CC), yes)
OBJ_MERGE_CMD = \
$(LD) -nostdlib $(OBJ_MERGE_CMD_FLAG) $(CORE_LDFLAGS) -o $(GNUSTEP_OBJ_DIR)/$(SUBPROJECT_PRODUCT) $^ ;
else
OBJ_MERGE_CMD = \
ar cr $(GNUSTEP_OBJ_DIR)/$(SUBPROJECT_PRODUCT) $^ ;
endif

HAVE_BUNDLES = yes
BUNDLE_LD = $(LD)

ifeq ($(CLANG_CC), yes)
BUNDLE_LDFLAGS += -shared -Wl,--export-all-symbols \
-Wl,--enable-auto-import \
-Wl,--enable-auto-image-base \
-Wl,--whole-archive
BUNDLE_LIBFLAGS += -Wl,--no-whole-archive
BUNDLE_LINK_CMD = \
$(BUNDLE_LD) $(BUNDLE_LDFLAGS) $(ALL_LDFLAGS) \
-o $(LDOUT)$(BUNDLE_FILE) \
$(OBJ_FILES_TO_LINK) \
$(BUNDLE_LIBFLAGS) $(ALL_LIB_DIRS) $(BUNDLE_LIBS)
else
BUNDLE_LDFLAGS += -shared -Wl,--enable-auto-image-base
endif

ADDITIONAL_LDFLAGS += -Wl,--enable-auto-import
ADDITIONAL_FLAGS += -fno-omit-frame-pointer

# On Mingw64, it looks like the class name symbols start with '__' rather
# than '___' like Mingw32

EXTRACT_CLASS_NAMES_COMMAND = $(NM) -Pg $$object_file | sed -n -e '/^._OBJC_CLASS_[A-Za-z0-9_.]* [^U]/ {s/^._OBJC_CLASS_\([A-Za-z0-9_.]*\) [^U].*/\1/p;}' -e '/^__objc_class_name_[A-Za-z0-9_.]* [^U]/ {s/^__objc_class_name_\([A-Za-z0-9_.]*\) [^U].*/\1/p;}'
endif

endif

# end Mingw64
# end Mingw32
#
####################################################

Expand Down

1 comment on commit 2270671

@triplef
Copy link
Member

@triplef triplef commented on 2270671 Mar 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Is there a way we can manually trigger a CI build of libs-base to test this?

Please sign in to comment.