summaryrefslogtreecommitdiff
path: root/rts
Commit message (Collapse)AuthorAgeFilesLines
* Fix #13433Simon Marlow2017-03-281-4/+17
| | | | | | | | | | | | Summary: See comments for details. Test Plan: validate Reviewers: mpickering, bgamari, austin, erikd Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3386
* Spelling in comments only [ci skip]Gabor Greif2017-03-283-7/+7
|
* Don't redefine typedef namesGabor Greif2017-03-271-4/+4
| | | | | | | | | | instead define the structs referred to by - SectionFormatInfo - ObjectCodeFormatInfo that were only forward-declared earlier. This fixes redefinition errors with gcc4.4
* Adds aarch64 linker for mach-o files.Moritz Angermann2017-03-261-27/+721
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the final commit that ties them all together. Here we add the aarch64 linker for macho files. - In D3238 we started allowing preloading object code with mmap in iOS, where we can't have r+w+x. - In D3239 we introduced a richer extension of the object code data type to make working with mach-o files easier. - In D3240 we set the stage to allow loading archives (.a) on iOS - In D3251 we added init and deinit functions to populate and depopulate the enriched object code data structure for mach-o files. - In D3252 we refactored most of the MachO.c file to use the new types and datastructure. This commit will than finally add the aarch64 (arm64) linker for mach-o files to ghc, using the improved foundation we have constructed above. The dependency structure therefore is as follows ``` .- D3240 v This <- D3252 <- D3251 <- D3239 ^ '- D3238 ``` Depends: D3252, D3240, D3238 Test Plan: To test this with iOS, we also need the remote-iserv diff D3233. With all that in place, proceed as follows: - Build ghc for the host ``` ghc $ ./configure --prefix=/test/opt \ --disable-large-address-space \ --with-llc=/path/to/llvm-3.9/bin/llc \ --with-opt=/path/to/llvm-3.9/bin/opt # edit mk/build.mk to specify quick ghc $ make && make install ``` - Build ghc for ios ``` ghc $ ./configure --target=aarch64-apple-darwin14 \ --prefix=/test/opt \ --disable-large-address-space \ --with-llc=/path/to/llvm-3.9/bin/llc \ --with-opt=/path/to/llvm-3.9/bin/opt \ --with-ghc=/test/bin/ghc \ --enable-bootstrap-with-devel-snapshot # edit mk/build.mk to specify quick-cross ghc $ make && make install ``` - Obtain the iOS wrapper scripts from https://github.com/angerman/ghc-ios-scripts and place them in PATH. - Build iserv-proxy for the host ``` ghc/iserv $ cabal install -fproxy -flibrary ``` - Build iserv-library for the target ``` # build cryptonite without integer-gmp ghc/iserv $ aarch64-apple-darwin14-cabal install cryptonite -f-integer-gmp ghc/iserv $ aarch64-apple-darwin14-cabal install -flibrary ``` - Create an iOS application with the following `main.m`: ``` #import <UIKit/UIKit.h> #include "HsFFI.h" extern void startSlave(bool, int, const char *); int main(int argc, char * argv[]) { const char * documents_path = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] firstObject].path.UTF8String; hs_init(NULL, NULL); startSlave(false, 5000, documents_path); @autoreleasepool { return UIApplicationMain(argc, argv, nil, nil); } } ``` and link it with: the iserv archive from `~/.cabal/lib/aarch64-ios-ghc` as well as all dependent archives. - Build, Install and Launch the iserv-slave application on your iphone - Compile some Template Haskell code with the `aarch64-apple-darwin14-ghc`, through the `iserv-proxy` ``` app $ aarch64-apple-darwin14-ghc Module.hs \ -threaded -staticlib \ -outputdir build/aarch64 -pgmlibtool libtool-quiet -stubdir . \ -fexternal-interpreter \ -pgmi=$HOME/.cabal/bin/iserv-proxy \ -opti10.0.0.1 \ -opti5000 ``` where 10.0.0.1 is the ip of your iserv-slave. magic. Reviewers: rwbarton, bgamari, austin, hvr, erikd, simonmar Subscribers: thomie, erikd, ryantrinkle Differential Revision: https://phabricator.haskell.org/D3255
* Refactor MachO.cMoritz Angermann2017-03-261-251/+183
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Rename existing structs with typedefs from MachOTypes. - Update the following functions to make use of the extended ObjectCode structure: - ocAllocateSymbolExtras_MachO - resolveImports - ocGetNames_MachO - ocResolve_MachO - ocRunInit_MachO - repalce int with size_t for fread - Add aarch64 to the 64bit magic header check. Depends on D3239, D3251 This is just one of the pieces for the rts linker support for ios (aarch64-macho) --- The following diagram and legend tries to explain the dependencies a bit: ``` .- D3240 v D3255 <- This <- D3251 <- D3239 ^ '- D3238 ``` - In D3238 we started allowing preloading object code with mmap in iOS, where we can't have r+w+x. - In D3239 we introduced a richer extension of the object code data type to make working with mach-o files easier. - In D3240 we set the stage to allow loading archives (.a) on iOS - In D3251 we added init and deinit functions to populate and depopulate the enriched object code data structure for mach-o files. - In D3252 we refactored most of the MachO.c file to use the new types and data structure. - in D3255 we finally introduce the aarch64-mach-o linker. Reviewers: austin, rwbarton, erikd, simonmar, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3252
* Add ocInit_MachOMoritz Angermann2017-03-264-4/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds ocInit_MachO function, used to populate the extended ObjectCode structure, and the corresponding stgFree. It also adds defines for iOS, such that MachO.o is also compiled for iOS targets. Depends on D3239 --- This is just one of the pieces for the rts linker support for ios (aarch64-macho) --- The following diagram and legend tries to explain the dependencies a bit: ``` .- D3240 v D3255 <- D3252 <- This <- D3239 ^ '- D3238 ``` - In D3238 we started allowing preloading object code with mmap in iOS, where we can't have r+w+x. - In D3239 we introduced a richer extension of the object code data type to make working with mach-o files easier. - In D3240 we set the stage to allow loading archives (.a) on iOS - In D3251 we added init and deinit functions to populate and depopulate the enriched object code data structure for mach-o files. - In D3252 we refactored most of the MachO.c file to use the new types and data structure. - in D3255 we finally introduce the aarch64-mach-o linker. Reviewers: rwbarton, bgamari, austin, erikd, simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3251
* rts linker: Introduce MachOTypesMoritz Angermann2017-03-263-2/+165
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This diff introduces MachOTypes, to reduce the need to typing `struct` all the time. It also coaleces the 64 and non 64 structs. It also adds additional fiedls to the object code structure for macho, which makes working with macho object code much simpler and requires less passing around of variabls or address recomputation for the header, symbol table, etc... Furthermore this diff introduces a type for a linked list of stubs. I had to move the #ifdef from the bottom of the file up, to be able to extend the object code structure conditional on the use of the macho file format. This is just one of the pieces for the rts linker support for ios (aarch64-macho) --- The following diagram and legend tries to explain the dependencies a bit: ``` .- D3240 v D3255 <- D3252 <- D3251 <- This ^ '- D3238 ``` - In D3238 we started allowing preloading object code with mmap in iOS, where we can't have r+w+x. - In D3239 we introduced a richer extension of the object code data type to make working with mach-o files easier. - In D3240 we set the stage to allow loading archives (.a) on iOS - In D3251 we added init and deinit functions to populate and depopulate the enriched object code data structure for mach-o files. - In D3252 we refactored most of the MachO.c file to use the new types and data structure. - in D3255 we finally introduce the aarch64-mach-o linker. Reviewers: austin, erikd, simonmar, rwbarton, bgamari Subscribers: rwbarton, thomie, ryantrinkle Differential Revision: https://phabricator.haskell.org/D3239
* Make mmap r+w only during preload for iOS.Moritz Angermann2017-03-261-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While we do not yet enable mmap for ios builds. If we later do, we must not try to mmap r+w+x, on iOS as that clearly fails. This diff also adds a check for the successful mmaping. I don't think we can blanket change this to r+w for every case, unless we are absolutely sure that we are going to remap this and set +x where needed. This is just one of the pieces for the rts linker support for ios (aarch64-macho) --- The following diagram and legend tries to explain the dependencies a bit: ``` .- D3240 v D3255 <- D3252 <- D3251 <- D3239 ^ '- This ``` - In D3238 we started allowing preloading object code with mmap in iOS, where we can't have r+w+x. - In D3239 we introduced a richer extension of the object code data type to make working with mach-o files easier. - In D3240 we set the stage to allow loading archives (.a) on iOS - In D3251 we added init and deinit functions to populate and depopulate the enriched object code data structure for mach-o files. - In D3252 we refactored most of the MachO.c file to use the new types and data structure. - in D3255 we finally introduce the aarch64-mach-o linker. Reviewers: ezyang, austin, erikd, simonmar, bgamari, rwbarton Reviewed By: bgamari Subscribers: rwbarton, ryantrinkle, thomie Differential Revision: https://phabricator.haskell.org/D3238
* Drop dead code in rts/{Prelude.h,package.conf.in}Moritz Angermann2017-03-262-54/+57
| | | | | | | | | | | | | | | The endevor to drop the `-Wl,-u,<sym>` requirement for linking the rts, base, ,... turned out to be less fruitful than I had hoped. However it did turn up a few dead symbols, that are referenced but for which the definition seems to have diminished. Reviewers: austin, rwbarton, geekosaur, erikd, simonmar, bgamari Reviewed By: geekosaur, simonmar Subscribers: thomie, snowleopard Differential Revision: https://phabricator.haskell.org/D3350
* rts: Fix stat output on 32-bit platformsBen Gamari2017-03-261-25/+33
| | | | The formatting strings fell out of sync with the arguments.
* linker: fix OpenBSD build failure, EM_PPC64 is not defined thereSergei Trofimovich2017-03-261-0/+2
| | | | | | | | | | | | | Adam Steen reported build failure on OpenBSD: rts/linker/Elf.c:402:0: error: error: 'EM_PPC64' undeclared (first use in this function) case EM_PPC64: IF_DEBUG(linker,debugBelch( "powerpc64" )); OpenBSD-6.0 does not define EM_PPC64: /usr/include/sys/exec_elf.h:#define EM_PPC 20 /* PowerPC */ Reported-by: Adam Steen <adam@adamsteen.com.au> Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* Fix Windows x86 buildTamar Christina2017-03-201-0/+2
| | | | | | | | | | | | | | | | | | Summary: Fix some `-Werror` failures and work around a bug in the `x86` version of `mingw-w64-crt`'s libraries. The bump in the `win32` submodule is required for this. Test Plan: ./validate Reviewers: austin, bgamari, erikd, simonmar Reviewed By: simonmar Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3362
* Typos in manual and comments [ci skip]Gabor Greif2017-03-171-1/+1
|
* Allow iOS to load archives through the linkerMoritz Angermann2017-03-031-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This basically just adds ios where darwin already was, and is just one of the pieces for the rts linker support for ios (aarch64-macho) --- The following diagram and legend tries to explain the dependencies a bit: ``` .- This v D3255 <- D3252 <- D3251 <- D3239 ^ '- D3238 ``` - In D3238 we started allowing preloading object code with mmap in iOS, where we can't have r+w+x. - In D3239 we introduced a richer extension of the object code data type to make working with mach-o files easier. - In D3240 we set the stage to allow loading archives (.a) on iOS - In D3251 we added init and deinit functions to populate and depopulate the enriched object code data structure for mach-o files. - In D3252 we refactored most of the MachO.c file to use the new types and data structure. - in D3255 we finally introduce the aarch64-mach-o linker. Reviewers: bgamari, austin, erikd, simonmar Reviewed By: bgamari Subscribers: thomie, ryantrinkle Differential Revision: https://phabricator.haskell.org/D3240
* Extend Windows runtime loader libsearchTamar Christina2017-03-021-1/+4
| | | | | | | | | | | | | | | | | | | | | | This adds `.obj` extension to the list of valid object file (we really shouldn't be using extensions but instead trying to read the file and see if the header makes sense.). Microsoft compilers use .obj instead of .o for object files. This also adds support to finding static archives when the "lib" prefix is already in the filename. e.g. `-llibfoo` to find `libfoo.a`. This is inline with binutils. Test Plan: ./validate Reviewers: simonmar, erikd, bgamari, hvr, austin Reviewed By: bgamari Subscribers: RyanGlScott, thomie, #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D3082
* SymbolExtras: A bit of spring cleaningBen Gamari2017-03-022-11/+9
| | | | Const-hygiene and use bool when possible.
* rts: Fix buildBen Gamari2017-02-281-0/+1
| | | | | I evidently neglected to consider that validate doesn't build profiled ways. Arg.
* Drop copy step from the rts/ghc.mkMoritz Angermann2017-02-283-12/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | Recently I've used a different build system for building the rts (Xcode). And in doing so, I looked through the rts/ghc.mk to figure out how to build the rts. In general it's quite straight forward to just compile all the c files with the proper flags. However there is one rather awkward copy step that copies some files for special handling for the rts way. I'm wondering if the proposed solution in this diff is better or worse than the current situation? The idea is to keep the files, but use #includes to produce identical files with just an additional define. It does however produce empty objects for non threaded ways. Reviewers: ezyang, bgamari, austin, erikd, simonmar, rwbarton Reviewed By: bgamari, simonmar, rwbarton Subscribers: rwbarton, thomie, snowleopard Differential Revision: https://phabricator.haskell.org/D3237
* rts: Allow profile output path to be specified on RTS command lineBen Gamari2017-02-282-22/+31
| | | | | | | | | | | | | | | | | | | | | | This introduces a RTS option, -po, which allows the user to override the stem used to form the output file names of the heap profile and cost center summary. It's a bit unclear to me whether this is really the interface we want. Alternatively we could just allow the user to specify the `.hp` and `.prof` file names separately. This would arguably be a bit more straightforward and would allow the user to name JSON output with an appropriate `.json` suffix if they so desired. However, this would come at the cost of taking more of the option space, which is a somewhat precious commodity. Test Plan: Validate, try using `-po` RTS option Reviewers: simonmar, austin, erikd Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3182
* configure: detect whether -lpthreads is necessary for pthreadsBen Gamari2017-02-281-0/+2
| | | | | | | | | | | | | | | Some platforms have pthreads support available without linking against libpthread (and indeed don't even offer a libpthread to link against). One example of this is Android's bionic library. Teach the RTS about this case. Test Plan: Validate while cross-compiling targetting Android on aarch64 Reviewers: simonmar, austin, hvr, erikd, rwbarton Subscribers: danharaj, thomie, erikd, snowleopard Differential Revision: https://phabricator.haskell.org/D3149
* rts: Usage message wibblesBen Gamari2017-02-261-1/+1
|
* Make list of deprecated symbols on Windows weak.Tamar Christina2017-02-263-7/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have a unfortunate workaround in place for the fact that most packages out there use POSIX names for symbols even on Windows. This means that we have to recognize e.g. both `_ungetch` and `ungetch`. The former is the actual symbol name on windows and the latter is the POSIX variant. The problem is that on normal windows programs `ungetch` should not be in the global namespace. To work around this, we now mark the deprecated symbols as weak symbols in the global namespace. This provides the flexibility we need: * If you use the symbol without defining it, we assume you meant to use the POSIX variant. * If you actually define the symbol, we'll hence forth use that definition and assume you didn't mean to use POSIX code. This is how MingW64's wrapper also works. This requires D3028. Fixes #13210. Test Plan: ./validate Reviewers: austin, bgamari, erikd, simonmar Reviewed By: bgamari Subscribers: thomie, #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D3154
* Load dependent dlls.Tamar Christina2017-02-261-63/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the `GCC` driver envokes the pipeline a `SPEC` is used to determine how to configure the compiler and which libraries to pass along. For Windows/mingw, this specfile is https://github.com/gcc-mirror/gcc/blob/master/gcc/config/i386/mingw32.h This has a lot of interesting things that we need to emulate in order to be able to link as many things out of the box as GCC. In particular this is why you never need to specify `-lgcc_s` when compiling, but you do when using `GHCi`. Unfortunately due to time constraints I can't set up the framework required in `GHC` to do this before the feature freeze. So I suggest this alternate implementation: When we load a dll, also bring it's dependencies into scope of the interpeter. This has pros and cons. Pro is, we'll fix many packages on hackage which specify just `-lstdc++`. Since this points to `libstdc++-6.dll` which will bring `libgcc` into scope. The downside is, we'll be more lenient than GCC, in that the interpreter will link much easier since it has implicit dependencies in scope. Whereas for compilation to work you will have to specify it as an argument to GHC. This will make the Windows runtime linker more consistent with the unix ones. The difference in semantics came about because of the differences between `dlsym` and `GetProcAddress`. The former seems to search the given library and all it's dependencies, while the latter only searches the export table of the library. So we need some extra manual work to search the dependencies which this patch provides. Test Plan: ``` ./validate ``` ``` $ echo :q | inplace/bin/ghc-stage2.exe --interactive +RTS -Dl -RTS -lstdc++ 2>&1 | grep "Loading dependency" ``` ``` $ echo :q | ../inplace/bin/ghc-stage2.exe --interactive -lstdc++ +RTS -Dl -RTS 2>&1 | grep "Loading dependency" Loading dependency *.exe -> GDI32.dll. Loading dependency GDI32.dll -> ntdll.dll. Loading dependency *.exe -> KERNEL32.dll. Loading dependency KERNEL32.dll -> KERNELBASE.dll. Loading dependency *.exe -> msvcrt.dll. Loading dependency *.exe -> SHELL32.dll. Loading dependency SHELL32.dll -> USER32.dll. Loading dependency USER32.dll -> win32u.dll. Loading dependency *.exe -> WINMM.dll. Loading dependency WINMM.dll -> WINMMBASE.dll. Loading dependency *.exe -> WSOCK32.dll. Loading dependency WSOCK32.dll -> WS2_32.dll. Loading dependency WS2_32.dll -> RPCRT4.dll. Loading dependency libstdc++-6.dll -> libwinpthread-1.dll. Loading dependency libstdc++-6.dll -> libgcc_s_seh-1.dll. ``` Trac tickets: #13093, #13189 Reviewers: simonmar, rwbarton, austin, bgamari, erikd Reviewed By: bgamari Subscribers: rwbarton, RyanGlScott, thomie, #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D3028
* base: Add handling of -- to getArgs for WindowsAndreas Klebinger2017-02-231-1/+8
| | | | | | | | | | | | | getArgs didn't match the treatmeant of -- in the RTS leading to inconsistencies between behavior on Windows and other platforms. See #13287. Reviewers: austin, hvr, bgamari, erikd, simonmar, rwbarton Reviewed By: bgamari, rwbarton Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3147
* rts: Correct the nursery size in the gen 1 growth computationJohn C. Carey2017-02-231-1/+13
| | | | | | | | | | | | Fixes trac issue #13288. Reviewers: austin, bgamari, erikd, simonmar Reviewed By: simonmar Subscribers: mutjida, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3143
* JSON profiler reportsBen Gamari2017-02-235-21/+185
| | | | | | | | | | | | | | | | | | | This introduces a JSON output format for cost-centre profiler reports. It's not clear whether this is really something we want to introduce given that we may also move to a more Haskell-driven output pipeline in the future, but I nevertheless found this helpful, so I thought I would put it up. Test Plan: Compile a program with `-prof -fprof-auto`; run with `+RTS -pj` Reviewers: austin, erikd, simonmar Reviewed By: simonmar Subscribers: duncan, maoe, thomie, simonmar Differential Revision: https://phabricator.haskell.org/D3132
* Spelling only [ci skip]Gabor Greif2017-02-231-1/+1
|
* Typos [ci skip]Gabor Greif2017-02-152-2/+2
|
* Fix ExtraSymbols jump table on Windows.Tamar Christina2017-02-141-16/+21
| | | | | | | | | | | | | | | | | | | This corrects the `jump islands` calculations for Windows. The code was incorrectly creating a new entry for every `usage` of a symbol instead of every used symbol. e.g. if a symbol is used 5 times it used to create 5 jump islands. This is incorrect and not in line with what the `ELF` and `Mach-O` linkers do. Also since we allocate `n` spaces where `n` is number of symbols, we would quickly run out of space and abort. Test Plan: ./validate Reviewers: simonmar, hvr, erikd, bgamari, austin Reviewed By: bgamari Subscribers: thomie, #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D3026
* Expand list of always loaded Windows shared libsTamar Christina2017-02-141-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | When the `GCC` driver envokes the pipeline a `SPEC` is used to determine how to configure the compiler and which libraries to pass along. For Windows/mingw, this specfile is https://github.com/gcc-mirror/gcc/blob/master/gcc/config/i386/mingw32.h This expands the list of base DLLs with the ones that GCC always links, and adds extra sibling dlls of `stdc++` in case it is linked in. Following D3028 this patch only needs to load the always load only the top level individual shared libs. Test Plan: ./validate Reviewers: RyanGlScott, austin, bgamari, erikd, simonmar Reviewed By: bgamari Subscribers: RyanGlScott, thomie, #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D3029
* Typecast covers entire expression to fix format warning.bollu2017-02-141-10/+15
| | | | | | | | | | | | | | - Fixes (#12636). - changes all the typecasts to _unsinged long long_ to have the format specifiers work. Reviewers: austin, bgamari, erikd, simonmar, Phyx Reviewed By: erikd, Phyx Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3129
* Apply SplitSections to all C compilationsSimon Brenner2017-02-111-4/+0
| | | | | | | | | | | | | | | | | | | Previously this was added only to the RTS's C files (those are the bulk of it though), but there are C bits in ghc-prim, integer-gmp and base too. Followup for #8405, allows the large table of character properties in base to be stripped when not used. Test Plan: validate Reviewers: austin, bgamari, simonmar Reviewed By: bgamari Subscribers: thomie, snowleopard Differential Revision: https://phabricator.haskell.org/D3121
* rts/Profiling: Factor out report generationBen Gamari2017-02-114-318/+374
| | | | | | | | | | | | | | | | | | | | | Here we move the actual report generation logic to `rts/ProfilerReport.c`. This break is actually quite clean, void writeCCSReport( FILE *prof_file, CostCentreStack const *ccs, ProfilerTotals totals ); This is more profiler refactoring in preparation for machine-readable output. Test Plan: Validate Reviewers: austin, erikd, simonmar Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3097
* rts/Profiling: Kill a few globals and add constsBen Gamari2017-02-112-51/+70
| | | | | | | | | | | | | | | | | | | Previously it was quite difficult to follow the dataflow through this file due to global mutation and rather non-descriptive types. This is a cleanup in preparation for factoring out the report-generating logic, which is itself in preparation for somedayteaching the profiler to produce more machine-readable reports (JSON perhaps?). Test Plan: Validate Reviewers: austin, erikd, simonmar Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3096
* Spelling in comments [ci skip]Gabor Greif2017-02-101-1/+1
|
* Fix stop_thread unwinding informationBen Gamari2017-02-082-8/+12
| | | | | | | | | | | | | | | | This corrects the unwind information for `stg_stop_thread`, which allows us to unwind back to the C stack after reaching the end of the STG stack. Test Plan: Validate Reviewers: simonmar, austin, erikd Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2746
* Cmm: Add support for undefined unwinding statementsBen Gamari2017-02-081-0/+2
| | | | | | | | | | | | | | And use to mark `stg_stack_underflow_frame`, which we are unable to determine a caller from. To simplify parsing at the moment we steal the `return` keyword to indicate an undefined unwind value. Perhaps this should be revisited. Reviewers: scpmw, simonmar, austin, erikd Subscribers: dfeuer, thomie Differential Revision: https://phabricator.haskell.org/D2738
* Generalize CmmUnwind and pass unwind information through NCGBen Gamari2017-02-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As discussed in D1532, Trac Trac #11337, and Trac Trac #11338, the stack unwinding information produced by GHC is currently quite approximate. Essentially we assume that register values do not change at all within a basic block. While this is somewhat true in normal Haskell code, blocks containing foreign calls often break this assumption. This results in unreliable call stacks, especially in the code containing foreign calls. This is worse than it sounds as unreliable unwinding information can at times result in segmentation faults. This patch set attempts to improve this situation by tracking unwinding information with finer granularity. By dispensing with the assumption of one unwinding table per block, we allow the compiler to accurately represent the areas surrounding foreign calls. Towards this end we generalize the representation of unwind information in the backend in three ways, * Multiple CmmUnwind nodes can occur per block * CmmUnwind nodes can now carry unwind information for multiple registers (while not strictly necessary; this makes emitting unwinding information a bit more convenient in the compiler) * The NCG backend is given an opportunity to modify the unwinding records since it may need to make adjustments due to, for instance, native calling convention requirements for foreign calls (see #11353). This sets the stage for resolving #11337 and #11338. Test Plan: Validate Reviewers: scpmw, simonmar, austin, erikd Subscribers: qnikst, thomie Differential Revision: https://phabricator.haskell.org/D2741
* Fix comment (old file names) in rts/Takenobu Tani2017-02-047-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [skip ci] There ware some old file names (.lhs, ...) at comments. * rts/win32/ThrIOManager.c - Conc.lhs -> Conc.hs * rts/PrimOps.cmm - ByteCodeLink.lhs -> ByteCodeLink.hs - StgMiscClosures.hc -> StgMiscClosures.cmm * rts/AutoApply.h - AutoApply.hc -> AutoApply.cmm * rts/HeapStackCheck.cmm - PrimOps.hc -> PrimOps.cmm * rts/LdvProfile.h - Updates.hc -> Updates.cmm * rts/Schedule.c - StgStartup.hc -> StgStartup.cmm * rts/Weak.c - StgMiscClosures.hc -> StgMiscClosures.cmm Reviewers: bgamari, austin, erikd, simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3075
* Ditch static flagsSylvain Henry2017-02-021-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch converts the 4 lasting static flags (read from the command line and unsafely stored in immutable global variables) into dynamic flags. Most use cases have been converted into reading them from a DynFlags. In cases for which we don't have easy access to a DynFlags, we read from 'unsafeGlobalDynFlags' that is set at the beginning of each 'runGhc'. It's not perfect (not thread-safe) but it is still better as we can set/unset these 4 flags before each run when using GHC API. Updates haddock submodule. Rebased and finished by: bgamari Test Plan: validate Reviewers: goldfire, erikd, hvr, austin, simonmar, bgamari Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2839 GHC Trac Issues: #8440
* Add support for StaticPointers in GHCiBen Gamari2017-02-022-4/+9
| | | | | | | | | | | | | | | | | | | | | Here we add support to GHCi for StaticPointers. This process begins by adding remote GHCi messages for adding entries to the static pointer table. We then collect binders needing SPT entries after linking and send the interpreter a message adding entries with the appropriate fingerprints. Test Plan: `make test TEST=StaticPtr` Reviewers: facundominguez, mboes, simonpj, simonmar, goldfire, austin, hvr, erikd Reviewed By: simonpj, simonmar Subscribers: RyanGlScott, simonpj, thomie Differential Revision: https://phabricator.haskell.org/D2504 GHC Trac Issues: #12356
* Abstract over the way eventlogs are flushedalexbiehl2017-01-315-81/+194
| | | | | | | | | | | | | | | | | | | | Currently eventlog data is always written to a file `progname.eventlog`. This patch introduces the `flushEventLog` field in `RtsConfig` which allows to customize the writing of eventlog data. One possible scenario is the ongoing live-profile-monitor effort by @NCrashed which slurps all eventlog data through `fluchEventLog`. `flushEventLog` takes a buffer with eventlog data and its size and returns `false` (0) in case eventlog data could not be procesed. Reviewers: simonmar, austin, erikd, bgamari Reviewed By: simonmar, bgamari Subscribers: qnikst, thomie, NCrashed Differential Revision: https://phabricator.haskell.org/D2934
* Slighly clean up symbol loading error.Tamar Christina2017-01-302-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The symbol not found error that is triggered during lazy-loading was a bit chaotic before. This reformats it a bit to: ``` ghc-stage2.exe: | E:\...\libLLVMSupport.a: unknown symbol `_ZN4llvm5APIntC1Ejyb' ghc-stage2.exe: | E:\...\libLLVMCore.a: unknown symbol `_ZN4llvm5APInt14AssignSlowCaseERKS0_' ghc-stage2.exe: | E:\...\libLLVMCore.a: unknown symbol `_ZN4llvm13ConstantRangeC1ENS_5APIntES1_' ghc-stage2.exe: | E:\...\libLLVMCore.a: unknown symbol `_ZN4llvm14FoldingSetImplC2Ej' ghc-stage2.exe: | E:\...\libLLVMCore.a: unknown symbol `_ZN4llvm15LLVMContextImplD1Ev' ghc-stage2.exe: | E:\...\libLLVMLTO.a: unknown symbol `_ZN4llvm11LLVMContextD1Ev' ghc-stage2.exe: | E:\...\libLLVMCore.a: unknown symbol `_ZNK4llvm5Value10getContextEv' ghc-stage2.exe: ^^ Could not load 'LLVMIsMultithreaded', dependency unresolved. See top entry above. ``` I have also thought about also showing the demangled names, as it may be useful for the end user. `libgcc` seems to provide a method for this so we wouldn't need any extra dependency. Any thoughts on this or would it not be useful? Reviewers: austin, erikd, simonmar, bgamari Reviewed By: bgamari Subscribers: RyanGlScott, thomie, #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D3027 GHC Trac Issues: #13093, #13113
* Fatal if we try to reinitialize the RTSSimon Marlow2017-01-261-0/+6
| | | | | | | | | | | | | | | This isn't supported, and fatalling with an error is better than segfaulting later. Test Plan: validate Reviewers: JonCoens, austin, erikd, niteria, bgamari Reviewed By: niteria, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D3020
* Clean up RTS Linker Windows.Tamar Christina2017-01-182-356/+263
| | | | | | | | | | | | | | | | | | | | | | Clean up the linker code for PE. 1. Stop copying structures from the windows header and use those that are in the headers. There's no point in copying them and we got a few types wrong. 2. Replace custom typedef with C99 types. If we're not going to use the Windows type aliases, at least use standard ones. Test Plan: ./validate Reviewers: simonmar, austin, erikd, bgamari Reviewed By: simonmar, bgamari Subscribers: dfeuer, thomie, #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D2944
* Spelling fixes in comments [ci skip]Gabor Greif2017-01-181-1/+1
|
* Unbreak libGHCi by adding missing symbol.Tamar Christina2017-01-161-0/+1
| | | | | | | | | | | | | | | | Summary: Someone committed a new public symbol `purgeObj` again without adding it to the symbols table. Test Plan: ./validate Reviewers: austin, bgamari, simonmar, erikd Reviewed By: erikd Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2980
* Improve access violation reporting on WindowsRyan Scott2017-01-151-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch is courtesy of @awson. Currently, whenever GHC catches a segfault on Windows, it simply reports the somewhat uninformative message `Segmentation fault/access violation in generated code`. This patch adds to the message the type of violation (read/write/dep) and location information, which should help debugging segfaults in the future. Fixes #13108. Test Plan: Build on Windows Reviewers: austin, erikd, bgamari, simonmar, Phyx Reviewed By: bgamari, Phyx Subscribers: awson, thomie, #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D2969 GHC Trac Issues: #13108
* Fix abort and import lib search on WindowsTamar Christina2017-01-151-2/+3
| | | | | | | | | | | | | | | | | | | | | | Summary: Apparently `sysErrorBelch` doesn't terminate the program anymore making previously unreachable code now execute. If a dll is not found the error message we return needs to be a heap value. Secondly also allow the pattern `lib<name>` to be allowed for finding an import library with the name `lib<name>.dll.a`. Test Plan: ./validate, new tests T13082_good and T13082_fail Reviewers: austin, RyanGlScott, hvr, erikd, simonmar, bgamari Reviewed By: RyanGlScott, bgamari Subscribers: thomie, #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D2941 GHC Trac Issues: #13082
* Typos in commentsGabor Greif2017-01-131-1/+1
|