Ben Gamari pushed to branch wip/T26166 at Glasgow Haskell Compiler / GHC Commits: bf8401bb by Ben Gamari at 2025-10-02T15:51:04-04:00 testsuite: Don't rely on non-PIC objects in shared objects When producing shared objects with `-shared` most platforms will require position-independent code. For this reason we need to build with `-dynamic` since otherwise we will link against, e.g., the static `ghc-internal` object, which is not built with `-fPIC`. - - - - - 52bb1eaf by Ben Gamari at 2025-10-02T16:20:31-04:00 testsuite: Explicitly flush in T10955dyn This shouldn't in principle be necessary but it appears that we fail to invoke the stdout finalizer when dynamically linking. - - - - - 2 changed files: - testsuite/tests/ghci/linking/dyn/Makefile - testsuite/tests/ghci/linking/dyn/T10955dyn.hs Changes: ===================================== testsuite/tests/ghci/linking/dyn/Makefile ===================================== @@ -50,7 +50,7 @@ MY_TEST_HC_OPTS = $(TEST_HC_OPTS) $(CFLAGS) load_short_name: rm -rf bin_short mkdir bin_short - '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_short" -shared A.c -o "bin_short/$(call DLL,A)" + '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_short" -dynamic -shared A.c -o "bin_short/$(call DLL,A)" rm -f bin_short/*.a echo ":q" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) -L"./bin_short" -lA @@ -58,14 +58,14 @@ load_short_name: compile_libT1407: rm -rf T1407dir mkdir T1407dir - '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "T1407dir" -shared A.c -o "T1407dir/$(call DLL,AS)" + '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "T1407dir" -dynamic -shared A.c -o "T1407dir/$(call DLL,AS)" rm -f T1407dir/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)" + '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "T10458dir" -dynamic -shared A.c -o "T10458dir/$(call DLL,AS)" rm -f T10458dir/libAS*.a .PHONY: compile_libAB_dep @@ -80,8 +80,8 @@ compile_libAB_dep: compile_libAB_dyn: rm -rf bin_dyn mkdir bin_dyn - '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_dyn" -shared A.c -o "bin_dyn/$(call DLL,A)" $(call DEF,A) - '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_dyn" -shared B.c -o "bin_dyn/$(call DLL,B)" $(call DEF,B) -lA -L"./bin_dyn" + '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_dyn" -dynamic -shared A.c -o "bin_dyn/$(call DLL,A)" $(call DEF,A) + '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_dyn" -dynamic -shared B.c -o "bin_dyn/$(call DLL,B)" $(call DEF,B) -lA -L"./bin_dyn" rm -f bin_dyn/*.a '$(TEST_HC)' $(TEST_HC_OPTS) -ignore-dot-ghci -v0 -o "bin_dyn/$(call EXE,T10955dyn)" -L./bin_dyn -lB -lA T10955dyn.hs -v0 DYLD_LIBRARY_PATH=./bin_dyn LD_LIBRARY_PATH=./bin_dyn ./bin_dyn/$(call EXE,T10955dyn) ===================================== testsuite/tests/ghci/linking/dyn/T10955dyn.hs ===================================== @@ -2,6 +2,12 @@ module Main where import Foreign import Foreign.C.Types +import System.IO + foreign import ccall "bar" dle :: IO CInt -main = dle >>= print +main = do + dle >>= print + -- This shouldn't be necessary but it appears that the finalizer is + -- not executed reliably, especially in the dynamic way. + hFlush stdout View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2500516d363d81829c2458a98556085... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/2500516d363d81829c2458a98556085... You're receiving this email because of your account on gitlab.haskell.org.