Skip to content
Snippets Groups Projects
  1. Jan 12, 2025
    • Cheng Shao's avatar
      ci: multi-project pipeline for wasm · dfb43bb5
      Cheng Shao authored
      (cherry picked from commit 3655c3fd)
      dfb43bb5
    • Cheng Shao's avatar
      xxhash: bump to v0.8.3 · 30d4f0ce
      Cheng Shao authored
      (cherry picked from commit 42826a89)
      (cherry picked from commit 3ea15740)
      30d4f0ce
    • Cheng Shao's avatar
      rts: remove -Wl,-U,___darwin_check_fd_set_overflow hack · 9f76a09c
      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)
      9f76a09c
    • Cheng Shao's avatar
      ci: avoid depending on stack job for test-bootstrap jobs · cb414918
      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)
      cb414918
    • Cheng Shao's avatar
      wasm: fix foreign import javascript "wrapper" in TH/ghci · 4b7664e6
      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)
      4b7664e6
    • Cheng Shao's avatar
      testsuite: add regression test T25473 · c39bb903
      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)
      c39bb903
    • Cheng Shao's avatar
      misc: improve clangd compile_flags.txt flags · e5b66003
      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)
      e5b66003
    • Cheng Shao's avatar
      hadrian: fix bindist makefile for wasm32-wasi target · e076d9b2
      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)
      e076d9b2
    • Cheng Shao's avatar
      Remove obsolete cross-port script · 1a75d8c6
      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)
      1a75d8c6
    • Cheng Shao's avatar
      wasm: fix FinalizationRegistry logic for Cloudflare Workers · 9e465118
      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)
      9e465118
    • Cheng Shao's avatar
      wasm: fix setImmediate() implementation for Cloudflare Workers · 19c115f6
      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)
      19c115f6
    • Cheng Shao's avatar
      Remove obsolete executable wrappers from the tree · 3de4005e
      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)
      3de4005e
    • Cheng Shao's avatar
      Remove unused USE_REPORT_PRELUDE code paths from the tree · 41719821
      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)
      41719821
    • Cheng Shao's avatar
      driver: fix foreign stub handling logic in hscParsedDecls · d52f887c
      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)
      d52f887c
    • Cheng Shao's avatar
      testsuite: add T25414 test case marked as broken · df825215
      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)
      df825215
    • Cheng Shao's avatar
      compiler: remove unused hscDecls/hscDeclsWithLocation · 86431ec1
      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)
      86431ec1
    • Cheng Shao's avatar
      wasm: fix safari console error message related to import("node:timers") · b695ed45
      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)
      b695ed45
    • Cheng Shao's avatar
      ghcid: use multi repl for ghcid · 40e0c4d1
      Cheng Shao authored
      (cherry picked from commit 589fea7f)
      40e0c4d1
    • Cheng Shao's avatar
      hadrian: make sure ghc-bin internal-interpreter is disabled for stage0 when not cross compiling · 61d6cb13
      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)
      61d6cb13
    • Cheng Shao's avatar
      wasm: bump dyld v8 heap size limit · c0fd3460
      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)
      c0fd3460
    • Luite Stegeman's avatar
      Interpreter: Add locking for communication with external interpreter · 22bd780a
      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
      22bd780a
    • Cheng Shao's avatar
      rts: fix pointer overflow undefined behavior in bytecode interpreter · fec0e29d
      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)
      fec0e29d
    • Cheng Shao's avatar
      Revert "compiler: start deprecating cmmToRawCmmHook" · 981c1c4d
      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)
      981c1c4d
    • Cheng Shao's avatar
      testsuite: flip on support for shared libs, TH & ghci for wasm · 22b948ce
      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)
      22b948ce
    • Cheng Shao's avatar
      hadrian/compiler: flip on support for shared libs & ghci for wasm · e574bccd
      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)
      e574bccd
    • Cheng Shao's avatar
      compiler: add PIC support to wasm backend NCG · 7a13bc98
      Cheng Shao authored
      This commit adds support for generating PIC to the wasm backend NCG.
      
      (cherry picked from commit 61f5baa5)
      7a13bc98
    • Cheng Shao's avatar
      driver: add wasm backend iserv logic · 75f072f1
      Cheng Shao authored
      This commit adds wasm backend iserv logic to the driver, see added
      comments for explanation.
      
      (cherry picked from commit 2d6107dc)
      75f072f1
    • Cheng Shao's avatar
      driver: fix getGccSearchDirectory for wasm target · df6229ce
      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)
      df6229ce
    • Cheng Shao's avatar
      hadrian/ghci: add wasm dyld · 7e740586
      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)
      7e740586
    • Cheng Shao's avatar
      ghc-bin: enforce dynamic way when the target requires so · 40f91813
      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)
      40f91813
    • Cheng Shao's avatar
      compiler: fix checkNonStdWay for targets that require dynamic libraries · f98c71d8
      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)
      f98c71d8
    • Cheng Shao's avatar
      compiler: fix dynamic_too_enable for targets that require dynamic libraries · 24c2e012
      Cheng Shao authored
      This commit fixes dynamic_too_enable for targets whose RTS linker can
      only load dynamic code.
      
      (cherry picked from commit fc3a5591)
      24c2e012
    • Cheng Shao's avatar
      driver: ensure static archives are picked when linking static .wasm modules · 2a9270d0
      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)
      2a9270d0
    • Cheng Shao's avatar
      driver: enforce -fno-use-rpaths for wasm · 6cd0bf23
      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)
      6cd0bf23
    • Cheng Shao's avatar
      driver: add necessary link-time flags for wasm shared libs · 0652cd9c
      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)
      0652cd9c
    • Cheng Shao's avatar
      driver: add necessary compile-time flags for wasm PIC mode · 14392532
      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)
      14392532
    • Cheng Shao's avatar
      compiler: fix Cmm dynamic CLabels for wasm · d6bd4107
      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)
      d6bd4107
    • Cheng Shao's avatar
      driver: use interpreterDynamic predicate in preloadLib · 25acfc58
      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)
      25acfc58
    • Cheng Shao's avatar
      driver: fix -fexternal-interpreter flag for JS backend · bc45028e
      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)
      bc45028e
    • Cheng Shao's avatar
      testsuite: fix T16180 on wasm · 8ab78094
      Cheng Shao authored
      This commit fixes T16180 on wasm once TH support is flipped on. The
      fix is simply adding right asm code for wasm.
      
      (cherry picked from commit 69bb4745)
      8ab78094
Loading