summaryrefslogtreecommitdiff
path: root/rts
Commit message (Collapse)AuthorAgeFilesLines
* RTS: Rename InCall.stat struct field to .rstatHerbert Valerio Riedel2015-12-044-10/+10
| | | | | | | | | | | On AIX, C system headers can redirect the token `stat` via #define stat stat64 to provide large-file support. Simply avoiding the use of `stat` as an identifier eschews macro-replacement. Differential Revision: https://phabricator.haskell.org/D1566
* Use Autoconf's AC_USE_SYSTEM_EXTENSIONSHerbert Valerio Riedel2015-12-042-13/+0
| | | | | | | | | | | | | | | | | | | | | | This takes care of setting feature test macros (i.e. let Autoconf decide when those can be set safely) to allow subsequent Autoconf tests to better detect available OS features. This also includes a submodule update of unix which enables the use of `AC_USE_SYSTEM_EXTENSIONS` in there as well. Specifically, this takes care of setting `_GNU_SOURCE` (which allows to remove two occurences where it's set manually) and `_ALL_SOURCE` (which fixes issues on AIX). See also https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Posix-Variants.html for details. At some point we may want to reconsider the purpose of "rts/PosixSource.h" and rely more on Autoconf instead.
* LibdwPool: Use poolTryTakeBen Gamari2015-11-261-1/+18
|
* rts/Pool: Add poolTryTakeBen Gamari2015-11-262-12/+39
|
* rts: Always export Libdw* symbolsBen Gamari2015-11-231-4/+0
| | | | | | | | | | | | | Otherwise we'll get link time failures as `base` always builds `GHC.ExecutionStack`. Test Plan: Validate Reviewers: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1519
* rts: Add LibdwPool, a pool for libdw sessionsBen Gamari2015-11-234-1/+86
| | | | Differential Revision: https://phabricator.haskell.org/D1198#40948
* rts: Add simple resource poolBen Gamari2015-11-232-0/+234
|
* rts: Expose more libdw symbolsBen Gamari2015-11-233-14/+28
|
* Libdw: Fix initial register collection on i386Ben Gamari2015-11-231-1/+2
| | | | RIP-relative addressing isn't available on i386.
* Libdw: Fix build on 32-bit platformsBen Gamari2015-11-231-5/+6
| | | | | | The casting here is a bit tricky since Dwarf_Addr is always 64-bits. This means we first need to narrow to uintptr_t before casting to/from a pointer for compatibility on 32-bit architectures.
* RtsFlags: Fix const warningBen Gamari2015-11-213-4/+11
| | | | | | | | | | Reviewers: austin Reviewed By: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1509
* rts: Kill PAPI supportBen Gamari2015-11-1811-652/+15
| | | | | | | | | | | | | | | This hasn't been used for a very long time and will soon be superceded by perf_events support. Test Plan: validate Reviewers: austin, simonmar Reviewed By: austin, simonmar Subscribers: thomie, erikd Differential Revision: https://phabricator.haskell.org/D1493
* Fix archive loading on Windows by the runtime loaderTamar Christina2015-11-172-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The runtime loader is unable to find archive files `.a` shipping with the inplace `GCC`. It seems the issue is caused by `findArchive` being unable to find any archives that are shipped using the in-place `GCC`. - It works on Linux because `findArchive` would search the standard Linux include path. - It works during compilation because `GCC` can find it's own libraries (we explicitly tell it where to look for libraries using the `gcc` wrapper around `realgcc`) So fixing the issue means using `searchForLibUsingGcc` in `findArchive` as well, which will then find the correct file. The reason for the error as it is, is because if we can't locate the library using any of the methods we have, we assume it is a system dll, or something on the system search path. e.g. if trying to load `kernel32.dll`. There is a slight issue in that the `GHCi` code (incorrectly) favors `static archives` over `dynamic` ones ``` findDll `orElse` findArchive `orElse` tryGcc `orElse` tryGccPrefixed `orElse` assumeDll ``` This has the unwanted effect of when `kernel32` is specified as a lib, it will try to load `kernel32.a` instead of `kernel32.dll`. To solve this I have added another search function that is able to search the Windows search paths using `SearchPath` in order to find if it is a dll on the system search path. The new search order is: ``` findDll `orElse` findSysDll `orElse` tryGcc `orElse` findArchive `orElse` assumeDll ``` (`tryGccPrefixed` was rolled into `tryGcc` so it is no longer needed at top level) Test Plan: ./validate added new windows tests T3242 Reviewers: thomie, erikd, hvr, austin, bgamari Reviewed By: thomie, erikd, bgamari Differential Revision: https://phabricator.haskell.org/D1455 GHC Trac Issues: #3242
* RtsFlags: Refactor some of the deeper switchesBen Gamari2015-11-161-199/+236
| | | | | | | | | | | | | | | | | | | This was previously nearly impossible to read; now it's merely difficult. Ideally we would do a more thorough refactoring of the RTS command line parser (#4243) but this is more effort than I have time for at the moment. Test Plan: Try using affected RTS flags Reviewers: simonmar, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1476 GHC Trac Issues: #4243
* RtsFlags: Clean up stale CPPBen Gamari2015-11-161-4/+1
|
* Implement function-sections for Haskell code, #8405Simon Brenner2015-11-121-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a flag -split-sections that does similar things to -split-objs, but using sections in single object files instead of relying on the Satanic Splitter and other abominations. This is very similar to the GCC flags -ffunction-sections and -fdata-sections. The --gc-sections linker flag, which allows unused sections to actually be removed, is added to all link commands (if the linker supports it) so that space savings from having base compiled with sections can be realized. Supported both in LLVM and the native code-gen, in theory for all architectures, but really tested on x86 only. In the GHC build, a new SplitSections variable enables -split-sections for relevant parts of the build. Test Plan: validate with both settings of SplitSections Reviewers: dterei, Phyx, austin, simonmar, thomie, bgamari Reviewed By: simonmar, thomie, bgamari Subscribers: hsyl20, erikd, kgardas, thomie Differential Revision: https://phabricator.haskell.org/D1242 GHC Trac Issues: #8405
* fix RTS Linker on platforms without SHN_XINDEX supportKarel Gardas2015-11-111-6/+30
| | | | | | | | | | | | | | | Summary: This patch fixes RTS Linker compilation issues on platforms where SHN_XINDEX is not defined. Tested on OpenBSD. When SHN_XINDEX is not defined, the code reverts to the old behavior, that means behavior of the Linker before D1357 which added SHN_XINDEX based functionality. Reviewers: bgamari, austin, erikd Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1446
* Add OpenBSD specific RTS symbolsKarel Gardas2015-11-081-0/+9
| | | | | | | | | | | | | This patch adds OpenBSD specific RTS symbols. The patch is taken from the OpenBSD ports tree, provided by the OpenBSD community. Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1445
* Allow the GHCi Linker to resolve related dependencies when loading DLLsTamar Christina2015-11-073-19/+199
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: GHCi does not correctly tell the Windows Loader how to handle dependencies to DLL's that are not on the standard Windows load path: 1. The directory from which the application loaded. 2. The current directory. 3. The system directory. Use the GetSystemDirectory function to get the path of this directory. 4. The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched. 5. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory. 6. The directories that are listed in the PATH environment variable. Note that this does not include the per-application path specified by the AppPaths registry key. The App Paths key is not used when computing the DLL search path. So what this means is given two DLLs `A` and `B` and `B` depending on `A`. If we put both DLLs into a new folder bin and then call GHC with: `ghc -L$(PWD)/bin -lB` the loading will fail as the Windows loader will try to load the dependency of `B` and fail since it cannot find `A`. *IMPORTANT* this patch drops XP Support. The APIs being used were natively added to Windows 8+ and backported to Windows 7 and Vista via a mandatory security patch (in 2011). This means that there is a chance that KB2533623 has not been installed on certain machines. For those machines I display a warning and temporarily expand the `PATH` to allow it to load. This patch will make sure that paths provided by the user with `-L` *and* the folder in which a DLL is found are added to the search path. It does so using one of two methods depending upon how new of a Windows version we are running on: - If the APIs are available it will use `addDllDirectory` and `removeDllDirectory`. The order of which these directories are searched is nondeterministic. - If the APIs are not available it means that we're running on a pretty old unpatched machine. But if it's being used in an environment with no internet access it may be the case. So if the APIs are not available we temporarily extend the `PATH` with the directories. A warning is also displayed to the user informing them that the linking may fail, and if it does, install the needed patch. The `PATH` variable has limitations. Test Plan: ./validate Added two new test T10955 and T10955dyn Reviewers: erikd, bgamari, thomie, hvr, austin Reviewed By: erikd, thomie Subscribers: #ghc_windows_task_force Differential Revision: https://phabricator.haskell.org/D1340 GHC Trac Issues: #10955
* Make GHCi & TH work when the compiler is built with -profSimon Marlow2015-11-078-40/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Amazingly, there were zero changes to the byte code generator and very few changes to the interpreter - mainly because we've used good abstractions that hide the differences between profiling and non-profiling. So that bit was pleasantly straightforward, but there were a pile of other wibbles to get the whole test suite through. Note that a compiler built with -prof is now like one built with -dynamic, in that to use TH you have to build the code the same way. For dynamic, we automatically enable -dynamic-too when TH is required, but we don't have anything equivalent for profiling, so you have to explicitly use -prof when building code that uses TH with a profiled compiler. For this reason Cabal won't work with TH. We don't expect to ship a profiled compiler, so I think that's OK. Test Plan: validate with GhcProfiled=YES in validate.mk Reviewers: goldfire, bgamari, rwbarton, austin, hvr, erikd, ezyang Reviewed By: ezyang Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1407 GHC Trac Issues: #4837, #545
* Linker: #ifdef cleanupErik de Castro Lopo2015-11-042-45/+14
| | | | | | | | | | | | | Test Plan: - Run tests on x86_64/linux and powerpc/linux - Cross compile rts/Linker.c with the i686-w64-mingw32-gcc and x86_64-w64-mingw32-gcc Linux to Windows cross-compilers. Reviewers: bgamari, austin, hvr, Phyx Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1429
* rts/Hash: Constify HashTable* in lookupHashTableBen Gamari2015-11-033-8/+8
| | | | | | | | This seems like an obvious place to apply `const` Reviewed By: simonmar, austin Differential Revision: https://phabricator.haskell.org/D1416
* get rid of Elf32/Elf64_Section as this is a non-portable Linux-ism.Karel Gardas2015-11-021-3/+1
| | | | | | | | | | | | | | | | Summary: D1357 introduces usage of Elf32_Section/Elf64_Section in RTS linker code. Unfortunately this is a non-portable Linux-ism and such types are not defined anywhere except the Linux-land probably. I've checked Solaris 11.2, Solaris 11.3, FreeBSD 10.1, NetBSD 6.1.5 and OpenBSD current. The fix is easy to use `unsigned short' as this is also an underlying type of those Elf*_Section defines in Linux. Reviewers: olsner, austin, bgamari, erikd Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1419
* rts: Produce stack trace on fatal errorBen Gamari2015-11-011-0/+12
| | | | | | | | | | | | Test Plan: Validate Reviewers: austin, simonmar Reviewed By: simonmar Subscribers: simonmar, thomie, scpmw Differential Revision: https://phabricator.haskell.org/D1418
* EventLog: Loop fwrite if necessary during flushBen Gamari2015-11-011-10/+12
| | | | | | | | | | | | | | | | | | | | | Previously the eventlog flush code would fail if `fwrite` wrote less than the requested amount. Like all Unix stream I/O operations, however, `fwrite` isn't guaranteed to write the entire buffer. Here we loop as long as `fwrite` succeeds in writing anything. Fixes #11041. Test Plan: Validate with eventlog Reviewers: austin, simonmar Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1415 GHC Trac Issues: #11041
* Libdw: Fix symbol namingBen Gamari2015-11-013-46/+47
| | | | RTS convention is to use camel-case.
* Libdw: Remove special treatment for stg_stop_threadBen Gamari2015-11-011-4/+1
| | | | | This is no longer necessary since this symbol can be unwound through with its DWARF information.
* StgStartup: Setup unwinding for stg_stop_threadBen Gamari2015-11-012-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a bit ugly as we need to assume the structure of the C stack as left by StgRun. Nevertheless, it allows us to unwind all the way back to `_start` on my machine. ``` Stack trace: set_initial_registers (rts/Libdw.c:272.0) dwfl_thread_getframes dwfl_getthreads dwfl_getthread_frames libdw_get_backtrace (rts/Libdw.c:243.0) base_GHCziExecutionStack_getStackTrace1_info (libraries/base/GHC/ExecutionStack.hs:43.1) base_GHCziExecutionStack_showStackTrace1_info (libraries/base/GHC/ExecutionStack.hs:47.1) base_GHCziBase_bindIO1_info (libraries/base/GHC/Base.hs:1085.1) base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1088.1) base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1088.1) base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1088.1) base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1088.1) base_GHCziBase_thenIO1_info (libraries/base/GHC/Base.hs:1088.1) stg_catch_frame_info (rts/Exception.cmm:370.1) stg_stop_thread_info (rts/StgStartup.cmm:42.1) scheduleWaitThread (rts/Schedule.c:465.0) hs_main (rts/RtsMain.c:65.0) __libc_start_main (/tmp/buildd/glibc-2.19/csu/libc-start.c:321.0) _start ```
* Linker: More uint64_t to uintptr_t fixesErik de Castro Lopo2015-11-011-2/+2
| | | | | | | | | | | | | | | Need to use `uintptr_t` on PowerPC and possibly other 32 bit architectures. Test Plan: Validate on x86_64 and powerpc Linux Reviewers: austin, hvr, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1412
* Enforce linkage with pthread library on OpenBSDKarel Gardas2015-11-011-0/+8
| | | | | | | | | | | | | | | | This patch enforces linkage with pthread library on OpenBSD. This is done in order to avoid linker errors when linking with libffi which requires POSIX threading but itself is not linked with libpthread directly. So client binaries (of libffi) needs to link against libpthread explicitly Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie, erikd Differential Revision: https://phabricator.haskell.org/D1410
* rts/posix: Reduce heap allocation amount on mmap failureBen Gamari2015-11-014-12/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | Since the two-step allocator the RTS asks the kernel for a large upfront mmap'd region of memory (on the order of terabytes). While we have no expectation that this entire region will be backed by physical memory, this scheme nevertheless fails on some systems with resource limits. Here we use a back-off scheme to reduce our allocation request until we find a size agreeable to the kernel. Fixes #10877. This also fixes a latent bug wherein the heap reservation retry logic would fail to free the previously reserved address space, which would likely result in a heap allocation failure. Test Plan: set address space limit with `ulimit -v 67108864` and try running a compiled program Reviewers: simonmar, austin Reviewed By: simonmar Subscribers: thomie, RyanGlScott Differential Revision: https://phabricator.haskell.org/D1405 GHC Trac Issues: #10877
* Add rts/Linker support for more than 64k sectionsSimon Brenner2015-11-011-39/+141
| | | | | | | | | | | | | | | | | | | Since some ELF fields ran out of range to represent that many sections, they've been extended with magic numbers that indicate that the full value is stored in another field. This will be necessary for GHCi with -split-sections on ELF platforms that don't use GNU ld. Reviewers: austin, bgamari, simonmar, erikd Reviewed By: bgamari, simonmar, erikd Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1357 GHC Trac Issues: #8405
* Signals: Ensure libdw session is freedBen Gamari2015-10-311-0/+1
|
* rts: Make MBLOCK_SPACE_SIZE dynamicBen Gamari2015-10-305-39/+50
| | | | | | | | | | | | | | | | | | | | | | | Previously this was introduced in D524 as a compile-time constant. Sadly, this isn't flexible enough to allow for environments where ulimits restrict the maximum address space size (see, for instance, Consequently, we are forced to make this dynamic. In principle this shouldn't be so terrible as we can place both the beginning and end addresses within the same cache line, likely incurring only one or so additional instruction in HEAP_ALLOCED. Test Plan: validate Reviewers: austin, simonmar Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1353 GHC Trac Issues: #10877
* Linker: Clean up USE_MMAP usageErik de Castro Lopo2015-10-301-33/+31
| | | | | | | | | | | | Test Plan: Validate on powerpc/linux, x86_64/linux and x86_64/darwin Reviewers: austin, bgamari, thomie Reviewed By: thomie Subscribers: Phyx, thomie Differential Revision: https://phabricator.haskell.org/D1398
* Fix segfault due to reading non-existent memorySimon Marlow2015-10-301-2/+14
| | | | | | | | | | | | | | | | | | | It was possible to read non-existent memory, if we try to read the srt_offset field of an info table when there is no SRT, and the info table is right at the start of the text section. This actually happened to me, I'm not sure why it never happened before. Test Plan: validate Reviewers: rwbarton, ezyang, austin, bgamari Reviewed By: austin, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1401
* Linker: Fix type in m32_free_internalErik de Castro Lopo2015-10-301-1/+1
| | | | | | | | | | | | | | | | | | | | | The code: uint64_t c = __sync_sub_and_fetch((uint64_t*)addr, 1); was causing GCC to emit atomic instructions for 64 bit values which are not available on PowerPC. However, since PowerPC only has a 32 bit address space, use of a 64 bit value is superflous. Switching the type from `uint64_t` to `uintptr_t` should simply do the correct thing on all 32 and 64 bit architectures. Reviewers: austin, bgamari, simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1399 GHC Trac Issues: #11036
* rts/Linker.c: Drop support for legacy OS X dyn loadingErik de Castro Lopo2015-10-291-15/+1
| | | | | | | | | | | | | Drop support for old OS X (OS X 10.2 and earlier) dynamic linking. 10.3 was released in 2003. Test Plan: Validate on OS X and Linux. Reviewers: bgamari, thomie, austin Reviewed By: thomie, austin Differential Revision: https://phabricator.haskell.org/D1393
* Fix the DYNAMIC_GHC_PROGRAMS=NO build on Mac/WindowsReid Barton2015-10-271-0/+1
| | | | | | | | | LEADING_UNDERSCORE is defined in a header file, so we need to #include that file where we use LEADING_UNDERSCORE. Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D1382
* Remove cygwin32_HOST_OS #ifdefsErik de Castro Lopo2015-10-264-114/+10
| | | | | | | | | | | | | | | | | Build system support for Cygwin was removed in b6be81b841. Test Plan: - Validate on x86_64/linux - Cross-compile rts/RtsSymbols.c and rts/Linker.c to Windows using the i686-w64-mingw32-gcc and x86_64-w64-mingw32-gcc cross compilers. Reviewers: hvr, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1371
* Remove redundant typedefGabor Greif2015-10-261-2/+0
| | | | | | | | $ git grep -n "typedef struct LibDwSession_ " rts/Libdw.c:63:typedef struct LibDwSession_ LibDwSession; rts/Libdw.h:22:typedef struct LibDwSession_ LibDwSession; This trips up (e.g.) GCC v4.4.7.
* rts/RtsSymbols.c: Fix Windows buildErik de Castro Lopo2015-10-251-0/+8
| | | | | | | | | | | | | Test Plan: - Build whole of GHC on Linux. - Cross-compile rts/RtsSymbols.c and rts/Linker.c to Windows using the i686-w64-mingw32-gcc and x86_64-w64-mingw32-gcc cross compilers. Reviewers: bgamari, awson, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1365
* rts/Linker.c: Convert #if/#else to if/elseErik de Castro Lopo2015-10-251-22/+28
| | | | | | | | | | Test Plan: validate Reviewers: austin, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1366
* rts/Linker.c: Split RTS symbols out into separate fileErik de Castro Lopo2015-10-243-1183/+1217
| | | | | | | | | | | | | Pull the RtsSymbolVal typedef and rtsSyms[] array out into a separate header and C file. No change in functionality. Test Plan: validate Reviewers: simonmar, austin, bgamari Subscribers: Phyx, thomie Differential Revision: https://phabricator.haskell.org/D1362
* rts/Schedule.c: remove unused variableÖmer Sinan Ağacan2015-10-221-6/+0
| | | | Differential Revision: https://phabricator.haskell.org/D1348
* Fix caching of pagesizeSimon Marlow2015-10-211-3/+2
| | | | | | | | | | | | Summary: Spotted by @erikd Test Plan: validate Reviewers: austin, bgamari, erikd Subscribers: thomie, erikd Differential Revision: https://phabricator.haskell.org/D1345
* fix RTS linker compilation failure on SolarisKarel Gardas2015-10-181-1/+2
| | | | | | | | Reviewers: bgamari, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1341
* Signals: Always install SIGUSR2 handlerBen Gamari2015-10-181-2/+0
| | | | Even if libdw isn't available.
* Signals: Print backtrace on SIGUSR2Ben Gamari2015-10-171-0/+30
| | | | | | | | | | | | | | | This uses the backtrace support introduced in D1196 to provide backtraces from Haskell processes when SIGUSR2 is thrown. Test Plan: Need to add a test. Reviewers: scpmw, simonmar, Tarrasch, austin Reviewed By: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1197
* Libdw: Add libdw-based stack unwindingBen Gamari2015-10-174-0/+404
| | | | | | | | | | | | | | | | | | | | | This adds basic support to the RTS for DWARF-assisted unwinding of the Haskell and C stack via libdw. This only adds the infrastructure; consumers of this functionality will be introduced in future diffs. Currently we are carrying the initial register collection code in Libdw.c but this will eventually make its way upstream to libdw. Test Plan: See future patches Reviewers: Tarrasch, scpmw, austin, simonmar Reviewed By: austin, simonmar Subscribers: simonmar, thomie, erikd Differential Revision: https://phabricator.haskell.org/D1196 GHC Trac Issues: #10656