1. 29 Mar, 2017 4 commits
    • Simon Marlow's avatar
      cg057: accept output · 01e12987
      Simon Marlow authored
      01e12987
    • Simon Peyton Jones's avatar
      Fix ASSERT failure in TcErrors · f88ac374
      Simon Peyton Jones authored
      This fixes Trac #13494, by improving
      
         commit e0ad55f8
         Author: Simon Peyton Jones <simonpj@microsoft.com>
         Date:   Mon Mar 27 10:32:08 2017 +0100
      
         Fix error-message suppress on given equalities
      
      which in turn was a fix to #13446
      f88ac374
    • Simon Peyton Jones's avatar
      Add a couple of HasDebugCallStack contexts · 60d338f5
      Simon Peyton Jones authored
      Just for future (and past) debugging...
      60d338f5
    • Simon Peyton Jones's avatar
      Allow unbound Refl binders in a RULE · 8674883c
      Simon Peyton Jones authored
      Trac #13410 was failing because we had a RULE with a binder
         (c :: t~t)
      and the /occurrences/ of c on the LHS were being optimised to Refl,
      leaving a binder that would not be filled in by matching the LHS
      of the rule.
      
      I flirted with trying to ensure that occurrences (c :: t~t) are
      not optimised to Relf, but that turned out to be fragile; it was
      being done, for good reasons, in multiple places, including
        - TyCoRep.substCoVarBndr
        - Simplify.simplCast
        - Corecion.mkCoVarCo
      
      So I fixed it in one place by making Rules.matchN deal happily
      with an unbound binder (c :: t~t).  Quite easy.  See "Coercion
      variables" in Note [Unbound RULE binders] in Rules.
      
      In addition, I needed to make CoreLint be happy with an bound
      RULE binder that is a Relf coercion variable
      
      In debugging this, I was perplexed that occurrences of a variable
      (c :: t~t) mysteriously turned into Refl.  I found out how it
      was happening, and decided to move it:
      
      * In TyCoRep.substCoVarBndr, do not substitute Refl for a
        binder (c :: t~t).
      
      * In mkCoVarCo do not optimise (c :: t~t) to Refl.
      
      Instead, we do this optimisation in optCoercion (specifically
      opt_co4) where, surprisingly, the optimisation was /not/
      being done.  This has no effect on what programs compile;
      it just moves a relatively-expensive optimisation to optCoercion,
      where it seems more properly to belong.  It's actually not clear
      to me which is really "better", but this way round is less
      surprising.
      
      One small simplifying refactoring
      
      * Eliminate TyCoRep.substCoVarBndrCallback, which was only
        called locally.
      8674883c
  2. 28 Mar, 2017 6 commits
  3. 27 Mar, 2017 17 commits
    • Richard Eisenberg's avatar
      Fix #13458 · cea71418
      Richard Eisenberg authored
      Core Lint shouldn't check representations of types that don't
      have representations.
      
      test case: typecheck/should_compile/T13458
      cea71418
    • Matthew Pickering's avatar
      5025fe24
    • Simon Peyton Jones's avatar
      Remove utterly bogus code · de4723fd
      Simon Peyton Jones authored
      The commit 67465497
          Author: Richard Eisenberg <eir@cis.upenn.edu>
          Date:   Fri Dec 11 18:19:53 2015 -0500
      
          Add kind equalities to GHC.
      
      added this entirely bogus code to Simplify.simplLam:
      
          env' | Coercion co <- arg
               = extendCvSubst env bndr co
               | otherwise
               = env
      
      It's bogus because 'co' is an 'InCoercion', but a CvSubst should have
      only OutCoercions in it.  Moreover, completeBind does the job nicely.
      
      This led to an ASSERT failure in an experimental branch; but I have
      not got a repro case that works on HEAD.  But still, the patch deletes
      code and fixes a bug, so it must be good.
      
      The only mystery is why Richard added it in the first place :-).
      I hope I'm not missing anything.  But it validates fine.
      de4723fd
    • Simon Peyton Jones's avatar
      Fix 'unsolved constraints' in GHCi · feca929b
      Simon Peyton Jones authored
      In initTc, if the computation fails with an exception, we
      should not complain about unsolved constraints.
      
      Fixes Trac #13466.
      feca929b
    • Simon Peyton Jones's avatar
      Fix error-message suppress on given equalities · e0ad55f8
      Simon Peyton Jones authored
      I'd got the logic slightly wrong when reporting type errors
      for insoluble 'given' equalities.  We suppress insoluble givens
      under some circumstances (see Note [Given errors]), but we then
      suppressed subsequent 'wanted' errors because the (suppressed)
      'given' error "won".  Result: no errors at all :-(.
      
      This patch fixes it and
       - Renames TcType.isTyVarUnderDatatype to the more
         perspicuous TcType.isInsolubleOccursCheck
      
      In doing this I realise that I don't understand why we need
      to keep the insolubles partitioned out separately at all...
      but that is for another day.
      e0ad55f8
    • Simon Peyton Jones's avatar
      Fix explicitly-bidirectional pattern synonyms · 7c7479d0
      Simon Peyton Jones authored
      This partly fixes Trac #13441, at least for the explicitly
      bidirectional case.
      
      See Note [Checking against a pattern signature], the part about
      "Existential type variables".
      
      Alas, the implicitly-bidirectional case is still not quite right, but
      at least there is a workaround by making it explicitly bidirectional.
      7c7479d0
    • Simon Peyton Jones's avatar
      7e1c492d
    • Simon Peyton Jones's avatar
      Eliminate a user manual warning · af33073c
      Simon Peyton Jones authored
      I was getting
        docs/users_guide/glasgow_exts.rst:12783:
           WARNING: Title underline too short.
      
        ``COLUMN`` pragma
        ---------------
      
      So I lengthened the row of hyphens.
      af33073c
    • Simon Peyton Jones's avatar
      Simplify the logic for tc_hs_sig_type · 1e06d8b8
      Simon Peyton Jones authored
      In fixing Trac #13337, and introducing solveSomeEqualities,
      Richard introduce the higher-order function tc_hs_sig_type_x,
      with a solver as its argument.
      
      It turned out that there was a much simpler way to do the
      same thing, which this patch implements.  Less code, easier
      to grok.  No change in behaviour though.
      1e06d8b8
    • 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
    • Matthew Pickering's avatar
      Only use locally bound variables in pattern synonym declarations · d819e416
      Matthew Pickering authored
      Summary:
      We were using the unconstrainted `lookupOccRn` function which looked up
      any variable in scope. Instead we only want to consider variables brought into
      scope by renaming the pattern on the RHS.
      
      A few more changes to make reporting of unbound names suggest the correct
      things.
      
      Fixes #13470
      
      Reviewers: simonpj, austin, bgamari
      
      Reviewed By: simonpj
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3377
      d819e416
    • Matthew Pickering's avatar
      Remove unused argument from importSuggestions · a6ce7f33
      Matthew Pickering authored
      Reviewers: austin, bgamari
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3376
      a6ce7f33
    • 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
  4. 26 Mar, 2017 13 commits