Commit 262e42aa authored by Peter Trommler's avatar Peter Trommler 🥁 Committed by Marge Bot

Do not panic on linker errors

parent 3e27205a
......@@ -187,7 +187,7 @@ getHValue hsc_env name = do
m <- lookupClosure hsc_env (unpackFS sym_to_find)
case m of
Just hvref -> mkFinalizedHValue hsc_env hvref
Nothing -> linkFail "GHC.ByteCode.Linker.lookupCE"
Nothing -> linkFail "GHC.Runtime.Linker.getHValue"
(unpackFS sym_to_find)
linkDependencies :: HscEnv -> PersistentLinkerState
......@@ -472,7 +472,7 @@ preloadLib hsc_env lib_paths framework_paths pls lib_spec = do
Nothing -> maybePutStrLn dflags "done"
Just mm -> preloadFailed mm framework_paths lib_spec
return pls
else panic "preloadLib Framework"
else throwGhcExceptionIO (ProgramError "preloadLib Framework")
where
dflags = hsc_dflags hsc_env
......@@ -964,7 +964,9 @@ dynLoadObjs hsc_env pls@PersistentLinkerState{..} objs = do
m <- loadDLL hsc_env soFile
case m of
Nothing -> return $! pls { temp_sos = (libPath, libName) : temp_sos }
Just err -> panic ("Loading temp shared object failed: " ++ err)
Just err -> linkFail msg err
where
msg = "GHC.Runtime.Linker.dynLoadObjs: Loading temp shared object failed"
rmDupLinkables :: [Linkable] -- Already loaded
-> [Linkable] -- New linkables
......
......@@ -127,6 +127,11 @@ T3333:
"$(TEST_HC)" -c T3333.c -o T3333.o
echo "weak_test 10" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) T3333.hs T3333.o
.PHONY: T11531
T11531:
"$(TEST_HC)" -dynamic -fPIC -c T11531.c -o T11531.o
- echo ":q" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) T11531.o T11531.hs 2>&1 | sed -e '/undefined symbol:/d' 1>&2
.PHONY: T14708
T14708:
$(RM) -rf T14708scratch
......
extern void undefined_function(void);
int some_function(int d) {
return 64;
}
void __attribute__ ((constructor)) setup(void) {
undefined_function();
}
{-# LANGUAGE ForeignFunctionInterface #-}
foreign import ccall "T11531.h some_function" someFunction :: Int -> Int
GHC.Runtime.Linker.dynLoadObjs: Loading temp shared object failed
During interactive linking, GHCi couldn't find the following symbol:
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session. Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please report this as a GHC bug:
https://www.haskell.org/ghc/reportabug
......@@ -43,6 +43,12 @@ test('T3333',
expect_broken(3333))],
makefile_test, ['T3333'])
test('T11531',
[extra_files(['T11531.hs', 'T11531.c', 'T11531.h']),
unless(doing_ghci, skip),
unless(opsys('linux'), skip)],
makefile_test, ['T11531'])
test('T14708',
[extra_files(['T14708.hs', 'add.c']),
unless(doing_ghci, skip),
......
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