Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve cross-compiling for Windows #505

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,14 @@ BASE_LIB_PATH := $(LIB_PATH)
LIBBLIS := libblis

# The shared (dynamic) library file suffix is different for Linux and OS X.
ifeq ($(OS_NAME),Darwin)
SHLIB_EXT := dylib
else ifeq ($(IS_WIN),yes)
ifeq ($(IS_WIN),yes)
ifeq ($(CC_VENDOR),gcc)
SHLIB_EXT := dll.a
else
SHLIB_EXT := lib
endif
else ifeq ($(OS_NAME),Darwin)
Copy link
Contributor

@isuruf isuruf May 25, 2021

Choose a reason for hiding this comment

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

This is only partially related, but we should do the as IS_WIN here. (Set IS_DARWIN by checking for __APPLE__ macro)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure what you're suggesting. IS_WIN is checked, I just moved that check before checking OS_NAME. I don't think that having OS_NAME=Darwin is necessarily bad in this circumstance, and I was able to successfully create a .dll on my machine.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean when cross compiling for macOS from Linux.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah. I didn't even know such a thing was possible. I'll save that for another issue/PR.

SHLIB_EXT := dylib
else
SHLIB_EXT := so
endif
Expand All @@ -421,14 +421,14 @@ LIBBLIS_SO_PATH := $(BASE_LIB_PATH)/$(LIBBLIS_SO)
# number, a symlink in BASE_LIB_PATH is needed so that ld can find the local
# shared library when the testsuite is run via 'make test' or 'make check'.

ifeq ($(OS_NAME),Darwin)
# OS X shared library extensions.
LIBBLIS_SO_MAJ_EXT := $(SO_MAJOR).$(SHLIB_EXT)
LIBBLIS_SO_MMB_EXT := $(SO_MMB).$(SHLIB_EXT)
else ifeq ($(IS_WIN),yes)
ifeq ($(IS_WIN),yes)
# Windows shared library extension.
LIBBLIS_SO_MAJ_EXT := $(SO_MAJOR).dll
LIBBLIS_SO_MMB_EXT :=
else ifeq ($(OS_NAME),Darwin)
# OS X shared library extensions.
LIBBLIS_SO_MAJ_EXT := $(SO_MAJOR).$(SHLIB_EXT)
LIBBLIS_SO_MMB_EXT := $(SO_MMB).$(SHLIB_EXT)
else
# Linux shared library extensions.
LIBBLIS_SO_MAJ_EXT := $(SHLIB_EXT).$(SO_MAJOR)
Expand Down Expand Up @@ -515,23 +515,21 @@ endif

# Specify the shared library's 'soname' field.
# NOTE: The flag for creating shared objects is different for Linux and OS X.
ifeq ($(OS_NAME),Darwin)
# OS X shared library link flags.
SOFLAGS := -dynamiclib
SOFLAGS += -Wl,-install_name,$(libdir)/$(LIBBLIS_SONAME)
else
SOFLAGS := -shared
ifeq ($(IS_WIN),yes)
# Windows shared library link flags.
SOFLAGS := -shared
ifeq ($(CC_VENDOR),clang)
SOFLAGS += -Wl,-implib:$(BASE_LIB_PATH)/$(LIBBLIS).lib
else
SOFLAGS += -Wl,--out-implib,$(BASE_LIB_PATH)/$(LIBBLIS).dll.a
endif
else ifeq ($(OS_NAME),Darwin)
# OS X shared library link flags.
SOFLAGS := -dynamiclib
SOFLAGS += -Wl,-install_name,$(libdir)/$(LIBBLIS_SONAME)
else
# Linux shared library link flags.
SOFLAGS += -Wl,-soname,$(LIBBLIS_SONAME)
endif
SOFLAGS += -shared -Wl,-soname,$(LIBBLIS_SONAME)
endif

# Decide which library to link to for things like the testsuite and BLIS test
Expand Down