summaryrefslogtreecommitdiff
path: root/rts
Commit message (Collapse)AuthorAgeFilesLines
* [linker] Add ocInit/ocDeinit for ELFMoritz Angermann2017-05-014-22/+209
| | | | | | | | | | | | | | | This fills out the extended `info` structs, and will be subsequently used in the arm and arm64 linker for elf. Depends on: D3446, D3459 Reviewers: bgamari, austin, erikd, simonmar Reviewed By: simonmar Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3447
* Prefer #if defined to #ifdefBen Gamari2017-04-28128-591/+591
| | | | Our new CPP linter enforces this.
* Enable new warning for fragile/incorrect CPP #if usageErik de Castro Lopo2017-04-2816-33/+39
| | | | | | | | | | | | | | | | The C code in the RTS now gets built with `-Wundef` and the Haskell code (stages 1 and 2 only) with `-Wcpp-undef`. We now get warnings whereever `#if` is used on undefined identifiers. Test Plan: Validate on Linux and Windows Reviewers: austin, angerman, simonmar, bgamari, Phyx Reviewed By: bgamari Subscribers: thomie, snowleopard Differential Revision: https://phabricator.haskell.org/D3278
* [linker] Adds elf_compat.h, util.h, elf_util.hMoritz Angermann2017-04-2310-112/+671
| | | | | | | | | | | | | | | | | Further cleanup of the linker, we'll add elf_compat.h for a more complete set of relocations. Also Util.h has been added as suggested in the code already. Depends on D3444, D3445 Reviewers: bgamari, austin, erikd, simonmar Reviewed By: simonmar Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3446
* [linker] Adds ElfTypesMoritz Angermann2017-04-233-86/+195
| | | | | | | | | | | | | | This diff introduces ElfTypes similar to provide the linker code with a richer data structure, similar to the approach taken for mach-o already. Reviewers: bgamari, austin, erikd, simonmar Reviewed By: simonmar Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3445
* rts: Fix "ASSERT ("sBen Gamari2017-04-234-22/+22
| | | | | | | | | | Reviewers: austin, erikd, simonmar Reviewed By: erikd Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3486
* cpp: Use #pragma once instead of #ifndef guardsBen Gamari2017-04-2392-365/+98
| | | | | | | | | | | | | | This both says what we mean and silences a bunch of spurious CPP linting warnings. This pragma is supported by all CPP implementations which we support. Reviewers: austin, erikd, simonmar, hvr Reviewed By: simonmar Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3482
* win32/Ticker: Stop ticker on exitBen Gamari2017-04-231-0/+1
| | | | | | | | | | | | | | | | While debugging an unrelated issue I noticed that we leak a TimerQueueTimer on exit since we don't necessarily call stopTicker before exitTicker. Fix this. Test Plan: Validate on Windows Reviewers: simonmar, austin, erikd Reviewed By: simonmar Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3477
* Minor reordering of `#include`s fixing compilation on AIXHerbert Valerio Riedel2017-04-233-7/+7
| | | | | | | This helps ensure that system includes on some more fragile platforms (like e.g. AIX) see a more consistent set of CPP defines, and consequently reduce the risk of conflicting typdefs/prototypes being exposed.
* rts: tweak cross-compilation to mingw32Sergei Trofimovich2017-04-231-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Found the problem on x86_64-linux host where I tried to cross-compile GHC to windows as: $ ./configure --target=i686-w64-mingw32 \ Windres=i686-w64-mingw32-windres \ DllWrap=i686-w64-mingw32-dllwrap As a result build failed as POSIX bits of RTS. For example 'rts/posix/OSMem.c' contains unix-specific mmap() syscalls and constants and thus can't be compiled by i686-w64-mingw32 toolchain. It's caused by the following part of 'rts/ghc.mk': ifeq "$(HostOS_CPP)" "mingw32" ALL_DIRS += win32 else ALL_DIRS += posix endif In our case _CPP variables are defined this way (project.mk): BuildOS_CPP = linux HostOS_CPP = linux TargetOS_CPP = mingw32 RTS should never be built for 'BuildOS' or 'HostOS' as it's always built by ghc-stage1 (targeted at TargetOS). The change is to flip 'HostOS_CPP' to 'TargetOS_CPP' in 'rts/ghc.mk'. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* catch the case where there is no symCmdMoritz Angermann2017-04-212-1/+5
| | | | | | | | | | | | | | | | | We do check for symCmd, to set the info->nlist value, but forgot to do the same check for info->names. Thus when trying to extract stroff from symCmd, we hit a segfault. Test Plan: The validation failure on windows is rather suspicious... let's try this one Reviewers: bgamari, adinapoli, austin, erikd, simonmar Reviewed By: adinapoli Subscribers: thomie, rwbarton Differential Revision: https://phabricator.haskell.org/D3468
* Fix build on DragonflyBSDBen Gamari2017-04-212-3/+6
| | | | | | | | | | | | Test Plan: Validate on DragonflyBSD Reviewers: austin, erikd, simonmar Reviewed By: erikd Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3480
* Revert "linker/mach-o: Catch the case where there is no symCmd"Ben Gamari2017-04-182-5/+1
| | | | | | This causes validation failures on Windows. This reverts commit 6c05b27e5bafe9f232e7014f4760335f5e3ba591.
* hs_add_root() RTS API removalSergei Trofimovich2017-04-173-34/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | Before ghc-7.2 hs_add_root() had to be used to initialize haskell modules when haskell was called from FFI. commit a52ff7619e8b7d74a9d933d922eeea49f580bca8 ("Change the way module initialisation is done (#3252, #4417)") removed needs for hs_add_root() and made function a no-op. For backward compatibility '__stginit_<module>' symbol was not removed. This change removes no-op hs_add_root() function and unused '__stginit_<module>' symbol from each haskell module. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Test Plan: ./validate Reviewers: simonmar, austin, bgamari, erikd Reviewed By: simonmar Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3460
* rts/RtsUtils.c: drop stale commentsSergei Trofimovich2017-04-161-3/+3
| | | | Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* linker/mach-o: Catch the case where there is no symCmdMoritz Angermann2017-04-152-1/+5
| | | | | | | | | | | | | | We do check for symCmd, to set the info->nlist value, but forgot to do the same check for info->names. Thus when trying to extract stroff from symCmd, we hit a segfault. Reviewers: bgamari, adinapoli, austin, erikd, simonmar Reviewed By: bgamari, adinapoli Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3459
* [linker] Remove dead code (ELF_FUNCTION_DESC)Moritz Angermann2017-04-121-107/+0
| | | | | | | | | | Reviewers: bgamari, austin, erikd, simonmar, rwbarton Reviewed By: bgamari, rwbarton Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3444
* [Elf/arm] Thumb indicator bit only for STT_FUNCMoritz Angermann2017-04-101-9/+31
| | | | | | | | | | Reviewers: rwbarton, bgamari, austin, erikd, simonmar, trofi Reviewed By: trofi Subscribers: trofi, thomie Differential Revision: https://phabricator.haskell.org/D3438
* [MachO] Use OBJFORMAT_MACHO.Moritz Angermann2017-04-102-3/+3
| | | | | | | | | | Reviewers: bgamari, austin, erikd, simonmar, rwbarton Reviewed By: rwbarton Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3433
* Revert "Enable new warning for fragile/incorrect CPP #if usage"Ben Gamari2017-04-0516-43/+37
| | | | | | | | This is causing too much platform dependent breakage at the moment. We will need a more rigorous testing strategy before this can be merged again. This reverts commit 7e340c2bbf4a56959bd1e95cdd1cfdb2b7e537c2.
* Typos in comments [ci skip]Gabor Greif2017-04-051-2/+2
|
* rts: Fix lingering #ifsBen Gamari2017-04-045-8/+8
| | | | These were missed in D3278.
* Enable new warning for fragile/incorrect CPP #if usageErik de Castro Lopo2017-04-0516-37/+43
| | | | | | | | | | | | | | | | The C code in the RTS now gets built with `-Wundef` and the Haskell code (stages 1 and 2 only) with `-Wcpp-undef`. We now get warnings whereever `#if` is used on undefined identifiers. Test Plan: Validate on Linux and Windows Reviewers: austin, angerman, simonmar, bgamari, Phyx Reviewed By: bgamari Subscribers: thomie, snowleopard Differential Revision: https://phabricator.haskell.org/D3278
* rts: Make out-of-memory errors more consistentBen Gamari2017-04-022-2/+2
| | | | This will make it a bit easier to maintain consistent output in the testsuite.
* Report heap overflow in the same way as stack overflowSimon Marlow2017-04-026-20/+22
| | | | | | | | | | | | | | | | | | | | | | | Now that we throw an exception for heap overflow, we should only print the heap overflow message in the main thread when the HeapOverflow exception is caught, rather than as a side effect in the GC. Stack overflows were already done this way, I just made heap overflow consistent with stack overflow, and did some related cleanup. Fixes broken T2592(profasm) which was reporting the heap overflow message twice (you would only notice when building with profiling libs enabled). Test Plan: validate Reviewers: bgamari, niteria, austin, DemiMarie, hvr, erikd Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3394
* rts: print incorrect prev_what_nextSergei Trofimovich2017-04-011-1/+1
| | | | | | | | | | Moritz Angermann reports mysterious rts crash: A: link: internal error: schedule: invalid what_next field A: (GHC version 8.3.20170321 for arm_none_linux_android) This change prints actual prev_what_next value. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* Various patches to support android cross compilationMoritz Angermann2017-03-291-3/+7
| | | | | | | | | | | | | | | | | | | | - Better test for SHT_INIT_ARRAY than openbsd_HOST_OS This is actually bens patch: https://gist.github.com/bgamari/c846e6a5f2cd988716cd5e36c68d5bef - linux-android defines. - No need for -lpthread on OSAndroid However, I’m confused why we do not use the AC NEED_PTHREAD_LIB value here? - Use mmap on android - Support `none` vendor. Reviewers: austin, hvr, bgamari, erikd, simonmar Reviewed By: bgamari Subscribers: rwbarton, thomie, erikd Differential Revision: https://phabricator.haskell.org/D3356
* 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