Commit 7613a812 authored by Ryan Scott's avatar Ryan Scott Committed by Ben Gamari
Browse files

Fix #9438 by converting a panic to an error message

Previously, GHC was quite eager to panic whenever it was fed
an archive file when `DYNAMIC_GHC_PROGRAMS=YES`. This ought to be an
explicit error message instead, so this patch accomplishes just that.

Test Plan: make test TEST=T14708

Reviewers: Phyx, hvr, bgamari

Reviewed By: Phyx

Subscribers: thomie, carter

GHC Trac Issues: #9438, #14708, #15032

Differential Revision:
parent 6f623030
......@@ -71,7 +71,10 @@ import System.Win32.Info (getSystemDirectory)
import Exception
import Foreign (Ptr) -- needed for 2nd stage
-- needed for 2nd stage
#if STAGE >= 2
import Foreign (Ptr)
{- **********************************************************************
......@@ -504,9 +507,17 @@ preloadLib hsc_env lib_paths framework_paths pls lib_spec = do
= do b <- doesFileExist name
if not b then return False
else do if dynamicGhc
then panic "Loading archives not supported"
then throwGhcExceptionIO $
CmdLineError dynamic_msg
else loadArchive hsc_env name
return True
dynamic_msg = unlines
[ "User-specified static library could not be loaded ("
++ name ++ ")"
, "Loading static libraries is not supported in this configuration."
, "Try using a dynamic library instead."
{- **********************************************************************
......@@ -776,6 +776,7 @@ mk/ghcconfig*_test___spaces_ghc*
......@@ -126,3 +126,11 @@ endif
"$(TEST_HC)" -c T3333.c -o T3333.o
echo "weak_test 10" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) T3333.hs T3333.o
.PHONY: T14708
$(RM) -rf T14708scratch
mkdir T14708scratch
"$(TEST_HC)" -c add.c -o T14708scratch/add.o
"$(AR)" cqs T14708scratch/libadd.a T14708scratch/add.o
-"$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) -LT14708scratch -ladd T14708.hs
main :: IO ()
main = return ()
<command line>: User-specified static library could not be loaded (T14708scratch/libadd.a)
Loading static libraries is not supported in this configuration.
Try using a dynamic library instead.
int add2(int x, int y) { return x + y; }
......@@ -31,3 +31,11 @@ test('T3333',
unless(opsys('linux') or opsys('darwin') or ghc_dynamic(),
run_command, ['$MAKE -s --no-print-directory T3333'])
[extra_files(['T14708.hs', 'add.c']),
unless(doing_ghci, skip),
unless(ghc_dynamic(), skip),
extra_clean(['T14708scratch/*', 'T14708'])],
['$MAKE -s --no-print-directory T14708'])
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