[commit: ghc] master: Fix archive loading on Windows by the runtime loader (acce37f)

git at git.haskell.org git at git.haskell.org
Tue Nov 17 15:20:03 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/acce37f38bc3867f86cf717694915746bb2f278e/ghc

>---------------------------------------------------------------

commit acce37f38bc3867f86cf717694915746bb2f278e
Author: Tamar Christina <tamar at zhox.com>
Date:   Tue Nov 17 15:35:46 2015 +0100

    Fix archive loading on Windows by the runtime loader
    
    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


>---------------------------------------------------------------

acce37f38bc3867f86cf717694915746bb2f278e
 compiler/ghci/Linker.hs                   | 26 ++++++++++++++-------
 compiler/ghci/ObjLink.hs                  | 39 ++++++++++++++++++++-----------
 includes/rts/Linker.h                     |  7 ++++++
 rts/Linker.c                              | 37 +++++++++++++++++++++++++++++
 rts/RtsSymbols.c                          |  1 +
 testsuite/tests/ghci/linking/dyn/Makefile |  5 +++-
 testsuite/tests/ghci/linking/dyn/all.T    |  5 ++++
 7 files changed, 98 insertions(+), 22 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc acce37f38bc3867f86cf717694915746bb2f278e


More information about the ghc-commits mailing list