Commit 5bbc839e authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Add a test for #4464: -rtsopts and dynamic libraries

parent 5695c1aa
......@@ -13,3 +13,20 @@ T3807:
'$(TEST_HC)' T3807-load.c -o T3807-load -ldl
./T3807-load
.PHONY: T4464
T4464:
$(RM) T4464B.o T4464C.o T4464H.hi T4464H.o
$(RM) T4464H_stub.c T4464H_stub.h T4464H_stub.o
$(RM) HS4464.dll HS4464.dll.a t4464.exe
'$(TEST_HC)' -v0 -shared T4464H.hs T4464B.c -o HS4464.dll
'$(TEST_HC)' -v0 T4464C.c HS4464.dll.a -o t4464.exe
-./t4464.exe
echo "====="
echo "=====" >&2
$(RM) T4464B.o T4464C.o T4464H.hi T4464H.o
$(RM) T4464H_stub.c T4464H_stub.h T4464H_stub.o
$(RM) HS4464.dll HS4464.dll.a t4464.exe
'$(TEST_HC)' -v0 -shared T4464H.hs T4464B.c -o HS4464.dll -rtsopts
'$(TEST_HC)' -v0 T4464C.c HS4464.dll.a -o t4464.exe
./t4464.exe
Creating library file: HS4464.dll.a
ghcDll: Most RTS options are disabled. Link with -rtsopts to enable them.
=====
Creating library file: HS4464.dll.a
#include <Rts.h>
extern void __stginit_T4464H(void);
void HsStart(void) {
int argc = 3;
char* argv[] = {"ghcDll", "+RTS", "-H50M", NULL}; // argv must end with NULL
// Initialize Haskell runtime
char** args = argv;
hs_init(&argc, &args);
// Tell Haskell about all root modules
hs_add_root(__stginit_T4464H);
}
void HsEnd(void) {
hs_exit();
}
#include "HsFFI.h"
#include "T4464H_stub.h"
#include <stdio.h>
void HsStart(void);
void HsEnd(void);
int main(void) {
HsStart();
printf("f 12 = %i\n", f(12));
HsEnd();
return 0;
}
{-# LANGUAGE ForeignFunctionInterface #-}
module T4464H where
f :: Int -> Int
f x = x + 1
foreign export ccall f :: Int -> Int
......@@ -11,3 +11,11 @@ test('T3807',
run_command,
['$MAKE --no-print-directory -s T3807'])
test('T4464',
[extra_clean(['T4464B.o', 'T4464C.o', 'T4464H.hi', 'T4464H.o',
'T4464H_stub.c', 'T4464H_stub.h', 'T4464H_stub.o',
'HS4464.dll', 'HS4464.dll.a', 't4464.exe']),
unless_os('mingw32', skip)],
run_command,
['$MAKE --no-print-directory -s T4464'])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment