Skip to content
Snippets Groups Projects
  1. Jan 14, 2025
    • Cheng Shao's avatar
      ci: multi-project pipeline for wasm · 16d1b887
      Cheng Shao authored
      (cherry picked from commit 3655c3fd)
      16d1b887
    • amesgen's avatar
      wasm: prevent bundlers from resolving import("node:timers") · 61b36fb0
      amesgen authored and Cheng Shao's avatar Cheng Shao committed
      (cherry picked from commit 7202a02c0a5238682de6a3a06a9b5137f02ad70c)
      (cherry picked from commit 5e60fd64)
      61b36fb0
    • Cheng Shao's avatar
      xxhash: bump to v0.8.3 · 8c0d793a
      Cheng Shao authored
      (cherry picked from commit 42826a89)
      (cherry picked from commit 3ea15740)
      8c0d793a
    • Cheng Shao's avatar
      rts: remove -Wl,-U,___darwin_check_fd_set_overflow hack · 74a70364
      Cheng Shao authored
      This patch bumps macOS minimum SDK version to 11.0 for x86_64-darwin
      to align it with aarch64-darwin. This allows us to get rid of the
      horrible -Wl,-U,___darwin_check_fd_set_overflow hack, which is causing
      linker warnings and testsuite failures on macOS 15. Fixes #25504.
      
      (cherry picked from commit 88c4fe1d)
      (cherry picked from commit 5c7e7695)
      74a70364
    • Cheng Shao's avatar
      ci: avoid depending on stack job for test-bootstrap jobs · 57485fa7
      Cheng Shao authored
      This patch makes test-bootstrap related ci jobs only depend on
      hadrian-ghc-in-ghci job to finish, consistent with other jobs in the
      full-build stage generated by gen_ci.hs. This allows the jobs to be
      spawned earlier and improve overall pipeline parallelism.
      
      (cherry picked from commit e684c406)
      (cherry picked from commit 4884eb08)
      57485fa7
    • Cheng Shao's avatar
      wasm: fix foreign import javascript "wrapper" in TH/ghci · d2f9a287
      Cheng Shao authored
      This patch fixes foreign import javascript "wrapper" in wasm backend's
      TH/ghci by fixing the handling of dyld/finalization_registry magic
      variables. Fixes T25473 and closes #25473.
      
      (cherry picked from commit bd0a8b7e)
      (cherry picked from commit 610b0f77)
      d2f9a287
    • Cheng Shao's avatar
      testsuite: add regression test T25473 · f652ebc4
      Cheng Shao authored
      This commit adds regression test T25473 marked as broken due to #25473.
      It will be fixed in the subsequent commit.
      
      (cherry picked from commit ed2ed6c5)
      (cherry picked from commit fb470cb6)
      f652ebc4
    • Cheng Shao's avatar
      misc: improve clangd compile_flags.txt flags · 2fdf32e9
      Cheng Shao authored
      This patch improves the compile_flags.txt config used to power clangd
      for the rts C codebase. The flags in the file are sampled & deduped
      from a real stage1 build with clang-19 and vastly improves the IDE
      accuracy when hacking the rts.
      
      For maximum code coverage under the default settings,
      compile_flags.txt defaults to threaded+profiled+dynamic+debug way.
      This does not mean profdyn needs to be actually built in _build/stage1
      for IDE to work. To activate IDE for other RTS ways, simply remove one
      of the -D flags at the end of compile_flags.txt and restart clangd.
      
      (cherry picked from commit 59e0a770)
      (cherry picked from commit 222a08ae)
      2fdf32e9
    • Cheng Shao's avatar
      hadrian: fix bindist makefile for wasm32-wasi target · 2a6e81ca
      Cheng Shao authored
      This patch fixes one incoherent place between bindist makefile and
      hadrian logic: I forgot to include wasi/wasm32 in
      OsSupportsGHCi/ArchSupportsGHCi as well. And this results in incorrect
      settings file generated after installing the bindist, and "Use
      interpreter"/"Have interpreter" fields incorrectly have "NO" values
      where they should be "YES" like --info output of in-tree version.
      
      (cherry picked from commit 75a2eae4)
      (cherry picked from commit 735f3f9a)
      2a6e81ca
    • Cheng Shao's avatar
      Remove obsolete cross-port script · e94da470
      Cheng Shao authored
      This patch removes the obsolete cross-port script in the tree. The
      script was based on the legacy Make build system which has been pruned
      from the tree long ago. For hadrian, proper support for two-stage
      bootstrapping onto a new unsupported platform is a work in progress in
      !11444.
      
      (cherry picked from commit 00d551bf)
      (cherry picked from commit 329a26da)
      e94da470
    • Cheng Shao's avatar
      wasm: fix FinalizationRegistry logic for Cloudflare Workers · ff0cce4b
      Cheng Shao authored
      This patch fixes FinalizationRegistry related logic for Cloudflare
      Workers in wasm backend js post linker. Cloudflare Workers doesn't
      support FinalizationRegistry, in this case we use a dummy
      implementation that doesn't do anything.
      
      (cherry picked from commit bea8ea4c)
      (cherry picked from commit 0346e7b7)
      ff0cce4b
    • Cheng Shao's avatar
      wasm: fix setImmediate() implementation for Cloudflare Workers · dacd990c
      Cheng Shao authored
      This patch fixes setImmediate() implementation for Cloudflare Workers
      in the wasm backend's js prelude script. Cloudflare Workers doesn't
      support the MessageChannel API, and we use a setTimeout() based
      fallback implementation in this case.
      
      (cherry picked from commit c37b96fa)
      (cherry picked from commit 6bd2d9ad)
      dacd990c
    • Cheng Shao's avatar
      Remove obsolete executable wrappers from the tree · a828628e
      Cheng Shao authored
      The executable wrappers are handled by hadrian and bindist Makefile.
      The various .wrapper scripts in the tree are unused since removal of
      Make build system, so this patch removes them all.
      
      (cherry picked from commit 9ede97f3)
      (cherry picked from commit 737e9e0b)
      a828628e
    • Cheng Shao's avatar
      Remove unused USE_REPORT_PRELUDE code paths from the tree · 43e08bf9
      Cheng Shao authored
      This patch removes unused `USE_REPORT_PRELUDE` code paths from the
      tree. They have been present since the first git revision
      4fb94ae5, and might have been useful
      for debugging purposes many years ago, but these code paths are never
      actually built. Removing these ease maintenance of relevant modules in
      the future, and also allows us to get rid of `CPP` extension in those
      modules as a nice byproduct.
      
      (cherry picked from commit 573cad4b)
      43e08bf9
    • Cheng Shao's avatar
      driver: fix foreign stub handling logic in hscParsedDecls · 84a6f8ff
      Cheng Shao authored
      This patch fixes foreign stub handling logic in `hscParsedDecls`.
      Previously foreign stubs were simply ignored here, so any feature that
      involve foreign stubs would not work in ghci (e.g. CApiFFI). The patch
      reuses `generateByteCode` logic and eliminates a large chunk of
      duplicate logic that implements Core to bytecode generation pipeline
      here. Fixes #25414.
      
      (cherry picked from commit 677e3aa56e905524071fc9717a88ad2cd1bc2951)
      84a6f8ff
    • Cheng Shao's avatar
      testsuite: add T25414 test case marked as broken · bc8ff131
      Cheng Shao authored
      This commit adds T25414 test case to demonstrate #25414. It is marked
      as broken and will be fixed by the next commit.
      
      (cherry picked from commit 82213395dc2fbdc8b452336da0909896b4300218)
      bc8ff131
    • Cheng Shao's avatar
      compiler: remove unused hscDecls/hscDeclsWithLocation · 56b0d222
      Cheng Shao authored
      This patch removes unused `hscDecls`/`hscDeclsWithLocation` functions
      from the compiler, to reduce maintenance burden when doing
      refactorings related to ghci.
      
      (cherry picked from commit e3496ef6)
      56b0d222
    • Cheng Shao's avatar
      wasm: fix safari console error message related to import("node:timers") · 0b334771
      Cheng Shao authored
      This patch fixes the wasm backend JSFFI prelude script to avoid
      calling `import("node:timers")` on non-deno hosts. Safari doesn't like
      it and would print an error message to the console. Fixes
      https://gitlab.haskell.org/ghc/ghc-wasm-meta/-/issues/13.
      
      (cherry picked from commit 301c3b54)
      0b334771
    • Cheng Shao's avatar
      ghcid: use multi repl for ghcid · 619741ff
      Cheng Shao authored
      (cherry picked from commit 589fea7f)
      619741ff
    • Cheng Shao's avatar
      hadrian: make sure ghc-bin internal-interpreter is disabled for stage0 when not cross compiling · 48aa8a0b
      Cheng Shao authored
      This patch disables internal-interpreter flag for stage0 ghc-bin when
      not cross compiling, see added comment for explanation. Fixes #25406.
      
      (cherry picked from commit fde12aba)
      48aa8a0b
    • Cheng Shao's avatar
      wasm: bump dyld v8 heap size limit · 9b0c5c40
      Cheng Shao authored
      This patch adds `--max-old-space-size=8192` to wasm dyld shebang
      arguments to bump V8 heap size limit. The default limit
      (`heap_size_limit` returned by `v8.getHeapStatistics()`) is
      dynamically determined and a bit too low under certain workloads, and
      V8 would waste too much CPU time to garbage collect old generation
      heap more aggressively. Bumping the limit to 8G doesn't imply dyld
      would really take that much memory at run-time, but it lessens V8 heap
      stress significantly.
      
      (cherry picked from commit 14c5143899d164c7ac1213d918b4819684538c4b)
      9b0c5c40
    • Luite Stegeman's avatar
      Interpreter: Add locking for communication with external interpreter · 42d6102a
      Luite Stegeman authored and Cheng Shao's avatar Cheng Shao committed
      This adds locking to communication with the external interpreter
      to prevent concurrent tasks interfering with each other. This
      fixes Template Haskell with the external interpreter in parallel (-j)
      builds.
      
      Fixes #25083
      42d6102a
    • Cheng Shao's avatar
      rts: fix pointer overflow undefined behavior in bytecode interpreter · 9509c7ba
      Cheng Shao authored
      This patch fixes an unnoticed undefined behavior in the bytecode
      interpreter. It can be caught by building `rts/Interpreter.c` with
      `-fsanitize=pointer-overflow`, the warning message is something like:
      
      ```
      rts/Interpreter.c:1369:13: runtime error: addition of unsigned offset to 0x004200197660 overflowed to 0x004200197658
      SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior rts/Interpreter.c:1369:13
      rts/Interpreter.c:1265:13: runtime error: addition of unsigned offset to 0x004200197660 overflowed to 0x004200197658
      SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior rts/Interpreter.c:1265:13
      rts/Interpreter.c:1645:13: runtime error: addition of unsigned offset to 0x0042000b22f8 overflowed to 0x0042000b22f0
      SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior rts/Interpreter.c:1645:13
      ```
      
      Whenever we do something like `SpW(-1)`, the negative argument is
      implicitly converted to an unsigned integer type and causes pointer
      arithmetic overflow. It happens to be harmless for most targets since
      overflowing would wrap the result to desired value, but it's still
      coincidental and undefined behavior. Furthermore, it causes real
      damage to the wasm backend, given clang-20 will emit invalid wasm code
      that crashes at run-time for this kind of C code! (see
      https://github.com/llvm/llvm-project/issues/108770)
      
      The fix here is adding some explicit casts to ensure we always use the
      signed `ptrdiff_t` type as right hand operand of pointer arithmetic.
      
      (cherry picked from commit 5bcfefd5)
      9509c7ba
    • Cheng Shao's avatar
      Revert "compiler: start deprecating cmmToRawCmmHook" · d58727c3
      Cheng Shao authored
      This reverts commit 1c064ef1. Turns
      out the GHC-WPC project does use it to observe Cmm in the pipeline,
      see #25363.
      
      (cherry picked from commit 525d451e)
      d58727c3
    • Cheng Shao's avatar
      testsuite: flip on support for shared libs, TH & ghci for wasm · e2a2b176
      Cheng Shao authored
      This commit flips on support for shared libs, TH & ghci for wasm in
      the testsuite, given support has been landed in previous commits.
      
      (cherry picked from commit 74a1f681)
      e2a2b176
    • Cheng Shao's avatar
      hadrian/compiler: flip on support for shared libs & ghci for wasm · 895a3866
      Cheng Shao authored
      This commit flips on the support for shared libs and ghci for the wasm
      target, given all required support logic has been added in previous
      commits.
      
      (cherry picked from commit 652e7239)
      895a3866
    • Cheng Shao's avatar
      compiler: add PIC support to wasm backend NCG · e3d1bc27
      Cheng Shao authored
      This commit adds support for generating PIC to the wasm backend NCG.
      
      (cherry picked from commit 61f5baa5)
      e3d1bc27
    • Cheng Shao's avatar
      driver: add wasm backend iserv logic · 3c40f393
      Cheng Shao authored
      This commit adds wasm backend iserv logic to the driver, see added
      comments for explanation.
      
      (cherry picked from commit 2d6107dc)
      3c40f393
    • Cheng Shao's avatar
      driver: fix getGccSearchDirectory for wasm target · 44624a19
      Cheng Shao authored
      This commit fixes getGccSearchDirectory logic for wasm target, ensures
      the correct search directory containing libc.so etc can be found by
      GHC. getGccSearchDirectory is also exported so it can be used
      elsewhere to obtain the wasi-sdk libdir and pass to the dyld script.
      
      (cherry picked from commit b562e3a6)
      44624a19
    • Cheng Shao's avatar
      hadrian/ghci: add wasm dyld · abc76e9f
      Cheng Shao authored
      This commit adds the wasm dynamic linker implementation, as well as
      ghci logic to call it and hadrian logic to install it to the correct
      location. See the top-level note in utils/jsffi/dyld.mjs for more
      details.
      
      (cherry picked from commit 549582ef)
      abc76e9f
    • Cheng Shao's avatar
      ghc-bin: enforce dynamic way when the target requires so · baba3f2d
      Cheng Shao authored
      This commit makes ghc-bin use dynamic way when it is doing interactive
      stuff on certain targets whose RTS linker can only handle dynamic
      code.
      
      (cherry picked from commit 88e99248)
      baba3f2d
    • Cheng Shao's avatar
      compiler: fix checkNonStdWay for targets that require dynamic libraries · d2872dbe
      Cheng Shao authored
      This commit fixes checkNonStdWay to ensure that for targets whose RTS
      linker can only load dynamic code, the dynamic way of object is
      selected.
      
      (cherry picked from commit 94ef949e)
      d2872dbe
    • Cheng Shao's avatar
      compiler: fix dynamic_too_enable for targets that require dynamic libraries · e1c03708
      Cheng Shao authored
      This commit fixes dynamic_too_enable for targets whose RTS linker can
      only load dynamic code.
      
      (cherry picked from commit fc3a5591)
      e1c03708
    • Cheng Shao's avatar
      driver: ensure static archives are picked when linking static .wasm modules · 063e94b4
      Cheng Shao authored
      This commit ensures static archives are picked when linking .wasm
      modules which are supposed to be fully static, even when ghc may be
      invoked with -dynamic, see added comment for explanation.
      
      (cherry picked from commit 47baa904)
      063e94b4
    • Cheng Shao's avatar
      driver: enforce -fno-use-rpaths for wasm · afba389f
      Cheng Shao authored
      This commit ensures the GHC driver never passes any RPATH-related
      link-time flags on wasm, which is not supported at all.
      
      (cherry picked from commit 649aae00)
      afba389f
    • Cheng Shao's avatar
      driver: add necessary link-time flags for wasm shared libs · b11220e0
      Cheng Shao authored
      This commit adds necessary link-time flags for wasm shared libs, see
      added comments for detailed explanation.
      
      (cherry picked from commit 9745fcfb)
      b11220e0
    • Cheng Shao's avatar
      driver: add necessary compile-time flags for wasm PIC mode · b3741f99
      Cheng Shao authored
      This commit adds necessary compile-time flags when compiling for wasm
      PIC mode, see added comment for detailed explanation.
      
      (cherry picked from commit f6abaf13)
      b3741f99
    • Cheng Shao's avatar
      compiler: fix Cmm dynamic CLabels for wasm · b3d33118
      Cheng Shao authored
      This commit fixes the handling of dynamic CLabels for the wasm
      backend. Just do the simplest handling: preserve the original CLabel,
      both unreg/NCG backends can handle them properly without issue.
      
      (cherry picked from commit 74411461)
      b3d33118
    • Cheng Shao's avatar
      driver: use interpreterDynamic predicate in preloadLib · 19ec87cc
      Cheng Shao authored
      This commit use the interpreterDynamic predicate in preloadLib to
      decide if we should do dynLoadObjs instead of loadObj. Previously we
      used hostIsDynamic which was only written with non-cross internal
      interpreter in mind.
      
      The testsuite is also adjusted to remove hard-wired -fPIC flag for
      cbits (doesn't work in i386 RTS linker in vanilla way, #25260) and
      properly pass ghc_th_way_flags to ghc.
      
      (cherry picked from commit 80aa8983)
      19ec87cc
    • Cheng Shao's avatar
      driver: fix -fexternal-interpreter flag for JS backend · bcd397b0
      Cheng Shao authored
      Previously, -fexternal-interpreter is broken for JS backend, since GHC
      would attempt to launch a non-existent ghc-iserv* executable. This
      commit fixes it by adjusting pattern matching order in
      setTopSessionDynFlags.
      
      (cherry picked from commit 621c753d)
      bcd397b0
Loading