[commit: ghc] master: Load `pthreads` by default on Windows (be3f436)

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


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

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

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

commit be3f436277042477d4a9215c4d5022a6f2225ed9
Author: Tamar Christina <tamar at zhox.com>
Date:   Thu Feb 23 18:34:33 2017 -0500

    Load `pthreads` by default on Windows
    
    The GCC Bindists that we use compile with `pthread` enabled by default.
    This means that on every link the dll is passed as a dependency by the
    driver. Lots of packages depend on it but the runtime linker doesn't
    provide it by default making compiled code work but not interpreted.
    
    Following D3028 `pthreads` would be provided by default ONLY when linked
    dynamicly, which we don't support yet (See D2592). Until this is the
    case we need to manually provide `libpthreads`.
    
    Test Plan: ./validate
    
    Reviewers: austin, hvr, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: thomie, #ghc_windows_task_force
    
    Differential Revision: https://phabricator.haskell.org/D3155


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

be3f436277042477d4a9215c4d5022a6f2225ed9
 compiler/ghci/Linker.hs | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/compiler/ghci/Linker.hs b/compiler/ghci/Linker.hs
index e89f1bb..ebd27b0 100644
--- a/compiler/ghci/Linker.hs
+++ b/compiler/ghci/Linker.hs
@@ -312,7 +312,19 @@ linkCmdLineLibs' hsc_env pls =
                            , libraryPaths = lib_paths}) = hsc_dflags hsc_env
 
       -- (c) Link libraries from the command-line
-      let minus_ls = [ lib | Option ('-':'l':lib) <- cmdline_ld_inputs ]
+      let minus_ls_1 = [ lib | Option ('-':'l':lib) <- cmdline_ld_inputs ]
+
+      -- On Windows we want to add libpthread by default just as GCC would.
+      -- However because we don't know the actual name of pthread's dll we
+      -- need to defer this to the locateLib call so we can't initialize it
+      -- inside of the rts. Instead we do it here to be able to find the
+      -- import library for pthreads. See Trac #13210.
+      let platform = targetPlatform dflags
+          os       = platformOS platform
+          minus_ls = case os of
+                       OSMinGW32 -> "pthread" : minus_ls_1
+                       _         -> minus_ls_1
+
       libspecs <- mapM (locateLib hsc_env False lib_paths) minus_ls
 
       -- (d) Link .o files from the command-line



More information about the ghc-commits mailing list