Commit 4facbfd8 authored by jberryman's avatar jberryman

Rough LLVM/clang LTO WIP

`StgReturn` and `StgRun` defined with inline ASM are not making it into archive
built from `StgCRun.thr_o`, which is an LLVM bitcode LTO object.

(see commented .ll file)

After getting most of way through a build, did:

- used `llc` to compile `rts/dist/build/StgCRun.thr_o` and inspected assembly file
- copy-pasted code into textual IR (from `llvm-dis`) and removed wrapper function
   https://releases.llvm.org/6.0.0/docs/LangRef.html#moduleasm
- convert back into bitcode IR using `llvm-as rts/dist/build/StgCRun.thr_o.ll`
- re-run the `ar` command

It took a lot of other tweaking and trial and error to complete a build
though, so it's likely the state of repo here won't actually complete
successfully.

TODO for moar-LTO:
- bypass mangler with -fast-llvm (which for some reason seems not to
break things..?)
- shim `llc` to be a simple `cp`
- add flags to clang shim :  -O2 -mrelocation-model=static -msse -msse2

This will hopefully allow cross-module optimization of fllvm haskell,
e.g. more of our `libraries/*`
parent 41ec5884
#!/bin/bash
# YOU DON'T NEED THIS (and it doesn't work)
# Also point to liblto_plugin.so directly (not sure if necessary; I thought we sorted this out...)
# https://stackoverflow.com/questions/46934111/which-is-the-correct-way-to-build-a-static-library-with-link-time-code-generatio/46935769
# I don't think --plugin is necessary now that we fixed symlink...
#exec /usr/bin/ar -T --plugin /usr/lib/gcc/x86_64-linux-gnu/6/liblto_plugin.so ${1+"$@"}
# https://stackoverflow.com/questions/24733986/gcc-lto-shared-library-am-i-right
export PATH=/usr/local/bin:/usr/bin:/bin
exec /usr/bin/gcc-ar ${1+"$@"}
echo "$@" >> /tmp/hlint-lto-ar.out
# https://releases.llvm.org/6.0.0/docs/GoldPlugin.html#quickstart-for-using-lto-with-autotooled-projects
#exec /usr/lib/llvm-6.0/bin/llvm-ar ${1+"$@"}
# Try newer `ar` (doesn't seem to help undefined StgReturn when making libHSrts_thr.a)
# Not sure if version mismatch is a problem here, but older is incompatible with GNU ar:
exec /usr/lib/llvm-9/bin/llvm-ar ${1+"$@"}
#!/bin/bash
# Hack to strip DWARF debug, see
# https://bugzilla.redhat.com/show_bug.cgi?id=436374
# https://sourceware.org/bugzilla/show_bug.cgi?id=6428
exec /usr/bin/as ${1+$(echo "$@" | sed "s/--gdwarf2//g")}
#!/bin/bash
# -fno-semantic-interposition is apparently default, but at least not recognized in clang-6
echo ${1+"$@"} >> /tmp/clang.out.hask
#exec /usr/lib/llvm-6.0/bin/clang -flto -gline-tables-only ${1+"$@"}
if [[ "$(pwd)" == *"/libffi"* ]]; then
exec gcc ${1+"$@"}
# Trying to ignore `-traditional` just results in errors
elif [[ "$@" == *"assembler-with-cpp"* || "$@" == *"-traditional"* ]]; then
exec gcc ${1+"$@"}
# DIDN'T HELP
# elif [[ "$@" == *"-shared"* ]]; then
# echo SHAAAAAARED >> /tmp/clang.out
# exec /usr/lib/llvm-6.0/bin/clang -gline-tables-only ${1+"$@"}
else
# This we used somewhat successfully to build ghc:
#/usr/lib/llvm-6.0/bin/clang -flto -gline-tables-only ${1+$(echo "$@" | sed "s/-x assembler /-x ir /g")} || /usr/lib/llvm-6.0/bin/clang -flto -gline-tables-only ${1+"$@"}
# This we're trying in conjunction with llc shim for building haskell projects:
# Copying some flags from `llc` invocation,
/usr/lib/llvm-6.0/bin/clang -flto -gline-tables-only -O2 -msse -msse2 ${1+$(echo "$@" | sed "s/-x assembler /-x ir /g")}
# -mllvm '-relocation-model=static'
# ^ doesn't work
fi
#!/bin/bash
#
# - Try to silence LTO type error: -Wno-lto-type-mismatch
# - -fno-semantic-interposition , but see:
# $ ack HAS_VISIBILITY_HIDDEN -A4
# $ ack RTS_PRIVATE
# $ ack 'visibility.*default'
# It looks like these annotations are pretty sparse so maybe good idea!
# https://kristerw.blogspot.com/2016/11/inlining-shared-libraries-are-special.html
# https://stackoverflow.com/questions/35745543/new-option-in-gcc-5-3-fno-semantic-interposition
# - add (maybe pointless) -O2 -Wl,-O2 for link/compile in built binaries
# These should be unnecessary, at least in later gccs...
# - add -Wno-sync-nand
# See note in: libraries/ghc-prim/cbits/atomic.c
# - this seems to do nothing... nor -Wno-error ...
## NOTE! with -fno-fat-lto-objects (but with LTO) we erroneously get ".subsections_via_symbols... yes" in configure
exec /usr/bin/gcc -Wno-sync-nand -O2 -Wl,-O2 -grecord-gcc-switches -fno-semantic-interposition -Wno-lto-type-mismatch -flto -fno-fat-lto-objects -g1 -time=/tmp/gcc_lto_shim_build.nofat3.hello ${1+"$@"}
# NOTE: Use -ffat-lto-objects instead to (hopefully) create e.g. a bindist that
# will work normally if the user doesn't have a working gcc LTO setup
# We use nofat above so that things don't just quietly work when LTO is
# misconfigured/fubar
# DISABLED FOR NOW SINCE WE GET ERRORS RIGHT AWAY
# Big hammer, make sure we use clang always; not sure if necessary.
exec clang ${1+"$@"}
#!/bin/bash
ld.lld ${1+"$@"}
lld
\ No newline at end of file
#!/bin/bash
/usr/lib/llvm-6.0/bin/ld.lld ${1+"$@"}
# (doesn't seem to help undefined StgReturn when making libHSrts_thr.a):
#/usr/lib/llvm-9/bin/ld.lld ${1+"$@"}
#!/bin/bash
# It seemed like there was some fuckery with 'lld' I had trouble working around with ./config opts
exec gold ${1+"$@"}
/usr/lib/llvm-6.0/bin/ld.lld ${1+"$@"}
# (doesn't seem to help undefined StgReturn when making libHSrts_thr.a):
#/usr/lib/llvm-9/bin/ld.lld ${1+"$@"}
#!/bin/bash
# https://releases.llvm.org/6.0.0/docs/GoldPlugin.html#quickstart-for-using-lto-with-autotooled-projects
exec /usr/lib/llvm-6.0/bin/llvm-nm ${1+"$@"}
#!/bin/bash
# I think this is probably unnecessary now that we set up the plugin symlink:
# https://stackoverflow.com/questions/25878407/how-can-i-use-lto-with-static-libraries
export PATH=/usr/local/bin:/usr/bin:/bin
exec /usr/bin/gcc-ranlib ${1+"$@"}
# https://releases.llvm.org/6.0.0/docs/GoldPlugin.html#quickstart-for-using-lto-with-autotooled-projects
#exec /bin/true
exec /usr/lib/llvm-6.0/bin/llvm-ranlib ${1+"$@"}
......@@ -25,14 +25,12 @@
# define RTS_THUNK_INFO(i) extern const W_(i)[]
# define RTS_INFO(i) extern const W_(i)[]
# define RTS_CLOSURE(i) extern W_(i)[]
# define RTS_FUN_DECL(f) extern DLL_IMPORT_RTS StgFunPtr f(void)
#else
# define RTS_RET_INFO(i) extern DLL_IMPORT_RTS const StgRetInfoTable i
# define RTS_FUN_INFO(i) extern DLL_IMPORT_RTS const StgFunInfoTable i
# define RTS_THUNK_INFO(i) extern DLL_IMPORT_RTS const StgThunkInfoTable i
# define RTS_INFO(i) extern DLL_IMPORT_RTS const StgInfoTable i
# define RTS_CLOSURE(i) extern DLL_IMPORT_RTS StgClosure i
# define RTS_FUN_DECL(f) extern DLL_IMPORT_RTS StgFunPtr f(void)
#endif
#if defined(TABLES_NEXT_TO_CODE)
......@@ -46,6 +44,8 @@
# define RTS_FUN(f) RTS_FUN_INFO(f##_info); RTS_FUN_DECL(f##_entry)
# define RTS_THUNK(f) RTS_THUNK_INFO(f##_info); RTS_FUN_DECL(f##_entry)
#endif
// Again, trying to work around undefined reference issues
# define RTS_FUN_DECL(f) extern DLL_IMPORT_RTS StgFunPtr __attribute__((used)) f(void)
/* Stack frames */
RTS_RET(stg_upd_frame);
......
......@@ -8,10 +8,10 @@
# Uncomment one of these to select a build profile below:
# Full build with max optimisation and everything enabled (very slow build)
BuildFlavour = perf
#BuildFlavour = perf
# As above but build GHC using the LLVM backend
#BuildFlavour = perf-llvm
BuildFlavour = perf-llvm
# Perf build configured for a cross-compiler (using the LLVM backend)
#BuildFlavour = perf-cross
......
......@@ -365,6 +365,24 @@ stack unwinding.
*/
// ATTEMPT WORKAROUND: https://bugs.llvm.org/show_bug.cgi?id=28218
//
// else we get errors...
//
/* "inplace/bin/ghc-stage1" -o utils/iserv/stage2/build/tmp/ghc-iserv -hisuf hi -osuf o -hcsuf hc -static -O -H64m -fllvm -Wall -hide-all-packages -i -iutils/iserv/src -iutils/iserv/stage2/build -Iutils/iserv/stage2/build -iutils/iserv/stage2/build/iserv/autogen -Iutils/iserv/stage2/build/iserv/autogen -Iutils/iserv/. -Iutils/iserv/stage2/build/. -optP-include -optPutils/iserv/stage2/build/iserv/autogen/cabal_macros.h -package-id array-0.5.3.0 -package-id base-4.12.0.0 -package-id binary-0.8.6.0 -package-id bytestring-0.10.8.2 -package-id containers-0.6.0.1 -package-id deepseq-1.4.4.0 -package-id ghci-8.6.3 -package-id libiserv-8.6.3 -package-id unix-2.7.2.2 -no-hs-main -XHaskell2010 -threaded -optl-Wl,--export-dynamic -no-hs-main -no-user-package-db -rtsopts -Wnoncanonical-monad-instances -odir utils/iserv/stage2/build -hidir utils/iserv/stage2/build -stubdir utils/iserv/stage2/build -split-sections -static -O -H64m -fllvm -Wall -hide-all-packages -i -iutils/iserv/src -iutils/iserv/stage2/build -Iutils/iserv/stage2/build -iutils/iserv/stage2/build/iserv/autogen -Iutils/iserv/stage2/build/iserv/autogen -Iutils/iserv/. -Iutils/iserv/stage2/build/. -optP-include -optPutils/iserv/stage2/build/iserv/autogen/cabal_macros.h -package-id array-0.5.3.0 -package-id base-4.12.0.0 -package-id binary-0.8.6.0 -package-id bytestring-0.10.8.2 -package-id containers-0.6.0.1 -package-id deepseq-1.4.4.0 -package-id ghci-8.6.3 -package-id libiserv-8.6.3 -package-id unix-2.7.2.2 -no-hs-main -XHaskell2010 -threaded -optl-Wl,--export-dynamic -no-hs-main -no-user-package-db -rtsopts -Wnoncanonical-monad-instances utils/iserv/stage2/build/Main.o utils/iserv/stage2/build/cbits/iservmain.o */
/* Warning: -rtsopts and -with-rtsopts have no effect with -no-hs-main. */
/* Call hs_init_ghc() from your main() function to set these options. */
/* ld.lld: error: undefined symbol: StgReturn */
/* >>> referenced by ghc_8.s:29 */
/* >>> StgStartup.thr_o:(stg_stop_thread_info) in archive /home/me/Code/NOT_MY_CODE/ghc/rts/dist/build/libHSrts_thr.a */
static void dummmmmy(void) __attribute__((used));
static void dummmmmy(void) {
/* StgRunIsImplementedInAssembler(); */
StgRun(NULL, NULL);
StgReturn();
}
static void GNUC3_ATTRIBUTE(used)
StgRunIsImplementedInAssembler(void)
{
......
; ModuleID = 'rts/dist/build/StgCRun.thr_o'
source_filename = "rts/StgCRun.c"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
%struct.StgRegTable = type { %union.StgUnion, %union.StgUnion, %union.StgUnion, %union.StgUnion, %union.StgUnion, %union.StgUnion, %union.StgUnion, %union.StgUnion, %union.StgUnion, %union.StgUnion, float, float, float, float, float, float, double, double, double, double, double, double, %struct.StgWord128, %struct.StgWord128, %struct.StgWord128, %struct.StgWord128, %struct.StgWord128, %struct.StgWord128, %struct.StgWord256, %struct.StgWord256, %struct.StgWord256, %struct.StgWord256, %struct.StgWord256, %struct.StgWord256, %struct.StgWord512, %struct.StgWord512, %struct.StgWord512, %struct.StgWord512, %struct.StgWord512, %struct.StgWord512, i64, i64*, i64*, i64*, i64*, %struct.CostCentreStack_*, %struct.StgTSO_*, %struct.nursery_*, %struct.bdescr_*, %struct.bdescr_*, i64, i64 }
%union.StgUnion = type { i64 }
%struct.StgWord128 = type { i64, i64 }
%struct.StgWord256 = type { %struct.StgWord128, %struct.StgWord128 }
%struct.StgWord512 = type { %struct.StgWord256, %struct.StgWord256 }
%struct.CostCentreStack_ = type { i64, %struct.CostCentre_*, %struct.CostCentreStack_*, %struct.IndexTable_*, %struct.CostCentreStack_*, i64, i64, i64, i64, i64, i64, i64 }
%struct.CostCentre_ = type { i64, i8*, i8*, i8*, i64, i64, i64, %struct.CostCentre_* }
%struct.IndexTable_ = type opaque
%struct.StgTSO_ = type { %struct.StgHeader, %struct.StgTSO_*, %struct.StgTSO_*, %struct.StgStack_*, i16, i16, i32, %union.StgTSOBlockInfo, i32, i32, i32, %struct.InCall_*, %struct.Capability_*, %struct.StgTRecHeader_*, %struct.MessageThrowTo_*, %struct.StgBlockingQueue_*, i64, i32 }
%struct.StgHeader = type { %struct.StgInfoTable_* }
%struct.StgInfoTable_ = type { %union.StgClosureInfo, i32, i32, [0 x i8] }
%union.StgClosureInfo = type { i64 }
%struct.StgStack_ = type { %struct.StgHeader, i32, i32, i64*, [0 x i64] }
%union.StgTSOBlockInfo = type { %struct.StgClosure_* }
%struct.StgClosure_ = type { %struct.StgHeader, [0 x %struct.StgClosure_*] }
%struct.InCall_ = type { %struct.StgTSO_*, %struct.StgTSO_*, %struct.Capability_*, i32, %struct.StgClosure_**, %struct.Task_*, %struct.InCall_*, %struct.InCall_*, %struct.InCall_* }
%struct.Task_ = type { i64, i32, %union.pthread_cond_t, %union.pthread_mutex_t, i8, %struct.Capability_*, %struct.InCall_*, i32, %struct.InCall_*, i8, i8, i8, i32, %struct.Task_*, %struct.Task_*, %struct.Task_* }
%union.pthread_cond_t = type { %struct.anon.0 }
%struct.anon.0 = type { i32, i32, i64, i64, i64, i8*, i32, i32 }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { %struct.__pthread_internal_list*, %struct.__pthread_internal_list* }
%struct.Capability_ = type { %struct.StgFunTable, %struct.StgRegTable, i32, i32, %struct.Task_*, i8, i32, i8, %struct.StgTSO_*, %struct.StgTSO_*, i32, %struct.InCall_*, i32, %struct.bdescr_**, %struct.bdescr_**, %struct.bdescr_*, %struct.bdescr_*, %struct._StgWeak*, %struct._StgWeak*, i32, i32, i64, %struct.Task_*, i32, %union.pthread_mutex_t, %struct.Task_*, %struct.Task_*, i32, %struct.Message_*, %struct.PutMVar_*, %struct.WSDeque_*, %struct.SparkCounters, i32, %struct.StgTVarWatchQueue_*, %struct.StgTRecChunk_*, %struct.StgTRecHeader_*, i32, [12 x i8] }
%struct.StgFunTable = type { i64, i8* ()* ()*, i8* ()* ()* }
%struct._StgWeak = type { %struct.StgHeader, %struct.StgClosure_*, %struct.StgClosure_*, %struct.StgClosure_*, %struct.StgClosure_*, %struct._StgWeak* }
%struct.Message_ = type { %struct.StgHeader, %struct.Message_* }
%struct.PutMVar_ = type { i8*, %struct.PutMVar_* }
%struct.WSDeque_ = type { i64, i64, i64, i64, i64, i8** }
%struct.SparkCounters = type { i64, i64, i64, i64, i64, i64 }
%struct.StgTVarWatchQueue_ = type { %struct.StgHeader, %struct.StgClosure_*, %struct.StgTVarWatchQueue_*, %struct.StgTVarWatchQueue_* }
%struct.StgTRecChunk_ = type { %struct.StgHeader, %struct.StgTRecChunk_*, i64, [16 x %struct.TRecEntry] }
%struct.TRecEntry = type { %struct.StgTVar*, %struct.StgClosure_*, %struct.StgClosure_*, i64 }
%struct.StgTVar = type { %struct.StgHeader, %struct.StgClosure_*, %struct.StgTVarWatchQueue_*, i64 }
%struct.StgTRecHeader_ = type { %struct.StgHeader, %struct.StgTRecHeader_*, %struct.StgTRecChunk_*, i32 }
%struct.MessageThrowTo_ = type { %struct.StgHeader, %struct.MessageThrowTo_*, %struct.StgTSO_*, %struct.StgTSO_*, %struct.StgClosure_* }
%struct.StgBlockingQueue_ = type { %struct.StgHeader, %struct.StgBlockingQueue_*, %struct.StgClosure_*, %struct.StgTSO_*, %struct.MessageBlackHole_* }
%struct.MessageBlackHole_ = type { %struct.StgHeader, %struct.MessageBlackHole_*, %struct.StgTSO_*, %struct.StgClosure_* }
%struct.nursery_ = type { %struct.bdescr_*, i64 }
%struct.bdescr_ = type { i64*, i64*, %struct.bdescr_*, %union.anon, %struct.generation_*, i16, i16, i16, i16, i32, [3 x i32] }
%union.anon = type { %struct.bdescr_* }
%struct.generation_ = type { i32, %struct.bdescr_*, i64, i64, %struct.bdescr_*, i64, i64, i64, %struct.bdescr_*, i64, %struct.bdescr_*, i64, i64, %struct.StgTSO_*, %struct._StgWeak*, %struct.generation_*, i32, i32, i32, [128 x i8], %struct.SpinLock_, i32, i32, %struct.bdescr_*, i64, i64, %struct.bdescr_*, i64, %struct.bdescr_*, i64, %struct.bdescr_*, %struct.StgTSO_*, %struct._StgWeak* }
%struct.SpinLock_ = type { i64, i64, i64 }
; Function Attrs: nounwind uwtable
define internal void @dummmmmy() #0 !dbg !7 {
%1 = tail call %struct.StgRegTable* @StgRun(i8* ()* ()* null, %struct.StgRegTable* null) #2, !dbg !9
%2 = tail call i8* ()* ()* @StgReturn() #2, !dbg !10
ret void, !dbg !11
}
declare hidden %struct.StgRegTable* @StgRun(i8* ()* ()*, %struct.StgRegTable*) local_unnamed_addr #1
declare i8* ()* ()* @StgReturn() local_unnamed_addr #1
;;;; WE NEEDED TO ASSEMBLE THIS BACK INTO LLVM BITCODE AND REBUILD ARCHIVE once buiild completes, with:
;;;;; $ llvm-as rts/dist/build/StgCRun.thr_o.ll -o rts/dist/build/StgCRun.thr_o
;;;;; $ rm rts/dist/build/libHSrts_thr.a
;;;; $ echo rts/dist/build/Heap.thr_o rts/dist/build/TopHandler.thr_o rts/dist/build/Arena.thr_o rts/dist/build/Stable.thr_o rts/dist/build/RtsFlags.thr_o rts/dist/build/RtsMessages.thr_o rts/dist/build/RetainerSet.thr_o rts/dist/build/RtsStartup.thr_o rts/dist/build/FileLock.thr_o rts/dist/build/StgPrimFloat.thr_o rts/dist/build/Profiling.thr_o rts/dist/build/StaticPtrTable.thr_o rts/dist/build/Disassembler.thr_o rts/dist/build/Linker.thr_o rts/dist/build/WSDeque.thr_o rts/dist/build/RtsDllMain.thr_o rts/dist/build/Schedule.thr_o rts/dist/build/RtsAPI.thr_o rts/dist/build/Adjustor.thr_o rts/dist/build/Globals.thr_o rts/dist/build/Capability.thr_o rts/dist/build/Threads.thr_o rts/dist/build/xxhash.thr_o rts/dist/build/Timer.thr_o rts/dist/build/Messages.thr_o rts/dist/build/Interpreter.thr_o rts/dist/build/Stats.thr_o rts/dist/build/RetainerProfile.thr_o rts/dist/build/ClosureFlags.thr_o rts/dist/build/LdvProfile.thr_o rts/dist/build/StgCRun.thr_o rts/dist/build/Libdw.thr_o rts/dist/build/Task.thr_o rts/dist/build/ProfilerReportJson.thr_o rts/dist/build/RtsUtils.thr_o rts/dist/build/Weak.thr_o rts/dist/build/Sparks.thr_o rts/dist/build/Inlines.thr_o rts/dist/build/Hash.thr_o rts/dist/build/Proftimer.thr_o rts/dist/build/ProfHeap.thr_o rts/dist/build/RaiseAsync.thr_o rts/dist/build/RtsSymbolInfo.thr_o rts/dist/build/HsFFI.thr_o rts/dist/build/Hpc.thr_o rts/dist/build/STM.thr_o rts/dist/build/CheckUnload.thr_o rts/dist/build/OldARMAtomic.thr_o rts/dist/build/RtsSymbols.thr_o rts/dist/build/RtsMain.thr_o rts/dist/build/PathUtils.thr_o rts/dist/build/ProfilerReport.thr_o rts/dist/build/Trace.thr_o rts/dist/build/ThreadLabels.thr_o rts/dist/build/Ticky.thr_o rts/dist/build/Pool.thr_o rts/dist/build/LibdwPool.thr_o rts/dist/build/ThreadPaused.thr_o rts/dist/build/Printer.thr_o rts/dist/build/fs.thr_o rts/dist/build/hooks/OutOfHeap.thr_o rts/dist/build/hooks/MallocFail.thr_o rts/dist/build/hooks/FlagDefaults.thr_o rts/dist/build/hooks/OnExit.thr_o rts/dist/build/hooks/LongGCSync.thr_o rts/dist/build/hooks/StackOverflow.thr_o rts/dist/build/sm/MBlock.thr_o rts/dist/build/sm/Scav.thr_o rts/dist/build/sm/GCUtils.thr_o rts/dist/build/sm/Compact.thr_o rts/dist/build/sm/CNF.thr_o rts/dist/build/sm/Sweep.thr_o rts/dist/build/sm/GCAux.thr_o rts/dist/build/sm/MarkWeak.thr_o rts/dist/build/sm/BlockAlloc.thr_o rts/dist/build/sm/Evac_thr.thr_o rts/dist/build/sm/GC.thr_o rts/dist/build/sm/Sanity.thr_o rts/dist/build/sm/Evac.thr_o rts/dist/build/sm/Storage.thr_o rts/dist/build/sm/Scav_thr.thr_o rts/dist/build/eventlog/EventLogWriter.thr_o rts/dist/build/eventlog/EventLog.thr_o rts/dist/build/linker/elf_reloc_aarch64.thr_o rts/dist/build/linker/MachO.thr_o rts/dist/build/linker/elf_plt.thr_o rts/dist/build/linker/elf_plt_aarch64.thr_o rts/dist/build/linker/M32Alloc.thr_o rts/dist/build/linker/Elf.thr_o rts/dist/build/linker/CacheFlush.thr_o rts/dist/build/linker/elf_got.thr_o rts/dist/build/linker/SymbolExtras.thr_o rts/dist/build/linker/elf_plt_arm.thr_o rts/dist/build/linker/LoadArchive.thr_o rts/dist/build/linker/PEi386.thr_o rts/dist/build/linker/elf_reloc.thr_o rts/dist/build/linker/elf_util.thr_o rts/dist/build/posix/OSMem.thr_o rts/dist/build/posix/GetTime.thr_o rts/dist/build/posix/OSThreads.thr_o rts/dist/build/posix/Itimer.thr_o rts/dist/build/posix/TTY.thr_o rts/dist/build/posix/Signals.thr_o rts/dist/build/posix/Select.thr_o rts/dist/build/posix/GetEnv.thr_o rts/dist/build/StgStartup.thr_o rts/dist/build/PrimOps.thr_o rts/dist/build/Updates.thr_o rts/dist/build/StgMiscClosures.thr_o rts/dist/build/Apply.thr_o rts/dist/build/Exception.thr_o rts/dist/build/StgStdThunks.thr_o rts/dist/build/HeapStackCheck.thr_o rts/dist/build/Compact.thr_o rts/dist/build/AutoApply.thr_o | "xargs" "ar" qcls rts/dist/build/libHSrts_thr.a
module asm "StgRun:"
module asm ".cfi_startproc simple"
module asm "subq $48, %rsp"
module asm "movq %rsp, %rax"
module asm "subq $16384, %rsp"
module asm "movq %rbx, (%rax)"
module asm "movq %rbp, 8(%rax)"
module asm "movq %r12, 16(%rax)"
module asm "movq %r13, 24(%rax)"
module asm "movq %r14, 32(%rax)"
module asm "movq %r15, 40(%rax)"
module asm ".cfi_def_cfa %rsp, 0"
module asm ".cfi_offset %rbx, 16384"
module asm ".cfi_offset %rbp, 16392"
module asm ".cfi_offset %r12, 16400"
module asm ".cfi_offset %r13, 16408"
module asm ".cfi_offset %r14, 16416"
module asm ".cfi_offset %r15, 16424"
module asm ".cfi_offset %rip, 16432"
module asm ".cfi_escape 0x16, 0x07, 0x04, 0x77, 0xb8, 0x80, 0x01"
module asm "movq %rsi, %r13"
module asm "movq %rdi, %rax"
module asm ".globl StgRunJmp"
module asm ".hidden StgRunJmp"
module asm ".cfi_endproc"
module asm "StgRunJmp:"
module asm "jmpq *%rax"
module asm ".globl StgReturn"
module asm "StgReturn:"
module asm "movq %rbx, %rax"
module asm "addq $16384, %rsp"
module asm "movq (%rsp), %rbx"
module asm "movq 8(%rsp), %rbp"
module asm "movq 16(%rsp), %r12"
module asm "movq 24(%rsp), %r13"
module asm "movq 32(%rsp), %r14"
module asm "movq 40(%rsp), %r15"
module asm "addq $48, %rsp"
module asm "retq"
module asm "retq"
;;;;
attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #2 = { nounwind }
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4, !5}
!llvm.ident = !{!6}
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0-1~bpo9+1 (tags/RELEASE_600/final)", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2)
!1 = !DIFile(filename: "rts/StgCRun.c", directory: "/home/me/Code/NOT_MY_CODE/ghc")
!2 = !{}
!3 = !{i32 2, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{i32 1, !"wchar_size", i32 4}
!6 = !{!"clang version 6.0.0-1~bpo9+1 (tags/RELEASE_600/final)"}
!7 = distinct !DISubprogram(name: "dummmmmy", scope: !1, file: !1, line: 380, type: !8, isLocal: true, isDefinition: true, scopeLine: 380, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !2)
!8 = !DISubroutineType(types: !2)
!9 = !DILocation(line: 382, column: 5, scope: !7)
!10 = !DILocation(line: 383, column: 5, scope: !7)
!11 = !DILocation(line: 384, column: 1, scope: !7)
!14 = !{i32 -2145395701, i32 -2145395681, i32 -2145395661, i32 15740, i32 15769, i32 15801, i32 15830, i32 15864, i32 15898, i32 15933, i32 15968, i32 16003, i32 16038, i32 16924, i32 16959, i32 16994, i32 17029, i32 17064, i32 17099, i32 17134, i32 17169, i32 17919, i32 18063, i32 18260, i32 -2145395272, i32 -2145395189, i32 18955, i32 18980, i32 -2145395165, i32 19043, i32 19076, i32 19225, i32 19259, i32 19339, i32 19374, i32 19409, i32 19444, i32 19479, i32 19992}
......@@ -511,11 +511,11 @@ rts/StgCRun_CC_OPTS += -w
#rts/StgCRun_CC_OPTS += -fno-lto
#rts/StgCRun_CC_OPTS += -g0
# How About for `gcc` LTO?:
# TODO find which of these worked:
rts/StgCRun_HC_OPTS += -optc-fno-lto
rts/StgCRun_HC_OPTS += -optl-fno-lto
rts/StgCRun_CC_OPTS += -Wl,-fno-lto
rts/StgCRun_CC_OPTS += -fno-lto
# TODO find which of these worked: ---------- disabling again for now
#rts/StgCRun_HC_OPTS += -optc-fno-lto
#rts/StgCRun_HC_OPTS += -optl-fno-lto
#rts/StgCRun_CC_OPTS += -Wl,-fno-lto
#rts/StgCRun_CC_OPTS += -fno-lto
rts/RetainerProfile_CC_OPTS += -w
# On Windows:
......
......@@ -689,6 +689,7 @@ getWanted verbose os tmpdir gccProgram gccFlags nmProgram mobjdumpProgram
oFile = tmpdir </> "tmp.o"
writeFile cFile cStuff
-- `nm` doesn't seem to work correctly on -flto -ffat-lto-objects :
-- UPDATE: ...nor with `clang` -flto...
-- https://stackoverflow.com/q/55126627/176841
execute verbose gccProgram (gccFlags ++ ["-fno-lto", "-c", cFile, "-o", oFile])
-- TODO DEBUGGING
......
......@@ -96,6 +96,13 @@ NEED_iserv_dyn = NO
endif
endif
# Bypass for failure due to undefined reference to StgRun/StgReturn
# in archive libHSrts_thr.a built from rts/dist/build/StgCRun.thr_o
# which is LLVM IR (from LTO)
NEED_iserv = NO
NEED_iserv_p = NO
NEED_iserv_dyn = NO
ifeq "$(NEED_iserv)" "YES"
$(eval $(call build-prog,utils/iserv,stage2,1))
endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment