Skip to content

Commit e97506d

Browse files
committed
Fix mostly-static test on windows
1 parent 5a8ec6f commit e97506d

File tree

9 files changed

+19
-10
lines changed

9 files changed

+19
-10
lines changed

compiler/GHC/Driver/Session.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ dynamic_flags_deps = [
11131113
(NoArg (setGeneralFlag Opt_SingleLibFolder))
11141114
, make_ord_flag defGhcFlag "pie" (NoArg (setGeneralFlag Opt_PICExecutable))
11151115
, make_ord_flag defGhcFlag "no-pie" (NoArg (unSetGeneralFlag Opt_PICExecutable))
1116-
, make_ord_flag defGhcFlag "static-external" (noArg (\d -> d { ghcLink=LinkExecutable (MostlyStatic ["c", "m", "rt", "dl", "pthread", "stdc++", "c++", "c++abi", "atomic"]) }))
1116+
, make_ord_flag defGhcFlag "static-external" (noArg (\d -> d { ghcLink=LinkExecutable (MostlyStatic ["c", "m", "rt", "dl", "pthread", "stdc++", "c++", "c++abi", "atomic", "wsock32", "gdi32", "winmm", "dbghelp", "psapi", "user32", "shell32", "mingw32", "kernel32", "advapi32", "mingwex", "ws2_32", "shlwapi", "ole32", "rpcrt4", "ntdll", "ucrt"]) }))
11171117
, make_ord_flag defGhcFlag "exclude-static-external"
11181118
(OptPrefix (\str -> upd $ \d -> case ghcLink d of
11191119
LinkExecutable (MostlyStatic _) ->

libraries/ghc-internal/ghc-internal.cabal.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,9 @@ Library
493493
extra-libraries:
494494
wsock32, user32, shell32, mingw32, kernel32, advapi32,
495495
mingwex, ws2_32, shlwapi, ole32, rpcrt4, ntdll, ucrt
496+
extra-libraries-static:
497+
wsock32, user32, shell32, mingw32, kernel32, advapi32,
498+
mingwex, ws2_32, shlwapi, ole32, rpcrt4, ntdll, ucrt
496499
-- Minimum supported Windows version.
497500
-- These numbers can be found at:
498501
-- https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx

testsuite/ghc-config/ghc-config.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ main = do
5050
getGhcFieldOrDefault fields "GhcLeadingUnderscore" "Leading underscore" "NO"
5151
getGhcFieldOrDefault fields "GhcTablesNextToCode" "Tables next to code" "NO"
5252
getGhcFieldProgWithDefault fields "AR" "ar command" "ar"
53+
getGhcFieldProgWithDefault fields "RANLIB" "ranlib command" "ranlib"
5354
getGhcFieldProgWithDefault fields "LLC" "LLVM llc command" "llc"
5455
getGhcFieldProgWithDefault fields "TEST_CC" "C compiler command" "gcc"
5556
getGhcFieldProgWithDefault fields "TEST_CC_OPTS" "C compiler flags" ""
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
import Test
1+
foreign import ccall "my_func" c_my_func :: IO Int
22

3-
main = print test
3+
main = do
4+
x <- c_my_func
5+
print x

testsuite/tests/driver/mostly-static/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ clean:
1919
.PHONY: mostly-static
2020
mostly-static:
2121
@rm -rf $(LOCAL_PKGCONF)
22-
"$(TEST_HC)" $(TEST_HC_OPTS) -this-unit-id test-1.0 -c test/Test.hs -staticlib -o test/libtest-1.0.a
22+
"$(TEST_CC)" -c "test/test.c" -o "test/test.o"
23+
"$(AR)" qc "test/libtest-1.0.a" "test/test.o"
24+
"$(RANLIB)" "test/libtest-1.0.a"
2325
"$(GHC_PKG)" init $(LOCAL_PKGCONF)
2426
"$(GHC_PKG)" --no-user-package-db -f $(LOCAL_PKGCONF) register test/test.pkg -v0
25-
"$(TEST_HC)" $(TEST_HC_OPTS) --make -static-external -exclude-static-external=c,m,rt,dl,pthread,stdc++,atomic,gmp,ffi,iconv -hide-all-packages -package-db $(LOCAL_PKGCONF)/ -package base -package-id test-1.0 Hello.hs
27+
"$(TEST_HC)" $(TEST_HC_OPTS) --make -static-external -exclude-static-external=c,m,rt,dl,pthread,stdc++,atomic,gmp,ffi,iconv,wsock32,gdi32,winmm,dbghelp,psapi,user32,shell32,mingw32,kernel32,advapi32,mingwex,ws2_32,shlwapi,ole32,rpcrt4,ntdll,ucrt -hide-all-packages -package-db $(LOCAL_PKGCONF)/ -package base -package-id test-1.0 Hello.hs
2628
./Hello
2729
$(LDD) Hello | grep libtest || true

testsuite/tests/driver/mostly-static/test/Test.hs

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
int my_func(void) {
2+
return 42;
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int my_func(void);

testsuite/tests/driver/mostly-static/test/test.pkg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ name: test
22
version: 1.0
33
id: test-1.0
44
key: test-1.0
5-
exposed-modules: Test
65
import-dirs: ${pkgroot}/test
6+
include-dirs: ${pkgroot}/test
7+
includes: test.h
78
library-dirs-static: ${pkgroot}/test
89
extra-libraries-static: test-1.0
910
exposed: True

0 commit comments

Comments
 (0)