[Git][ghc/ghc][master] 2 commits: Use x86_64-unknown-windows-gnu target for LLVM on Windows

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Sat Sep 21 21:49:15 UTC 2024



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
21aaa34b by sheaf at 2024-09-21T17:48:36-04:00
Use x86_64-unknown-windows-gnu target for LLVM on Windows

- - - - -
992a7624 by sheaf at 2024-09-21T17:48:36-04:00
LLVM: use -relocation-model=pic on Windows

This is necessary to avoid the segfaults reported in #22487.

Fixes #22487

- - - - -


7 changed files:

- compiler/GHC/Driver/Pipeline/Execute.hs
- llvm-targets
- m4/ghc_llvm_target.m4
- + testsuite/tests/llvm/should_run/T22487.hs
- + testsuite/tests/llvm/should_run/T22487.stdout
- + testsuite/tests/llvm/should_run/all.T
- utils/llvm-targets/gen-data-layout.sh


Changes:

=====================================
compiler/GHC/Driver/Pipeline/Execute.hs
=====================================
@@ -969,13 +969,18 @@ llvmOptions llvm_config dflags =
     ++ [("", "-target-abi=" ++ abi) | not (null abi) ]
 
   where target = platformMisc_llvmTarget $ platformMisc dflags
+        target_os = platformOS (targetPlatform dflags)
         Just (LlvmTarget _ mcpu mattr) = lookup target (llvmTargets llvm_config)
 
         -- Relocation models
-        rmodel | gopt Opt_PIC dflags         = "pic"
-               | positionIndependent dflags  = "pic"
-               | ways dflags `hasWay` WayDyn = "dynamic-no-pic"
-               | otherwise                   = "static"
+        rmodel |  gopt Opt_PIC dflags
+               || positionIndependent dflags
+               || target_os == OSMinGW32 -- #22487: use PIC on (64-bit) Windows
+               = "pic"
+               | ways dflags `hasWay` WayDyn
+               = "dynamic-no-pic"
+               | otherwise
+               = "static"
 
         platform = targetPlatform dflags
         arch = platformArch platform


=====================================
llvm-targets
=====================================
@@ -1,4 +1,4 @@
-[("x86_64-unknown-windows", ("e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", "x86-64", ""))
+[("x86_64-unknown-windows-gnu", ("e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", "x86-64", ""))
 ,("arm-unknown-linux-gnueabi", ("e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", "arm7tdmi", "+strict-align"))
 ,("arm-unknown-linux-gnueabihf", ("e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", "arm1176jzf-s", "+strict-align"))
 ,("arm-unknown-linux-musleabihf", ("e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", "arm1176jzf-s", "+strict-align"))


=====================================
m4/ghc_llvm_target.m4
=====================================
@@ -14,7 +14,7 @@ AC_DEFUN([GHC_LLVM_TARGET], [
       ;;
     *-mingw32|*-mingw64|*-msys)
       llvm_target_vendor="unknown"
-      llvm_target_os="windows"
+      llvm_target_os="windows-gnu"
       ;;
     # apple is a bit about their naming scheme for
     # aarch64; and clang on macOS doesn't know that


=====================================
testsuite/tests/llvm/should_run/T22487.hs
=====================================
@@ -0,0 +1,8 @@
+
+module Main where
+
+add :: Double -> Double -> Double
+add x y = x + y
+{-# NOINLINE add #-}
+main = do putStrLn "Hello world!"
+          print (add 1.0 2.0)


=====================================
testsuite/tests/llvm/should_run/T22487.stdout
=====================================
@@ -0,0 +1,2 @@
+Hello world!
+3.0


=====================================
testsuite/tests/llvm/should_run/all.T
=====================================
@@ -0,0 +1,15 @@
+
+def f( name, opts ):
+  opts.only_ways = ['optllvm', 'llvm', 'debugllvm']
+
+setTestOpts(f)
+
+# Apples LLVM Toolchain knows about a `vortex` cpu (and possibly others), that
+# the stock LLVM toolchain doesn't know about and will warn about. Let's not
+# have test fail just because of processor name differences due to different
+# LLVM Toolchains.  GHC tries to pass what apple expects (on darwin), but can
+# be used with the stock LLVM toolchain as well.
+def ignore_llvm_and_vortex( msg ):
+     return re.sub(r".* is not a recognized processor for this target.*\n",r"",msg)
+
+test('T22487', [normal, normalise_errmsg_fun(ignore_llvm_and_vortex)], compile_and_run, [''])


=====================================
utils/llvm-targets/gen-data-layout.sh
=====================================
@@ -26,7 +26,7 @@ TARGETS=(
     #########################
 
     # Windows
-    "x86_64-unknown-windows"
+    "x86_64-unknown-windows-gnu"
 
     #########################
     # Linux



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9e96dad809667c777ebb86983a6e8b372d605e17...992a7624817cdab4b566387f2e877f420f7b27d4

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9e96dad809667c777ebb86983a6e8b372d605e17...992a7624817cdab4b566387f2e877f420f7b27d4
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240921/d676b5d5/attachment-0001.html>


More information about the ghc-commits mailing list