diff options
author | Ian Lynagh <igloo@earth.li> | 2012-10-14 13:36:08 +0100 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2012-10-14 15:31:07 +0100 |
commit | 0271742138ffc55d992be549c027ae690fde5080 (patch) | |
tree | fa99b538693da25f282f0e2752083c95d2f3e427 | |
parent | 8c24ab98cde96ce20dea6a9280231d978ffc7690 (diff) | |
download | haskell-0271742138ffc55d992be549c027ae690fde5080.tar.gz |
Get dynamic-by-default mostly working on OS X
-rw-r--r-- | rts/ghc.mk | 3 | ||||
-rw-r--r-- | rules/build-package-way.mk | 3 | ||||
-rw-r--r-- | rules/build-package.mk | 4 | ||||
-rw-r--r-- | rules/build-prog.mk | 15 | ||||
-rw-r--r-- | rules/shell-wrapper.mk | 4 |
5 files changed, 28 insertions, 1 deletions
diff --git a/rts/ghc.mk b/rts/ghc.mk index 2147c1fdd2..36df61d2d5 100644 --- a/rts/ghc.mk +++ b/rts/ghc.mk @@ -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) diff --git a/rules/build-package-way.mk b/rules/build-package-way.mk index aa3f277bf8..7a028d5b88 100644 --- a/rules/build-package-way.mk +++ b/rules/build-package-way.mk @@ -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] diff --git a/rules/build-package.mk b/rules/build-package.mk index d21f449d93..c0b9902b55 100644 --- a/rules/build-package.mk +++ b/rules/build-package.mk @@ -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 diff --git a/rules/build-prog.mk b/rules/build-prog.mk index a0cb9e64ce..df96598586 100644 --- a/rules/build-prog.mk +++ b/rules/build-prog.mk @@ -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)) diff --git a/rules/shell-wrapper.mk b/rules/shell-wrapper.mk index 8085ad150a..395968a0d9 100644 --- a/rules/shell-wrapper.mk +++ b/rules/shell-wrapper.mk @@ -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) >> $$@ |