diff options
| author | Tom Smeding <tom@tomsmeding.com> | 2022-06-03 15:57:06 +0200 | 
|---|---|---|
| committer | Tom Smeding <tom@tomsmeding.com> | 2022-06-03 15:57:06 +0200 | 
| commit | dba9bbcffc6436d37dec362b03dfe84c9707add6 (patch) | |
| tree | e9dfe4195c64e19129e1d9cf77a6e683a9a377fc /cbits | |
| parent | df15ed04bd85105178e236b6ca8caa5c78f4e523 (diff) | |
Use weak symbol for rtsConfig (support existence of TH in client programs)
Diffstat (limited to 'cbits')
| -rw-r--r-- | cbits/hook.c | 7 | 
1 files changed, 6 insertions, 1 deletions
| diff --git a/cbits/hook.c b/cbits/hook.c index b13576f..22aa259 100644 --- a/cbits/hook.c +++ b/cbits/hook.c @@ -9,7 +9,7 @@ static size_t min_sz(size_t a, size_t b) {  	return a < b ? a : b;  } -extern RtsConfig rtsConfig; +extern RtsConfig __attribute__((weak)) rtsConfig;  // A copy of GCDetails_ with known structure that can be depended on by the Haskell code.  struct ShadowDetails { @@ -226,6 +226,11 @@ bool set_gchook(void) {  		goto unlock_return_retval;  	} +	if (&rtsConfig == NULL) { +		fprintf(stderr, "ghc-gc-hook: ERROR: rtsConfig not defined; the GC hook cannot be used from within a TemplateHaskell splice\n"); +		goto unlock_return_retval; +	} +  	old_hook = rtsConfig.gcDoneHook;  	rtsConfig.gcDoneHook = hook_callback; | 
