From 065419affb4346bb81e91f8260e531a6e2342fa5 Mon Sep 17 00:00:00 2001 From: Matthew Pickering Date: Fri, 25 Feb 2022 16:07:33 +0000 Subject: linking: Don't pass --hash-size and --reduce-memory-overhead to ld These flags were added to help with the high linking cost of the old split-objs mode. Now we are using split-sections these flags appear to make no difference to memory usage or time taken to link. I tested various configurations linking together the ghc library with -split-sections enabled. | linker | time (s) | | ------ | ------ | | gold | 0.95 | | ld | 1.6 | | ld (hash-size = 31, reduce-memory-overheads) | 1.6 | | ldd | 0.47 | Fixes #20967 --- compiler/GHC/SysTools/Info.hs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/compiler/GHC/SysTools/Info.hs b/compiler/GHC/SysTools/Info.hs index 81650495ba..580e76ab8e 100644 --- a/compiler/GHC/SysTools/Info.hs +++ b/compiler/GHC/SysTools/Info.hs @@ -31,9 +31,7 @@ See also: #5240, #6063, #10110 Before 'runLink', we need to be sure to get the relevant information about the linker we're using at runtime to see if we need any extra -options. For example, GNU ld requires '--reduce-memory-overheads' and -'--hash-size=31' in order to use reasonable amounts of memory (see -trac #5240.) But this isn't supported in GNU gold. +options. Generally, the linker changing from what was detected at ./configure time has always been possible using -pgml, but on Linux it can happen @@ -127,13 +125,8 @@ getLinkerInfo' logger dflags = do -- Try to grab the info from the process output. parseLinkerInfo stdo _stde _exitc | any ("GNU ld" `isPrefixOf`) stdo = - -- GNU ld specifically needs to use less memory. This especially - -- hurts on small object files. #5240. -- Set DT_NEEDED for all shared libraries. #10110. - -- TODO: Investigate if these help or hurt when using split sections. - return (GnuLD $ map Option ["-Wl,--hash-size=31", - "-Wl,--reduce-memory-overheads", - -- ELF specific flag + return (GnuLD $ map Option [-- ELF specific flag -- see Note [ELF needed shared libs] "-Wl,--no-as-needed"]) @@ -173,12 +166,9 @@ getLinkerInfo' logger dflags = do -- Process creation is also fairly expensive on win32, so -- we short-circuit here. return $ GnuLD $ map Option - [ -- Reduce ld memory usage - "-Wl,--hash-size=31" - , "-Wl,--reduce-memory-overheads" - -- Emit gcc stack checks + [ -- Emit gcc stack checks -- See Note [Windows stack allocations] - , "-fstack-check" + "-fstack-check" -- Force static linking of libGCC -- See Note [Windows static libGCC] , "-static-libgcc" ] -- cgit v1.2.1