Support clang targetting MinGW (#639)

* Support clang targetting MinGW

* Fix pthread linking
This commit is contained in:
Isuru Fernando
2022-06-28 15:34:10 -05:00
committed by GitHub
parent d93df02334
commit d429b6bfce
3 changed files with 19 additions and 5 deletions

View File

@@ -73,6 +73,7 @@ OS_NAME := @os_name@
# Check for whether the operating system is Windows.
IS_WIN := @is_win@
IS_MSVC := @is_msvc@
# The directory path to the top level of the source distribution. When
# building in-tree, this path is ".". When building out-of-tree, this path

View File

@@ -436,7 +436,7 @@ LIBBLIS := libblis
ifeq ($(OS_NAME),Darwin)
SHLIB_EXT := dylib
else ifeq ($(IS_WIN),yes)
ifeq ($(CC_VENDOR),gcc)
ifeq ($(IS_MSVC),no)
SHLIB_EXT := dll.a
else
SHLIB_EXT := lib
@@ -524,7 +524,7 @@ GIT_LOG := $(GIT) log --decorate
# manually override whatever they need.
# Define the external libraries we may potentially need at link-time.
ifeq ($(IS_WIN),yes)
ifeq ($(IS_MSVC),yes)
LIBM :=
else
LIBM := -lm
@@ -566,7 +566,7 @@ else
SOFLAGS := -shared
ifeq ($(IS_WIN),yes)
# Windows shared library link flags.
ifeq ($(CC_VENDOR),clang)
ifeq ($(IS_MSVC),yes)
SOFLAGS += -Wl,-implib:$(BASE_LIB_PATH)/$(LIBBLIS).lib
else
SOFLAGS += -Wl,--out-implib,$(BASE_LIB_PATH)/$(LIBBLIS).dll.a
@@ -687,7 +687,7 @@ $(foreach c, $(CONFIG_LIST_FAM), $(eval $(call append-var-for,CWARNFLAGS,$(c))))
# --- Position-independent code flags (shared libraries only) ---
# Emit position-independent code for dynamic linking.
ifeq ($(IS_WIN),yes)
ifeq ($(IS_MSVC),yes)
# Note: Don't use any fPIC flags for Windows builds since all code is position-
# independent.
CPICFLAGS :=
@@ -739,6 +739,14 @@ endif
# Determine default export behavior / visibility of symbols for clang.
ifeq ($(CC_VENDOR),clang)
ifeq ($(IS_WIN),yes)
ifeq ($(IS_MSVC),no)
# This is a clang build targetting MinGW-w64 env
ifeq ($(EXPORT_SHARED),all)
BUILD_SYMFLAGS := -Wl,--export-all-symbols, -Wl,--enable-auto-import
else # ifeq ($(EXPORT_SHARED),all)
BUILD_SYMFLAGS := -Wl,--exclude-all-symbols
endif
endif # ifeq ($(IS_MSVC),no)
ifeq ($(EXPORT_SHARED),all)
# NOTE: clang on Windows does not appear to support exporting all symbols
# by default, and therefore we ignore the value of EXPORT_SHARED.

7
configure vendored
View File

@@ -1170,7 +1170,7 @@ auto_detect()
# Set the linker flags. We typically need pthreads (or BLIS's homerolled
# equiavlent) because it is needed for parts of bli_arch.c unrelated to
# bli_arch_string(), which is called by the main() function in ${main_c}.
if [[ "$is_win" == "no" || "$cc_vendor" != "clang" ]]; then
if [[ "$is_msvc" == "no" ]]; then
ldflags="${LIBPTHREAD--lpthread}"
fi
@@ -2828,6 +2828,10 @@ main()
if ${found_cc} -dM -E - < /dev/null 2> /dev/null | grep -q _WIN32; then
is_win=yes
fi
is_msvc=no
if ${found_cc} -dM -E - < /dev/null 2> /dev/null | grep -q _MSC_VER; then
is_msvc=yes
fi
# -- Check the compiler version --------------------------------------------
@@ -3830,6 +3834,7 @@ main()
| sed -e "s/@kconfig_map@/${kconfig_map}/g" \
| sed -e "s/@os_name@/${os_name_esc}/g" \
| sed -e "s/@is_win@/${is_win}/g" \
| sed -e "s/@is_msvc@/${is_msvc}/g" \
| sed -e "s/@dist_path@/${dist_path_esc}/g" \
| sed -e "s/@CC_VENDOR@/${cc_vendor}/g" \
| sed -e "s/@gcc_older_than_4_9_0@/${gcc_older_than_4_9_0}/g" \