Skip to content
Snippets Groups Projects
  1. Feb 06, 2025
    • Cheng Shao's avatar
      hadrian: disable PIC for in-tree GMP on wasm32 · 9506a531
      Cheng Shao authored
      This patch disables PIC for in-tree GMP on wasm32 target. Enabling PIC
      unconditionally adds undesired code size and runtime overhead for
      wasm32.
      
      (cherry picked from commit f9c1ae12)
      (cherry picked from commit 5f728fc4)
      9506a531
    • Cheng Shao's avatar
      compiler: fix -ddump-cmm-raw when compiling .cmm · 2131143f
      Cheng Shao authored
      This patch fixes missing -ddump-cmm-raw output when compiling .cmm,
      which is useful for debugging cmm related codegen issues.
      
      (cherry picked from commit 6346c669)
      (cherry picked from commit e5a1dd43)
      2131143f
    • Cheng Shao's avatar
      hadrian: handle findExecutable "" gracefully · 6bee4d8a
      Cheng Shao authored
      hadrian may invoke findExecutable "" at run-time due to a certain
      program is not found by configure script. Which is fine and
      findExecutable is supposed to return Nothing in this case. However, on
      Windows there's a directory bug that throws an exception (see
      https://github.com/haskell/directory/issues/180), so we might as well
      use a wrapper for findExecutable and handle exceptions gracefully.
      
      (cherry picked from commit 1e5752f6)
      (cherry picked from commit 78150bfc)
      6bee4d8a
    • Cheng Shao's avatar
      utils: add hie.yaml config file for ghc-config · 223df0a0
      Cheng Shao authored
      Add hie.yaml to ghc-config project directory so it can be edited using
      HLS.
      
      (cherry picked from commit 7eda4bd2)
      (cherry picked from commit ed81a875)
      223df0a0
    • Cheng Shao's avatar
      compiler: remove ArchWasm32 special case in cmmDoCmmSwitchPlans · 0570b5e3
      Cheng Shao authored
      This patch removes special consideration for ArchWasm32 in
      cmmDoCmmSwitchPlans, which means the compiler will now disable
      cmmImplementSwitchPlans for wasm unreg backend, just like unreg
      backend of other targets. We enabled it in the past to workaround some
      compile-time panic in older versions of LLVM, but those panics are no
      longer present, hence no need to keep this workaround.
      
      (cherry picked from commit bf0737c0)
      (cherry picked from commit 8bd28cf2)
      0570b5e3
    • Cheng Shao's avatar
      driver: build C/C++ with -ffunction-sections -fdata-sections when split sections is enabled · a74925be
      Cheng Shao authored
      When -fsplit-sections is passed to GHC, pass -ffunction-sections
      -fdata-sections to gcc/clang when building C/C++. Previously,
      -fsplit-sections was only respected by the NCG/LLVM backends, but not
      the unregisterised backend; the GHC driver did not pass
      -fdata-sections and -ffunction-sections to the C compiler, which
      resulted in excessive executable sizes.
      
      Fixes #23381.
      
      -------------------------
      Metric Decrease:
          size_hello_artifact
          size_hello_unicode
      -------------------------
      
      (cherry picked from commit 02b1f91e)
      (cherry picked from commit 74cdf564)
      a74925be
    • Cheng Shao's avatar
      hadrian: build C/C++ with split sections when enabled · 35c5fe69
      Cheng Shao authored
      When split sections is enabled, ensure -fsplit-sections is passed to
      GHC as well when invoking GHC to compile C/C++; and pass
      -ffunction-sections -fdata-sections to gcc/clang when compiling C/C++
      with the hadrian Cc builder. Fixes #23381.
      
      (cherry picked from commit 0958937e)
      (cherry picked from commit 7d5a22c2)
      35c5fe69
    • Cheng Shao's avatar
      testsuite: bump MultiLayerModulesDefsGhciReload timeout to 10x · ec0170b6
      Cheng Shao authored
      (cherry picked from commit e17f2df9)
      (cherry picked from commit 9a2f3313)
      ec0170b6
    • Cheng Shao's avatar
      compiler: avoid saving foreign call target to local when there are no caller-save GlobalRegs · ed2f14de
      Cheng Shao authored
      This patch makes the STG->Cmm backend avoid saving foreign call target
      to local when there are no caller-save GlobalRegs.
      
      Since 321941a8, when we lower a
      foreign call, we unconditionally save the foreign call target to a
      temporary local first, then rely on cmmSink to clean it up later,
      which only happens with -fcmm-sink (implied by -O) and not in
      unoptimized code.
      
      And this is troublesome for the wasm backend NCG, which needs to infer
      a foreign call target symbol's type signature from the Cmm call site.
      Previously, the NCG has been emitting incorrect type signatures for
      unoptimized code, which happens to work with `wasm-ld` most of the
      time, but this is never future-proof against upstream toolchain
      updates, and it causes horrible breakages when LTO objects are
      included in linker input. Hence this patch.
      
      (cherry picked from commit 8dd8a076)
      (cherry picked from commit 2b2a3db8)
      ed2f14de
    • Cheng Shao's avatar
      testsuite: don't attempt to detect host cpu features when testing cross ghc · 4124ec97
      Cheng Shao authored
      The testsuite driver CPU feature detection logic only detects host CPU
      and only makes sense when we are not testing a cross GHC.
      
      (cherry picked from commit c4c6d714)
      (cherry picked from commit 07641012)
      4124ec97
    • Cheng Shao's avatar
      testsuite: fix T17920 for wasm backend · 99f53099
      Cheng Shao authored
      T17920 was marked as fragile on wasm before; it can be trivially fixed
      by avoiding calling variadic printf() in cmm.
      
      (cherry picked from commit 7b4c1998)
      (cherry picked from commit c4060ce3)
      99f53099
    • Cheng Shao's avatar
      autoconf: remove unused context diff check · f6aa2bc3
      Cheng Shao authored
      This patch removes redundant autoconf check for the context diff
      program given it isn't actually been used anywhere, especially since
      make removal.
      
      (cherry picked from commit b7bcf729)
      (cherry picked from commit 0e9d2a0f)
      f6aa2bc3
    • Cheng Shao's avatar
      rts: fix I/O manager compilation errors for win32 target · 22a9d504
      Cheng Shao authored
      This patch fixes I/O manager compilation errors for win32 target
      discovered when cross-compiling to win32 using recent clang:
      
      ```
      rts/win32/ThrIOManager.c:117:7: error:
           error: call to undeclared function 'is_io_mng_native_p'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
            117 |   if (is_io_mng_native_p ()) {
                |       ^
          |
      117 |   if (is_io_mng_native_p ()) {
          |       ^
      
      1 error generated.
      `x86_64-w64-mingw32-clang' failed in phase `C Compiler'. (Exit code: 1)
      
      rts/fs.c:143:28: error:
           error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
            143 | int setErrNoFromWin32Error () {
                |                            ^
                |                             void
          |
      143 | int setErrNoFromWin32Error () {
          |                            ^
      
      1 error generated.
      `x86_64-w64-mingw32-clang' failed in phase `C Compiler'. (Exit code: 1)
      
      rts/win32/ConsoleHandler.c:227:9: error:
           error: call to undeclared function 'interruptIOManagerEvent'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
            227 |         interruptIOManagerEvent ();
                |         ^
          |
      227 |         interruptIOManagerEvent ();
          |         ^
      
      rts/win32/ConsoleHandler.c:227:9: error:
           note: did you mean 'getIOManagerEvent'?
          |
      227 |         interruptIOManagerEvent ();
          |         ^
      
      rts/include/rts/IOInterface.h:27:10: error:
           note: 'getIOManagerEvent' declared here
             27 | void *   getIOManagerEvent  (void);
                |          ^
         |
      27 | void *   getIOManagerEvent  (void);
         |          ^
      
      1 error generated.
      `x86_64-w64-mingw32-clang' failed in phase `C Compiler'. (Exit code: 1)
      
      rts/win32/ConsoleHandler.c:196:9: error:
           error: call to undeclared function 'setThreadLabel'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
            196 |         setThreadLabel(cap, t, "signal handler thread");
                |         ^
          |
      196 |         setThreadLabel(cap, t, "signal handler thread");
          |         ^
      
      rts/win32/ConsoleHandler.c:196:9: error:
           note: did you mean 'postThreadLabel'?
          |
      196 |         setThreadLabel(cap, t, "signal handler thread");
          |         ^
      
      rts/eventlog/EventLog.h:118:6: error:
           note: 'postThreadLabel' declared here
            118 | void postThreadLabel(Capability    *cap,
                |      ^
          |
      118 | void postThreadLabel(Capability    *cap,
          |      ^
      
      1 error generated.
      `x86_64-w64-mingw32-clang' failed in phase `C Compiler'. (Exit code: 1)
      ```
      
      (cherry picked from commit 710665bd)
      (cherry picked from commit 9499ed96)
      22a9d504
    • Cheng Shao's avatar
      testsuite: bump PartialDownSweep timeout to 5x on wasm32 · 3269bb74
      Cheng Shao authored
      (cherry picked from commit b1e0c313)
      (cherry picked from commit 34882192)
      3269bb74
    • Cheng Shao's avatar
      testsuite: fix req_target_smp predicate · 25a6b98e
      Cheng Shao authored
      (cherry picked from commit a580722e)
      (cherry picked from commit 4f317bfd)
      25a6b98e
    • Cheng Shao's avatar
      autoconf: remove obsolete patch detection · 3f22f236
      Cheng Shao authored
      This commit removes obsolete deletection logic of the patch command
      from autoconf scripts, given we no longer need to patch anything in
      the GHC build process.
      
      (cherry picked from commit 71f28958)
      (cherry picked from commit 1e77ded1)
      3f22f236
    • Cheng Shao's avatar
      hadrian: remove obsolete Patch logic · 4f02268c
      Cheng Shao authored
      This commit removes obsolete Patch logic from hadrian, given we no
      longer need to patch the gmp tarball when building in-tree GMP.
      
      (cherry picked from commit 65b4b92f)
      (cherry picked from commit 92065500)
      4f02268c
    • Cheng Shao's avatar
      ghc-bignum: update gmp to 6.3.0 · 37c4d8b7
      Cheng Shao authored
      This patch bumps the gmp-tarballs submodule and updates gmp to 6.3.0.
      The tarball format is now xz, and gmpsrc.patch has been patched into
      the tarball so hadrian no longer needs to deal with patching logic
      when building in-tree GMP.
      
      (cherry picked from commit 6399d52b)
      (cherry picked from commit f845a792)
      37c4d8b7
    • Cheng Shao's avatar
      ghc-bignum: remove obsolete ln script · 11bebb6c
      Cheng Shao authored
      This commit removes an obsolete ln script in ghc-bignum/gmp. See
      060251c2 for its original intention,
      but it's been obsolete for a long time, especially since the removal
      of the make build system. Hence the house cleaning.
      
      (cherry picked from commit c62dc317)
      (cherry picked from commit 5f4848c0)
      11bebb6c
    • Cheng Shao's avatar
      rts: assert pointer is indeed heap allocated in Bdescr() · 57661d96
      Cheng Shao authored
      This commit adds an assertion to Bdescr() to assert the pointer is
      indeed heap allocated. This is useful to rule out RTS bugs that
      attempt to access non-existent block descriptor of a static closure, #24492
      being one such example.
      
      (cherry picked from commit d19441d7)
      57661d96
    • Cheng Shao's avatar
      rts: expose HeapAlloc.h as public header · 95b4ac32
      Cheng Shao authored
      This commit exposes HeapAlloc.h as a public header. The intention is
      to expose HEAP_ALLOCED/HEAP_ALLOCED_GC, so they can be used in
      assertions in other public headers, and they may also be useful for
      user code.
      
      (cherry picked from commit dedcf102)
      95b4ac32
    • Cheng Shao's avatar
      utils: remove unused lndir from tree · ffe92d84
      Cheng Shao authored
      Ever since the removal of the make build system, the in tree lndir
      hasn't been actually built, so this patch removes it.
      
      (cherry picked from commit d3a050d2)
      ffe92d84
    • Cheng Shao's avatar
      ci: enable parallelism in hadrian/ghci scripts · 087baa1a
      Cheng Shao authored
      This commit enables parallelism when the hadrian/ghci scripts are
      called in CI. The time bottleneck is in the hadrian build step, but
      previously the build step wasn't parallelized.
      
      (cherry picked from commit 50bfdb46)
      087baa1a
    • Cheng Shao's avatar
      hadrian/hie-bios: pass -j to hadrian · c8919379
      Cheng Shao authored
      This commit passes -j to hadrian in the hadrian/hie-bios scripts. When
      the user starts HLS in a fresh clone that has just been configured, it
      takes quite a while for hie-bios to pick up the ghc flags and start
      actual indexing, due to the fact that the hadrian build step defaulted
      to -j1, so -j speeds things up and improve HLS user experience in GHC.
      Also add -j flag to .ghcid to speed up ghcid, and sets the Windows
      build root to .hie-bios which also works and unifies with other
      platforms, the previous build root _hie-bios was missing from
      .gitignore anyway.
      
      (cherry picked from commit c71bfdff)
      c8919379
    • Cheng Shao's avatar
      rts: remove redundant rCCCS initialization · b802da2a
      Cheng Shao authored
      This commit removes the redundant logic of initializing each
      Capability's rCCCS to CCS_SYSTEM in initProfiling(). Before
      initProfiling() is called during RTS startup, each Capability's rCCCS
      has already been assigned CCS_SYSTEM when they're first initialized.
      
      (cherry picked from commit a7569495)
      b802da2a
    • Cheng Shao's avatar
      testsuite: fix hs_try_putmvar002 for targets without pthread.h · ad5ab554
      Cheng Shao authored
      hs_try_putmvar002 includes pthread.h and doesn't work on targets
      without this header (e.g. wasm32). It doesn't need to include this
      header at all. This was previously unnoticed by wasm CI, though recent
      toolchain upgrade brought in upstream changes that completely removes
      pthread.h in the single-threaded wasm32-wasi sysroot, therefore we
      need to handle that change.
      
      (cherry picked from commit 2ce2a493)
      ad5ab554
    • Cheng Shao's avatar
      rts: define XXH_INLINE_ALL · 7b97caa6
      Cheng Shao authored
      This commit cleans up how we include the xxhash.h header and only
      define XXH_INLINE_ALL, which is sufficient to inline the xxHash
      functions without symbol collision.
      
      (cherry picked from commit ee01de7d)
      7b97caa6
    • Cheng Shao's avatar
      rts: use XXH3_64bits hash on all 64-bit platforms · a0fa4382
      Cheng Shao authored
      This commit enables XXH3_64bits hash to be used on all 64-bit
      platforms. Previously it was only enabled on x86_64, so platforms like
      aarch64 silently falls back to using XXH32 which degrades the hashing
      function quality.
      
      (cherry picked from commit 4a97bdb8)
      a0fa4382
    • Cheng Shao's avatar
      rts: update xxHash to v0.8.2 · e2cf7d61
      Cheng Shao authored
      (cherry picked from commit b19ec331)
      e2cf7d61
    • Cheng Shao's avatar
      compiler: enable generic cmm optimizations in wasm backend NCG · d149cbc3
      Cheng Shao authored
      This commit enables the generic cmm optimizations in other NCGs to be
      run in the wasm backend as well, followed by a late cmm control-flow
      optimization pass. The added optimizations do catch some corner cases
      not handled by the pre-NCG cmm pipeline and are useful in generating
      smaller CFGs.
      
      (cherry picked from commit c6ce242e)
      d149cbc3
    • Cheng Shao's avatar
      compiler: explicitly disable PIC in wasm32 NCG · d97fb00f
      Cheng Shao authored
      This commit explicitly disables the ncgPIC flag for the wasm32 target.
      The wasm backend doesn't support PIC for the time being.
      
      (cherry picked from commit 87e34888)
      d97fb00f
    • Cheng Shao's avatar
      compiler: move generic cmm optimization logic in NCG to a standalone module · 3d5bce88
      Cheng Shao authored
      This commit moves GHC.CmmToAsm.cmmToCmm to a standalone module,
      GHC.Cmm.GenericOpt. The main motivation is enabling this logic to be
      run in the wasm backend NCG code, which is defined in other modules
      that's imported by GHC.CmmToAsm, causing a cyclic dependency issue.
      
      (cherry picked from commit 6534da24)
      3d5bce88
    • Cheng Shao's avatar
      base: treat all FDs as "nonblocking" on wasm · 641ed0c7
      Cheng Shao authored
      On posix platforms, when performing read/write on FDs, we check the
      nonblocking flag first. For FDs without this flag (e.g. stdout), we
      call fdReady() first, which in turn calls poll() to wait for I/O to be
      available on that FD. This is problematic for wasm32-wasi: although
      select()/poll() is supported via the poll_oneoff() wasi syscall, that
      syscall is rather heavyweight and runtime behavior differs in
      different wasi implementations. The issue is even worse when targeting
      browsers, given there's no satisfactory way to implement async I/O as
      a synchronous syscall, so existing JS polyfills for wasi often give up
      and simply return ENOSYS.
      
      Before we have a proper I/O manager that avoids poll_oneoff() for
      async I/O on wasm, this patch improves the status quo a lot by merely
      pretending all FDs are "nonblocking". Read/write on FDs will directly
      invoke read()/write(), which are much more reliably handled in
      existing wasi implementations, especially those in browsers.
      
      Fixes #23275 and the following test cases: T7773 isEOF001 openFile009
      T4808 cgrun025
      
      Approved by CLC proposal #234:
      https://github.com/haskell/core-libraries-committee/issues/234
      
      (cherry picked from commit 2eca52b4)
      641ed0c7
    • Cheng Shao's avatar
      testsuite: fix optasm tests for wasm32 · f3cee258
      Cheng Shao authored
      (cherry picked from commit af771148)
      f3cee258
    • Cheng Shao's avatar
      rts: drop stale mentions of MIN_UPD_SIZE · beab16a9
      Cheng Shao authored
      We used to have MIN_UPD_SIZE macro that describes the minimum reserved
      size for thunks, so that the thunk can be overwritten in place as
      indirections or blackholes. However, this macro has not been actually
      defined or used anywhere since a long time ago; StgThunkHeader already
      reserves a padding word for this purpose. Hence this patch which drops
      stale mentions of MIN_UPD_SIZE.
      
      (cherry picked from commit c1e3719c)
      beab16a9
    • Cheng Shao's avatar
      rts: fix incorrect ticket reference · 095d24d4
      Cheng Shao authored
      (cherry picked from commit a4785b33)
      095d24d4
    • Cheng Shao's avatar
      Bump time submodule · c40b17cc
      Cheng Shao authored
      c40b17cc
    • amesgen's avatar
      compiler: handle CmmRegOff in lower_CmmExpr_Ptr · 1547ab54
      amesgen authored and Cheng Shao's avatar Cheng Shao committed
      (cherry picked from commit def46c8c)
      1547ab54
    • amesgen's avatar
      compiler: refactor lower_CmmExpr_Ptr · 9156a757
      amesgen authored and Cheng Shao's avatar Cheng Shao committed
      (cherry picked from commit fb629e24)
      9156a757
    • amesgen's avatar
      WASM metadata: use correct GHC version · 2ed52508
      amesgen authored and Cheng Shao's avatar Cheng Shao committed
      (cherry picked from commit 08d14925)
      2ed52508
Loading