Commit 02717421 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Get dynamic-by-default mostly working on OS X

parent 8c24ab98
......@@ -16,6 +16,9 @@
# We build the RTS with stage 1
rts_dist_HC = $(GHC_STAGE1)
rts_INSTALL_INFO = rts
rts_VERSION = 1.0
# merge GhcLibWays and GhcRTSWays but strip out duplicates
rts_WAYS = $(GhcLibWays) $(filter-out $(GhcLibWays),$(GhcRTSWays))
rts_dist_WAYS = $(rts_WAYS)
......
......@@ -25,7 +25,8 @@ $(call hs-objs,$1,$2,$3)
# The .a/.so library file, indexed by two different sets of vars:
# the first is indexed by the dir, distdir and way
# the second is indexed by the package id, distdir and way
$1_$2_$3_LIB = $1/$2/build/libHS$$($1_PACKAGE)-$$($1_$2_VERSION)$$($3_libsuf)
$1_$2_$3_LIB_NAME = libHS$$($1_PACKAGE)-$$($1_$2_VERSION)$$($3_libsuf)
$1_$2_$3_LIB = $1/$2/build/$$($1_$2_$3_LIB_NAME)
$$($1_PACKAGE)-$$($1_$2_VERSION)_$2_$3_LIB = $$($1_$2_$3_LIB)
# Note [inconsistent distdirs]
......
......@@ -66,6 +66,10 @@ define build-package-helper
$(call package-config,$1,$2,$3)
ifeq "$3" "1"
$$($1_PACKAGE)_INSTALL_INFO = $1_$2
endif
# Bootstrapping libs are only built one way
ifeq "$3" "0"
$1_$2_WAYS = v
......
......@@ -173,9 +173,13 @@ endif
ifneq "$3" "0"
ifeq "$$(DYNAMIC_BY_DEFAULT)" "YES"
ifeq "$$(TargetOS_CPP)" "linux"
$1_$2_GHC_LD_OPTS = \
-fno-use-rpaths \
$$(foreach d,$$($1_$2_TRANSITIVE_DEPS),-optl-Wl$$(comma)-rpath -optl-Wl$$(comma)'$$$$ORIGIN/../$$d')
else ifeq "$$(TargetOS_CPP)" "darwin"
$1_$2_GHC_LD_OPTS = -optl-Wl,-headerpad_max_install_names
endif
endif
endif
......@@ -194,6 +198,17 @@ $1/$2/build/tmp/$$($1_$2_PROG) : \
ifeq "$$($1_$2_LINK_WITH_GCC)" "NO"
$1/$2/build/tmp/$$($1_$2_PROG) : $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) | $$$$(dir $$$$@)/.
$$(call cmd,$1_$2_HC) -o $$@ $$($1_$2_$$($1_$2_PROGRAM_WAY)_ALL_HC_OPTS) $$(LD_OPTS) $$($1_$2_GHC_LD_OPTS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES))
ifeq "$$(TargetOS_CPP)" "darwin"
ifneq "$3" "0"
ifeq "$$($1_$2_PROGRAM_WAY)" "dyn"
# Use relative paths for all the libraries
install_name_tool $$(foreach d,$$($1_$2_TRANSITIVE_DEP_NAMES), -change $$(TOP)/$$($$($$d_INSTALL_INFO)_dyn_LIB) @loader_path/../$$d-$$($$($$d_INSTALL_INFO)_VERSION)/$$($$($$d_INSTALL_INFO)_dyn_LIB_NAME)) $$@
# Use relative paths for the RTS. Rather than try to work out which RTS
# way is being linked, we just change it for all ways
install_name_tool $$(foreach w,$$(rts_WAYS), -change $$(TOP)/$$(rts_$$w_LIB) @loader_path/../$$d-$$(rts_VERSION)/$$(rts_$$w_LIB_NAME)) $$@
endif
endif
endif
else
$1/$2/build/tmp/$$($1_$2_PROG) : $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) | $$$$(dir $$$$@)/.
$$(call cmd,$1_$2_CC) -o $$@ $$($1_$2_$$($1_$2_PROGRAM_WAY)_ALL_CC_OPTS) $$(LD_OPTS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_EXTRA_CC_OPTS) $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES))
......
......@@ -45,7 +45,11 @@ $$(INPLACE_WRAPPER): $$($1_$2_INPLACE)
$$($1_$2_SHELL_WRAPPER_EXTRA)
$$($1_$2_INPLACE_SHELL_WRAPPER_EXTRA)
ifeq "$$(DYNAMIC_BY_DEFAULT)" "YES"
ifeq "$$(TargetOS_CPP)" "linux"
echo 'export LD_LIBRARY_PATH="$$($1_$2_DEP_LIB_DIRS_SEARCHPATH)"' >> $$@
else ifeq "$$(TargetOS_CPP)" "darwin"
echo 'export DYLD_LIBRARY_PATH="$$($1_$2_DEP_LIB_DIRS_SEARCHPATH)"' >> $$@
endif
endif
ifeq "$$($1_$2_SHELL_WRAPPER)" "YES"
cat $$($1_$2_SHELL_WRAPPER_NAME) >> $$@
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment