diff options
author | Ben Gamari <ben@well-typed.com> | 2022-03-22 12:44:12 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2022-04-06 15:18:26 -0400 |
commit | 7e97cc23e47d12c4050f257c7271976b5b846180 (patch) | |
tree | 6e3b855f24d40be27e6c56b649900ec6c6e56222 /testsuite/tests/ghci | |
parent | 3c08a1981e99a24295fb229a0c71defe1f100386 (diff) | |
download | haskell-7e97cc23e47d12c4050f257c7271976b5b846180.tar.gz |
testsuite: Provide module definitions in T10955dyn
Otherwise the linker will export all symbols, including those provided
by the RTS, from the produced shared object. Consequently, attempting
to link against multiple objects simultaneously will cause the linker
to complain that RTS symbols are multiply defined. Avoid this
by limiting the DLL exports with a module definition file.
Diffstat (limited to 'testsuite/tests/ghci')
-rw-r--r-- | testsuite/tests/ghci/linking/dyn/A.def | 3 | ||||
-rw-r--r-- | testsuite/tests/ghci/linking/dyn/B.def | 3 | ||||
-rw-r--r-- | testsuite/tests/ghci/linking/dyn/Makefile | 18 | ||||
-rw-r--r-- | testsuite/tests/ghci/linking/dyn/all.T | 8 |
4 files changed, 25 insertions, 7 deletions
diff --git a/testsuite/tests/ghci/linking/dyn/A.def b/testsuite/tests/ghci/linking/dyn/A.def new file mode 100644 index 0000000000..5198ddd028 --- /dev/null +++ b/testsuite/tests/ghci/linking/dyn/A.def @@ -0,0 +1,3 @@ +LIBRARY libA +EXPORTS +foo
\ No newline at end of file diff --git a/testsuite/tests/ghci/linking/dyn/B.def b/testsuite/tests/ghci/linking/dyn/B.def new file mode 100644 index 0000000000..bdfc2cbfbb --- /dev/null +++ b/testsuite/tests/ghci/linking/dyn/B.def @@ -0,0 +1,3 @@ +LIBRARY libB +EXPORTS +bar diff --git a/testsuite/tests/ghci/linking/dyn/Makefile b/testsuite/tests/ghci/linking/dyn/Makefile index c139038b14..da8ee20790 100644 --- a/testsuite/tests/ghci/linking/dyn/Makefile +++ b/testsuite/tests/ghci/linking/dyn/Makefile @@ -2,6 +2,16 @@ TOP=../../../.. include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/test.mk +# On Windows we must provide module definitions (.def files) +# for shared libraries, lest the linker exports *everything*, including RTS +# symbols. This would mean that we couldn't link against multiple dynamic +# objects simultaneously as the RTS symbols would be defined multiple times. +ifeq "$(WINDOWS)" "YES" +DEF = "$1.def" +else +DEF = +endif + ifeq "$(WINDOWS)" "YES" DLL = lib$1.dll else ifeq "$(DARWIN)" "YES" @@ -62,16 +72,16 @@ compile_libT10458: compile_libAB_dep: rm -rf bin_dep mkdir bin_dep - '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_dep" -shared A.c -o "bin_dep/$(call DLL,A)" - '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_dep" -shared B.c -o "bin_dep/$(call DLL,B)" -lA -L"./bin_dep" + '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_dep" -shared A.c -o "bin_dep/$(call DLL,A)" $(call DEF,A) + '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_dep" -shared B.c -o "bin_dep/$(call DLL,B)" $(call DEF,B) -lA -L"./bin_dep" rm -f bin_dep/*.a .PHONY: compile_libAB_dyn 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)" - '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_dyn" -shared B.c -o "bin_dyn/$(call DLL,B)" -lA -L"./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" 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 LD_LIBRARY_PATH=./bin_dyn ./bin_dyn/$(call EXE,T10955dyn) diff --git a/testsuite/tests/ghci/linking/dyn/all.T b/testsuite/tests/ghci/linking/dyn/all.T index 0092f7febe..9b05ed5fc3 100644 --- a/testsuite/tests/ghci/linking/dyn/all.T +++ b/testsuite/tests/ghci/linking/dyn/all.T @@ -16,13 +16,15 @@ test('T3242', makefile_test, ['T3242']) test('T10955', - [extra_files(['A.c', 'B.c']), - unless(doing_ghci, skip), unless(opsys('mingw32'), skip), + [extra_files(['A.c', 'B.c', 'A.def', 'B.def']), + unless(doing_ghci, skip), + unless(opsys('mingw32'), skip), pre_cmd('$MAKE -s --no-print-directory compile_libAB_dep'), extra_hc_opts('-L. -L./bin_dep')], ghci_script, ['T10955.script']) -test('T10955dyn', [extra_files(['A.c', 'B.c'])], makefile_test, ['compile_libAB_dyn']) +test('T10955dyn', [extra_files(['A.c', 'B.c', 'A.def', 'B.def'])], + makefile_test, ['compile_libAB_dyn']) test('T10458', [extra_files(['A.c']), |