diff options
author | Moritz Angermann <moritz.angermann@gmail.com> | 2017-03-06 17:31:04 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-03-06 18:51:03 -0500 |
commit | 1686f30951292e94bf3076ce8b3eafb0bcbba91d (patch) | |
tree | 72ef3e65e10c6d446c65e2988ab07b2f120c4e2e /compiler/llvmGen/LlvmMangler.hs | |
parent | 2fa44217c1d9722227297eefb0d6c6aed7e128ca (diff) | |
download | haskell-1686f30951292e94bf3076ce8b3eafb0bcbba91d.tar.gz |
Mangle .subsections_via_symbols away.
This is a rather stupid mangler hack. However, when using prefix data
with llvm, on systems that support -dead_strip (macOS, iOS), the prefix
data is stipped.
llvm generiously adds .subsections_via_symbols for macho in any case.
Thus we use our trusted mangler to drop the .subsections_via_symbols
line from the assembly.
This ultimately means that for (macOS, llvm), and (iOS, llvm) will not
benefit from -dead_strip. Yet, this patch will allow building ghc on
macOS again.
Test Plan: build ghc with llvm on macOS
Reviewers: rwbarton, bgamari, austin
Reviewed By: rwbarton, bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D3287
Diffstat (limited to 'compiler/llvmGen/LlvmMangler.hs')
-rw-r--r-- | compiler/llvmGen/LlvmMangler.hs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/llvmGen/LlvmMangler.hs b/compiler/llvmGen/LlvmMangler.hs index acf344fe2d..eed13ba203 100644 --- a/compiler/llvmGen/LlvmMangler.hs +++ b/compiler/llvmGen/LlvmMangler.hs @@ -47,11 +47,20 @@ type Rewrite = DynFlags -> B.ByteString -> Maybe B.ByteString -- | Rewrite a line of assembly source with the given rewrites, -- taking the first rewrite that applies. rewriteLine :: DynFlags -> [Rewrite] -> B.ByteString -> B.ByteString -rewriteLine dflags rewrites l = +rewriteLine dflags rewrites l + -- We disable .subsections_via_symbols on darwin and ios, as the llvm code + -- gen uses prefix data for the info table. This however does not prevent + -- llvm from generating .subsections_via_symbols, which in turn with + -- -dead_strip, strips the info tables, and therefore breaks ghc. + | isSubsectionsViaSymbols l = + (B.pack "## no .subsection_via_symbols for ghc. We need our info tables!") + | otherwise = case firstJust $ map (\rewrite -> rewrite dflags rest) rewrites of Nothing -> l Just rewritten -> B.concat $ [symbol, B.pack "\t", rewritten] where + isSubsectionsViaSymbols = B.isPrefixOf (B.pack ".subsections_via_symbols") + (symbol, rest) = splitLine l firstJust :: [Maybe a] -> Maybe a |