1. 23 Nov, 2015 4 commits
  2. 21 Nov, 2015 1 commit
  3. 18 Nov, 2015 1 commit
  4. 17 Nov, 2015 1 commit
    • Tamar Christina's avatar
      Fix archive loading on Windows by the runtime loader · acce37f3
      Tamar Christina authored
      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
      acce37f3
  5. 16 Nov, 2015 2 commits
  6. 12 Nov, 2015 1 commit
    • olsner's avatar
      Implement function-sections for Haskell code, #8405 · 4a32bf92
      olsner authored
      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
      
      G...
      4a32bf92
  7. 11 Nov, 2015 1 commit
    • kgardas's avatar
      fix RTS Linker on platforms without SHN_XINDEX support · 9bea234d
      kgardas authored
      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
      9bea234d
  8. 07 Nov, 2015 3 commits
    • kgardas's avatar
      Add OpenBSD specific RTS symbols · 2b7d9c2b
      kgardas authored
      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
      2b7d9c2b
    • Tamar Christina's avatar
      Allow the GHCi Linker to resolve related dependencies when loading DLLs · 6e6438e1
      Tamar Christina authored
      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
      6e6438e1
    • Simon Marlow's avatar
      Make GHCi & TH work when the compiler is built with -prof · ce1f1607
      Simon Marlow authored
      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
      ce1f1607
  9. 04 Nov, 2015 1 commit
  10. 03 Nov, 2015 1 commit
  11. 02 Nov, 2015 1 commit
    • kgardas's avatar
      get rid of Elf32/Elf64_Section as this is a non-portable Linux-ism. · c00c5e5b
      kgardas authored
      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
      c00c5e5b
  12. 01 Nov, 2015 9 commits
    • Ben Gamari's avatar
      rts: Produce stack trace on fatal error · 9fe5497e
      Ben Gamari authored
      Test Plan: Validate
      
      Reviewers: austin, simonmar
      
      Reviewed By: simonmar
      
      Subscribers: simonmar, thomie, scpmw
      
      Differential Revision: https://phabricator.haskell.org/D1418
      9fe5497e
    • Ben Gamari's avatar
      EventLog: Loop fwrite if necessary during flush · f46f32b9
      Ben Gamari authored
      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
      f46f32b9
    • Ben Gamari's avatar
      Libdw: Fix symbol naming · 52c6e3d6
      Ben Gamari authored
      RTS convention is to use camel-case.
      52c6e3d6
    • Ben Gamari's avatar
      Libdw: Remove special treatment for stg_stop_thread · bb446b26
      Ben Gamari authored
      This is no longer necessary since this symbol can be unwound through
      with its DWARF information.
      bb446b26
    • Ben Gamari's avatar
      StgStartup: Setup unwinding for stg_stop_thread · d9f88628
      Ben Gamari authored
      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
      ```
      d9f88628
    • Erik de Castro Lopo's avatar
      Linker: More uint64_t to uintptr_t fixes · 184dfced
      Erik de Castro Lopo authored
      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
      184dfced
    • kgardas's avatar
      Enforce linkage with pthread library on OpenBSD · c8e866a1
      kgardas authored
      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
      c8e866a1
    • Ben Gamari's avatar
      rts/posix: Reduce heap allocation amount on mmap failure · 4ad2a8f9
      Ben Gamari authored
      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
      4ad2a8f9
    • olsner's avatar
      Add rts/Linker support for more than 64k sections · 3021cc06
      olsner authored
      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
      3021cc06
  13. 31 Oct, 2015 1 commit
  14. 30 Oct, 2015 4 commits
    • Ben Gamari's avatar
      rts: Make MBLOCK_SPACE_SIZE dynamic · f5974c88
      Ben Gamari authored
      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
      f5974c88
    • Erik de Castro Lopo's avatar
      Linker: Clean up USE_MMAP usage · 3e2c227e
      Erik de Castro Lopo authored
      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
      3e2c227e
    • Simon Marlow's avatar
      Fix segfault due to reading non-existent memory · 2624298a
      Simon Marlow authored
      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
      2624298a
    • Erik de Castro Lopo's avatar
      Linker: Fix type in m32_free_internal · 8ddf4174
      Erik de Castro Lopo authored
      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
      8ddf4174
  15. 29 Oct, 2015 1 commit
  16. 27 Oct, 2015 1 commit
  17. 26 Oct, 2015 2 commits
    • Erik de Castro Lopo's avatar
      Remove cygwin32_HOST_OS #ifdefs · 23e344bb
      Erik de Castro Lopo authored
      Build system support for Cygwin was removed in b6be81b8.
      
      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
      23e344bb
    • Gabor Greif's avatar
      Remove redundant typedef · 86e5eb9e
      Gabor Greif authored
      $ 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.
      86e5eb9e
  18. 25 Oct, 2015 2 commits
  19. 24 Oct, 2015 1 commit
  20. 22 Oct, 2015 1 commit
  21. 21 Oct, 2015 1 commit