[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: Add -single-threaded flag to force single threaded rts

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Thu Feb 16 03:23:02 UTC 2023



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


Commits:
26df73fb by Oleg Grenrus at 2023-02-15T22:20:57-05:00
Add -single-threaded flag to force single threaded rts

This is the small part of implementing
https://github.com/ghc-proposals/ghc-proposals/pull/240

- - - - -
a8823c7a by Cheng Shao at 2023-02-15T22:22:41-05:00
docs: add a section for the wasm backend

Fixes #22658

- - - - -
92d8d926 by Bryan Richter at 2023-02-15T22:22:41-05:00
tests: Mark T12903 fragile everywhere

See #21184

- - - - -
6b55e7a5 by Bryan Richter at 2023-02-15T22:22:41-05:00
Mark all T5435 variants as fragile

See #22970.

- - - - -
c9051c55 by Sylvain Henry at 2023-02-15T22:22:51-05:00
Testsuite: mark T13167 as fragile for JS (#22921)

- - - - -
1ca8be00 by Sylvain Henry at 2023-02-15T22:22:54-05:00
JS: disable debugging info for heap objects

- - - - -


14 changed files:

- compiler/GHC/Driver/Session.hs
- compiler/GHC/StgToJS/Linker/Linker.hs
- docs/users_guide/index.rst
- docs/users_guide/phases.rst
- + docs/users_guide/wasm.rst
- libraries/base/tests/all.T
- + testsuite/tests/rts/T22795a.hs
- + testsuite/tests/rts/T22795a.stdout
- + testsuite/tests/rts/T22795b.hs
- + testsuite/tests/rts/T22795b.stdout
- + testsuite/tests/rts/T22795c.hs
- + testsuite/tests/rts/T22795c.stdout
- testsuite/tests/rts/all.T
- testsuite/tests/rts/linker/all.T


Changes:

=====================================
compiler/GHC/Driver/Session.hs
=====================================
@@ -2081,6 +2081,7 @@ dynamic_flags_deps = [
          return d)
   , make_ord_flag defGhcFlag "debug"          (NoArg (addWayDynP WayDebug))
   , make_ord_flag defGhcFlag "threaded"       (NoArg (addWayDynP WayThreaded))
+  , make_ord_flag defGhcFlag "single-threaded" (NoArg (removeWayDynP WayThreaded))
 
   , make_ord_flag defGhcFlag "ticky"
       (NoArg (setGeneralFlag Opt_Ticky >> addWayDynP WayDebug))
@@ -2089,7 +2090,7 @@ dynamic_flags_deps = [
     -- is required to get the RTS ticky support.
 
         ----- Linker --------------------------------------------------------
-  , make_ord_flag defGhcFlag "static"         (NoArg removeWayDyn)
+  , make_ord_flag defGhcFlag "static"         (NoArg (removeWayDynP WayDyn))
   , make_ord_flag defGhcFlag "dynamic"        (NoArg (addWayDynP WayDyn))
   , make_ord_flag defGhcFlag "rdynamic" $ noArg $
 #if defined(linux_HOST_OS)
@@ -4187,8 +4188,8 @@ addWay' w dflags0 =
                        (wayUnsetGeneralFlags platform w)
    in dflags3
 
-removeWayDyn :: DynP ()
-removeWayDyn = upd (\dfs -> dfs { targetWays_ = removeWay WayDyn (targetWays_ dfs) })
+removeWayDynP :: Way -> DynP ()
+removeWayDynP w = upd (\dfs -> dfs { targetWays_ = removeWay w (targetWays_ dfs) })
 
 --------------------------
 setGeneralFlag, unSetGeneralFlag :: GeneralFlag -> DynP ()


=====================================
compiler/GHC/StgToJS/Linker/Linker.hs
=====================================
@@ -867,11 +867,13 @@ linkModules mods = (compact_mods, meta)
     statics = nubStaticInfo (concatMap mc_statics mods)
 
     infos   = concatMap mc_closures mods
+    debug   = False -- TODO: this could be enabled in a debug build.
+                    -- It adds debug info to heap objects
     meta = mconcat
             -- render metadata as individual statements
             [ mconcat (map staticDeclStat statics)
             , mconcat (map staticInitStat statics)
-            , mconcat (map (closureInfoStat True) infos)
+            , mconcat (map (closureInfoStat debug) infos)
             ]
 
 -- | Only keep a single StaticInfo with a given name


=====================================
docs/users_guide/index.rst
=====================================
@@ -23,6 +23,7 @@ Contents:
    hints
    utils
    win32-dlls
+   wasm
    bugs
    eventlog-formats
    editing-guide
@@ -33,4 +34,3 @@ Indices and tables
 
 * :ref:`genindex`
 * :ref:`search`
-


=====================================
docs/users_guide/phases.rst
=====================================
@@ -1076,6 +1076,7 @@ for example).
     :shortdesc: Use the threaded runtime
     :type: dynamic
     :category: linking
+    :reverse: -single-threaded
 
     Link the program with the "threaded" version of the runtime system.
     The threaded runtime system is so-called because it manages multiple
@@ -1099,6 +1100,16 @@ for example).
        called from multiple OS threads simultaneously. See
        :ref:`ffi-threads`.
 
+.. ghc-flag:: -single-threaded
+    :shortdesc: Use the single-threaded runtime
+    :type: dynamic
+    :category: linking
+    :reverse: -threaded
+
+    :since: 9.8
+
+    Switch to the single threaded (default) version of the runtime.
+
 .. ghc-flag:: -eventlog
     :shortdesc: Enable runtime event tracing
     :type: dynamic


=====================================
docs/users_guide/wasm.rst
=====================================
@@ -0,0 +1,101 @@
+.. _wasm:
+
+Using the GHC WebAssembly backend
+=================================
+
+.. _wasm-clarify:
+
+What does the WebAssembly “backend” mean
+----------------------------------------
+
+In order to compile Haskell to wasm, you need a custom GHC build that
+targets wasm. There isn't a GHC option which allows you to use a
+stock GHC installed via ``ghcup`` or ``stack`` to generate wasm. That’s
+because GHC is still a single-target compiler, so each GHC build is only
+capable of compiling code that runs on a single architecture and operating
+system.
+
+So, the term GHC wasm backend isn’t the same sense as the
+unregisterised/LLVM/NCG backends. It merely describes GHC’s support as a
+cross compiler that targets wasm, and more specifically,
+``wasm32-wasi``.
+
+The generated wasm module makes use of a few post-MVP extensions that
+are supported by default in latest releases of
+Chrome/Firefox/Safari/`wasmtime <https://wasmtime.dev>`__. The wasm
+module uses `WASI <https://wasi.dev>`__ as the system call layer, so
+it’s supported by any wasm engine that implements WASI (including
+browsers, which can provide the WASI layer via JavaScript).
+
+.. _wasm-setup:
+
+Setting up the GHC wasm backend
+-------------------------------
+
+The wasm backend is still a tech preview and not included in the
+official bindists yet. If you are using x86_64-linux, you can follow the
+“getting started” subsections in
+`ghc-wasm-meta <https://gitlab.haskell.org/ghc/ghc-wasm-meta>`__ to
+quickly set up the GHC wasm backend using the nightly artifacts.
+
+It’s also possible to build the GHC wasm backend manually, if your host
+system is one of {x86_64,aarch64}-{linux,darwin}. Refer to the
+``ghc-wasm-meta`` readme for detailed instructions.
+
+.. _wasm-compile:
+
+Using the GHC wasm backend to compile & link code
+-------------------------------------------------
+
+Once the GHC wasm backend is set up, you can use it to compile and link
+code. The compiler executables follow the cross compiler linking
+convention, so you need to call ``wasm32-wasi-ghc``,
+``wasm32-wasi-ghc-pkg`` and ``wasm32-wasi-hsc2hs`` instead of ``ghc``,
+``ghc-pkg`` and ``hsc2hs``.
+
+You can also use the ``--with-compiler=``, ``--with-hc-pkg=`` and
+``--with-hsc2hs`` flags of ``cabal`` to build cabal projects. The
+``wasm32-wasi-cabal`` wrapper script set up by the ``ghc-wasm-meta``
+installer does this automatically for you, but using flags manually also
+works with stock ``cabal`` installations. When ``cabal`` builds an
+executable component, that executable will be built as a wasm module,
+and you can use ``cabal list-bin exe:foo`` to find the wasm module’s
+location in the build directory.
+
+.. _wasm-run:
+
+Running the GHC wasm backend’s output
+-------------------------------------
+
+Once you have a wasm module, you can run it with a dedicated wasm engine
+like ``wasmtime``, or inside the browsers.
+
+To run it with ``wasmtime``, you can simply do:
+
+.. code:: sh
+
+   $ wasmtime run foo.wasm
+
+Just like native executables, you can pass command line arguments, and
+also RTS options, as long as it’s built with ``-rtsopts``:
+
+.. code:: sh
+
+   $ wasmtime run foo.wasm --bar +RTS --nonmoving-gc -RTS
+
+You can also mount some host directory into it:
+
+.. code:: sh
+
+   $ wasmtime run --mapdir /::$PWD foo.wasm
+
+As long as the filesystem capability is provided, in addition to
+filesystem I/O in Haskell code, you can use the RTS eventlog and
+profiling functionality, then inspect the report files:
+
+.. code:: sh
+
+   $ wasmtime run --mapdir /::$PWD foo.wasm +RTS -hc -l -RTS
+
+To run the wasm module in the browsers, refer to the ``ghc-wasm-meta``
+documentation for more details.


=====================================
libraries/base/tests/all.T
=====================================
@@ -271,7 +271,8 @@ test('T13167',
      [ when(opsys('mingw32')
      , only_ways(['winio', 'winio_threaded']))
      , fragile_for(16536, concurrent_ways)
-     , js_broken(22261)
+       # fragile on JS
+     , when(js_arch(), fragile(22921))
      ],
      compile_and_run, [''])
 test('T15183', normal, compile_and_run, [''])


=====================================
testsuite/tests/rts/T22795a.hs
=====================================
@@ -0,0 +1,6 @@
+module Main (main) where
+
+import System.Posix.Internals (hostIsThreaded)
+
+main :: IO ()
+main = print hostIsThreaded


=====================================
testsuite/tests/rts/T22795a.stdout
=====================================
@@ -0,0 +1 @@
+True


=====================================
testsuite/tests/rts/T22795b.hs
=====================================
@@ -0,0 +1,6 @@
+module Main (main) where
+
+import System.Posix.Internals (hostIsThreaded)
+
+main :: IO ()
+main = print hostIsThreaded


=====================================
testsuite/tests/rts/T22795b.stdout
=====================================
@@ -0,0 +1 @@
+False


=====================================
testsuite/tests/rts/T22795c.hs
=====================================
@@ -0,0 +1,6 @@
+module Main (main) where
+
+import System.Posix.Internals (hostIsThreaded)
+
+main :: IO ()
+main = print hostIsThreaded


=====================================
testsuite/tests/rts/T22795c.stdout
=====================================
@@ -0,0 +1 @@
+False


=====================================
testsuite/tests/rts/all.T
=====================================
@@ -418,13 +418,9 @@ test('T12497', [ unless(opsys('mingw32'), skip), expect_broken(22694)
 test('T13617', [ unless(opsys('mingw32'), skip)],
                makefile_test, ['T13617'])
 
-# This test sometimes produces out of sequence samples in the profasm way, but
-# not reliably, so we just skip it. See ticket #15065.
-# Test is being skipped on darwin due to it's flakiness.
-test('T12903', [ when(opsys('mingw32'), skip)
-               , when(opsys('darwin'), skip)
-               , when(arch('i386'), fragile(20377))
-               , omit_ways(['ghci', 'profasm'])
+# Test is fragile on all systems. #21184 links to various other reports through
+# its history.
+test('T12903', [ fragile(21184)
                , js_broken(22374)]
                , compile_and_run, [''])
 
@@ -568,3 +564,8 @@ test('decodeMyStack_emptyListForMissingFlag',
   , ignore_stderr
   , js_broken(22261) # cloneMyStack# not yet implemented
   ], compile_and_run, [''])
+
+# Skip for JS platform as the JS RTS is always single threaded
+test('T22795a', [js_skip], compile_and_run, ['-threaded'])
+test('T22795b', [js_skip], compile_and_run, ['-single-threaded'])
+test('T22795c', [js_skip], compile_and_run, ['-threaded -single-threaded'])


=====================================
testsuite/tests/rts/linker/all.T
=====================================
@@ -59,6 +59,7 @@ def checkDynAsm(actual_file, normaliser):
 test('T5435_v_asm_a',
      [extra_files(['T5435.hs', 'T5435_asm.c']),
       req_rts_linker,
+      fragile(22970),
       when(arch('arm'), expect_broken(17559)),
       when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))],
      makefile_test, ['T5435_v_asm_a'])
@@ -67,6 +68,7 @@ test('T5435_v_asm_a',
 test('T5435_v_asm_b',
      [extra_files(['T5435.hs', 'T5435_asm.c']),
       req_rts_linker,
+      fragile(22970),
       when(arch('arm'), expect_broken(17559)),
       when(opsys('darwin') or opsys('mingw32'), skip),
       when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))],
@@ -74,16 +76,19 @@ test('T5435_v_asm_b',
 test('T5435_v_gcc',
      [extra_files(['T5435.hs', 'T5435_gcc.c']),
       req_rts_linker,
+      fragile(22970),
       when(arch('arm'), expect_broken(17559)),
       when(opsys('linux') and not ghc_dynamic(), expect_broken(20706))],
      makefile_test, ['T5435_v_gcc'])
 test('T5435_dyn_asm',
      [extra_files(['T5435.hs', 'T5435_asm.c']),
+      fragile(22970),
       js_skip, # dynamic linking not supported by the JS backend
       check_stdout(checkDynAsm)],
      makefile_test, ['T5435_dyn_asm'])
 test('T5435_dyn_gcc',
      [extra_files(['T5435.hs', 'T5435_gcc.c']),
+      fragile(22970),
       js_skip], # dynamic linking not supported by the JS backend
      makefile_test, ['T5435_dyn_gcc'])
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bd89bb5539ecbbd3d61a5117c673dc8e9796b6d6...1ca8be00c150fb25cfc29558a6f91675968abb7c

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/bd89bb5539ecbbd3d61a5117c673dc8e9796b6d6...1ca8be00c150fb25cfc29558a6f91675968abb7c
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/20230215/557e24a3/attachment-0001.html>


More information about the ghc-commits mailing list