From a651264d58fdcd8d37e0215adc95444c41213525 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Tue, 16 Mar 2010 23:33:57 +0000 Subject: [PATCH] Don't use -Bsymbolic when linking the RTS This makes the RTS hooks work when doing dynamic linking --- compiler/main/DriverPipeline.hs | 11 ++++++++++- rts/ghc.mk | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index 0ca76a2..12925ad 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -1731,6 +1731,14 @@ linkDynLib dflags o_files dep_packages = do ----------------------------------------------------------------------------- let output_fn = case o_file of { Just s -> s; Nothing -> "a.out"; } + let buildingRts = thisPackage dflags == rtsPackageId + let bsymbolicFlag = if buildingRts + then -- -Bsymbolic breaks the way we implement + -- hooks in the RTS + [] + else -- we need symbolic linking to resolve + -- non-PIC intra-package-relocations + ["-Wl,-Bsymbolic"] SysTools.runLink dflags ([ SysTools.Option verb @@ -1740,7 +1748,8 @@ linkDynLib dflags o_files dep_packages = do ++ map SysTools.Option ( md_c_flags ++ o_files - ++ [ "-shared", "-Wl,-Bsymbolic" ] -- we need symbolic linking to resolve non-PIC intra-package-relocations + ++ [ "-shared" ] + ++ bsymbolicFlag ++ [ "-Wl,-soname," ++ takeFileName output_fn ] -- set the library soname ++ extra_ld_inputs ++ lib_path_opts diff --git a/rts/ghc.mk b/rts/ghc.mk index b238728..a7a2c11 100644 --- a/rts/ghc.mk +++ b/rts/ghc.mk @@ -165,7 +165,7 @@ ifneq "$$(findstring dyn, $1)" "" ifeq "$$(HOSTPLATFORM)" "i386-unknown-mingw32" $$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) rts/libs.depend "$$(RM)" $$(RM_OPTS) $$@ - "$$(rts_dist_HC)" -shared -dynamic -dynload deploy \ + "$$(rts_dist_HC)" -package-name rts -shared -dynamic -dynload deploy \ -no-auto-link-packages `cat rts/libs.depend` $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) -o $$@ ifeq "$$(darwin_TARGET_OS)" "1" # Ensure library's install name is correct before anyone links with it. @@ -174,7 +174,7 @@ endif else $$(rts_$1_LIB) : $$(rts_$1_OBJS) rts/libs.depend "$$(RM)" $$(RM_OPTS) $$@ - "$$(rts_dist_HC)" -shared -dynamic -dynload deploy \ + "$$(rts_dist_HC)" -package-name rts -shared -dynamic -dynload deploy \ -no-auto-link-packages `cat rts/libs.depend` $$(rts_$1_OBJS) -o $$@ endif else -- 1.7.10.4