[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 4 commits: hadrian: disable PIC for in-tree GMP on wasm32
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Sun Jun 2 11:01:51 UTC 2024
Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
Commits:
2dab6368 by Cheng Shao at 2024-06-02T07:01:38-04:00
hadrian: disable PIC for in-tree GMP on wasm32
This patch disables PIC for in-tree GMP on wasm32 target. Enabling PIC
unconditionally adds undesired code size and runtime overhead for
wasm32.
- - - - -
b6c5b6ee by Cheng Shao at 2024-06-02T07:01:38-04:00
hadrian: disable in-tree gmp fft code path for wasm32
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.
- - - - -
26bf70a8 by Cheng Shao at 2024-06-02T07:01:38-04:00
hadrian: build in-tree GMP with malloc-notreentrant on wasm32
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.
- - - - -
dd0c1732 by ARATA Mizuki at 2024-06-02T07:01:44-04:00
Set package include paths when assembling .S files
Fixes #24839.
Co-authored-by: Sylvain Henry <hsyl20 at gmail.com>
- - - - -
6 changed files:
- compiler/GHC/Driver/Pipeline/Execute.hs
- hadrian/src/Settings/Builders/Configure.hs
- + testsuite/tests/driver/T24839.hs
- + testsuite/tests/driver/T24839.stdout
- testsuite/tests/driver/all.T
- + testsuite/tests/driver/t24839_sub.S
Changes:
=====================================
compiler/GHC/Driver/Pipeline/Execute.hs
=====================================
@@ -290,6 +290,7 @@ runGenericAsPhase :: (Logger -> DynFlags -> [Option] -> IO ()) -> [Option] -> Bo
runGenericAsPhase run_as extra_opts with_cpp pipe_env hsc_env location input_fn = do
let dflags = hsc_dflags hsc_env
let logger = hsc_logger hsc_env
+ let unit_env = hsc_unit_env hsc_env
let cmdline_include_paths = includePaths dflags
let pic_c_flags = picCCOpts dflags
@@ -300,16 +301,21 @@ runGenericAsPhase run_as extra_opts with_cpp pipe_env hsc_env location input_fn
-- might be a hierarchical module.
createDirectoryIfMissing True (takeDirectory output_fn)
- let global_includes = [ GHC.SysTools.Option ("-I" ++ p)
- | p <- includePathsGlobal cmdline_include_paths ]
- let local_includes = [ GHC.SysTools.Option ("-iquote" ++ p)
- | p <- includePathsQuote cmdline_include_paths ++
- includePathsQuoteImplicit cmdline_include_paths]
+ -- add package include paths
+ all_includes <- if not with_cpp
+ then pure []
+ else do
+ pkg_include_dirs <- mayThrowUnitErr (collectIncludeDirs <$> preloadUnitsInfo unit_env)
+ let global_includes = [ GHC.SysTools.Option ("-I" ++ p)
+ | p <- includePathsGlobal cmdline_include_paths ++ pkg_include_dirs]
+ let local_includes = [ GHC.SysTools.Option ("-iquote" ++ p)
+ | p <- includePathsQuote cmdline_include_paths ++ includePathsQuoteImplicit cmdline_include_paths]
+ pure (local_includes ++ global_includes)
let runAssembler inputFilename outputFilename
= withAtomicRename outputFilename $ \temp_outputFilename ->
run_as
logger dflags
- (local_includes ++ global_includes
+ (all_includes
-- See Note [-fPIC for assembler]
++ map GHC.SysTools.Option pic_c_flags
-- See Note [Produce big objects on Windows]
=====================================
hadrian/src/Settings/Builders/Configure.hs
=====================================
@@ -15,16 +15,23 @@ configureBuilderArgs = do
targetPlatform <- queryTarget targetPlatformTriple
buildPlatform <- queryBuild targetPlatformTriple
pure $ [ "--enable-shared=no"
- , "--with-pic=yes"
, "--host=" ++ targetPlatform -- GMP's host is our target
, "--build=" ++ buildPlatform ]
+ -- Disable FFT logic on wasm32, sacrifice
+ -- performance of multiplying very large operands
+ -- to save code size
+ <> [ "--disable-fft" | targetArch == "wasm32" ]
-- Disable GMP's alloca usage on wasm32, it may
-- cause stack overflow (#22602) due to the
-- rather small 64KB default stack size. See
-- https://gmplib.org/manual/Build-Options for
-- more detailed explanation of this configure
-- option.
- <> [ "--enable-alloca=malloc-reentrant" | targetArch == "wasm32" ]
+ <> [ "--enable-alloca=malloc-notreentrant" | targetArch == "wasm32" ]
+ -- Enable PIC unless target is wasm32, in which
+ -- case we don't want libgmp.a to be bloated due
+ -- to PIC overhead.
+ <> [ "--with-pic=yes" | targetArch /= "wasm32" ]
, builder (Configure libffiPath) ? do
top <- expr topDirectory
=====================================
testsuite/tests/driver/T24839.hs
=====================================
@@ -0,0 +1,8 @@
+import Data.Int
+import Foreign.Ptr
+import Foreign.Storable
+
+foreign import ccall "&" foo :: Ptr Int64
+
+main :: IO ()
+main = peek foo >>= print
=====================================
testsuite/tests/driver/T24839.stdout
=====================================
@@ -0,0 +1 @@
+24839
=====================================
testsuite/tests/driver/all.T
=====================================
@@ -327,3 +327,4 @@ test('T23339B', [extra_files(['T23339.hs']), req_c], makefile_test, [])
test('T23613', normal, compile_and_run, ['-this-unit-id=foo'])
test('T23944', [unless(have_dynamic(), skip), extra_files(['T23944A.hs'])], multimod_compile, ['T23944 T23944A', '-fprefer-byte-code -fbyte-code -fno-code -dynamic-too -fwrite-interface'])
test('T24286', [cxx_src, unless(have_profiling(), skip), extra_files(['T24286.cpp'])], compile, ['-prof -no-hs-main'])
+test('T24839', [unless(arch('x86_64') or arch('aarch64'), skip), extra_files(["t24839_sub.S"])], compile_and_run, ['t24839_sub.S'])
=====================================
testsuite/tests/driver/t24839_sub.S
=====================================
@@ -0,0 +1,10 @@
+/* Note that the filename must begin with a lowercase letter, because GHC thinks it as a module name otherwise. */
+#include "ghcconfig.h"
+#if LEADING_UNDERSCORE
+ .globl _foo
+_foo:
+#else
+ .globl foo
+foo:
+#endif
+ .quad 24839
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6304030eacb0bd3acab5f8589dd25e3f286c65d9...dd0c1732c5f51bd946ba7b79ad965af3e283e5bd
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6304030eacb0bd3acab5f8589dd25e3f286c65d9...dd0c1732c5f51bd946ba7b79ad965af3e283e5bd
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240602/8a74fa54/attachment-0001.html>
More information about the ghc-commits
mailing list