[commit: ghc] master: Make dtrace enabled GHC work as a bootstrap compiler on FreeBSD (9c89ef3)

git at git.haskell.org git at git.haskell.org
Fri Jun 15 18:58:52 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/9c89ef39f54943dd3fcd9d196ce1a5bdf7f5f94b/ghc

>---------------------------------------------------------------

commit 9c89ef39f54943dd3fcd9d196ce1a5bdf7f5f94b
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Fri Jun 15 14:07:51 2018 -0400

    Make dtrace enabled GHC work as a bootstrap compiler on FreeBSD
    
    Fixes #15040.
    
    Reviewers: bgamari, simonmar
    
    Reviewed By: bgamari
    
    Subscribers: rwbarton, thomie, carter
    
    Differential Revision: https://phabricator.haskell.org/D4772


>---------------------------------------------------------------

9c89ef39f54943dd3fcd9d196ce1a5bdf7f5f94b
 rts/ghc.mk | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/rts/ghc.mk b/rts/ghc.mk
index e96e147..6154720 100644
--- a/rts/ghc.mk
+++ b/rts/ghc.mk
@@ -46,6 +46,7 @@ ALL_DIRS += posix
 endif
 
 rts_C_SRCS := $(wildcard rts/*.c $(foreach dir,$(ALL_DIRS),rts/$(dir)/*.c))
+rts_C_HOOK_SRCS := $(wildcard rts/hooks/*.c)
 rts_CMM_SRCS := $(wildcard rts/*.cmm)
 
 # Don't compile .S files when bootstrapping a new arch
@@ -171,9 +172,10 @@ $(call cmm-suffix-rules,rts,dist,$1)
 rts_$1_LIB_FILE = libHSrts$$($1_libsuf)
 rts_$1_LIB = rts/dist/build/$$(rts_$1_LIB_FILE)
 
-rts_$1_C_OBJS   = $$(patsubst rts/%.c,rts/dist/build/%.$$($1_osuf),$$(rts_C_SRCS)) $$(patsubst %.c,%.$$($1_osuf),$$(rts_$1_EXTRA_C_SRCS))
-rts_$1_S_OBJS   = $$(patsubst rts/%.S,rts/dist/build/%.$$($1_osuf),$$(rts_S_SRCS))
-rts_$1_CMM_OBJS = $$(patsubst rts/%.cmm,rts/dist/build/%.$$($1_osuf),$$(rts_CMM_SRCS)) $$(patsubst %.cmm,%.$$($1_osuf),$$(rts_AUTO_APPLY_CMM))
+rts_$1_C_OBJS      = $$(patsubst rts/%.c,rts/dist/build/%.$$($1_osuf),$$(rts_C_SRCS)) $$(patsubst %.c,%.$$($1_osuf),$$(rts_$1_EXTRA_C_SRCS))
+rts_$1_C_HOOK_OBJS = $$(patsubst rts/hooks/%.c,rts/dist/build/hooks/%.$$($1_osuf),$$(rts_C_HOOK_SRCS))
+rts_$1_S_OBJS      = $$(patsubst rts/%.S,rts/dist/build/%.$$($1_osuf),$$(rts_S_SRCS))
+rts_$1_CMM_OBJS    = $$(patsubst rts/%.cmm,rts/dist/build/%.$$($1_osuf),$$(rts_CMM_SRCS)) $$(patsubst %.cmm,%.$$($1_osuf),$$(rts_AUTO_APPLY_CMM))
 
 rts_$1_OBJS = $$(rts_$1_C_OBJS) $$(rts_$1_S_OBJS) $$(rts_$1_CMM_OBJS)
 
@@ -254,9 +256,21 @@ else
 
 ifeq "$(USE_DTRACE)" "YES"
 ifeq "$(NEED_DTRACE_PROBES_OBJ)" "YES"
+# A list of objects that do not get included in the RTS object that is created
+# during the linking step. To prevent future linking errors, especially when
+# using the compiler as a bootstrap compiler, we need to exclude the hook
+# objects from being re-linked into the single LINKED_OBJS object file. When the
+# hooks are being linked into the RTS object this will result in duplicated
+# symbols causing the linker to fail (e.g. `StackOverflowHook` in RTS.o and
+# hschooks.o). The excluded objects do not get relinked into the RTS object but
+# get included separately so prevent linker errors.
+# (see issue #15040)
+rts_$1_EXCLUDED_OBJS = $$(rts_$1_C_HOOK_OBJS)
+# The RTS object that gets generated to package up all of the runtime system
+# with the dtrace probe code.
 rts_$1_LINKED_OBJS = rts/dist/build/RTS.$$($1_osuf)
 
-$$(rts_$1_LINKED_OBJS) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS)
+$$(rts_$1_LINKED_OBJS) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) $$(rts_$1_C_HOOK_OBJS)
 	"$$(RM)" $$(RM_OPTS) $$@
 
 	# When linking an archive the linker will only include the object files that
@@ -264,11 +278,17 @@ $$(rts_$1_LINKED_OBJS) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS)
 	# specific code for initializing the probes. By creating a single object that
 	# also includes the probe object code we force the linker to include the
 	# probes when linking the static runtime.
-	$(LD) -r -o $$(rts_$1_LINKED_OBJS) $$(rts_$1_DTRACE_OBJS) $$(rts_$1_OBJS)
+	#
+	# The reason why we are re-linking all the objects into a single object file
+	# is stated in this thread:
+	# https://thr3ads.net/dtrace-discuss/2005/08/384778-Problem-with-probes-defined-in-static-libraries
+	$(LD) -r -o $$(rts_$1_LINKED_OBJS) $$(rts_$1_DTRACE_OBJS) $$(filter-out $$(rts_$1_EXCLUDED_OBJS), $$(rts_$1_OBJS))
 else
+rts_$1_EXCLUDED_OBJS =
 rts_$1_LINKED_OBJS = $$(rts_$1_OBJS)
 endif
 else
+rts_$1_EXCLUDED_OBJS =
 rts_$1_LINKED_OBJS = $$(rts_$1_OBJS)
 endif
 
@@ -276,7 +296,7 @@ endif
 $$(rts_$1_LIB) : $$(rts_$1_LINKED_OBJS)
 	"$$(RM)" $$(RM_OPTS) $$@
 
-	echo $$(rts_$1_LINKED_OBJS) | "$$(XARGS)" $$(XARGS_OPTS) "$$(AR_STAGE1)" \
+	echo $$(rts_$1_LINKED_OBJS) $$(rts_$1_EXCLUDED_OBJS) | "$$(XARGS)" $$(XARGS_OPTS) "$$(AR_STAGE1)" \
 		$$(AR_OPTS_STAGE1) $$(EXTRA_AR_ARGS_STAGE1) $$@
 
 ifneq "$$(UseSystemLibFFI)" "YES"



More information about the ghc-commits mailing list