Skip to content

Commit

Permalink
Fixed link error when building only shared library.
Browse files Browse the repository at this point in the history
Details:
- Fixed a linker error that occurred when attempting to compile and link
  the testsuite and/or BLAS test drivers after having configured BLIS to
  only generate a shared library (no static library). The chosen
  solution involved
  (1) adding the local library path, $(BASE_LIB_PATH), to the search
      paths for the shared library via the link option
      -Wl,-rpath,$(BASE_LIB_PATH).
  (2) adding a local symlink to $(BASE_LIB_PATH) that uses the .so major
      version number so that ld would find the shared library at
      execution time.
  Thanks to Sajid Ali for reporting this issue, to Devin Matthews for
  pointing out the need for the -rpath option, and to Devangi Parikh for
  helping Sajid isolate the problem.
- Added #include <ctype.h> to bli_system.h to avoid a compiler warning
  resulting from using toupper() from bli_string.c without a prototype.
  Thanks again to Sajid Ali, whose build log revealed this compiler
  warning.
- Added '*.so.*' to .gitignore.
- CREDITS file update.
  • Loading branch information
fgvanzee committed Aug 14, 2018
1 parent 9cb0b02 commit 4f6745d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# since its only contents are .a files.
*.a
*.so
*.so.*
# test executables
*.x
*.pexe
Expand Down
3 changes: 2 additions & 1 deletion CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The BLIS framework was primarily authored by
but many others have contributed code and feedback, including

Murtaza Ali (Texas Instruments)
Sajid Ali @s-sajid-ali (Northwestern University)
Erling Andersen @erling-d-andersen
Alex Arslan @ararslan
Vernon Austel (IBM, T.J. Watson Research Center)
Expand Down Expand Up @@ -41,7 +42,7 @@ but many others have contributed code and feedback, including
Dave Love @loveshack
Tze Meng Low (The University of Texas at Austin)
Nisanth Padinharepatt (AMD)
Devangi Parikh (The University of Texas at Austin)
Devangi Parikh @dnparikh (The University of Texas at Austin)
Elmar Peise @elmar-peise (RWTH-Aachen)
Clément Pernet @ClementPernet
Ilya Polkovnichenko
Expand Down
19 changes: 17 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ MK_LIBS_INST += $(LIBBLIS_A_INST)
MK_LIBS_SYML +=
endif
ifeq ($(MK_ENABLE_SHARED),yes)
MK_LIBS += $(LIBBLIS_SO_PATH)
MK_LIBS += $(LIBBLIS_SO_PATH) \
$(LIBBLIS_SO_MAJ_PATH)
MK_LIBS_INST += $(LIBBLIS_SO_MMB_INST)
MK_LIBS_SYML += $(LIBBLIS_SO_INST) \
$(LIBBLIS_SO_MAJ_INST)
Expand Down Expand Up @@ -584,7 +585,7 @@ endif
endif


# --- Dynamic library linker rules ---
# --- Shared library linker rules ---

$(LIBBLIS_SO_PATH): $(MK_BLIS_OBJS)
ifeq ($(ENABLE_VERBOSE),yes)
Expand All @@ -607,6 +608,20 @@ else
endif
endif

# Local symlink for shared library.
# NOTE: We use a '.loc' suffix to avoid filename collisions in case this
# rule is executed concurrently with the install-lib-symlinks rule, which
# also creates symlinks in the current directory (before installing them).
$(LIBBLIS_SO_MAJ_PATH): $(LIBBLIS_SO_PATH)
ifeq ($(ENABLE_VERBOSE),yes)
$(SYMLINK) $(<F) $(@F).loc
$(MV) $(@F).loc $(BASE_LIB_PATH)/$(@F)
else # ifeq ($(ENABLE_VERBOSE),no)
@echo "Creating symlink $@"
@$(SYMLINK) $(<F) $(@F).loc
@$(MV) $(@F).loc $(BASE_LIB_PATH)/$(@F)
endif


# --- BLAS test suite rules ---

Expand Down
19 changes: 12 additions & 7 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@ LIBBLIS_SO := $(LIBBLIS).$(SHLIB_EXT)
LIBBLIS_A_PATH := $(BASE_LIB_PATH)/$(LIBBLIS_A)
LIBBLIS_SO_PATH := $(BASE_LIB_PATH)/$(LIBBLIS_SO)

# Create a filepath to a local symlink to the soname--that is, the same as
# LIBBLIS_SO_PATH except with the .so major version number. Since the shared
# library lists its soname as 'libblis.so.n', where n is the .so major version
# 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'.
LIBBLIS_SO_MAJ_PATH := $(BASE_LIB_PATH)/$(LIBBLIS_SO).$(SO_MAJOR)


#
Expand Down Expand Up @@ -388,8 +394,8 @@ ifeq ($(DEBUG_TYPE),sde)
LDFLAGS := $(filter-out $(LIBMEMKIND),$(LDFLAGS))
endif

# The default flag for creating shared objects is different for Linux and
# OS X.
# 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)
SOFLAGS := -dynamiclib
SOFLAGS += -Wl,-install_name,$(LIBBLIS_SO).$(SO_MAJOR)
Expand All @@ -398,15 +404,14 @@ SOFLAGS := -shared
SOFLAGS += -Wl,-soname,$(LIBBLIS_SO).$(SO_MAJOR)
endif

# Specify the shared library's 'soname' field.

# Decide which library to link to for things like the testsuite. Default
# to the static library, unless only the shared library was enabled, in
# which case we use the shared library.
# Decide which library to link to for things like the testsuite and BLIS test
# drivers. We default to the static library, unless only the shared library was
# enabled, in which case we use the shared library.
LIBBLIS_LINK := $(LIBBLIS_A_PATH)
ifeq ($(MK_ENABLE_SHARED),yes)
ifeq ($(MK_ENABLE_STATIC),no)
LIBBLIS_LINK := $(LIBBLIS_SO_PATH)
LDFLAGS += -Wl,-rpath,$(BASE_LIB_PATH)
endif
endif

Expand Down
1 change: 1 addition & 0 deletions frame/include/bli_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <stdarg.h>
#include <float.h>
#include <errno.h>
#include <ctype.h>

// Determine if we are on a 64-bit or 32-bit architecture.
#if defined(_M_X64) || defined(__x86_64) || defined(__aarch64__) || \
Expand Down

0 comments on commit 4f6745d

Please sign in to comment.