Skip to content

Commit 9905f44

Browse files
Merge pull request flame#553 from flame/rpath-fix
Add an option to use an @rpath-dependent install_name on macOS
2 parents 6d3036e + 64a421f commit 9905f44

File tree

4 files changed

+43
-18
lines changed

4 files changed

+43
-18
lines changed

Makefile

+5-11
Original file line numberDiff line numberDiff line change
@@ -725,19 +725,13 @@ else
725725
@$(RANLIB) $@
726726
endif
727727

728-
# first argument: the base name of the BLAS test driver.
729-
define make-blat-rule
730-
$(BASE_OBJ_BLASTEST_PATH)/$(1).x: $(BASE_OBJ_BLASTEST_PATH)/$(1).o $(BLASTEST_F2C_LIB) $(LIBBLIS_LINK)
728+
$(BASE_OBJ_BLASTEST_PATH)/%.x: $(BASE_OBJ_BLASTEST_PATH)/%.o $(BLASTEST_F2C_LIB) $(LIBBLIS_LINK)
731729
ifeq ($(ENABLE_VERBOSE),yes)
732-
$(LINKER) $(BASE_OBJ_BLASTEST_PATH)/$(1).o $(BLASTEST_F2C_LIB) $(LIBBLIS_LINK) $(LDFLAGS) -o $$@
730+
$(LINKER) $< $(BLASTEST_F2C_LIB) $(LIBBLIS_LINK) $(LDFLAGS) -o $@
733731
else
734-
@echo "Linking $$(@F) against '$(notdir $(BLASTEST_F2C_LIB)) $(LIBBLIS_LINK) $(LDFLAGS)'"
735-
@$(LINKER) $(BASE_OBJ_BLASTEST_PATH)/$(1).o $(BLASTEST_F2C_LIB) $(LIBBLIS_LINK) $(LDFLAGS) -o $$@
732+
@echo "Linking $@ against '$(notdir $(BLASTEST_F2C_LIB)) $(LIBBLIS_LINK) "$(LDFLAGS)"'"
733+
@$(LINKER) $< $(BLASTEST_F2C_LIB) $(LIBBLIS_LINK) $(LDFLAGS) -o $@
736734
endif
737-
endef
738-
739-
# Instantiate the rule above for each driver file.
740-
$(foreach name, $(BLASTEST_DRV_BASES), $(eval $(call make-blat-rule,$(name))))
741735

742736
# A rule to run ?blat1.x driver files.
743737
define make-run-blat1-rule
@@ -806,7 +800,7 @@ $(TESTSUITE_BIN): $(MK_TESTSUITE_OBJS) $(LIBBLIS_LINK)
806800
ifeq ($(ENABLE_VERBOSE),yes)
807801
$(LINKER) $(MK_TESTSUITE_OBJS) $(LIBBLIS_LINK) $(LDFLAGS) -o $@
808802
else
809-
@echo "Linking $@ against '$(LIBBLIS_LINK) $(LDFLAGS)'"
803+
@echo "Linking $@ against '$(LIBBLIS_LINK) "$(LDFLAGS)"'"
810804
@$(LINKER) $(MK_TESTSUITE_OBJS) $(LIBBLIS_LINK) $(LDFLAGS) -o $@
811805
endif
812806

build/config.mk.in

+3
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ ARG_MAX_HACK := @enable_arg_max_hack@
171171
MK_ENABLE_STATIC := @enable_static@
172172
MK_ENABLE_SHARED := @enable_shared@
173173

174+
# Whether to use an install_name based on @rpath.
175+
MK_ENABLE_RPATH := @enable_rpath@
176+
174177
# Whether to export all symbols within the shared library, even those symbols
175178
# that are considered to be for internal use only.
176179
EXPORT_SHARED := @export_shared@

common.mk

+15-1
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,11 @@ endif
518518
ifeq ($(OS_NAME),Darwin)
519519
# OS X shared library link flags.
520520
SOFLAGS := -dynamiclib
521+
ifeq ($(MK_ENABLE_RPATH),yes)
522+
SOFLAGS += -Wl,-install_name,@rpath/$(LIBBLIS_SONAME)
523+
else
521524
SOFLAGS += -Wl,-install_name,$(libdir)/$(LIBBLIS_SONAME)
525+
endif
522526
else
523527
SOFLAGS := -shared
524528
ifeq ($(IS_WIN),yes)
@@ -545,7 +549,17 @@ LIBBLIS_L := $(LIBBLIS_SO)
545549
LIBBLIS_LINK := $(LIBBLIS_SO_PATH)
546550
ifeq ($(IS_WIN),no)
547551
# For Linux and OS X: set rpath property of shared object.
548-
LDFLAGS += -Wl,-rpath,$(BASE_LIB_PATH)
552+
ifeq ($(OS_NAME),Darwin)
553+
# rpath for test_libblis.x
554+
LDFLAGS += -Wl,-rpath,@executable_path/$(BASE_LIB_PATH)
555+
# rpath for BLAS tests
556+
LDFLAGS += -Wl,-rpath,@executable_path/../../../$(BASE_LIB_PATH)
557+
else
558+
# rpath for test_libblis.x
559+
LDFLAGS += -Wl,-rpath,'$$ORIGIN/$(BASE_LIB_PATH)'
560+
# rpath for BLAS tests
561+
LDFLAGS += -Wl,-rpath,'$$ORIGIN/../../../$(BASE_LIB_PATH)'
562+
endif
549563
endif
550564
endif
551565
# On windows, use the shared library even if static is created.

