summaryrefslogtreecommitdiff
path: root/testsuite/tests/llvm
diff options
context:
space:
mode:
authorMoritz Angermann <moritz@lichtzwerge.de>2014-11-19 16:38:22 -0600
committerAustin Seipp <austin@well-typed.com>2014-11-19 17:03:06 -0600
commit53a4742d037da2bfd00d1d34a8ea0d49d4cdb490 (patch)
tree1922721e21e3b6618ff9b7184d9dc96e9145e535 /testsuite/tests/llvm
parent146dd138e2c3b4ec9b211dcbcedf752aeb79d3d1 (diff)
downloadhaskell-53a4742d037da2bfd00d1d34a8ea0d49d4cdb490.tar.gz
Allow -dead_strip linking on platforms with .subsections_via_symbols
Summary: This allows to link objects produced with the llvm code generator to be linked with -dead_strip. This applies to at least the iOS cross compiler and OS X compiler. Signed-off-by: Moritz Angermann <moritz@lichtzwerge.de> Test Plan: Create a ffi library and link it with -dead_strip. If the resulting binary does not crash, the patch works as advertised. Reviewers: rwbarton, simonmar, hvr, dterei, mzero, ezyang, austin Reviewed By: dterei, ezyang, austin Subscribers: thomie, mzero, simonmar, ezyang, carter Differential Revision: https://phabricator.haskell.org/D206
Diffstat (limited to 'testsuite/tests/llvm')
-rw-r--r--testsuite/tests/llvm/should_run/Makefile3
-rw-r--r--testsuite/tests/llvm/should_run/subsections_via_symbols/Makefile13
-rw-r--r--testsuite/tests/llvm/should_run/subsections_via_symbols/SubsectionsViaSymbols.hs5
-rw-r--r--testsuite/tests/llvm/should_run/subsections_via_symbols/all.T15
-rwxr-xr-xtestsuite/tests/llvm/should_run/subsections_via_symbols/subsections_via_symbols-libtool-quiet4
-rw-r--r--testsuite/tests/llvm/should_run/subsections_via_symbols/subsections_via_symbols.m11
-rw-r--r--testsuite/tests/llvm/should_run/subsections_via_symbols/subsections_via_symbols.stderr0
-rw-r--r--testsuite/tests/llvm/should_run/subsections_via_symbols/subsections_via_symbols.stdout2
8 files changed, 53 insertions, 0 deletions
diff --git a/testsuite/tests/llvm/should_run/Makefile b/testsuite/tests/llvm/should_run/Makefile
new file mode 100644
index 0000000000..9101fbd40a
--- /dev/null
+++ b/testsuite/tests/llvm/should_run/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/llvm/should_run/subsections_via_symbols/Makefile b/testsuite/tests/llvm/should_run/subsections_via_symbols/Makefile
new file mode 100644
index 0000000000..c108a37d98
--- /dev/null
+++ b/testsuite/tests/llvm/should_run/subsections_via_symbols/Makefile
@@ -0,0 +1,13 @@
+TOP=../../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+# pass -dead_strip to the linker.
+HCFLAGS = -O2 -fllvm
+HCINC = $(TOP)/../includes
+
+.PHONY: subsections_via_symbols_test
+subsections_via_symbols_test:
+ '$(TEST_HC)' -o SubsectionsViaSymbols.o SubsectionsViaSymbols.hs $(HCFLAGS) -staticlib
+ '$(TEST_HC)' -o subsections_via_symbols SubsectionsViaSymbols subsections_via_symbols.m $(HCFLAGS) -optl -dead_strip -no-hs-main
+ ./subsections_via_symbols
diff --git a/testsuite/tests/llvm/should_run/subsections_via_symbols/SubsectionsViaSymbols.hs b/testsuite/tests/llvm/should_run/subsections_via_symbols/SubsectionsViaSymbols.hs
new file mode 100644
index 0000000000..9725717909
--- /dev/null
+++ b/testsuite/tests/llvm/should_run/subsections_via_symbols/SubsectionsViaSymbols.hs
@@ -0,0 +1,5 @@
+{-# LANGUAGE ForeignFunctionInterface #-}
+module SymbolsViaSections where
+foreign export ccall test :: Int -> IO ()
+test :: Int -> IO ()
+test i = putStrLn (replicate i '.')
diff --git a/testsuite/tests/llvm/should_run/subsections_via_symbols/all.T b/testsuite/tests/llvm/should_run/subsections_via_symbols/all.T
new file mode 100644
index 0000000000..2ecbaa5798
--- /dev/null
+++ b/testsuite/tests/llvm/should_run/subsections_via_symbols/all.T
@@ -0,0 +1,15 @@
+if config.os == 'darwin':
+ only_darwin = normal
+else:
+ only_darwin = skip
+
+
+# Note [_ffi_call_unix64]
+#
+# Please refer to https://ghc.haskell.org/trac/ghc/ticket/5019
+# for the subsections_via_symbols.stderr
+
+test('subsections_via_symbols',
+ [extra_clean(['SubsectionsViaSymbols.hi', 'SubsectionsViaSymbols.o', 'SymbolsViaSections_stub.h', 'subsections_via_symbols', 'SubsectionsViaSymbols.a', 'SymbolsViaSections.hi', 'SymbolsViaSections.o', 'subsections_via_symbols.o']),
+ only_darwin],
+ run_command, ['$MAKE -s --no-print-directory subsections_via_symbols_test'])
diff --git a/testsuite/tests/llvm/should_run/subsections_via_symbols/subsections_via_symbols-libtool-quiet b/testsuite/tests/llvm/should_run/subsections_via_symbols/subsections_via_symbols-libtool-quiet
new file mode 100755
index 0000000000..fcc0a8ea14
--- /dev/null
+++ b/testsuite/tests/llvm/should_run/subsections_via_symbols/subsections_via_symbols-libtool-quiet
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Script to suppress annoying warnings from libtool (without suppressing any other interesting output)
+libtool $@ 2>&1 | sed -e "/has no symbols/D" | sed -e "/due to use of basename, truncation and blank padding/D" \ No newline at end of file
diff --git a/testsuite/tests/llvm/should_run/subsections_via_symbols/subsections_via_symbols.m b/testsuite/tests/llvm/should_run/subsections_via_symbols/subsections_via_symbols.m
new file mode 100644
index 0000000000..9fb2bc6839
--- /dev/null
+++ b/testsuite/tests/llvm/should_run/subsections_via_symbols/subsections_via_symbols.m
@@ -0,0 +1,11 @@
+#import <Foundation/Foundation.h>
+#import "HsFFI.h"
+#import "SymbolsViaSections_stub.h"
+
+int
+main(int argc, char * argv[]) {
+ hs_init(&argc, &argv);
+ atexit(&hs_exit);
+ test(10);
+ return EXIT_SUCCESS;
+}
diff --git a/testsuite/tests/llvm/should_run/subsections_via_symbols/subsections_via_symbols.stderr b/testsuite/tests/llvm/should_run/subsections_via_symbols/subsections_via_symbols.stderr
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuite/tests/llvm/should_run/subsections_via_symbols/subsections_via_symbols.stderr
diff --git a/testsuite/tests/llvm/should_run/subsections_via_symbols/subsections_via_symbols.stdout b/testsuite/tests/llvm/should_run/subsections_via_symbols/subsections_via_symbols.stdout
new file mode 100644
index 0000000000..0daadb5013
--- /dev/null
+++ b/testsuite/tests/llvm/should_run/subsections_via_symbols/subsections_via_symbols.stdout
@@ -0,0 +1,2 @@
+Linking subsections_via_symbols ...
+..........