1. 08 Apr, 2019 1 commit
  2. 20 Mar, 2019 1 commit
  3. 15 Mar, 2019 1 commit
  4. 09 Mar, 2019 2 commits
  5. 06 Mar, 2019 1 commit
    • Ben Gamari's avatar
      Rip out object splitting · 37f257af
      Ben Gamari authored
      The splitter is an evil Perl script that processes assembler code.
      Its job can be done better by the linker's --gc-sections flag. GHC
      passes this flag to the linker whenever -split-sections is passed on
      the command line.
      
      This is based on @DemiMarie's D2768.
      
      Fixes Trac #11315
      Fixes Trac #9832
      Fixes Trac #8964
      Fixes Trac #8685
      Fixes Trac #8629
      37f257af
  6. 04 Mar, 2019 2 commits
  7. 22 Feb, 2019 2 commits
  8. 21 Jan, 2019 1 commit
  9. 11 Dec, 2018 1 commit
  10. 06 Dec, 2018 1 commit
  11. 22 Aug, 2018 1 commit
  12. 21 Aug, 2018 2 commits
  13. 16 Jul, 2018 1 commit
    • Simon Marlow's avatar
      Fix space leaks · 71f6b18b
      Simon Marlow authored
      Summary:
      All these were detected by -fghci-leak-check when GHC was
      compiled *without* optimisation (e.g. using the "quick" build flavour).
      
      Unfortunately I don't know of a good way to keep this working.  I'd like
      to just disable the -fghci-leak-check flag when the compiler is built
      without optimisation, but it doesn't look like we have an easy way to do
      that. And even if we could, it would be fragile anyway,
      
      Test Plan: `cd testsuite/tests/ghci; make`
      
      Reviewers: bgamari, hvr, erikd, tdammers
      
      Subscribers: tdammers, rwbarton, thomie, carter
      
      GHC Trac Issues: #15246
      
      Differential Revision: https://phabricator.haskell.org/D4872
      71f6b18b
  14. 20 Jun, 2018 1 commit
    • Moritz Angermann's avatar
      Fix gcc.exe: error: CreateProcess: No such file or directory · 227ede4a
      Moritz Angermann authored
      When GHC links binaries on windows, we pass a -L and -l flag
      to gcc for each dependency in the transitive dependency
      closure.  As this will usually overflow the command argument
      limit on windows, we use response files to pass all arguments
      to gcc.  gcc however internally passes only the -l flags via
      a response file to the collect2 command, but puts the -L flags
      on the command line. As such if we pass enough -L flags to
      gcc--even via a response file--we will eventually overflow the
      command line argument length limit due to gcc passing them
      to collect2 without resorting to a response file.
      
      To prevent this from happening we move all lirbaries into a
      shared temporary folder, and only need to pass a single -L
      flag to gcc.  Ideally however this was fixed in gcc.
      
      Reviewers: bgamari, Phyx
      
      Reviewed By: bgamari
      
      Subscribers: erikd, rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4762
      227ede4a
  15. 31 May, 2018 1 commit
    • Moritz Angermann's avatar
      dead strip dylibs on macOS · b592bd98
      Moritz Angermann authored
      When linking dynamic libraries or executables, we compute the full
      transitive closure over the dependencies, and instruct the linker
      to link all dependencies.  With deep dependency trees the number
      of transitive dependencies can grow quickly.
      
      macOS since the Sierra release has an upper limit on the load
      command sizes the linker parses when loading dynamic lirbaries.
      As such it is mandatory to keep the number of load commands (and
      their size) small on recent macOS releases.
      
      An approach that would just link direct dependencies as specified
      by the -package-id flag is insufficient, because GHC can inline
      across packages and the library or executable being linked could
      refer to symbols deep in the dependency tree.
      
      If we just recursively linked librarys and re-exported their
      symbols, this increases the number of symbols in libraries with
      many dependencies and ultimately puts excessive strain on the
      linker to the point where linking takes a lot longer than even
      the compilation of the modules.
      
      We can however build a list of symbols from the obejcts we want
      to link, and try to compute the libraries we need to link that
      contain those symbols from the transitive dependency closure.
      Luckily, we don't need to write this ourselves, but can use
      the ld64 `-dead_strip_dylibs` linker flag on macOS to achive
      the same result.  This will link only the libraries that are
      actually referenced, which is usually a small subset of the
      full transitive dependency closure.  As such we should stay
      within the load command size limit for almost all but pathological
      cases.
      
      Reviewers: bgamari
      
      Reviewed By: bgamari
      
      Subscribers: lelf, rwbarton, thomie, carter
      
      GHC Trac Issues: #14444
      
      Differential Revision: https://phabricator.haskell.org/D4714
      b592bd98
  16. 30 May, 2018 1 commit
    • Kavon Farvardin's avatar
      Extract hard-coded LLVM opt flags into a file · a4ae199c
      Kavon Farvardin authored
      To resolve ticket #11295, I think it makes sense to stop hard-coding
      the pass sequences used by GHC when compiling with LLVM into the
      compiler
      itself.
      
      This patchset introduces a companion to the existing `llvm-targets` file
      called `llvm-passes`. The passes file is a simple association list that
      holds the default LLVM `opt` pass sequence used by GHC. This allows end
      users to easily save their favorite optimization flags when compiling
      with LLVM.
      
      The main benefit for ticket #11295 is that when adding a custom pass
      sequence, it tends to be an extremely long string that would be
      unsightly in the code.
      
      This is essentially part 1 of 2 for ticket #11295.
      
      Test Plan: ./validate
      
      Reviewers: bgamari, angerman
      
      Reviewed By: angerman
      
      Subscribers: rwbarton, thomie, carter
      
      Differential Revision: https://phabricator.haskell.org/D4695
      a4ae199c
  17. 13 May, 2018 1 commit
    • Matthew Pickering's avatar
      Simplify -ddump-json implementation · 6ab7cf99
      Matthew Pickering authored
      This patch takes the much simpler route of whenever the compiler tries
      to output something. We just dump a JSON document there and then.
      
      I think this should be sufficient to work with and anything more refined
      quickly got complicated as it was necessary to demarcate message scopes
      and so on.
      
      Reviewers: bgamari, dfeuer
      
      Reviewed By: bgamari
      
      Subscribers: Phyx, dfeuer, rwbarton, thomie, carter
      
      GHC Trac Issues: #14078
      
      Differential Revision: https://phabricator.haskell.org/D4532
      6ab7cf99
  18. 05 May, 2018 1 commit
  19. 25 Mar, 2018 1 commit
    • Alec Theriault's avatar
      Support adding objects from TH · ceb91477
      Alec Theriault authored
      The user facing TH interface changes are:
      
        * 'addForeignFile' is renamed to 'addForeignSource'
        * 'qAddForeignFile'/'addForeignFile' now expect 'FilePath's
        * 'RawObject' is now a constructor for 'ForeignSrcLang'
        * 'qAddTempFile'/'addTempFile' let you request a temporary file
          from the compiler.
      
      Test Plan: unsure about this, added a TH test
      
      Reviewers: goldfire, bgamari, angerman
      
      Reviewed By: bgamari, angerman
      
      Subscribers: hsyl20, mboes, carter, simonmar, bitonic, ljli, rwbarton, thomie
      
      GHC Trac Issues: #14298
      
      Differential Revision: https://phabricator.haskell.org/D4217
      ceb91477
  20. 12 Mar, 2018 1 commit
  21. 20 Feb, 2018 1 commit
    • Tamar Christina's avatar
      Change how includes for input file directory works · eb2daa2b
      Tamar Christina authored
      GHC Used to only allow for one include mode, namely `-I`.  The problem
      with `-I` includes is that it supercedes all other includes, including
      the system include paths.
      
      This is not a problem for paths requested by the user, but it is a
      problem for the ones we implicitly derive and add.
      
      In particular we add the source directory of the input file to the
      include path. This is problematic because it causes any file with the
      name of a system include, to inadvertently loop as the wrong file gets
      included.
      
      Since this is an implicitly include, and as far as I can tell, only done
      so local includes are found (as the sources given to GCC reside in a
      temp folder) then switch from `-I` to `-iquote`.
      
      This requires a submodule update for haddock
      
      Test Plan: ./validate
      
      Reviewers: austin, bgamari, hvr
      
      Reviewed By: bgamari
      
      Subscribers: carter, rwbarton, thomie
      
      GHC Trac Issues: #14312
      
      Differential Revision: https://phabricator.haskell.org/D4080
      eb2daa2b
  22. 21 Jan, 2018 1 commit
    • John Ky's avatar
      Add new mbmi and mbmi2 compiler flags · f8557696
      John Ky authored
      This adds support for the bit deposit and extraction operations provided
      by the BMI and BMI2 instruction set extensions on modern amd64 machines.
      
      Implement x86 code generator for pdep and pext.  Properly initialise
      bmiVersion field.
      
      pdep and pext test cases
      
      Fix pattern match for pdep and pext instructions
      
      Fix build of pdep and pext code for 32-bit architectures
      
      Test Plan: Validate
      
      Reviewers: austin, simonmar, bgamari, angerman
      
      Reviewed By: bgamari
      
      Subscribers: trommler, carter, angerman, thomie, rwbarton, newhoggy
      
      GHC Trac Issues: #14206
      
      Differential Revision: https://phabricator.haskell.org/D4236
      f8557696
  23. 19 Dec, 2017 1 commit
  24. 20 Nov, 2017 1 commit
  25. 18 Nov, 2017 1 commit
    • Moritz Angermann's avatar
      Adds -ghc-version flag to ghc. · 12a74444
      Moritz Angermann authored
      Summary:
      When building the rts with ghc (e.g. using ghc as a c compiler), ghc's
      "Value Add"[1] is, it includes adding `-include /path/to/ghcversion.h`.  For
      this it looksup the rts package in the package database, which--if
      empty--fails.  Thus to allow compiling C files with GHC, we add the
      `-ghc-version` flag, which takes the path to the `ghcversion.h` file.
      
      A `-no-ghc-version` flag was omitted, as at that point it becomes
      questionable why one would use ghc to compile c if one doesn't
      any of the added value.
      
      --
      
      [1] from `compiler/main/DriverPipeline.hs`
      >        -- add package include paths even if we're just compiling .c
      >        -- files; this is the Value Add(TM) that using ghc instead of
      >        -- gcc gives you :)
      
      Reviewers: bgamari, geekosaur, austin
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D4135
      12a74444
  26. 30 Oct, 2017 1 commit
  27. 10 Oct, 2017 1 commit
    • Tamar Christina's avatar
      Split SysTools up some · e51e565d
      Tamar Christina authored
      Summary:
      SysTools and DriverTools have an annoying mutual dependency.
      They also each contain pieces of the linker. In order for
      changes to be shared between the library and the exe linking
      code this dependency needs to be broken in order to avoid
      using hs-boot files.
      
      Reviewers: austin, bgamari, erikd
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D4071
      e51e565d
  28. 19 Sep, 2017 1 commit
    • Herbert Valerio Riedel's avatar
      compiler: introduce custom "GhcPrelude" Prelude · f63bc730
      Herbert Valerio Riedel authored
      This switches the compiler/ component to get compiled with
      -XNoImplicitPrelude and a `import GhcPrelude` is inserted in all
      modules.
      
      This is motivated by the upcoming "Prelude" re-export of
      `Semigroup((<>))` which would cause lots of name clashes in every
      modulewhich imports also `Outputable`
      
      Reviewers: austin, goldfire, bgamari, alanz, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: goldfire, rwbarton, thomie, mpickering, bgamari
      
      Differential Revision: https://phabricator.haskell.org/D3989
      f63bc730
  29. 13 Sep, 2017 1 commit
  30. 08 Sep, 2017 1 commit
  31. 06 Sep, 2017 1 commit
    • Moritz Angermann's avatar
      Clean up opt and llc · 22733532
      Moritz Angermann authored
      The LLVM backend shells out to LLVMs `opt` and `llc` tools. This clean
      up introduces a shared data structure to carry the arguments we pass to
      each tool so that corresponding flags are next to each other. It drops
      the hard coded data layouts in favor of using `-mtriple` and have LLVM
      infer them. Furthermore we add `clang` as a proper tool, so we don't
      rely on assuming that `clang` is called `clang` on the `PATH` when using
      `clang` as the assembler.  Finally this diff also changes the type of
      `optLevel` from `Int` to `Word`, as we do not have negative optimization
      levels.
      
      Reviewers: erikd, hvr, austin, rwbarton, bgamari, kavon
      
      Reviewed By: kavon
      
      Subscribers: michalt, Ericson2314, ryantrinkle, dfeuer, carter, simonpj,
      kavon, simonmar, thomie, erikd, snowleopard
      
      Differential Revision: https://phabricator.haskell.org/D3352
      22733532
  32. 22 Aug, 2017 1 commit
  33. 28 Jul, 2017 1 commit
  34. 18 Jul, 2017 1 commit
    • niteria's avatar
      Make module membership on ModuleGraph faster · b8fec695
      niteria authored
      When loading/reloading with a large number of modules
      (>5000) the cost of linear lookups becomes significant.
      
      The changes here made `:reload` go from 6s to 1s on my
      test case.
      
      The bottlenecks were `needsLinker` in `DriverPipeline` and
      `getModLoop` in `GhcMake`.
      
      Test Plan: ./validate
      
      Reviewers: simonmar, austin, bgamari
      
      Subscribers: thomie, rwbarton
      
      Differential Revision: https://phabricator.haskell.org/D3703
      b8fec695
  35. 11 Jul, 2017 2 commits
    • Ben Gamari's avatar
      Use correct section types syntax for architecture · 9b9f978f
      Ben Gamari authored
      Previously GHC would always assume that section types began with `@` while
      producing assembly, which is not true. For instance, in ARM assembly syntax
      section types begin with `%`. This abstracts out section type pretty-printing
      and adjusts it to correctly account for the target architectures assembly
      flavor.
      
      Reviewers: austin, hvr, Phyx
      
      Reviewed By: Phyx
      
      Subscribers: Phyx, rwbarton, thomie, erikd
      
      GHC Trac Issues: #13937
      
      Differential Revision: https://phabricator.haskell.org/D3712
      9b9f978f
    • Moritz Angermann's avatar
      Always allow -staticlib · b8f33bc6
      Moritz Angermann authored
      the `-staticlib` flag is currently only supported on apple platforms,
      due to the avaiablity of libtool (the apple version, which is unlike the
      gnu version).  This however prevents the use of -staticlib in cases
      where it would be beneficial as well.  The functionality that
      `-staticlib` uses from `libtool` can be stubbed with a small script like
      the following:
      
      ```
      #!/bin/bash
      
      # This script pretends to be libtool.  And supports
      # only a limited set of flags.
      #
      # It is supposed to be a stand in for libtool -static, whic
      # creates a static archive.  This is done by locating all -l<lib>
      # libs in the provied -L<lib path> library paths, and building an
      # MRI script to create the final archive from all the libraries, and
      # other provided inputs.
      #
      
      name=${0##*/}
      target=${name%-*}
      
      set -e
      
      ldflags_L=()
      ldflags_l=()
      output=""
      inputs=()
      STATIC=0
      DYNAMIC=1
      mode=$DYNAMIC
      verbose=0
      
      # find_lib <name> path path path path
      function find_lib () {
              lib=$1; shift 1;
              for dir in $@; do
                      if [ -f "$dir/$lib" ]; then
                              echo "$dir/$lib"
                              break
                      fi
              done
      }
      
      while [ "$#" -gt 0 ]; do
              case "$1" in
                      -v|--verbose) verbose=1; shift 1;;
                      -o) output="$2"; shift 2;;
                      -L*) ldflags_L+=("${1:2:${#1}-2}"); shift 1;;
                      -l*) ldflags_l+=("lib${1:2:${#1}-2}.a"); shift 1;;
                      -static) mode=$STATIC; shift 1;;
                      -dynamic) mode=$DYNAMIC; shift 1;;
                      -Wl,*) ldflags+=("${1#*,}"); shift 1;;
                      -*) echo "unknown option: $1" >&2; exit 1;;
                      *) inputs+=("$1"); shift 1;;
              esac
      done
      
      if [ ! $mode == $STATIC ]; then
              echo "-dynamic not supported!" >&2; exit 1;
      fi
      
      MRI="create ${output}\n"
      for input in "${ldflags_l[@]}"; do
              lib=$(find_lib $input ${ldflags_L[@]})
              if [ -z $lib ]; then
                      echo "Failed to find lib $input" >&2
                      exit 1
              else
                      MRI+="addlib $lib\n"
                      continue
              fi
      done
      for input in "${inputs[@]}"; do
              MRI+="addmod $input\n"
      done
      MRI+="save\nend\n"
      echo -e "$MRI" | $target-ar -M
      $target-ranlib $output
      ```
      
      if `ar` supports MRI scripts.
      
      Reviewers: austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3706
      b8f33bc6