summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghci/linking
diff options
context:
space:
mode:
authorTamar Christina <tamar@zhox.com>2016-04-17 13:03:17 +0200
committerTamar Christina <tamar@zhox.com>2016-04-17 13:06:40 +0200
commit97f2b16483aae28dc8fd60b6d2e1e283618f2390 (patch)
tree6b9444496a6cbe758a9fff0b05ac969fd87fa188 /testsuite/tests/ghci/linking
parent4cbae1bd70097a2d365ce0644145a8203956d59a (diff)
downloadhaskell-97f2b16483aae28dc8fd60b6d2e1e283618f2390.tar.gz
Add Windows import library support to the Runtime Linker
Summary: Import libraries are files ending in `.dll.a` and `.lib` depending on which compiler creates them (GCC, vs MSVC). Import Libraries are standard `archive` files that contain object files. These object files can have two different formats: 1) The normal COFF Object format for object files (contains all ascii data and very little program code, so do not try to execute.) 2) "short import" format which just contains a symbol name and the dll in which the symbol can be found. Import Libraries are useful for two things: 1) Allowing applications that don't support dynamic linking to link against the import lib (non-short format) which then makes calls into the DLL by loading it at runtime. 2) Allow linking of mutually recursive dlls. if `A.DLL` requires `B.DLL` and vice versa, import libs can be used to break the cycle as they can be created from the expected exports of the DLLs. A side effect of having these two capabilities is that Import libs are often used to hide specific versions of DLLs behind a non-versioned import lib. e.g. GCC_S.a (non-conventional import lib) will point to the correct `libGCC` DLL. With this support Windows Haskell files can now just link to `-lGCC_S` and not have to worry about what the actual name of libGCC is. Also third party libraries such as `icuuc` use import libs to forward to versioned DLLs. e.g. `icuuc.lib` points to `icuuc51.dll` etc. Test Plan: ./validate Two new tests added T11072gcc T11072msvc Two binary files have been added to the test folder because the "short" import library format doesn't seem to be creatable via `dlltool` and requires Microsoft's `lib.exe`. Reviewers: bgamari, RyanGlScott, erikd, goldfire, austin, hvr Reviewed By: RyanGlScott, erikd Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1696 GHC Trac Issues: #11072
Diffstat (limited to 'testsuite/tests/ghci/linking')
-rw-r--r--testsuite/tests/ghci/linking/dyn/Makefile16
-rw-r--r--testsuite/tests/ghci/linking/dyn/T11072.hs7
-rw-r--r--testsuite/tests/ghci/linking/dyn/T11072gcc.stdout1
-rw-r--r--testsuite/tests/ghci/linking/dyn/T11072msvc.stdout1
-rw-r--r--testsuite/tests/ghci/linking/dyn/all.T10
-rw-r--r--testsuite/tests/ghci/linking/dyn/i686/libAS.libbin0 -> 1698 bytes
-rw-r--r--testsuite/tests/ghci/linking/dyn/libAS.def3
-rw-r--r--testsuite/tests/ghci/linking/dyn/x86_64/libAS.libbin0 -> 1700 bytes
8 files changed, 38 insertions, 0 deletions
diff --git a/testsuite/tests/ghci/linking/dyn/Makefile b/testsuite/tests/ghci/linking/dyn/Makefile
index 56e27b13fa..b37fdeaf21 100644
--- a/testsuite/tests/ghci/linking/dyn/Makefile
+++ b/testsuite/tests/ghci/linking/dyn/Makefile
@@ -64,6 +64,22 @@ compile_libAB_dyn:
'$(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)
+.PHONY: compile_libAS_impl_gcc
+compile_libAS_impl_gcc:
+ rm -rf bin_impl_gcc
+ mkdir bin_impl_gcc
+ '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_impl_gcc" -shared A.c -o "bin_impl_gcc/$(call DLL,ASimpL)"
+ mv bin_impl_gcc/libASimpL.dll.a bin_impl_gcc/libASx.dll.a
+ echo "main" | '$(TEST_HC)' $(TEST_HC_OPTS) --interactive -ignore-dot-ghci -v0 T11072.hs -lASx -L./bin_impl_gcc
+
+.PHONY: compile_libAS_impl_msvc
+compile_libAS_impl_msvc:
+ rm -rf bin_impl_msvc
+ mkdir bin_impl_msvc
+ '$(TEST_HC)' $(MY_TEST_HC_OPTS) -odir "bin_impl_msvc" -shared A.c -o "bin_impl_msvc/$(call DLL,ASimpL)"
+ rm -f bin_impl_msvc/libAS*.a
+ echo "main" | '$(TEST_HC)' $(TEST_HC_OPTS) --interactive -ignore-dot-ghci -v0 T11072.hs -lAS -L./bin_impl_msvc -L"./$(shell uname -m)"
+
.PHONY: T1407
T1407:
cat T1407.script | LD_LIBRARY_PATH=. "$(TEST_HC)" $(TEST_HC_OPTS) -ignore-dot-ghci -v0 --interactive -L.
diff --git a/testsuite/tests/ghci/linking/dyn/T11072.hs b/testsuite/tests/ghci/linking/dyn/T11072.hs
new file mode 100644
index 0000000000..56636d809f
--- /dev/null
+++ b/testsuite/tests/ghci/linking/dyn/T11072.hs
@@ -0,0 +1,7 @@
+module Main where
+
+import Foreign
+import Foreign.C.Types
+foreign import ccall "foo" dle :: IO CInt
+
+main = dle >>= print
diff --git a/testsuite/tests/ghci/linking/dyn/T11072gcc.stdout b/testsuite/tests/ghci/linking/dyn/T11072gcc.stdout
new file mode 100644
index 0000000000..78c6baefdd
--- /dev/null
+++ b/testsuite/tests/ghci/linking/dyn/T11072gcc.stdout
@@ -0,0 +1 @@
+2
diff --git a/testsuite/tests/ghci/linking/dyn/T11072msvc.stdout b/testsuite/tests/ghci/linking/dyn/T11072msvc.stdout
new file mode 100644
index 0000000000..78c6baefdd
--- /dev/null
+++ b/testsuite/tests/ghci/linking/dyn/T11072msvc.stdout
@@ -0,0 +1 @@
+2
diff --git a/testsuite/tests/ghci/linking/dyn/all.T b/testsuite/tests/ghci/linking/dyn/all.T
index e1e0fd289e..d54c84eec9 100644
--- a/testsuite/tests/ghci/linking/dyn/all.T
+++ b/testsuite/tests/ghci/linking/dyn/all.T
@@ -34,3 +34,13 @@ test('T10458',
pre_cmd('$MAKE -s --no-print-directory compile_libT10458'),
extra_hc_opts('-L$PWD/T10458dir -lAS')],
ghci_script, ['T10458.script'])
+
+test('T11072gcc',
+ [unless(doing_ghci, skip), unless(opsys('mingw32'), skip), extra_clean(['bin_impl_gcc/*', 'bin_impl_gcc'])],
+ run_command,
+ ['$MAKE -s --no-print-directory compile_libAS_impl_gcc'])
+
+test('T11072msvc',
+ [unless(doing_ghci, skip), unless(opsys('mingw32'), skip), extra_clean(['bin_impl_msvc/*', 'bin_impl_msvc'])],
+ run_command,
+ ['$MAKE -s --no-print-directory compile_libAS_impl_msvc'])
diff --git a/testsuite/tests/ghci/linking/dyn/i686/libAS.lib b/testsuite/tests/ghci/linking/dyn/i686/libAS.lib
new file mode 100644
index 0000000000..3d976ea0df
--- /dev/null
+++ b/testsuite/tests/ghci/linking/dyn/i686/libAS.lib
Binary files differ
diff --git a/testsuite/tests/ghci/linking/dyn/libAS.def b/testsuite/tests/ghci/linking/dyn/libAS.def
new file mode 100644
index 0000000000..4873b34ac7
--- /dev/null
+++ b/testsuite/tests/ghci/linking/dyn/libAS.def
@@ -0,0 +1,3 @@
+LIBRARY libASimpL
+EXPORTS
+foo
diff --git a/testsuite/tests/ghci/linking/dyn/x86_64/libAS.lib b/testsuite/tests/ghci/linking/dyn/x86_64/libAS.lib
new file mode 100644
index 0000000000..3b207086fb
--- /dev/null
+++ b/testsuite/tests/ghci/linking/dyn/x86_64/libAS.lib
Binary files differ