[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: rts: fix missing dirty_MVAR argument in stg_writeIOPortzh

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Mon Sep 12 14:09:13 UTC 2022



Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC


Commits:
ee471dfb by Cheng Shao at 2022-09-12T07:07:33-04:00
rts: fix missing dirty_MVAR argument in stg_writeIOPortzh

- - - - -
c4853e43 by Cheng Shao at 2022-09-12T10:08:58-04:00
ci: enable parallel compression for xz

- - - - -
5060f11b by Ryan Scott at 2022-09-12T10:08:58-04:00
Windows: Always define _UCRT when compiling C code

As seen in #22159, this is required to ensure correct behavior when MinGW-w64
headers are in the `C_INCLUDE_PATH`.

Fixes #22159.

- - - - -


8 changed files:

- .gitlab/ci.sh
- m4/fp_setup_windows_toolchain.m4
- rts/PrimOps.cmm
- testsuite/tests/ffi/should_run/Makefile
- + testsuite/tests/ffi/should_run/T22159.hs
- + testsuite/tests/ffi/should_run/T22159.stdout
- + testsuite/tests/ffi/should_run/T22159_c.c
- testsuite/tests/ffi/should_run/all.T


Changes:

=====================================
.gitlab/ci.sh
=====================================
@@ -503,7 +503,7 @@ function build_hadrian() {
   if [[ -n "${REINSTALL_GHC:-}" ]]; then
     run_hadrian build-cabal -V
   else
-    run_hadrian binary-dist -V
+    XZ_OPT="${XZ_OPT:-} -T$cores" run_hadrian binary-dist -V
     mv _build/bindist/ghc*.tar.xz "$BIN_DIST_NAME.tar.xz"
   fi
 


=====================================
m4/fp_setup_windows_toolchain.m4
=====================================
@@ -82,7 +82,11 @@ AC_DEFUN([FP_SETUP_WINDOWS_TOOLCHAIN],[
 
     CC="${mingwbin}clang.exe"
     CXX="${mingwbin}clang++.exe"
-    cflags="--rtlib=compiler-rt"
+
+    # Signal that we are linking against UCRT with the _UCRT macro. This is
+    # necessary to ensure correct behavior when MinGW-w64 headers are in the
+    # header include path (#22159).
+    cflags="--rtlib=compiler-rt -D_UCRT"
     CFLAGS="$cflags"
     CONF_CC_OPTS_STAGE1="$cflags"
     CONF_CC_OPTS_STAGE2="$cflags"


=====================================
rts/PrimOps.cmm
=====================================
@@ -2246,7 +2246,7 @@ loop:
     if (q == stg_END_TSO_QUEUE_closure) {
         /* No takes, the IOPort is now full. */
         if (info == stg_MVAR_CLEAN_info) {
-            ccall dirty_MVAR(BaseReg "ptr", ioport "ptr");
+            ccall dirty_MVAR(BaseReg "ptr", ioport "ptr", StgMVar_value(ioport) "ptr");
         }
         StgMVar_value(ioport) = val;
 


=====================================
testsuite/tests/ffi/should_run/Makefile
=====================================
@@ -49,3 +49,10 @@ T15933:
 	'$(TEST_HC)' $(TEST_HC_OPTS) -c T15933.hs
 	'$(TEST_HC)' $(TEST_HC_OPTS) T15933_c.o T15933.o -o T15933
 	./T15933
+
+.PHONY: T22159
+T22159:
+	C_INCLUDE_PATH=/mingw64/include '$(TEST_HC)' $(TEST_HC_OPTS) -c T22159.hs
+	C_INCLUDE_PATH=/mingw64/include '$(TEST_HC)' $(TEST_HC_OPTS) -c T22159_c.c
+	C_INCLUDE_PATH=/mingw64/include '$(TEST_HC)' $(TEST_HC_OPTS) T22159.o T22159_c.o -o T22159
+	./T22159


=====================================
testsuite/tests/ffi/should_run/T22159.hs
=====================================
@@ -0,0 +1,23 @@
+{-# LANGUAGE CPP #-}
+module Main (main) where
+
+#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 (peekCWString)
+import Foreign.C.Types (CWchar)
+import Foreign.Marshal.Alloc (allocaBytes)
+import Foreign.Ptr (Ptr)
+
+foreign import WINDOWS_CCONV "hello" c_hello :: Ptr CWchar -> IO ()
+
+main :: IO ()
+main = allocaBytes 12 $ \buf -> do
+  c_hello buf
+  str <- peekCWString buf
+  putStrLn str


=====================================
testsuite/tests/ffi/should_run/T22159.stdout
=====================================
@@ -0,0 +1 @@
+hello


=====================================
testsuite/tests/ffi/should_run/T22159_c.c
=====================================
@@ -0,0 +1,6 @@
+#include <stdio.h>
+#include <wchar.h>
+
+void hello(wchar_t *buf) {
+  swprintf_s(buf, 12, L"hello");
+}


=====================================
testsuite/tests/ffi/should_run/all.T
=====================================
@@ -229,3 +229,8 @@ test('T19237', normal, compile_and_run, ['T19237_c.c'])
 
 test('T21305', omit_ways(['ghci']), multi_compile_and_run,
                  ['T21305', [('T21305_cmm.cmm', '')], ''])
+
+test('T22159',
+     [unless(opsys('mingw32'), skip),
+      extra_files(['T22159_c.c'])],
+     makefile_test, ['T22159'])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9e599f1b215cbf3a4c43a0cdee2e308330a759c8...5060f11b2bca2bcb052c91dc8eb20664f61c49e0

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9e599f1b215cbf3a4c43a0cdee2e308330a759c8...5060f11b2bca2bcb052c91dc8eb20664f61c49e0
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20220912/5bd5b575/attachment-0001.html>


More information about the ghc-commits mailing list