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

Commits:

4 changed files:

Changes:

  • compiler/GHC/Driver/Main.hs
    ... ... @@ -165,7 +165,7 @@ import GHC.JS.Syntax
    165 165
     
    
    166 166
     import GHC.IfaceToCore  ( typecheckIface, typecheckWholeCoreBindings )
    
    167 167
     
    
    168
    -import GHC.Iface.Load   ( ifaceStats, writeIface, flagsToIfCompression, getGhcPrimIface )
    
    168
    +import GHC.Iface.Load   ( ifaceStats, writeIface, flagsToIfCompression, getGhcPrimIface, loadSysInterface )
    
    169 169
     import GHC.Iface.Make
    
    170 170
     import GHC.Iface.Recomp
    
    171 171
     import GHC.Iface.Tidy
    
    ... ... @@ -1765,7 +1765,7 @@ hscCheckSafe' m l = do
    1765 1765
             -- so we need to call 'getModuleInterface' to load from disk
    
    1766 1766
             case iface of
    
    1767 1767
                 Just _  -> return iface
    
    1768
    -            Nothing -> snd `fmap` (liftIO $ getModuleInterface hsc_env m)
    
    1768
    +            Nothing -> liftIO $ initIfaceLoad hsc_env (Just <$> loadSysInterface (text "checkSafeImports") m)
    
    1769 1769
     
    
    1770 1770
     
    
    1771 1771
     -- | Check the list of packages are trusted.
    

  • libraries/base/changelog.md
    ... ... @@ -6,7 +6,6 @@
    6 6
       * Fix issues with toRational for types capable to represent infinite and not-a-number values ([CLC proposal #338](https://github.com/haskell/core-libraries-committee/issues/338))
    
    7 7
       * Ensure that `rationalToFloat` and `rationalToDouble` always inline in the end. ([CLC proposal #356](https://github.com/haskell/core-libraries-committee/issues/356))
    
    8 8
       * Modify the implementation of `Data.List.sortOn` to use `(>)` instead of `compare`. ([CLC proposal #332](https://github.com/haskell/core-libraries-committee/issues/332))
    
    9
    -  * `GHC.Exts.IOPort#` and its related operations have been removed  ([CLC #213](https://github.com/haskell/core-libraries-committee/issues/213))
    
    10 9
       * Add `thenA` and `thenM`. ([CLC proposal #351](https://github.com/haskell/core-libraries-committee/issues/351))
    
    11 10
       * Fix bug where `naturalAndNot` was incorrectly truncating results ([CLC proposal #350](github.com/haskell/core-libraries-committee/issues/350))
    
    12 11
       * Remove extra laziness from `Data.Bifunctor.Bifunctor` instances for all tuples to have the same laziness as their `Data.Functor.Functor` counterparts (i.e. they became more strict than before) ([CLC proposal #339](https://github.com/haskell/core-libraries-committee/issues/339))
    
    ... ... @@ -37,7 +36,7 @@
    37 36
           * `GHC.TypeNats.Internal`
    
    38 37
           * `GHC.ExecutionStack.Internal`.
    
    39 38
       * Deprecate `GHC.JS.Prim.Internal.Build`, as per [CLC #329](https://github.com/haskell/core-libraries-committee/issues/329)
    
    40
    -
    
    39
    +  * `GHC.Exts.IOPort#` and its related operations have been removed  ([CLC #213](https://github.com/haskell/core-libraries-committee/issues/213))
    
    41 40
       * Fix incorrect results of `integerPowMod` when the base is 0 and the exponent is negative, and `integerRecipMod` when the modulus is zero ([#26017](https://gitlab.haskell.org/ghc/ghc/-/issues/26017)).
    
    42 41
       * Fix the rewrite rule for `scanl'` not being strict in the first element of the output list ([#26143](https://gitlab.haskell.org/ghc/ghc/-/issues/26143)).
    
    43 42
     
    

  • rts/ExecPage.c
    ... ... @@ -10,15 +10,23 @@
    10 10
     #include "linker/MMap.h"
    
    11 11
     
    
    12 12
     ExecPage *allocateExecPage(void) {
    
    13
    +#if defined(wasm32_HOST_ARCH)
    
    14
    +    return NULL;
    
    15
    +#else
    
    13 16
         ExecPage *page = (ExecPage *) mmapAnon(getPageSize());
    
    14 17
         return page;
    
    18
    +#endif
    
    15 19
     }
    
    16 20
     
    
    17 21
     void freezeExecPage(ExecPage *page) {
    
    22
    +#if !defined(wasm32_HOST_ARCH)
    
    18 23
         mprotectForLinker(page, getPageSize(), MEM_READ_EXECUTE);
    
    19 24
         flushExec(getPageSize(), page);
    
    25
    +#endif
    
    20 26
     }
    
    21 27
     
    
    22 28
     void freeExecPage(ExecPage *page) {
    
    29
    +#if !defined(wasm32_HOST_ARCH)
    
    23 30
         munmapForLinker(page, getPageSize(), "freeExecPage");
    
    31
    +#endif
    
    24 32
     }

  • rts/wasm/JSFFI.c
    ... ... @@ -5,6 +5,8 @@
    5 5
     #include "Threads.h"
    
    6 6
     #include "sm/Sanity.h"
    
    7 7
     
    
    8
    +#include <sysexits.h>
    
    9
    +
    
    8 10
     #if defined(__wasm_reference_types__)
    
    9 11
     
    
    10 12
     extern HsBool rts_JSFFI_flag;
    
    ... ... @@ -12,21 +14,8 @@ extern HsStablePtr rts_threadDelay_impl;
    12 14
     extern StgClosure ghczminternal_GHCziInternalziWasmziPrimziImports_raiseJSException_closure;
    
    13 15
     extern StgClosure ghczminternal_GHCziInternalziWasmziPrimziConcziInternal_threadDelay_closure;
    
    14 16
     
    
    15
    -int __main_void(void);
    
    16
    -
    
    17
    -int __main_argc_argv(int, char*[]);
    
    18
    -
    
    19
    -int __main_argc_argv(int argc, char *argv[]) {
    
    20
    -  RtsConfig __conf = defaultRtsConfig;
    
    21
    -  __conf.rts_opts_enabled = RtsOptsAll;
    
    22
    -  __conf.rts_hs_main = false;
    
    23
    -  hs_init_ghc(&argc, &argv, __conf);
    
    24
    -  // See Note [threadDelay on wasm] for details.
    
    25
    -  rts_JSFFI_flag = HS_BOOL_TRUE;
    
    26
    -  getStablePtr((StgPtr)&ghczminternal_GHCziInternalziWasmziPrimziImports_raiseJSException_closure);
    
    27
    -  rts_threadDelay_impl = getStablePtr((StgPtr)&ghczminternal_GHCziInternalziWasmziPrimziConcziInternal_threadDelay_closure);
    
    28
    -  return 0;
    
    29
    -}
    
    17
    +__attribute__((__weak__))
    
    18
    +int __main_argc_argv(int argc, char *argv[]);
    
    30 19
     
    
    31 20
     // Note [JSFFI initialization]
    
    32 21
     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    ... ... @@ -66,11 +55,69 @@ int __main_argc_argv(int argc, char *argv[]) {
    66 55
     // by the GHC codegen, and priority 102 to the initialization logic
    
    67 56
     // here to ensure hs_init_ghc() sees everything it needs to see.
    
    68 57
     __attribute__((constructor(102))) static void __ghc_wasm_jsffi_init(void) {
    
    69
    -  // See
    
    70
    -  // https://gitlab.haskell.org/ghc/wasi-libc/-/blob/master/libc-bottom-half/sources/__main_void.c
    
    71
    -  // for its definition. It initializes some libc state, then calls
    
    72
    -  // __main_argc_argv defined above.
    
    73
    -  __main_void();
    
    58
    +  // If linking static code without -no-hs-main, then the driver
    
    59
    +  // emitted main() is in charge of its own RTS initialization, so
    
    60
    +  // skip.
    
    61
    +#if !defined(__PIC__)
    
    62
    +  if (__main_argc_argv) {
    
    63
    +    return;
    
    64
    +  }
    
    65
    +#endif
    
    66
    +
    
    67
    +  // Code below is mirrored from
    
    68
    +  // https://gitlab.haskell.org/haskell-wasm/wasi-libc/-/blob/master/libc-bottom-half/sources/__main_void.c,
    
    69
    +  // fetches argc/argv using wasi api
    
    70
    +  __wasi_errno_t err;
    
    71
    +
    
    72
    +  // Get the sizes of the arrays we'll have to create to copy in the args.
    
    73
    +  size_t argv_buf_size;
    
    74
    +  size_t argc;
    
    75
    +  err = __wasi_args_sizes_get(&argc, &argv_buf_size);
    
    76
    +  if (err != __WASI_ERRNO_SUCCESS) {
    
    77
    +    _Exit(EX_OSERR);
    
    78
    +  }
    
    79
    +
    
    80
    +  // Add 1 for the NULL pointer to mark the end, and check for overflow.
    
    81
    +  size_t num_ptrs = argc + 1;
    
    82
    +  if (num_ptrs == 0) {
    
    83
    +    _Exit(EX_SOFTWARE);
    
    84
    +  }
    
    85
    +
    
    86
    +  // Allocate memory for storing the argument chars.
    
    87
    +  char *argv_buf = malloc(argv_buf_size);
    
    88
    +  if (argv_buf == NULL) {
    
    89
    +    _Exit(EX_SOFTWARE);
    
    90
    +  }
    
    91
    +
    
    92
    +  // Allocate memory for the array of pointers. This uses `calloc` both to
    
    93
    +  // handle overflow and to initialize the NULL pointer at the end.
    
    94
    +  char **argv = calloc(num_ptrs, sizeof(char *));
    
    95
    +  if (argv == NULL) {
    
    96
    +    free(argv_buf);
    
    97
    +    _Exit(EX_SOFTWARE);
    
    98
    +  }
    
    99
    +
    
    100
    +  // Fill the argument chars, and the argv array with pointers into those chars.
    
    101
    +  // TODO: Remove the casts on `argv_ptrs` and `argv_buf` once the witx is
    
    102
    +  // updated with char8 support.
    
    103
    +  err = __wasi_args_get((uint8_t **)argv, (uint8_t *)argv_buf);
    
    104
    +  if (err != __WASI_ERRNO_SUCCESS) {
    
    105
    +    free(argv_buf);
    
    106
    +    free(argv);
    
    107
    +    _Exit(EX_OSERR);
    
    108
    +  }
    
    109
    +
    
    110
    +  // Now that we have argc/argv, proceed to initialize the GHC RTS
    
    111
    +  RtsConfig __conf = defaultRtsConfig;
    
    112
    +  __conf.rts_opts_enabled = RtsOptsAll;
    
    113
    +  __conf.rts_hs_main = false;
    
    114
    +  hs_init_ghc((int *)&argc, &argv, __conf);
    
    115
    +  // See Note [threadDelay on wasm] for details.
    
    116
    +  rts_JSFFI_flag = HS_BOOL_TRUE;
    
    117
    +  getStablePtr((
    
    118
    +      StgPtr)&ghczminternal_GHCziInternalziWasmziPrimziImports_raiseJSException_closure);
    
    119
    +  rts_threadDelay_impl = getStablePtr((
    
    120
    +      StgPtr)&ghczminternal_GHCziInternalziWasmziPrimziConcziInternal_threadDelay_closure);
    
    74 121
     }
    
    75 122
     
    
    76 123
     typedef __externref_t HsJSVal;