diff --git a/build/config.mk.in b/build/config.mk.in index 1b3468642..7ef8c6bd0 100644 --- a/build/config.mk.in +++ b/build/config.mk.in @@ -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 diff --git a/common.mk b/common.mk index a93f8ab24..6661f84c5 100644 --- a/common.mk +++ b/common.mk @@ -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. diff --git a/configure b/configure index 7e825f1dc..5ff877317 100755 --- a/configure +++ b/configure @@ -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" \