Skip to content
Snippets Groups Projects
Commit 03efe283 authored by Ben Gamari's avatar Ben Gamari Committed by Marge Bot
Browse files

testsuite: Add tests for system-cxx-std-lib package

Test that we can successfully link against C++ code both in GHCi and
batch compilation.

See #20010
parent 0ef249aa
No related branches found
No related tags found
No related merge requests found
TOP=../../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
T20010:
'$(TEST_HC)' $(TEST_HC_OPTS) -c T20010.hs
'$(TEST_HC)' $(TEST_HC_OPTS) -c T20010_c.cpp
'$(TEST_HC)' $(TEST_HC_OPTS) -package system-cxx-std-lib T20010_c.o T20010.o -o T20010
./T20010
T20010-ghci:
'$(TEST_HC)' $(TEST_HC_OPTS) -c T20010.hs
# We must build with PIC lest we end up with R_X86_64_32 relocations in
# .rodata which precludes linking into a shared object and therefore loading
# in GHCi
'$(TEST_HC)' $(TEST_HC_OPTS) -c -fPIC T20010_c.cpp
'$(TEST_HC)' $(TEST_HC_OPTS_INTERACTIVE) -package system-cxx-std-lib T20010_c.o <T20010-ghci.script
:load T20010
hello 42
hello world 42
module Main where
import Foreign.C.Types
foreign import ccall unsafe "hello" hello :: CInt -> IO ()
main :: IO ()
main = do
hello 42
hello world 42
#include <iostream>
extern "C" {
void hello(int x) {
std::cout << "hello world " << x << std::endl;
}
}
# Test that GHC links to the C++ standard library as expected
# when the system-cxx-std-lib package is used.
test('T20010', normal, makefile_test, [])
test('T20010-ghci', extra_files(['T20010_c.cpp', 'T20010.hs']), makefile_test, [])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment