Skip to content
Snippets Groups Projects
  1. Oct 18, 2024
    • Cheng Shao's avatar
      testsuite: bump T7653 timeout for wasm · 3f7b718f
      Cheng Shao authored
      (cherry picked from commit 2eee65e1)
      3f7b718f
    • Cheng Shao's avatar
      compiler: remove unused CompilerInfo/LinkerInfo types · db957a4d
      Cheng Shao authored
      This patch removes CompilerInfo/LinkerInfo types from the compiler
      since they aren't actually used anywhere.
      
      (cherry picked from commit 98ad1ea5)
      db957a4d
    • Cheng Shao's avatar
      compiler: emit NaturallyAligned when element type & index type are the same width · b6fce5bf
      Cheng Shao authored
      This commit fixes a subtle mistake in alignmentFromTypes that used to
      generate Unaligned when element type & index type are the same width.
      Fixes #24930.
      
      (cherry picked from commit 0cff083a)
      b6fce5bf
    • Cheng Shao's avatar
      testsuite: mark T7773 as fragile on wasm · b7e93bc9
      Cheng Shao authored
      (cherry picked from commit ae50a8eb)
      b7e93bc9
    • Cheng Shao's avatar
      hadrian: build in-tree GMP with malloc-notreentrant on wasm32 · 0f9a8aaf
      Cheng Shao authored
      This patch makes hadrian build in-tree GMP with the
      --enable-alloca=malloc-notreentrant configure option. We will only
      need malloc-reentrant when we have threaded RTS and SMP support on
      wasm32, which will take some time to happen, before which we should
      use malloc-notreentrant to avoid undesired runtime overhead.
      
      (cherry picked from commit 06277d56)
      0f9a8aaf
    • Cheng Shao's avatar
      hadrian: disable in-tree gmp fft code path for wasm32 · 097ea6e2
      Cheng Shao authored
      This patch disables in-tree GMP FFT code paths for wasm32 target in
      order to give up some performance of multiplying very large operands
      in exchange for reduced code size.
      
      (cherry picked from commit 1a32f828)
      097ea6e2
    • Cheng Shao's avatar
      hadrian: disable PIC for in-tree GMP on wasm32 · 5f728fc4
      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)
      5f728fc4
    • Cheng Shao's avatar
      compiler: fix -ddump-cmm-raw when compiling .cmm · e5a1dd43
      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)
      e5a1dd43
    • Cheng Shao's avatar
      configure: do not set LLC/OPT/LLVMAS fallback values when FIND_LLVM_PROG fails · 76b7ae55
      Cheng Shao authored
      When configure fails to find LLC/OPT/LLVMAS within supported version
      range, it used to set "llc"/"opt"/"clang" as fallback values. This
      behavior is particularly troublesome when the user has llc/opt/clang
      with other versions in their PATH and run the testsuite, since hadrian
      will incorrectly assume have_llvm=True and pass that to the testsuite
      driver, resulting in annoying optllvm test failures (#23186). If
      configure determines llc/opt/clang wouldn't work, then we shouldn't
      pretend it'll work at all, and the bindist configure will invoke
      FIND_LLVM_PROG check again at install time anyway.
      
      (cherry picked from commit 4eb5ad09)
      76b7ae55
    • Cheng Shao's avatar
      hadrian: handle findExecutable "" gracefully · 78150bfc
      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)
      78150bfc
    • Cheng Shao's avatar
      utils: add hie.yaml config file for ghc-config · ed81a875
      Cheng Shao authored
      Add hie.yaml to ghc-config project directory so it can be edited using
      HLS.
      
      (cherry picked from commit 7eda4bd2)
      ed81a875
    • Cheng Shao's avatar
      compiler: remove ArchWasm32 special case in cmmDoCmmSwitchPlans · 8bd28cf2
      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)
      8bd28cf2
    • Cheng Shao's avatar
      testsuite: mark process005 as fragile on JS · 19e450a5
      Cheng Shao authored
      (cherry picked from commit fd47e2e3)
      19e450a5
    • Cheng Shao's avatar
      driver: build C/C++ with -ffunction-sections -fdata-sections when split sections is enabled · 74cdf564
      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)
      74cdf564
    • Cheng Shao's avatar
      hadrian: build C/C++ with split sections when enabled · 7d5a22c2
      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)
      7d5a22c2
    • Cheng Shao's avatar
      rts: use __builtin_offsetof to implement STG_FIELD_OFFSET · e18ea578
      Cheng Shao authored
      This patch fixes the STG_FIELD_OFFSET macro definition by using
      __builtin_offsetof, which is what gcc/clang uses to implement offsetof
      in standard C. The previous definition that uses NULL pointer involves
      subtle undefined behavior in C and thus reported by
      UndefinedBehaviorSanitizer as well:
      
      ```
      rts/Capability.h:243:58: runtime error: member access within null pointer of type 'Capability' (aka 'struct Capability_')
      SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior rts/Capability.h:243:58
      ```
      
      (cherry picked from commit 05c4fafb)
      e18ea578
    • Cheng Shao's avatar
      rts: fix an unaligned load in nonmoving gc · b18aa8e2
      Cheng Shao authored
      This patch fixes an unaligned load in nonmoving gc by ensuring the
      closure address is properly untagged first before attempting to
      prefetch its header. The unaligned load is reported by
      UndefinedBehaviorSanitizer:
      
      ```
      rts/sm/NonMovingMark.c:921:9: runtime error: member access within misaligned address 0x0042005f3a71 for type 'StgClosure' (aka 'struct StgClosure_'), which requires 8 byte alignment
      0x0042005f3a71: note: pointer points here
       00 00 00  98 43 13 8e 12 7f 00 00  50 3c 5f 00 42 00 00 00  58 17 b7 92 12 7f 00 00  89 cb 5e 00 42
                    ^
      SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior rts/sm/NonMovingMark.c:921:9
      ```
      
      This issue had previously gone unnoticed since it didn't really harm
      runtime correctness, the invalid header address directly loaded from a
      tagged pointer is only used as prefetch address and will not cause
      segfaults. However, it still should be corrected because the prefetch
      would be rendered useless by this issue, and untagging only involves a
      single bitwise operation without memory access so it's cheap enough to
      add.
      
      (cherry picked from commit c77a48af)
      b18aa8e2
    • Cheng Shao's avatar
      rts: ensure gc_thread/gen_workspace is allocated with proper alignment · f77369b9
      Cheng Shao authored
      gc_thread/gen_workspace are required to be aligned by 64 bytes.
      However, this property has not been properly enforced before, and
      numerous alignment violations at runtime has been caught by
      UndefinedBehaviorSanitizer that look like:
      
      ```
      rts/sm/GC.c:1167:8: runtime error: member access within misaligned address 0x0000027a3390 for type 'gc_thread' (aka 'struct gc_thread_'), which requires 64 byte alignment
      0x0000027a3390: note: pointer points here
       00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior rts/sm/GC.c:1167:8
      
      rts/sm/GC.c:1184:13: runtime error: member access within misaligned address 0x0000027a3450 for type 'gen_workspace' (aka 'struct gen_workspace_'), which requires 64 byte alignment
      0x0000027a3450: note: pointer points here
       00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
                    ^
      SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior rts/sm/GC.c:1184:13
      ```
      
      This patch fixes the gc_thread/gen_workspace misalignment issue by
      explicitly allocating them with alignment constraint.
      
      (cherry picked from commit 7a660042)
      f77369b9
    • Cheng Shao's avatar
      testsuite: bump MultiLayerModulesDefsGhciReload timeout to 10x · 9a2f3313
      Cheng Shao authored
      (cherry picked from commit e17f2df9)
      9a2f3313
    • Cheng Shao's avatar
      rts: fix missing function prototypes in ClosureMacros.h · 952dd3f4
      Cheng Shao authored
      (cherry picked from commit 3ca72ad9)
      952dd3f4
    • Cheng Shao's avatar
      testsuite: add callee-no-local regression test · e33a21a4
      Cheng Shao authored
      (cherry picked from commit 986df1ab)
      e33a21a4
    • Cheng Shao's avatar
      compiler: avoid saving foreign call target to local when there are no caller-save GlobalRegs · 2b2a3db8
      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)
      2b2a3db8
    • Cheng Shao's avatar
      testsuite: don't attempt to detect host cpu features when testing cross ghc · 07641012
      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)
      07641012
    • Cheng Shao's avatar
      testsuite: bump T22744 timeout to 5x · f21a1e56
      Cheng Shao authored
      (cherry picked from commit c739383b)
      f21a1e56
    • Cheng Shao's avatar
      testsuite: fix T17920 for wasm backend · c4060ce3
      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)
      c4060ce3
    • Cheng Shao's avatar
      autoconf: remove unused context diff check · 0e9d2a0f
      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)
      0e9d2a0f
    • Cheng Shao's avatar
      rts: fix I/O manager compilation errors for win32 target · 9499ed96
      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)
      9499ed96
    • Cheng Shao's avatar
      rts: do not prefetch mark_closure bdescr in non-moving gc when ASSERTS_ENABLED · 6997f0b8
      Cheng Shao authored
      This commit fixes a small an oversight in !12148: the prefetch logic
      in non-moving GC may trap in debug RTS because it calls Bdescr() for
      mark_closure which may be a static one. It's fine in non-debug RTS
      because even invalid bdescr addresses are prefetched, they will not
      cause segfaults, so this commit implements the most straightforward
      fix: don't prefetch mark_closure bdescr when assertions are enabled.
      
      (cherry picked from commit 886ab43a)
      6997f0b8
    • Cheng Shao's avatar
      testsuite: bump PartialDownSweep timeout to 5x on wasm32 · 34882192
      Cheng Shao authored
      (cherry picked from commit b1e0c313)
      34882192
    • Cheng Shao's avatar
      linters: fix lint-whitespace compilation with ghc-9.10.1 · b7965ff0
      Cheng Shao authored
      (cherry picked from commit ad38e954)
      b7965ff0
    • Cheng Shao's avatar
      hadrian: fix hadrian building with ghc-9.10.1 · d72f2e78
      Cheng Shao authored
      (cherry picked from commit be514bb4)
      d72f2e78
    • Cheng Shao's avatar
      ghc-heap: fix typo in ghc-heap cbits · 6a4eb3c6
      Cheng Shao authored
      (cherry picked from commit 2b1af08b)
      6a4eb3c6
    • Cheng Shao's avatar
      testsuite: fix testwsdeque with recent clang · 6d1ee58c
      Cheng Shao authored
      This patch fixes compilation of testwsdeque.c with recent versions of
      clang, which will fail with the error below:
      
      ```
      testwsdeque.c:95:33: error:
           warning: format specifies type 'long' but the argument has type 'void *' [-Wformat]
             95 |         barf("FAIL: %ld %d %d", p, n, val);
                |                     ~~~         ^
      
      testwsdeque.c:95:39: error:
           warning: format specifies type 'int' but the argument has type 'StgWord' (aka 'unsigned long') [-Wformat]
             95 |         barf("FAIL: %ld %d %d", p, n, val);
                |                            ~~         ^~~
                |                            %lu
      
      testwsdeque.c:133:42: error:
           error: incompatible function pointer types passing 'void (void *)' to parameter of type 'OSThreadProc *' (aka 'void *(*)(void *)') [-Wincompatible-function-pointer-types]
            133 |         createOSThread(&ids[n], "thief", thief, (void*)(StgWord)n);
                |                                          ^~~~~
      
      /workspace/ghc/_build/stage1/lib/../lib/x86_64-linux-ghc-9.11.20240502/rts-1.0.2/include/rts/OSThreads.h:193:51: error:
           note: passing argument to parameter 'startProc' here
            193 |                                     OSThreadProc *startProc, void *param);
                |                                                   ^
      
      2 warnings and 1 error generated.
      ```
      
      (cherry picked from commit a9979f55)
      6d1ee58c
    • Cheng Shao's avatar
      wasm: use scheduler.postTask() for context switch when available · 7389efbd
      Cheng Shao authored
      This patch makes use of scheduler.postTask() for JSFFI context switch
      when it's available. It's a more principled approach than our
      MessageChannel based setImmediate() implementation, and it's available
      in latest version of Chromium based browsers.
      
      (cherry picked from commit 43d48b44)
      7389efbd
    • Cheng Shao's avatar
      testsuite: fix req_target_smp predicate · 4f317bfd
      Cheng Shao authored
      (cherry picked from commit a580722e)
      4f317bfd
    • Ben Gamari's avatar
      Bump time submodule to 1.14 · 94144ebb
      Ben Gamari authored and Cheng Shao's avatar Cheng Shao committed
      As requested in #24528.
      
      -------------------------
      Metric Decrease:
          ghc_bignum_so
          rts_so
      Metric Increase:
          cabal_syntax_dir
          rts_so
          time_dir
          time_so
      -------------------------
      
      (cherry picked from commit 1dacb506)
      94144ebb
    • Sylvain Henry's avatar
      Fix TH dependencies (#22229) · 1979af97
      Sylvain Henry authored and Cheng Shao's avatar Cheng Shao committed
      Add a dependency between Syntax and Internal (via module reexport).
      
      (cherry picked from commit 4d78c53c)
      1979af97
    • Teo Camarasu's avatar
      Remove unecessary stage0 packages · 3c22f5be
      Teo Camarasu authored and Cheng Shao's avatar Cheng Shao committed
      Historically quite a few packages had to be stage0 as they depended on
      `template-haskell` and that was stage0. In #23536 we made it so that was
      no longer the case. This allows us to remove a bunch of packages from
      this list.
      
      A few still remain. A new version of `Win32` is required by
      `semaphore-compat`. Including `Win32` in the stage0 set requires also
      including `filepath` because otherwise Hadrian's dependency logic gets
      confused. Once our boot compiler has a newer version of `Win32` all of
      these will be able to be dropped.
      
      Resolves #24652
      
      (cherry picked from commit dd339c7a)
      3c22f5be
    • Teo Camarasu's avatar
      Make template-haskell a stage1 package · f3ce383c
      Teo Camarasu authored and Cheng Shao's avatar Cheng Shao committed
      
      Promoting template-haskell from a stage0 to a stage1 package means that
      we can much more easily refactor template-haskell.
      
      We implement this by duplicating the in-tree `template-haskell`.
      A new `template-haskell-next` library is autogenerated to mirror `template-haskell`
      `stage1:ghc` to depend on the new interface of the library including the
      `Binary` instances without adding an explicit dependency on `template-haskell`.
      
      This is controlled by the `bootstrap-th` cabal flag
      
      When building `template-haskell` modules as part of this vendoring we do
      not have access to quote syntax, so we cannot use variable quote
      notation (`'Just`). So we either replace these with hand-written `Name`s
      or hide the code behind CPP.
      
      We can remove the `th_hack` from hadrian, which was required when
      building stage0 packages using the in-tree `template-haskell` library.
      
      For more details see Note [Bootstrapping Template Haskell].
      
      Resolves #23536
      
      Co-Authored-By: default avatarSebastian Graf <sgraf1337@gmail.com>
      Co-Authored-By: default avatarMatthew Craven <5086-clyring@users.noreply.gitlab.haskell.org>
      (cherry picked from commit 42bd0407)
      f3ce383c
    • Cheng Shao's avatar
      Revert "hadrian: Refactor treatment of extra dependencies" · 39bc9621
      Cheng Shao authored
      This reverts commit 3a18d9e7.
      39bc9621
Loading