configure

+20-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
#
3-
# BLIS
3+
# BLIS
44
# An object-based framework for developing high-performance BLAS-like
55
# libraries.
66
#
@@ -143,6 +143,12 @@ print_usage()
143143
echo " Disable (enabled by default) building BLIS as a shared"
144144
echo " library. If the shared library build is disabled, the"
145145
echo " static library build must remain enabled."
146+
echo " "
147+
echo " --enable-rpath, --disable-rpath"
148+
echo " "
149+
echo " Enable (disabled by default) setting an install_name for"
150+
echo " dynamic libraries on macOS which starts with @rpath rather"
151+
echo " than the absolute install path."
146152
echo " "
147153
echo " -e SYMBOLS, --export-shared[=SYMBOLS]"
148154
echo " "
@@ -852,7 +858,7 @@ build_kconfig_registry()
852858
assign_key_value "kconfig_registry" "${kernel}" "${newvalue}"
853859

854860
done
855-
861+
856862
done
857863
}
858864

@@ -2050,6 +2056,7 @@ main()
20502056
enable_arg_max_hack='no'
20512057
enable_static='yes'
20522058
enable_shared='yes'
2059+
enable_rpath='no'
20532060
export_shared='public'
20542061
enable_pba_pools='yes'
20552062
enable_sba_pools='yes'
@@ -2175,6 +2182,12 @@ main()
21752182
disable-shared)
21762183
enable_shared='no'
21772184
;;
2185+
enable-rpath)
2186+
enable_rpath='yes'
2187+
;;
2188+
disable-rpath)
2189+
enable_rpath='no'
2190+
;;
21782191
export-shared=*)
21792192
export_shared=${OPTARG#*=}
21802193
;;
@@ -2404,7 +2417,7 @@ main()
24042417
fi
24052418

24062419
echo "${script_name}: using '${found_cc}' C compiler."
2407-
2420+
24082421
# Also check the compiler to see if we are (cross-)compiling for Windows
24092422
if ${found_cc} -dM -E - < /dev/null 2> /dev/null | grep -q _WIN32; then
24102423
is_win=yes
@@ -3162,7 +3175,7 @@ main()
31623175

31633176
enable_sandbox_01=0
31643177
fi
3165-
3178+
31663179
# Check the method used for returning complex numbers
31673180
if [ "x${complex_return}" = "xdefault" ]; then
31683181
if [ -n "${FC}" ]; then
@@ -3193,7 +3206,7 @@ main()
31933206
complex_return='gnu'
31943207
fi
31953208
fi
3196-
3209+
31973210
if [ "x${complex_return}" = "xgnu" ]; then
31983211
complex_return_intel01='0'
31993212
elif [ "x${complex_return}" = "xintel" ]; then
@@ -3346,14 +3359,15 @@ main()
33463359
| sed -e "s/@enable_arg_max_hack@/${enable_arg_max_hack}/g" \
33473360
| sed -e "s/@enable_static@/${enable_static}/g" \
33483361
| sed -e "s/@enable_shared@/${enable_shared}/g" \
3362+
| sed -e "s/@enable_rpath@/${enable_rpath}/g" \
33493363
| sed -e "s/@export_shared@/${export_shared}/g" \
33503364
| sed -e "s/@enable_blas@/${enable_blas}/g" \
33513365
| sed -e "s/@enable_cblas@/${enable_cblas}/g" \
33523366
| sed -e "s/@enable_memkind@/${enable_memkind}/g" \
33533367
| sed -e "s/@pragma_omp_simd@/${pragma_omp_simd}/g" \
33543368
| sed -e "s/@sandbox@/${sandbox}/g" \
33553369
> "${config_mk_out_path}"
3356-
3370+
33573371

33583372
# Begin substituting information into the bli_config_h_in file, outputting
33593373
# to bli_config_h_out. NOTE: We use perl instead of sed because the version

0 commit comments

Comments
 (0)