1. 29 Apr, 2017 2 commits
  2. 23 Apr, 2017 7 commits
    • Moritz Angermann's avatar
      [linker] Adds elf_compat.h, util.h, elf_util.h · 9eea43f9
      Moritz Angermann authored
      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
      9eea43f9
    • Moritz Angermann's avatar
      [linker] Adds ElfTypes · e5e8646d
      Moritz Angermann authored
      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
      e5e8646d
    • Ben Gamari's avatar
      rts: Fix "ASSERT ("s · 1d66f105
      Ben Gamari authored
      Reviewers: austin, erikd, simonmar
      
      Reviewed By: erikd
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3486
      1d66f105
    • Ben Gamari's avatar
      cpp: Use #pragma once instead of #ifndef guards · f13eebcc
      Ben Gamari authored
      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
      f13eebcc
    • Ben Gamari's avatar
      win32/Ticker: Stop ticker on exit · 87fbf39a
      Ben Gamari authored
      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
      87fbf39a
    • Herbert Valerio Riedel's avatar
      Minor reordering of `#include`s fixing compilation on AIX · 0d975a62
      Herbert Valerio Riedel authored
      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.
      0d975a62
    • Sergei Trofimovich's avatar
      rts: tweak cross-compilation to mingw32 · 745032dd
      Sergei Trofimovich authored
      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: default avatarSergei Trofimovich <slyfox@gentoo.org>
      745032dd
  3. 21 Apr, 2017 2 commits
  4. 18 Apr, 2017 1 commit
  5. 17 Apr, 2017 1 commit
    • Sergei Trofimovich's avatar
      hs_add_root() RTS API removal · a92ff5d6
      Sergei Trofimovich authored
      Before ghc-7.2 hs_add_root() had to be used to initialize haskell
      modules when haskell was called from FFI.
      
      commit a52ff761
      ("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: default avatarSergei 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
      a92ff5d6
  6. 16 Apr, 2017 2 commits
  7. 12 Apr, 2017 1 commit
  8. 11 Apr, 2017 2 commits
  9. 05 Apr, 2017 2 commits
  10. 04 Apr, 2017 2 commits
  11. 03 Apr, 2017 1 commit
  12. 02 Apr, 2017 1 commit
    • Simon Marlow's avatar
      Report heap overflow in the same way as stack overflow · 61ba4518
      Simon Marlow authored
      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
      61ba4518
  13. 01 Apr, 2017 1 commit
  14. 29 Mar, 2017 1 commit
  15. 28 Mar, 2017 2 commits
  16. 27 Mar, 2017 6 commits
    • Gabor Greif's avatar
      Don't redefine typedef names · a6675a93
      Gabor Greif authored
      instead define the structs referred to by
       - SectionFormatInfo
       - ObjectCodeFormatInfo
      
      that were only forward-declared earlier.
      
      This fixes redefinition errors with gcc4.4
      a6675a93
    • Moritz Angermann's avatar
      Adds aarch64 linker for mach-o files. · e8a27410
      Moritz Angermann authored
      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
      e8a27410
    • Moritz Angermann's avatar
      Refactor MachO.c · f1ce2766
      Moritz Angermann authored
      - 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
      f1ce2766
    • Moritz Angermann's avatar
      Add ocInit_MachO · 938392c8
      Moritz Angermann authored
      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
      938392c8
    • Moritz Angermann's avatar
      rts linker: Introduce MachOTypes · 8ed29b50
      Moritz Angermann authored
      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
      8ed29b50
    • Moritz Angermann's avatar
      Make mmap r+w only during preload for iOS. · fdbbd63d
      Moritz Angermann authored
      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
      fdbbd63d
  17. 26 Mar, 2017 3 commits
  18. 20 Mar, 2017 1 commit
    • Tamar Christina's avatar
      Fix Windows x86 build · 713ff920
      Tamar Christina authored
      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
      713ff920
  19. 17 Mar, 2017 1 commit
  20. 03 Mar, 2017 1 commit
    • Moritz Angermann's avatar
      Allow iOS to load archives through the linker · d5e0b4bd
      Moritz Angermann authored
      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
      d5e0b4bd