diff options
author | Simon Marlow <marlowsd@gmail.com> | 2014-09-26 20:08:43 +0100 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2014-11-28 14:10:32 +0000 |
commit | b5e8b3b162b3ff15ae6caf1afc659565365f54a8 (patch) | |
tree | 87e99c82b570a80340c624c88b6232747e4b66f4 /testsuite | |
parent | 58dcd5c2e2a94643454296ea0bb109db96bd154f (diff) | |
download | haskell-b5e8b3b162b3ff15ae6caf1afc659565365f54a8.tar.gz |
Make the linker API thread-safe
We used to be able to rely on the client to use the API in a
single-threaded way, but now that the GC calls into the linker to
unload objects this isn't a safe assumption.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/rts/Makefile | 8 | ||||
-rw-r--r-- | testsuite/tests/rts/T2615.hs | 1 | ||||
-rw-r--r-- | testsuite/tests/rts/rdynamic.hs | 2 |
3 files changed, 7 insertions, 4 deletions
diff --git a/testsuite/tests/rts/Makefile b/testsuite/tests/rts/Makefile index 8a7cb8af02..c943bb4135 100644 --- a/testsuite/tests/rts/Makefile +++ b/testsuite/tests/rts/Makefile @@ -124,7 +124,7 @@ linker_unload: $(RM) Test.o Test.hi "$(TEST_HC)" $(TEST_HC_OPTS) -c Test.hs -v0 # -rtsopts causes a warning - "$(TEST_HC)" $(filter-out -rtsopts, $(TEST_HC_OPTS)) linker_unload.c -o linker_unload -no-hs-main -optc-Werror -debug -optc-g + "$(TEST_HC)" $(filter-out -rtsopts, $(TEST_HC_OPTS)) linker_unload.c -o linker_unload -no-hs-main -optc-Werror -threaded ./linker_unload $(BASE) $(GHC_PRIM) $(INTEGER_GMP) # ----------------------------------------------------------------------------- @@ -142,7 +142,7 @@ linker_unload: .PHONY: linker_error1 linker_error1: "$(TEST_HC)" -c linker_error.c -o linker_error1.o - "$(TEST_HC)" linker_error1.o -o linker_error1 -no-hs-main -optc-g -debug + "$(TEST_HC)" linker_error1.o -o linker_error1 -no-hs-main -optc-g -debug -threaded ./linker_error1 linker_error.c # linker_error2: the object file has an unknown symbol (fails in @@ -152,7 +152,7 @@ linker_error1: linker_error2: "$(TEST_HC)" -c linker_error.c -o linker_error2.o "$(TEST_HC)" -c linker_error2.c -o linker_error2_o.o - "$(TEST_HC)" linker_error2.o -o linker_error2 -no-hs-main -optc-g -debug + "$(TEST_HC)" linker_error2.o -o linker_error2 -no-hs-main -optc-g -debug -threaded ./linker_error2 linker_error2_o.o # linker_error3: the object file duplicates an existing symbol (fails @@ -162,5 +162,5 @@ linker_error2: linker_error3: "$(TEST_HC)" -c linker_error.c -o linker_error3.o "$(TEST_HC)" -c linker_error3.c -o linker_error3_o.o - "$(TEST_HC)" linker_error3.o -o linker_error3 -no-hs-main -optc-g -debug + "$(TEST_HC)" linker_error3.o -o linker_error3 -no-hs-main -optc-g -debug -threaded ./linker_error3 linker_error3_o.o diff --git a/testsuite/tests/rts/T2615.hs b/testsuite/tests/rts/T2615.hs index ee04d93bcf..53c2d13ceb 100644 --- a/testsuite/tests/rts/T2615.hs +++ b/testsuite/tests/rts/T2615.hs @@ -3,6 +3,7 @@ import ObjLink library_name = "libfoo_script_T2615.so" -- this is really a linker script main = do + initObjLinker result <- loadDLL library_name case result of Nothing -> putStrLn (library_name ++ " loaded successfully") diff --git a/testsuite/tests/rts/rdynamic.hs b/testsuite/tests/rts/rdynamic.hs index 5fb4651ff9..17f8df76cd 100644 --- a/testsuite/tests/rts/rdynamic.hs +++ b/testsuite/tests/rts/rdynamic.hs @@ -26,6 +26,7 @@ loadFunction :: Maybe String -> String -> IO (Maybe a) loadFunction mpkg m valsym = do + c_initLinker let symbol = prefixUnderscore ++ maybe "" (\p -> zEncodeString p ++ "_") mpkg ++ zEncodeString m ++ "_" ++ zEncodeString valsym @@ -39,3 +40,4 @@ loadFunction mpkg m valsym = do prefixUnderscore = if elem os ["darwin","mingw32","cygwin"] then "_" else "" foreign import ccall safe "lookupSymbol" c_lookupSymbol :: CString -> IO (Ptr a) +foreign import ccall safe "initLinker" c_initLinker :: IO () |