Skip to content
Snippets Groups Projects
  1. Feb 06, 2025
    • Cheng Shao's avatar
      hadrian: fix bindist executable wrapper logic for cross targets · 295759bf
      Cheng Shao authored
      This commit fixes an oversight of hadrian wrapper generation logic:
      when doing cross compilation, `wrapper` is called on executable names
      with cross prefix, therefore we must use `isSuffixOf` when matching to
      take the cross prefix into account. Also add missing cross prefix to
      ghci wrapper content and fix hsc2hs wrapper logic.
      
      (cherry picked from commit b57c2174cf8b4804d400c7db774565b2be4ff493)
      295759bf
    • Cheng Shao's avatar
      hadrian: add the host_fully_static flavour transformer · c7ebad0f
      Cheng Shao authored
      This commit adds the host_fully_static flavour transformer to hadrian,
      which ensures stage0 is fully statically linked while still permitting
      stage1 libdir to contain shared libraries. This is intended to be used
      by the wasm backend to build portable linux bindists that contain wasm
      shared libraries.
      
      (cherry picked from commit b45080a3)
      (cherry picked from commit 91c0dbd4)
      (cherry picked from commit e077d581)
      c7ebad0f
    • Cheng Shao's avatar
      hadrian: disable internal-interpreter of ghc library when cross compiling · 01228288
      Cheng Shao authored
      This commit disable the internal-interpreter flag of ghc library when
      cross compiling, only external interpreter works in such cases.
      
      (cherry picked from commit f232c872)
      (cherry picked from commit 4e7d0cee)
      (cherry picked from commit 624335b2)
      01228288
    • Cheng Shao's avatar
      hadrian: remove unused ghciWithDebugger field from flavour config · 6209333d
      Cheng Shao authored
      This patch removes the ghciWithDebugger field from flavour config
      since it's actually not used anywhere.
      
      (cherry picked from commit c6e5fd3d)
      (cherry picked from commit 022d7565)
      (cherry picked from commit f8c17232)
      6209333d
    • Cheng Shao's avatar
      hadrian: build in-tree GMP with malloc-notreentrant on wasm32 · a3dde201
      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)
      (cherry picked from commit 0f9a8aaf)
      (cherry picked from commit 3c4f945a)
      a3dde201
    • Cheng Shao's avatar
      hadrian: disable in-tree gmp fft code path for wasm32 · 993e2946
      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)
      (cherry picked from commit 097ea6e2)
      (cherry picked from commit 0dac58e1)
      993e2946
    • Cheng Shao's avatar
      hadrian: disable PIC for in-tree GMP on wasm32 · c7faa919
      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)
      (cherry picked from commit f45b02a8)
      c7faa919
    • Cheng Shao's avatar
      hadrian: handle findExecutable "" gracefully · 2ee67f47
      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)
      (cherry picked from commit 10a74dcd)
      2ee67f47
    • Cheng Shao's avatar
      hadrian: build C/C++ with split sections when enabled · da656acd
      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)
      (cherry picked from commit 6de1c17d)
      da656acd
    • Cheng Shao's avatar
      autoconf: remove obsolete patch detection · c325e98c
      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)
      (cherry picked from commit e5506d09)
      c325e98c
    • Cheng Shao's avatar
      hadrian: remove obsolete Patch logic · 5c7b632a
      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)
      (cherry picked from commit e3d00525)
      5c7b632a
    • Cheng Shao's avatar
      utils: remove unused lndir from tree · fd781247
      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)
      (cherry picked from commit 04860c24)
      fd781247
    • Cheng Shao's avatar
      hadrian/hie-bios: pass -j to hadrian · 9aa04c3a
      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)
      (cherry picked from commit 57d706ed)
      9aa04c3a
    • Cheng Shao's avatar
      testsuite: add the req_ghc_with_threaded_rts predicate · ad9838c8
      Cheng Shao authored
      This patch adds the req_ghc_with_threaded_rts predicate to the
      testsuite to assert the platform has threaded RTS, and mark some tests
      as req_ghc_with_threaded_rts. Also makes ghc_with_threaded_rts a
      config field instead of a global variable.
      
      (cherry picked from commit aa6afe8a)
      ad9838c8
    • Cheng Shao's avatar
      testsuite: fix req_target_smp predicate · b83c00c4
      Cheng Shao authored
      (cherry picked from commit a580722e)
      (cherry picked from commit 4f317bfd)
      (cherry picked from commit d94d0176)
      b83c00c4
    • Sylvain Henry's avatar
      testsuite: req_smp --> req_target_smp, req_ghc_smp · 73528452
      Sylvain Henry authored and Cheng Shao's avatar Cheng Shao committed
      See #22630 and !9552
      
      This commit:
       - splits req_smp into req_target_smp and req_ghc_smp
       - changes the testsuite driver to calculate req_ghc_smp
       - changes a handful of tests to use req_target_smp instead of req_smp
       - changes a handful of tests to use req_host_smp when needed
      
      The problem:
       - the problem this solves is the ambiguity surrounding req_smp
       - on master req_smp was used to express the constraint that the program
       being compiled supports smp _and_ that the host RTS (i.e., the RTS used
       to compile the program) supported smp. Normally that is fine, but in
       cross compilation this is not always the case as was discovered in #22630.
      
      The solution:
       - Differentiate the two constraints:
         - use req_target_smp to say the RTS the compiled program is linked
         with (and the platform) supports smp
         - use req_host_smp to say the RTS the host is linked with supports smp
      
      WIP: fix req_smp (target vs ghc)
      
      add flag to separate bootstrapper
      
      split req_smp -> req_target_smp and req_ghc_smp
      
      update tests smp flags
      
      cleanup and add some docstrings
      
      only set ghc_with_smp to bootstrapper on S1 or CC
      
      Only set ghc_with_smp to bootstrapperWithSMP of when testing stage 1
      and cross compiling
      
      test the RTS in config/ghc not hadrian
      
      re-add ghc_with_smp
      
      fix and align req names
      
      fix T11760 to use req_host_smp
      
      test the rts directly, avoid python 3.5 limitation
      
      test the compiler in a try block
      
      align out of tree and in tree withSMP flags
      
      mark failing tests as host req smp
      
      testsuite: req_host_smp --> req_ghc_smp
      
      Fix ghc vs host, fix ghc_with_smp leftover
      
      (cherry picked from commit 06036d93)
      73528452
    • Cheng Shao's avatar
      fbf44f0a
    • Cheng Shao's avatar
      rts: always build 64-bit atomic ops · 59e7a38f
      Cheng Shao authored
      This patch does a few things:
      
      - Always build 64-bit atomic ops in rts/ghc-prim, even on 32-bit
        platforms
      - Remove legacy "64bit" cabal flag of rts package
      - Fix hs_xchg64 function prototype for 32-bit platforms
      - Fix AtomicFetch test for wasm32
      
      (cherry picked from commit 87095f6a)
      59e7a38f
    • Ben Gamari's avatar
      hadrian: Pass CROSS_EMULATOR to runtests.py · ae967fde
      Ben Gamari authored and Cheng Shao's avatar Cheng Shao committed
      (cherry picked from commit ee160d06)
      ae967fde
    • amesgen's avatar
      Fix unlit path in cross bindists · e9807aa7
      amesgen authored and Cheng Shao's avatar Cheng Shao committed
      (cherry picked from commit 8fde4ac8)
      e9807aa7
  2. Jan 27, 2025
  3. Jan 16, 2025
  4. Jun 28, 2024
    • Cheng Shao's avatar
      hadrian: fix no_dynamic_libs flavour transformer · 52235ada
      Cheng Shao authored and Zubin's avatar Zubin committed
      This patch fixes the no_dynamic_libs flavour transformer and make
      fully_static reuse it. Previously building with no_dynamic_libs fails
      since ghc program is still dynamic and transitively brings in dyn ways
      of rts which are produced by no rules.
      
      (cherry picked from commit 1bb24432)
      52235ada
  5. Jun 25, 2024
    • Matthew Pickering's avatar
      Don't depend on registerPackage function in Cabal · bf9b110b
      Matthew Pickering authored and Zubin's avatar Zubin committed
      More recent versions of Cabal modify the behaviour of libAbiHash which
      breaks our usage of registerPackage.
      
      It is simpler to inline the part of registerPackage that we need and
      avoid any additional dependency and complication using the higher-level
      function introduces.
      
      (cherry picked from commit 3fff0977)
      bf9b110b
  6. Apr 15, 2024
    • Hannes Siebenhandl's avatar
      Escape multiple arguments in the settings file · d74ffbbb
      Hannes Siebenhandl authored and Zubin's avatar Zubin committed
      Uses responseFile syntax.
      
      The issue arises when GHC is installed on windows into a location that
      has a space, for example the user name is 'Fake User'.
      The $topdir will also contain a space, consequentially.
      When we resolve the top dir in the string `-I$topdir/mingw/include`,
      then `words` will turn this single argument into `-I/C/Users/Fake` and
      `User/.../mingw/include` which trips up the flag argument parser of
      various tools such as gcc or clang.
      We avoid this by escaping the $topdir before replacing it in
      `initSettngs`.
      Additionally, we allow to escape spaces and quotation marks for
      arguments in `settings` file.
      
      Add regression test case to count the number of options after variable
      expansion and argument escaping took place.
      Additionally, we check that escaped spaces and double quotation marks are
      correctly parsed.
      
      (cherry picked from commit 31bf85ee)
      d74ffbbb
  7. Apr 02, 2024
    • Ben Gamari's avatar
      hadrian: Generate HSC2HS_EXTRAS variable in bindist installation · a4767444
      Ben Gamari authored and Zubin's avatar Zubin committed
      We must generate the hsc2hs wrapper at bindist installation time since
      it must contain `--lflag` and `--cflag` arguments which depend upon the
      installation path.
      
      The solution here is to substitute these variables in the configure
      script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in
      the install rules.
      
      Fixes #24050.
      
      (cherry picked from commit efcbad2d)
      (cherry picked from commit 2eca9c7a)
      a4767444
    • Cheng Shao's avatar
      Fix genapply for cross-compilation by nuking fragile CPP logic · a1bf252e
      Cheng Shao authored and Zubin's avatar Zubin committed
      This commit fixes incorrectly built genapply when cross compiling
      (#24347) by nuking all fragile CPP logic in it from the orbit. All
      target-specific info are now read from DerivedConstants.h at runtime,
      see added note for details. Also removes a legacy Makefile and adds
      haskell language server support for genapply.
      
      (cherry picked from commit dd4af0e5)
      a1bf252e
    • PHO's avatar
      Don't assume the current locale is *.UTF-8, set the encoding explicitly · 69b6dcb7
      PHO authored and Zubin's avatar Zubin committed
      primops.txt contains Unicode characters:
      > LC_ALL=C ./genprimopcode --data-decl < ./primops.txt
      > genprimopcode: <stdin>: hGetContents: invalid argument (cannot decode byte sequence starting from 226)
      
      Hadrian must also avoid using readFile' to read primops.txt because it
      tries to decode the file with a locale-specific encoding.
      
      (cherry picked from commit 52c0fc69)
      69b6dcb7
    • Matthew Pickering's avatar
      testsuite: Add wasm32 to testsuite arches with NCG · 8bfaa7a4
      Matthew Pickering authored and Zubin's avatar Zubin committed
      The compiler --info reports that wasm32 compilers have a NCG, so we
      should agree with that here.
      
      (cherry picked from commit 1b90735c)
      8bfaa7a4
  8. Dec 18, 2023
    • Rodrigo Mesquita's avatar
      darwin: Fix single_module is obsolete warning · 273f5a3f
      Rodrigo Mesquita authored and Zubin's avatar Zubin committed
      In XCode 15's linker, -single_module is the default and otherwise
      passing it as a flag results in a warning being raised:
      
          ld: warning: -single_module is obsolete
      
      This patch fixes this warning by, at configure time, determining whether
      the linker supports -single_module (which is likely false for all
      non-darwin linkers, and true for darwin linkers in previous versions of
      macOS), and using that information at runtime to decide to pass or not
      the flag in the invocation.
      
      Fixes #24168
      
      (cherry picked from commit e6c803f7)
      273f5a3f
  9. Dec 15, 2023
  10. Dec 13, 2023
    • Ilias Tsitsimpis's avatar
      hadrian: Pass -DNOSMP to C compiler when needed · 54617f3b
      Ilias Tsitsimpis authored and Zubin's avatar Zubin committed
      Hadrian passes the -DNOSMP flag to GHC when the target doesn't support
      SMP, but doesn't pass it to CC as well, leading to the following
      compilation error on mips64el:
      
      | Run Cc (FindCDependencies CDep) Stage1: rts/sm/NonMovingScav.c => _build/stage1/rts/build/c/sm/NonMovingScav.o.d
      Command line: /usr/bin/mips64el-linux-gnuabi64-gcc -E -MM -MG -MF _build/stage1/rts/build/c/hooks/FlagDefaults.thr_debug_p_o.d -MT _build/stage1/rts/build/c/hooks/FlagDefaults.o -Irts/include -I_build/stage1/rts/build -I_build/stage1/rts/build/include -Irts/include -x c rts/hooks/FlagDefaults.c -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Winline -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls -Wundef -fno-strict-aliasing -DTHREADED_RTS -DDEBUG -fomit-frame-pointer -O2 -g -Irts -I_build/stage1/rts/build -DDEBUG -fno-omit-frame-pointer -g3 -O0
      ===> Command failed with error code: 1
      In file included from rts/include/Stg.h:348,
                       from rts/include/Rts.h:38,
                       from rts/hooks/FlagDefaults.c:8:
      rts/include/stg/SMP.h:416:2: error: #error memory barriers unimplemented on this architecture
        416 | #error memory barriers unimplemented on this architecture
            |  ^~~~~
      rts/include/stg/SMP.h:440:2: error: #error memory barriers unimplemented on this architecture
        440 | #error memory barriers unimplemented on this architecture
            |  ^~~~~
      rts/include/stg/SMP.h:464:2: error: #error memory barriers unimplemented on this architecture
        464 | #error memory barriers unimplemented on this architecture
            |  ^~~~~
      
      The old make system correctly passed this flag to both GHC and CC [1].
      
      Fix this error by passing -DNOSMP to CC as well.
      
      [1] https://gitlab.haskell.org/ghc/ghc/-/blob/00920f176b0235d5bb52a8e054d89a664f8938fe/rts/ghc.mk#L407
      
      Closes #24082
      
      (cherry picked from commit 257c2807)
      (cherry picked from commit b2a03315f6336e2708ff54689f2241eb38198dd5)
      54617f3b
    • Sylvain Henry's avatar
      Hadrian: enable `-fcheck-prim-bounds` in validate flavour · d5de8a2a
      Sylvain Henry authored and Zubin's avatar Zubin committed
      This allows T24066 to fail when the bug is present.
      
      Otherwise the out-of-bound access isn't detected as it happens in
      ghc-bignum which wasn't compiled with the bounds check.
      
      (cherry picked from commit 72c7380c)
      d5de8a2a
  11. Sep 19, 2023
  12. Sep 13, 2023
    • Ben Gamari's avatar
      hadrian: Ensure that way-flags are passed to CC · 36dc5121
      Ben Gamari authored and Zubin's avatar Zubin committed
      Previously the way-specific compilation flags (e.g. `-DDEBUG`,
      `-DTHREADED_RTS`) would not be passed to the CC invocations. This meant
      that C dependency files would not correctly reflect
      dependencies predicated on the way, resulting in the rather
      painful #23554.
      
      Closes #23554.
      
      (cherry picked from commit cca74dab)
Loading