[commit: ghc] master: Load dependent dlls. (41e54b4)

git at git.haskell.org git at git.haskell.org
Sun Feb 26 16:51:32 UTC 2017


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

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

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

commit 41e54b4b1a2934364759edcf77ba1f5b03a4098f
Author: Tamar Christina <tamar at zhox.com>
Date:   Thu Feb 23 18:32:28 2017 -0500

    Load dependent dlls.
    
    When the `GCC` driver envokes the pipeline a `SPEC` is used to determine
    how to configure the compiler and which libraries to pass along.
    
    For Windows/mingw, this specfile is
    https://github.com/gcc-mirror/gcc/blob/master/gcc/config/i386/mingw32.h
    
    This has a lot of interesting things that we need to emulate in order to
    be able to link as many things out of the box as GCC. In particular this
    is why you never need to specify `-lgcc_s` when compiling, but you do
    when using `GHCi`.
    
    Unfortunately due to time constraints I can't set up the framework
    required in `GHC` to do this before the feature freeze.
    
    So I suggest this alternate implementation:
    When we load a dll, also bring it's dependencies into scope of the
    interpeter.
    
    This has pros and cons. Pro is, we'll fix many packages on hackage which
    specify just `-lstdc++`. Since this points to `libstdc++-6.dll` which
    will bring `libgcc` into scope.
    
    The downside is, we'll be more lenient than GCC, in that the interpreter
    will link much easier since it has implicit dependencies in scope.
    Whereas for compilation to work you will have to specify it as an
    argument to GHC.
    
    This will make the Windows runtime linker more consistent with the unix
    ones. The difference in semantics came about because of the differences
    between `dlsym` and `GetProcAddress`.  The former seems to search the
    given library and all it's dependencies, while the latter only searches
    the export table of the library. So we need some extra manual work to
    search the dependencies which this patch provides.
    
    Test Plan:
    ```
    ./validate
    ```
    ```
    $ echo :q | inplace/bin/ghc-stage2.exe --interactive +RTS -Dl -RTS
    -lstdc++ 2>&1 | grep "Loading dependency"
    ```
    
    ```
    $ echo :q | ../inplace/bin/ghc-stage2.exe --interactive -lstdc++ +RTS
    -Dl -RTS 2>&1 | grep "Loading dependency"
    Loading dependency *.exe -> GDI32.dll.
    Loading dependency GDI32.dll -> ntdll.dll.
    Loading dependency *.exe -> KERNEL32.dll.
    Loading dependency KERNEL32.dll -> KERNELBASE.dll.
    Loading dependency *.exe -> msvcrt.dll.
    Loading dependency *.exe -> SHELL32.dll.
    Loading dependency SHELL32.dll -> USER32.dll.
    Loading dependency USER32.dll -> win32u.dll.
    Loading dependency *.exe -> WINMM.dll.
    Loading dependency WINMM.dll -> WINMMBASE.dll.
    Loading dependency *.exe -> WSOCK32.dll.
    Loading dependency WSOCK32.dll -> WS2_32.dll.
    Loading dependency WS2_32.dll -> RPCRT4.dll.
    Loading dependency libstdc++-6.dll -> libwinpthread-1.dll.
    Loading dependency libstdc++-6.dll -> libgcc_s_seh-1.dll.
    ```
    
    Trac tickets: #13093, #13189
    
    Reviewers: simonmar, rwbarton, austin, bgamari, erikd
    
    Reviewed By: bgamari
    
    Subscribers: rwbarton, RyanGlScott, thomie, #ghc_windows_task_force
    
    Differential Revision: https://phabricator.haskell.org/D3028


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

41e54b4b1a2934364759edcf77ba1f5b03a4098f
 rts/linker/PEi386.c                   | 169 +++++++++++++++++++++-------------
 testsuite/tests/ghci/linking/Makefile |   4 -
 2 files changed, 106 insertions(+), 67 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 41e54b4b1a2934364759edcf77ba1f5b03a4098f


More information about the ghc-commits mailing list