[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 5 commits: base: add missing autoconf checks for waitpid/umask

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Sun Dec 18 02:12:07 UTC 2022



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


Commits:
d1431cc0 by Cheng Shao at 2022-12-17T08:07:15-05:00
base: add missing autoconf checks for waitpid/umask

These are not present in wasi-libc. Required for fixing #22589

- - - - -
da3f1e91 by Cheng Shao at 2022-12-17T08:07:51-05:00
compiler: make .wasm the default executable extension on wasm32

Following convention as in other wasm toolchains. Fixes #22594.

- - - - -
ad21f4ef by Cheng Shao at 2022-12-17T08:07:51-05:00
ci: support hello.wasm in ci.sh cross testing logic

- - - - -
70aa5392 by amesgen at 2022-12-17T21:11:43-05:00
Correct `exitWith` Haddocks

The `IOError`-specific `catch` in the Prelude is long gone.

- - - - -
2961d83c by Ben Gamari at 2022-12-17T21:11:45-05:00
rts/libdw: Silence uninitialized usage warnings

As noted in #22538, previously some GCC versions warned that various
locals in Libdw.c may be used uninitialized. Although this wasn't
strictly true (since they were initialized in an inline assembler block)
we fix this by providing explicit empty initializers.

Fixes #22538
- - - - -


7 changed files:

- .gitlab/ci.sh
- compiler/GHC/Driver/Make.hs
- compiler/GHC/Linker/Static/Utils.hs
- libraries/base/System/Exit.hs
- libraries/base/System/Posix/Internals.hs
- libraries/base/configure.ac
- rts/Libdw.c


Changes:

=====================================
.gitlab/ci.sh
=====================================
@@ -608,6 +608,10 @@ function test_hadrian() {
     install_bindist _build/bindist/ghc-*/ "$instdir"
     echo 'main = putStrLn "hello world"' > expected
     run "$test_compiler" -package ghc "$TOP/.gitlab/hello.hs" -o hello
+    # Despite "-o hello", ghc may output something like hello.exe or
+    # hello.wasm depending on the backend. For the time being let's
+    # just move it to hello before proceeding to running it.
+    mv hello.wasm hello || true
     ${CROSS_EMULATOR:-} ./hello > actual
     run diff expected actual
   elif [[ -n "${REINSTALL_GHC:-}" ]]; then


=====================================
compiler/GHC/Driver/Make.hs
=====================================
@@ -788,9 +788,10 @@ guessOutputFile = modifySession $ \env ->
                   -- we must add the .exe extension unconditionally here, otherwise
                   -- when name has an extension of its own, the .exe extension will
                  -- not be added by GHC.Driver.Pipeline.exeFileName.  See #2248
-                 !name' <- if platformOS platform == OSMinGW32
-                           then fmap (<.> "exe") name
-                           else name
+                 !name' <- case platformArchOS platform of
+                             ArchOS _ OSMinGW32  -> fmap (<.> "exe") name
+                             ArchOS ArchWasm32 _ -> fmap (<.> "wasm") name
+                             _ -> name
                  mainModuleSrcPath' <- mainModuleSrcPath
                  -- #9930: don't clobber input files (unless they ask for it)
                  if name' == mainModuleSrcPath'


=====================================
compiler/GHC/Linker/Static/Utils.hs
=====================================
@@ -19,6 +19,7 @@ exeFileName (ArchOS arch os) staticLink output_fn
   | Just s <- output_fn = if
       | OSMinGW32      <- os   -> s <?.> "exe"
       | ArchJavaScript <- arch -> s <?.> "jsexe"
+      | ArchWasm32     <- arch -> s <?.> "wasm"
       | staticLink             -> s <?.> "a"
       | otherwise              -> s
   | otherwise = if
@@ -28,4 +29,3 @@ exeFileName (ArchOS arch os) staticLink output_fn
       | otherwise              -> "a.out"
  where s <?.> ext | null (takeExtension s) = s <.> ext
                   | otherwise              = s
-


=====================================
libraries/base/System/Exit.hs
=====================================
@@ -45,16 +45,14 @@ import GHC.IO.Exception
 -- A program that terminates successfully without calling 'exitWith'
 -- explicitly is treated as if it had called 'exitWith' 'ExitSuccess'.
 --
--- As an 'ExitCode' is not an 'IOError', 'exitWith' bypasses
--- the error handling in the 'IO' monad and cannot be intercepted by
--- 'catch' from the "Prelude".  However it is a 'Control.Exception.SomeException', and can
--- be caught using the functions of "Control.Exception".  This means
--- that cleanup computations added with 'Control.Exception.bracket'
--- (from "Control.Exception") are also executed properly on 'exitWith'.
+-- As an 'ExitCode' is an 'Control.Exception.Exception', it can be
+-- caught using the functions of "Control.Exception".  This means that
+-- cleanup computations added with 'Control.Exception.bracket' (from
+-- "Control.Exception") are also executed properly on 'exitWith'.
 --
 -- Note: in GHC, 'exitWith' should be called from the main program
 -- thread in order to exit the process.  When called from another
--- thread, 'exitWith' will throw an 'ExitException' as normal, but the
+-- thread, 'exitWith' will throw an 'ExitCode' as normal, but the
 -- exception will not cause the process itself to exit.
 --
 exitWith :: ExitCode -> IO a


=====================================
libraries/base/System/Posix/Internals.hs
=====================================
@@ -682,8 +682,13 @@ foreign import capi unsafe "HsBase.h read"
 foreign import capi safe "HsBase.h read"
    c_safe_read :: CInt -> Ptr Word8 -> CSize -> IO CSsize
 
+#if defined(HAVE_UMASK)
 foreign import ccall unsafe "HsBase.h umask"
    c_umask :: CMode -> IO CMode
+#else
+c_umask :: CMode -> IO CMode
+c_umask _ = ioError (ioeSetLocation unsupportedOperation "umask")
+#endif
 
 -- See Note: Windows types
 foreign import capi unsafe "HsBase.h write"
@@ -785,8 +790,14 @@ foreign import capi unsafe "HsBase.h tcsetattr"
 
 #endif
 
+#if defined(HAVE_GETPID)
 foreign import ccall unsafe "HsBase.h waitpid"
    c_waitpid :: CPid -> Ptr CInt -> CInt -> IO CPid
+#else
+c_waitpid :: CPid -> Ptr CInt -> CInt -> IO CPid
+c_waitpid _ _ _ = ioError (ioeSetLocation unsupportedOperation "waitpid")
+#endif
+
 #endif
 
 #if !defined(js_HOST_ARCH)


=====================================
libraries/base/configure.ac
=====================================
@@ -90,6 +90,7 @@ AC_CHECK_FUNCS([fork])
 AC_CHECK_FUNCS([getpid])
 AC_CHECK_FUNCS([mkfifo])
 AC_CHECK_FUNCS([pipe])
+AC_CHECK_FUNCS([umask])
 
 AC_CHECK_TYPE([struct rlimit],[AC_DEFINE([HAVE_STRUCT_RLIMIT],[1],[HAVE_STRUCT_RLIMIT])],[],[#include <sys/resource.h>])
 


=====================================
rts/Libdw.c
=====================================
@@ -290,7 +290,7 @@ static bool set_initial_registers(Dwfl_Thread *thread, void *arg);
 #if defined(x86_64_HOST_ARCH)
 static bool set_initial_registers(Dwfl_Thread *thread,
                                   void *arg STG_UNUSED) {
-    Dwarf_Word regs[17];
+    Dwarf_Word regs[17] = {};
     __asm__ ("movq %%rax, 0x00(%0)\n\t"
              "movq %%rdx, 0x08(%0)\n\t"
              "movq %%rcx, 0x10(%0)\n\t"
@@ -318,7 +318,7 @@ static bool set_initial_registers(Dwfl_Thread *thread,
 #elif defined(i386_HOST_ARCH)
 static bool set_initial_registers(Dwfl_Thread *thread,
                                   void *arg STG_UNUSED) {
-    Dwarf_Word regs[9];
+    Dwarf_Word regs[9] = {};
     __asm__ ("movl %%eax, 0x00(%0)\n\t"
              "movl %%ecx, 0x04(%0)\n\t"
              "movl %%edx, 0x08(%0)\n\t"
@@ -339,7 +339,7 @@ static bool set_initial_registers(Dwfl_Thread *thread,
 #elif defined(s390x_HOST_ARCH)
 static bool set_initial_registers(Dwfl_Thread *thread,
                                   void *arg STG_UNUSED) {
-    Dwarf_Word regs[32];
+    Dwarf_Word regs[32] = {};
     __asm__ ("stmg %%r0,%%r15,0(%0)\n\t"
              "std  %%f0,  128(0,%0)\n\t"
              "std  %%f2,  136(0,%0)\n\t"



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5fea92f7ffa2f6b6530711f5d2b82735b43fe1ee...2961d83cd25abc817a097b666ab085a19f6c6d67

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5fea92f7ffa2f6b6530711f5d2b82735b43fe1ee...2961d83cd25abc817a097b666ab085a19f6c6d67
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/20221217/6394c5ff/attachment-0001.html>


More information about the ghc-commits mailing list