diff options
author | Tamar Christina <tamar@zhox.com> | 2016-09-01 21:30:07 +0100 |
---|---|---|
committer | Tamar Christina <tamar@zhox.com> | 2016-09-01 21:31:52 +0100 |
commit | e5ecb2010514405ac1b9b1285a8a65c00a5fd4e0 (patch) | |
tree | 866ae612180fb7fab7af9281d8f43980ec6718e1 /testsuite | |
parent | f233f00b1915ac6c0a200b8017a9f07deefd401e (diff) | |
download | haskell-e5ecb2010514405ac1b9b1285a8a65c00a5fd4e0.tar.gz |
Added support for deprecated POSIX functions on Windows.
Summary:
With the introduction of 8.0.1 We've stopped supporting in GHCi
the use of POSIX functions under their deprecated names on Windows.
This to be compatible with object and libraries from the most
popular compilers on the platform (Microsoft and Intel compilers).
However this brings a confusing disparity between the compiled and
interpreted behavior since MingW-W64 does support the deprecated names.
Also It seems clear that package writers won't update their packages to
properly support Windows. As such I have added redirects in the RTS
for the deprecated functions as listed on
https://msdn.microsoft.com/en-us/library/ms235384.aspx.
This won't export the functions (as in, they won't be in the symbol table
of compiled code for the RTS.) but we inject them into the symbol table
of the dynamic linker at startup.
Test Plan:
./validate
and
make test TEST="ffi017 ffi021"
Reviewers: thomie, simonmar, RyanGlScott, bgamari, austin, hvr, erikd
Reviewed By: simonmar, bgamari
Subscribers: RyanGlScott, #ghc_windows_task_force
Differential Revision: https://phabricator.haskell.org/D2500
GHC Trac Issues: #12209, #12497, #12496
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/ffi/should_run/all.T | 6 | ||||
-rw-r--r-- | testsuite/tests/rts/Makefile | 4 | ||||
-rw-r--r-- | testsuite/tests/rts/T12497.hs | 24 | ||||
-rw-r--r-- | testsuite/tests/rts/T12497.stdout | 2 | ||||
-rw-r--r-- | testsuite/tests/rts/all.T | 5 |
5 files changed, 37 insertions, 4 deletions
diff --git a/testsuite/tests/ffi/should_run/all.T b/testsuite/tests/ffi/should_run/all.T index 2b35a0fa63..eb27564693 100644 --- a/testsuite/tests/ffi/should_run/all.T +++ b/testsuite/tests/ffi/should_run/all.T @@ -82,8 +82,7 @@ test('ffi015', [ omit_ways(['ghci']), extra_clean(['ffi015_cbits.o']) ], # GHCi can't handle foreign import "&" test('ffi016', omit_ways(['ghci']), compile_and_run, ['']) -test('ffi017', when(opsys('mingw32'), expect_broken_for(12209, ['ghci'])), - compile_and_run, ['']) +test('ffi017', normal, compile_and_run, ['']) test('ffi018', [ omit_ways(['ghci']), extra_clean(['ffi018_c.o']) ], compile_and_run, ['ffi018_c.c']) @@ -138,8 +137,7 @@ test('ffi020', [ omit_ways(prof_ways), exit_code(1) ], compile_and_run, ['']) -test('ffi021', when(opsys('mingw32'), expect_broken_for(12209, ['ghci'])), - compile_and_run, ['']) +test('ffi021', normal, compile_and_run, ['']) test('ffi022', normal, compile_and_run, ['']) diff --git a/testsuite/tests/rts/Makefile b/testsuite/tests/rts/Makefile index d3231b862c..94f38fa73d 100644 --- a/testsuite/tests/rts/Makefile +++ b/testsuite/tests/rts/Makefile @@ -168,3 +168,7 @@ T11788: "$(TEST_HC)" -c T11788.c -o T11788_obj.o "$(AR)" rsT libT11788.a T11788_obj.o 2> /dev/null echo main | "$(TEST_HC)" $(filter-out -rtsopts, $(TEST_HC_OPTS_INTERACTIVE)) T11788.hs -lT11788 -L"$(PWD)" + + .PHONY: T12497 +T12497: + echo main | "$(TEST_HC)" $(filter-out -rtsopts, $(TEST_HC_OPTS_INTERACTIVE)) T12497.hs diff --git a/testsuite/tests/rts/T12497.hs b/testsuite/tests/rts/T12497.hs new file mode 100644 index 0000000000..e649864842 --- /dev/null +++ b/testsuite/tests/rts/T12497.hs @@ -0,0 +1,24 @@ +{-# LANGUAGE CPP #-} + +#if defined(i386_HOST_ARCH) +# define WINDOWS_CCONV stdcall +#elif defined(x86_64_HOST_ARCH) +# define WINDOWS_CCONV ccall +#else +# error Unknown mingw32 arch +#endif + +import Foreign.C.String + +foreign import WINDOWS_CCONV "_strdup" strdup :: CString -> IO CString +foreign import WINDOWS_CCONV "strdup" strdup2 :: CString -> IO CString + +dupString :: String -> IO String +dupString str = newCString str >>= strdup >>= peekCString + +dupString2 :: String -> IO String +dupString2 str = newCString str >>= strdup2 >>= peekCString + +main = + do print =<< dupString "Hello World!" + print =<< dupString2 "Hello Again World!" diff --git a/testsuite/tests/rts/T12497.stdout b/testsuite/tests/rts/T12497.stdout new file mode 100644 index 0000000000..03d0e237d0 --- /dev/null +++ b/testsuite/tests/rts/T12497.stdout @@ -0,0 +1,2 @@ +"Hello World!" +"Hello Again World!" diff --git a/testsuite/tests/rts/all.T b/testsuite/tests/rts/all.T index 27e78099af..b82036f565 100644 --- a/testsuite/tests/rts/all.T +++ b/testsuite/tests/rts/all.T @@ -365,3 +365,8 @@ test('T10296b', [only_ways('threaded2')], compile_and_run, ['']) test('numa001', [ extra_run_opts('8'), extra_ways(['debug_numa']) ] , compile_and_run, ['']) + +test('T12497', [ unless(opsys('mingw32'), skip) + ], + run_command, ['$MAKE -s --no-print-directory T12497']) + |