[commit: ghc] master: Link command line libs to temp so (c6a3e22)
git at git.haskell.org
git at git.haskell.org
Fri Jan 15 15:31:26 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/c6a3e2277aef2d3b8a472cc82542c9b22cea86bf/ghc
>---------------------------------------------------------------
commit c6a3e2277aef2d3b8a472cc82542c9b22cea86bf
Author: Peter Trommler <ptrommler at acm.org>
Date: Fri Jan 15 13:25:38 2016 +0100
Link command line libs to temp so
Symbols in libraries specified on the GHCis command line are
not available to compiled modules because shared libraries
are loaded with local scope. So we link all libraries specified
on the command line into each temporary shared library.
Test Plan: validate
Reviewers: simonmar, hvr, austin, bgamari
Reviewed By: bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1631
GHC Trac Issues: #10458
>---------------------------------------------------------------
c6a3e2277aef2d3b8a472cc82542c9b22cea86bf
compiler/ghci/Linker.hs | 14 +++++++++++++-
testsuite/tests/ghci/linking/dyn/Makefile | 7 +++++++
.../tests/ghci/linking/dyn/{T1407.script => T10458.hs} | 6 +++++-
testsuite/tests/ghci/linking/dyn/T10458.script | 4 ++++
.../T3279.stdout => ghci/linking/dyn/T10458.stdout} | 0
testsuite/tests/ghci/linking/dyn/all.T | 7 +++++++
6 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/compiler/ghci/Linker.hs b/compiler/ghci/Linker.hs
index 8f1107f..44d272e 100644
--- a/compiler/ghci/Linker.hs
+++ b/compiler/ghci/Linker.hs
@@ -846,6 +846,8 @@ dynLoadObjs _ pls [] = return pls
dynLoadObjs hsc_env pls objs = do
let dflags = hsc_dflags hsc_env
let platform = targetPlatform dflags
+ let minus_ls = [ lib | Option ('-':'l':lib) <- ldInputs dflags ]
+ let minus_big_ls = [ lib | Option ('-':'L':lib) <- ldInputs dflags ]
(soFile, libPath , libName) <- newTempLibName dflags (soExt platform)
let
dflags2 = dflags {
@@ -863,7 +865,17 @@ dynLoadObjs hsc_env pls objs = do
, Option ("-Wl," ++ lp)
, Option ("-l" ++ l)
])
- (temp_sos pls),
+ (temp_sos pls)
+ ++ concatMap
+ (\lp ->
+ [ Option ("-L" ++ lp)
+ , Option ("-Wl,-rpath")
+ , Option ("-Wl," ++ lp)
+ ])
+ minus_big_ls
+ ++ map (\l -> Option ("-l" ++ l)) minus_ls,
+ -- Add -l options and -L options from dflags.
+ --
-- When running TH for a non-dynamic way, we still
-- need to make -l flags to link against the dynamic
-- libraries, so we need to add WayDyn to ways.
diff --git a/testsuite/tests/ghci/linking/dyn/Makefile b/testsuite/tests/ghci/linking/dyn/Makefile
index bc33048..0f2d6e1 100644
--- a/testsuite/tests/ghci/linking/dyn/Makefile
+++ b/testsuite/tests/ghci/linking/dyn/Makefile
@@ -39,6 +39,13 @@ compile_libAS:
'$(TEST_HC)' $(MY_TEST_HC_OPTS) -shared A.c -o $(call DLL,AS)
rm -f libAS*.a
+.PHONY: compile_libT10458
+compile_libT10458:
+ rm -rf T10458dir
+ mkdir T10458dir
+ '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "T10458dir" -shared A.c -o "T10458dir/$(call DLL,AS)"
+ rm -f T10458dir/libAS*.a
+
.PHONY: compile_libAB_dep
compile_libAB_dep:
rm -rf bin_dep
diff --git a/testsuite/tests/ghci/linking/dyn/T1407.script b/testsuite/tests/ghci/linking/dyn/T10458.hs
similarity index 56%
copy from testsuite/tests/ghci/linking/dyn/T1407.script
copy to testsuite/tests/ghci/linking/dyn/T10458.hs
index 0274f82..98fc4e4 100644
--- a/testsuite/tests/ghci/linking/dyn/T1407.script
+++ b/testsuite/tests/ghci/linking/dyn/T10458.hs
@@ -1,4 +1,8 @@
-:set -lAS
+module T10458 (callSO) where
+
import Foreign
import Foreign.C.Types
foreign import ccall "foo" dle :: IO CInt
+
+callSO :: IO CInt
+callSO = dle
diff --git a/testsuite/tests/ghci/linking/dyn/T10458.script b/testsuite/tests/ghci/linking/dyn/T10458.script
new file mode 100644
index 0000000..15ecb22
--- /dev/null
+++ b/testsuite/tests/ghci/linking/dyn/T10458.script
@@ -0,0 +1,4 @@
+:set -fobject-code
+:load T10458
+
+callSO
diff --git a/testsuite/tests/concurrent/should_run/T3279.stdout b/testsuite/tests/ghci/linking/dyn/T10458.stdout
similarity index 100%
copy from testsuite/tests/concurrent/should_run/T3279.stdout
copy to testsuite/tests/ghci/linking/dyn/T10458.stdout
diff --git a/testsuite/tests/ghci/linking/dyn/all.T b/testsuite/tests/ghci/linking/dyn/all.T
index e5b40d4..eb044fc 100644
--- a/testsuite/tests/ghci/linking/dyn/all.T
+++ b/testsuite/tests/ghci/linking/dyn/all.T
@@ -27,3 +27,10 @@ test('T10955dyn',
[extra_clean(['bin_dyn/*', 'bin_dyn'])],
run_command,
['$MAKE -s --no-print-directory compile_libAB_dyn'])
+
+test('T10458',
+ [unless(doing_ghci, skip),
+ extra_clean(['libAS.*']),
+ pre_cmd('$MAKE -s --no-print-directory compile_libT10458'),
+ extra_hc_opts('-L$PWD/T10458dir -lAS')],
+ ghci_script, ['T10458.script'])
More information about the ghc-commits
mailing list