summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2018-10-11 10:31:58 -0400
committerBen Gamari <ben@smart-cactus.org>2018-10-11 10:31:58 -0400
commit52b514003c60492f21790a823c488c49ec5fc89d (patch)
treea87141d383de4bb147dfdb7ae2a8fb751376d462
parent2fc8ce5f0c8c81771c26266ac0b150ca9b75c5f3 (diff)
parent7ce9ead4fddfbffb5cb63cce0f1b4533b7bcc0ad (diff)
downloadhaskell-ghc-8.2.tar.gz
Merge commit '7ce9ead4fddfbffb5cb63cce0f1b4533b7bcc0ad' into ghc-8.2ghc-8.2
John Ericson from Obsidian Systems proposed that we merge these backports, which Obsidian bases its cross-compiled builds on, to the upstream stable branch. I don't see why not.
-rw-r--r--aclocal.m492
-rw-r--r--compiler/ghc.mk2
-rw-r--r--compiler/llvmGen/LlvmCodeGen.hs11
-rw-r--r--compiler/llvmGen/LlvmCodeGen/Ppr.hs63
-rw-r--r--compiler/main/DriverPipeline.hs272
-rw-r--r--compiler/main/DynFlags.hs36
-rw-r--r--compiler/main/GHC.hs3
-rw-r--r--compiler/main/HscTypes.hs1
-rw-r--r--compiler/main/SysTools.hs27
-rw-r--r--compiler/nativeGen/RegAlloc/Linear/Main.hs2
-rw-r--r--compiler/specialise/SpecConstr.hs4
-rw-r--r--compiler/typecheck/TcCanonical.hs2
-rw-r--r--compiler/typecheck/TcInteract.hs4
-rw-r--r--compiler/utils/Platform.hs14
-rw-r--r--configure.ac9
-rw-r--r--docs/users_guide/phases.rst8
-rw-r--r--ghc.mk7
-rw-r--r--ghc/GHCi/UI.hs4
-rw-r--r--ghc/Main.hs2
-rw-r--r--ghc/ghc.mk5
-rw-r--r--libraries/base/configure.ac2
-rw-r--r--llvm-targets25
-rw-r--r--mk/config.mk.in1
-rw-r--r--mk/project.mk.in37
-rw-r--r--settings.in3
-rw-r--r--testsuite/mk/ghc-config.hs1
-rw-r--r--testsuite/tests/perf/compiler/all.T6
-rwxr-xr-xutils/llvm-targets/gen-data-layout.sh104
-rw-r--r--utils/mkUserGuidePart/Options/Linking.hs7
29 files changed, 463 insertions, 291 deletions
diff --git a/aclocal.m4 b/aclocal.m4
index d5078de92f..6d7616e339 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -20,14 +20,8 @@ AC_DEFUN([GHC_SELECT_FILE_EXTENSIONS],
$2='.exe'
$3='.dll'
;;
- i386-apple-darwin|powerpc-apple-darwin)
- $3='.dylib'
- ;;
- x86_64-apple-darwin)
- $3='.dylib'
- ;;
- arm-apple-darwin10|i386-apple-darwin11|aarch64-apple-darwin14|x86_64-apple-darwin14)
- $2='.a'
+ # apple platform uses .dylib (macOS, iOS, ...)
+ *-apple-*)
$3='.dylib'
;;
esac
@@ -115,6 +109,8 @@ AC_DEFUN([FPTOOLS_SET_PLATFORM_VARS],
GHC_CONVERT_OS([$target_os], [$TargetArch], [TargetOS])
fi
+ GHC_LLVM_TARGET([$target_cpu],[$target_vendor],[$target_os],[LlvmTarget])
+
GHC_SELECT_FILE_EXTENSIONS([$host], [exeext_host], [soext_host])
GHC_SELECT_FILE_EXTENSIONS([$target], [exeext_target], [soext_target])
windows=NO
@@ -142,9 +138,13 @@ AC_DEFUN([FPTOOLS_SET_PLATFORM_VARS],
TargetVendor_CPP=` echo "$TargetVendor" | sed -e 's/\./_/g' -e 's/-/_/g'`
TargetOS_CPP=` echo "$TargetOS" | sed -e 's/\./_/g' -e 's/-/_/g'`
+ # we intend to pass trough --targets to llvm as is.
+ LLVMTarget_CPP=` echo "$LlvmTarget"`
+
echo "GHC build : $BuildPlatform"
echo "GHC host : $HostPlatform"
echo "GHC target : $TargetPlatform"
+ echo "LLVM target: $LlvmTarget"
AC_SUBST(BuildPlatform)
AC_SUBST(HostPlatform)
@@ -160,6 +160,7 @@ AC_DEFUN([FPTOOLS_SET_PLATFORM_VARS],
AC_SUBST(HostOS_CPP)
AC_SUBST(BuildOS_CPP)
AC_SUBST(TargetOS_CPP)
+ AC_SUBST(LLVMTarget_CPP)
AC_SUBST(HostVendor_CPP)
AC_SUBST(BuildVendor_CPP)
@@ -238,13 +239,10 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS],
checkOS() {
case [$]1 in
- linux)
+ linux|linux-android)
test -z "[$]2" || eval "[$]2=OSLinux"
;;
- ios)
- test -z "[$]2" || eval "[$]2=OSiOS"
- ;;
- darwin)
+ darwin|ios|watchos|tvos)
test -z "[$]2" || eval "[$]2=OSDarwin"
;;
solaris2)
@@ -280,9 +278,6 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS],
aix)
test -z "[$]2" || eval "[$]2=OSAIX"
;;
- linux-android)
- test -z "[$]2" || eval "[$]2=OSAndroid"
- ;;
*)
echo "Unknown OS '[$]1'"
exit 1
@@ -482,6 +477,12 @@ AC_DEFUN([FP_SETTINGS],
SettingsLibtoolCommand="libtool"
SettingsTouchCommand='touch'
fi
+ if test -z "$ClangCmd"
+ then
+ SettingsClangCommand="clang"
+ else
+ SettingsClangCommand="$ClangCmd"
+ fi
if test -z "$LlcCmd"
then
SettingsLlcCommand="llc"
@@ -512,6 +513,7 @@ AC_DEFUN([FP_SETTINGS],
AC_SUBST(SettingsWindresCommand)
AC_SUBST(SettingsLibtoolCommand)
AC_SUBST(SettingsTouchCommand)
+ AC_SUBST(SettingsClangCommand)
AC_SUBST(SettingsLlcCommand)
AC_SUBST(SettingsOptCommand)
])
@@ -865,20 +867,17 @@ AC_CACHE_CHECK([leading underscore in symbol names], [fptools_cv_leading_undersc
# Hack!: nlist() under Digital UNIX insist on there being an _,
# but symbol table listings shows none. What is going on here?!?
case $TargetPlatform in
-*linux-android*) fptools_cv_leading_underscore=no;;
-*openbsd*) # x86 openbsd is ELF from 3.4 >, meaning no leading uscore
- case $build in
- i386-*2\.@<:@0-9@:>@ | i386-*3\.@<:@0-3@:>@ ) fptools_cv_leading_underscore=yes ;;
- *) fptools_cv_leading_underscore=no ;;
- esac ;;
-i386-unknown-mingw32) fptools_cv_leading_underscore=yes;;
-x86_64-unknown-mingw32) fptools_cv_leading_underscore=no;;
-
- # HACK: Apple doesn't seem to provide nlist in the 64-bit-libraries
-x86_64-apple-darwin*) fptools_cv_leading_underscore=yes;;
-*-apple-ios) fptools_cv_leading_underscore=yes;;
-
-*) AC_RUN_IFELSE([AC_LANG_SOURCE([[#ifdef HAVE_NLIST_H
+ # Apples mach-o platforms use leading underscores
+ *-apple-*) fptools_cv_leading_underscore=yes;;
+ *linux-android*) fptools_cv_leading_underscore=no;;
+ *openbsd*) # x86 openbsd is ELF from 3.4 >, meaning no leading uscore
+ case $build in
+ i386-*2\.@<:@0-9@:>@ | i386-*3\.@<:@0-3@:>@ ) fptools_cv_leading_underscore=yes ;;
+ *) fptools_cv_leading_underscore=no ;;
+ esac ;;
+ i386-unknown-mingw32) fptools_cv_leading_underscore=yes;;
+ x86_64-unknown-mingw32) fptools_cv_leading_underscore=no;;
+ *) AC_RUN_IFELSE([AC_LANG_SOURCE([[#ifdef HAVE_NLIST_H
#include <nlist.h>
struct nlist xYzzY1[] = {{"xYzzY1", 0},{0}};
struct nlist xYzzY2[] = {{"_xYzzY2", 0},{0}};
@@ -1214,7 +1213,7 @@ AC_DEFUN([FP_PROG_AR_NEEDS_RANLIB],[
if test $fp_prog_ar_is_gnu = yes
then
fp_cv_prog_ar_needs_ranlib=no
- elif test "$TargetOS_CPP" = "darwin"
+ elif test "$TargetVendor_CPP" = "apple"
then
# It's quite tedious to check for Apple's crazy timestamps in
# .a files, so we hardcode it.
@@ -1926,6 +1925,24 @@ case "$1" in
esac
])
+# GHC_LLVM_TARGET(target_cpu, target_vendor, target_os, llvm_target_var)
+# --------------------------------
+# converts the canonicalized target into someting llvm can understand
+AC_DEFUN([GHC_LLVM_TARGET], [
+ case "$2-$3" in
+ hardfloat-*eabi)
+ llvm_target_vendor="unknown"
+ llvm_target_os="$3""hf"
+ ;;
+ *)
+ GHC_CONVERT_VENDOR([$2],[llvm_target_vendor])
+ GHC_CONVERT_OS([$3],[$1],[llvm_target_os])
+ ;;
+ esac
+ $4="$1-$llvm_target_vendor-$llvm_target_os"
+])
+
+
# GHC_CONVERT_VENDOR(vendor, target_var)
# --------------------------------
# converts vendor from gnu to ghc naming, and assigns the result to $target_var
@@ -1951,12 +1968,11 @@ AC_DEFUN([GHC_CONVERT_VENDOR],[
# --------------------------------
# converts os from gnu to ghc naming, and assigns the result to $target_var
AC_DEFUN([GHC_CONVERT_OS],[
-case "$1-$2" in
- darwin10-arm|darwin11-i386|darwin14-aarch64|darwin14-x86_64)
- $3="ios"
- ;;
- *)
case "$1" in
+ # watchos and tvos are ios variant as of May 2017.
+ ios|watchos|tvos)
+ $3="ios"
+ ;;
linux-android*)
$3="linux-android"
;;
@@ -1983,8 +1999,6 @@ case "$1-$2" in
exit 1
;;
esac
- ;;
- esac
])
# BOOTSTRAPPING_GHC_INFO_FIELD
@@ -2016,7 +2030,7 @@ AC_SUBST(LIBRARY_[]translit([$1], [-], [_])[]_VERSION)
# --------------------------------
# Gets the version number of XCode, if on a Mac
AC_DEFUN([XCODE_VERSION],[
- if test "$TargetOS_CPP" = "darwin"
+ if test "$TargetVendor_CPP" = "apple"
then
AC_MSG_CHECKING(XCode version)
XCodeVersion=`xcodebuild -version | grep Xcode | sed "s/Xcode //"`
diff --git a/compiler/ghc.mk b/compiler/ghc.mk
index 614d193d94..e5b3d20e6f 100644
--- a/compiler/ghc.mk
+++ b/compiler/ghc.mk
@@ -170,6 +170,7 @@ compiler/stage1/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
@echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@
@echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@
@echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
+ @echo "#define LLVM_TARGET \"$(LLVMTarget_CPP)\"" >> $@
@echo >> $@
@echo "#define $(BuildOS_CPP)_BUILD_OS 1" >> $@
@echo "#define $(HostOS_CPP)_HOST_OS 1" >> $@
@@ -211,6 +212,7 @@ compiler/stage2/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
@echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
@echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
@echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
+ @echo "#define LLVM_TARGET \"$(LLVMTarget_CPP)\"" >> $@
@echo >> $@
@echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
@echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
diff --git a/compiler/llvmGen/LlvmCodeGen.hs b/compiler/llvmGen/LlvmCodeGen.hs
index 5596d599c4..d5d76ea4ba 100644
--- a/compiler/llvmGen/LlvmCodeGen.hs
+++ b/compiler/llvmGen/LlvmCodeGen.hs
@@ -71,7 +71,7 @@ llvmCodeGen dflags h us cmm_stream
llvmCodeGen' :: Stream.Stream LlvmM RawCmmGroup () -> LlvmM ()
llvmCodeGen' cmm_stream
= do -- Preamble
- renderLlvm pprLlvmHeader
+ renderLlvm header
ghcInternalFunctions
cmmMetaLlvmPrelude
@@ -84,6 +84,15 @@ llvmCodeGen' cmm_stream
-- Postamble
cmmUsedLlvmGens
+ where
+ header :: SDoc
+ header = sdocWithDynFlags $ \dflags ->
+ let target = LLVM_TARGET
+ layout = case lookup target (llvmTargets dflags) of
+ Just (LlvmTarget dl _ _) -> dl
+ Nothing -> error $ "Failed to lookup the datalayout for " ++ target ++ "; available targets: " ++ show (map fst $ llvmTargets dflags)
+ in text ("target datalayout = \"" ++ layout ++ "\"")
+ $+$ text ("target triple = \"" ++ target ++ "\"")
llvmGroupLlvmGens :: RawCmmGroup -> LlvmM ()
llvmGroupLlvmGens cmm = do
diff --git a/compiler/llvmGen/LlvmCodeGen/Ppr.hs b/compiler/llvmGen/LlvmCodeGen/Ppr.hs
index 37d1391519..e7444ee226 100644
--- a/compiler/llvmGen/LlvmCodeGen/Ppr.hs
+++ b/compiler/llvmGen/LlvmCodeGen/Ppr.hs
@@ -4,7 +4,7 @@
-- | Pretty print helpers for the LLVM Code generator.
--
module LlvmCodeGen.Ppr (
- pprLlvmHeader, pprLlvmCmmDecl, pprLlvmData, infoSection
+ pprLlvmCmmDecl, pprLlvmData, infoSection
) where
#include "HsVersions.h"
@@ -15,7 +15,6 @@ import LlvmCodeGen.Data
import CLabel
import Cmm
-import Platform
import FastString
import Outputable
@@ -26,66 +25,6 @@ import Unique
-- * Top level
--
--- | Header code for LLVM modules
-pprLlvmHeader :: SDoc
-pprLlvmHeader = moduleLayout
-
-
--- | LLVM module layout description for the host target
-moduleLayout :: SDoc
-moduleLayout = sdocWithPlatform $ \platform ->
- case platform of
- Platform { platformArch = ArchX86, platformOS = OSDarwin } ->
- text "target datalayout = \"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32\""
- $+$ text "target triple = \"i386-apple-darwin9.8\""
- Platform { platformArch = ArchX86, platformOS = OSMinGW32 } ->
- text "target datalayout = \"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f80:128:128-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32\""
- $+$ text "target triple = \"i686-pc-win32\""
- Platform { platformArch = ArchX86, platformOS = OSLinux } ->
- text "target datalayout = \"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32\""
- $+$ text "target triple = \"i386-pc-linux-gnu\""
- Platform { platformArch = ArchX86_64, platformOS = OSDarwin } ->
- text "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64\""
- $+$ text "target triple = \"x86_64-apple-darwin10.0.0\""
- Platform { platformArch = ArchX86_64, platformOS = OSLinux } ->
- text "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64\""
- $+$ text "target triple = \"x86_64-linux-gnu\""
- Platform { platformArch = ArchARM {}, platformOS = OSLinux } ->
- text "target datalayout = \"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32\""
- $+$ text "target triple = \"armv6-unknown-linux-gnueabihf\""
- Platform { platformArch = ArchARM {}, platformOS = OSAndroid } ->
- text "target datalayout = \"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32\""
- $+$ text "target triple = \"arm-unknown-linux-androideabi\""
- Platform { platformArch = ArchARM {}, platformOS = OSQNXNTO } ->
- text "target datalayout = \"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32\""
- $+$ text "target triple = \"arm-unknown-nto-qnx8.0.0eabi\""
- Platform { platformArch = ArchARM {}, platformOS = OSiOS } ->
- text "target datalayout = \"e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32\""
- $+$ text "target triple = \"thumbv7-apple-ios7.0.0\""
- Platform { platformArch = ArchARM64, platformOS = OSiOS } ->
- text "target datalayout = \"e-m:o-i64:64-i128:128-n32:64-S128\""
- $+$ text "target triple = \"arm64-apple-ios7.0.0\""
- Platform { platformArch = ArchX86, platformOS = OSiOS } ->
- text "target datalayout = \"e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128\""
- $+$ text "target triple = \"i386-apple-ios7.0.0\""
- Platform { platformArch = ArchX86_64, platformOS = OSiOS } ->
- text "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\""
- $+$ text "target triple = \"x86_64-apple-ios7.0.0\""
- Platform { platformArch = ArchARM64, platformOS = OSLinux } ->
- text "target datalayout = \"e-m:e-i64:64-i128:128-n32:64-S128\""
- $+$ text "target triple = \"aarch64-unknown-linux-gnu\""
- _ ->
- if platformIsCrossCompiling platform
- then panic "LlvmCodeGen.Ppr: Cross compiling without valid target info."
- else empty
- -- If you see the above panic, GHC is missing the required target datalayout
- -- and triple information. You can obtain this info by compiling a simple
- -- 'hello world' C program with the clang C compiler eg:
- -- clang -S hello.c -emit-llvm -o -
- -- and the first two lines of hello.ll should provide the 'target datalayout'
- -- and 'target triple' lines required.
-
-
-- | Pretty print LLVM data code
pprLlvmData :: LlvmData -> SDoc
pprLlvmData (globals, types) =
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 40e6a8dead..4cfc48eaa3 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -67,7 +67,7 @@ import System.Directory
import System.FilePath
import System.IO
import Control.Monad
-import Data.List ( isSuffixOf )
+import Data.List ( isSuffixOf, intercalate )
import Data.Maybe
import Data.Version
@@ -378,7 +378,7 @@ link' dflags batch_attempt_linking hpt
let
staticLink = case ghcLink dflags of
LinkStaticLib -> True
- _ -> platformBinariesAreStaticLibs (targetPlatform dflags)
+ _ -> False
home_mod_infos = eltsHpt hpt
@@ -818,6 +818,63 @@ getOutputFilename stop_phase output basename dflags next_phase maybe_location
| Just d <- odir = d </> persistent
| otherwise = persistent
+
+-- | The fast LLVM Pipeline skips the mangler and assembler,
+-- emiting object code dirctly from llc.
+--
+-- slow: opt -> llc -> .s -> mangler -> as -> .o
+-- fast: opt -> llc -> .o
+--
+-- hidden flag: -ffast-llvm
+--
+-- if keep-s-files is specified, we need to go through
+-- the slow pipeline (Kavon Farvardin requested this).
+fastLlvmPipeline :: DynFlags -> Bool
+fastLlvmPipeline dflags
+ = not (gopt Opt_KeepSFiles dflags) && gopt Opt_FastLlvm dflags
+
+-- | LLVM Options. These are flags to be passed to opt and llc, to ensure
+-- consistency we list them in pairs, so that they form groups.
+llvmOptions :: DynFlags
+ -> [(String, String)] -- ^ pairs of (opt, llc) arguments
+llvmOptions dflags =
+ [("-enable-tbaa -tbaa", "-enable-tbaa") | gopt Opt_LlvmTBAA dflags ]
+ ++ [("-relocation-model=" ++ rmodel
+ ,"-relocation-model=" ++ rmodel) | not (null rmodel)]
+ ++ [("-stack-alignment=" ++ (show align)
+ ,"-stack-alignment=" ++ (show align)) | align > 0 ]
+ ++ [("", "-filetype=obj") | fastLlvmPipeline dflags ]
+
+ -- Additional llc flags
+ ++ [("", "-mcpu=" ++ mcpu) | not (null mcpu) ]
+ ++ [("", "-mattr=" ++ attrs) | not (null attrs) ]
+
+ where target = LLVM_TARGET
+ Just (LlvmTarget _ mcpu mattr) = lookup target (llvmTargets dflags)
+
+ -- Relocation models
+ rmodel | gopt Opt_PIC dflags = "pic"
+ | positionIndependent dflags = "pic"
+ | WayDyn `elem` ways dflags = "dynamic-no-pic"
+ | otherwise = "static"
+
+ align :: Int
+ align = case platformArch (targetPlatform dflags) of
+ ArchX86_64 | isAvxEnabled dflags -> 32
+ _ -> 0
+
+ attrs :: String
+ attrs = intercalate "," $ mattr
+ ++ ["+sse42" | isSse4_2Enabled dflags ]
+ ++ ["+sse2" | isSse2Enabled dflags ]
+ ++ ["+sse" | isSseEnabled dflags ]
+ ++ ["+avx512f" | isAvx512fEnabled dflags ]
+ ++ ["+avx2" | isAvx2Enabled dflags ]
+ ++ ["+avx" | isAvxEnabled dflags ]
+ ++ ["+avx512cd"| isAvx512cdEnabled dflags ]
+ ++ ["+avx512er"| isAvx512erEnabled dflags ]
+ ++ ["+avx512pf"| isAvx512pfEnabled dflags ]
+
-- -----------------------------------------------------------------------------
-- | Each phase in the pipeline returns the next phase to execute, and the
-- name of the file in which the output was placed.
@@ -1419,121 +1476,115 @@ runPhase (RealPhase SplitAs) _input_fn dflags
-----------------------------------------------------------------------------
-- LlvmOpt phase
-
runPhase (RealPhase LlvmOpt) input_fn dflags
= do
- let opt_lvl = max 0 (min 2 $ optLevel dflags)
- -- don't specify anything if user has specified commands. We do this
- -- for opt but not llc since opt is very specifically for optimisation
- -- passes only, so if the user is passing us extra options we assume
- -- they know what they are doing and don't get in the way.
- optFlag = if null (getOpts dflags opt_lo)
- then map SysTools.Option $ words (llvmOpts !! opt_lvl)
- else []
- tbaa | gopt Opt_LlvmTBAA dflags = "--enable-tbaa=true"
- | otherwise = "--enable-tbaa=false"
-
-
output_fn <- phaseOutputFilename LlvmLlc
liftIO $ SysTools.runLlvmOpt dflags
- ([ SysTools.FileOption "" input_fn,
- SysTools.Option "-o",
- SysTools.FileOption "" output_fn]
- ++ optFlag
- ++ [SysTools.Option tbaa])
+ ( optFlag
+ ++ defaultOptions ++
+ [ SysTools.FileOption "" input_fn
+ , SysTools.Option "-o"
+ , SysTools.FileOption "" output_fn]
+ )
return (RealPhase LlvmLlc, output_fn)
where
-- we always (unless -optlo specified) run Opt since we rely on it to
-- fix up some pretty big deficiencies in the code we generate
- llvmOpts = [ "-mem2reg -globalopt"
- , "-O1 -globalopt"
- , "-O2"
- ]
+ llvmOpts = case optLevel dflags of
+ 0 -> "-mem2reg -globalopt"
+ 1 -> "-O1 -globalopt"
+ _ -> "-O2"
+
+ -- don't specify anything if user has specified commands. We do this
+ -- for opt but not llc since opt is very specifically for optimisation
+ -- passes only, so if the user is passing us extra options we assume
+ -- they know what they are doing and don't get in the way.
+ optFlag = if null (getOpts dflags opt_lo)
+ then map SysTools.Option $ words llvmOpts
+ else []
+
+ defaultOptions = map SysTools.Option . concat . fmap words . fst
+ $ unzip (llvmOptions dflags)
-----------------------------------------------------------------------------
-- LlvmLlc phase
runPhase (RealPhase LlvmLlc) input_fn dflags
= do
- let opt_lvl = max 0 (min 2 $ optLevel dflags)
- -- iOS requires external references to be loaded indirectly from the
- -- DATA segment or dyld traps at runtime writing into TEXT: see #7722
- rmodel | platformOS (targetPlatform dflags) == OSiOS = "dynamic-no-pic"
- | positionIndependent dflags = "pic"
- | WayDyn `elem` ways dflags = "dynamic-no-pic"
- | otherwise = "static"
- tbaa | gopt Opt_LlvmTBAA dflags = "--enable-tbaa=true"
- | otherwise = "--enable-tbaa=false"
-
- -- hidden debugging flag '-dno-llvm-mangler' to skip mangling
- let next_phase = case gopt Opt_NoLlvmMangler dflags of
- False -> LlvmMangle
- True | gopt Opt_SplitObjs dflags -> Splitter
- True -> As False
+ next_phase <- if fastLlvmPipeline dflags
+ then maybeMergeForeign
+ -- hidden debugging flag '-dno-llvm-mangler' to skip mangling
+ else case gopt Opt_NoLlvmMangler dflags of
+ False -> return LlvmMangle
+ True | gopt Opt_SplitObjs dflags -> return Splitter
+ True -> return (As False)
output_fn <- phaseOutputFilename next_phase
liftIO $ SysTools.runLlvmLlc dflags
- ([ SysTools.Option (llvmOpts !! opt_lvl),
- SysTools.Option $ "-relocation-model=" ++ rmodel,
- SysTools.FileOption "" input_fn,
- SysTools.Option "-o", SysTools.FileOption "" output_fn]
- ++ [SysTools.Option tbaa]
- ++ map SysTools.Option fpOpts
- ++ map SysTools.Option abiOpts
- ++ map SysTools.Option sseOpts
- ++ map SysTools.Option avxOpts
- ++ map SysTools.Option avx512Opts
- ++ map SysTools.Option stackAlignOpts)
+ ( optFlag
+ ++ defaultOptions
+ ++ [ SysTools.FileOption "" input_fn
+ , SysTools.Option "-o"
+ , SysTools.FileOption "" output_fn
+ ]
+ )
return (RealPhase next_phase, output_fn)
where
- -- Bug in LLVM at O3 on OSX.
- llvmOpts = if platformOS (targetPlatform dflags) == OSDarwin
- then ["-O1", "-O2", "-O2"]
- else ["-O1", "-O2", "-O3"]
- -- On ARMv7 using LLVM, LLVM fails to allocate floating point registers
- -- while compiling GHC source code. It's probably due to fact that it
- -- does not enable VFP by default. Let's do this manually here
- fpOpts = case platformArch (targetPlatform dflags) of
- ArchARM ARMv7 ext _ -> if (elem VFPv3 ext)
- then ["-mattr=+v7,+vfp3"]
- else if (elem VFPv3D16 ext)
- then ["-mattr=+v7,+vfp3,+d16"]
- else []
- ArchARM ARMv6 ext _ -> if (elem VFPv2 ext)
- then ["-mattr=+v6,+vfp2"]
- else ["-mattr=+v6"]
- _ -> []
- -- On Ubuntu/Debian with ARM hard float ABI, LLVM's llc still
- -- compiles into soft-float ABI. We need to explicitly set abi
- -- to hard
- abiOpts = case platformArch (targetPlatform dflags) of
- ArchARM _ _ HARD -> ["-float-abi=hard"]
- ArchARM _ _ _ -> []
- _ -> []
-
- sseOpts | isSse4_2Enabled dflags = ["-mattr=+sse42"]
- | isSse2Enabled dflags = ["-mattr=+sse2"]
- | isSseEnabled dflags = ["-mattr=+sse"]
- | otherwise = []
-
- avxOpts | isAvx512fEnabled dflags = ["-mattr=+avx512f"]
- | isAvx2Enabled dflags = ["-mattr=+avx2"]
- | isAvxEnabled dflags = ["-mattr=+avx"]
- | otherwise = []
-
- avx512Opts =
- [ "-mattr=+avx512cd" | isAvx512cdEnabled dflags ] ++
- [ "-mattr=+avx512er" | isAvx512erEnabled dflags ] ++
- [ "-mattr=+avx512pf" | isAvx512pfEnabled dflags ]
-
- stackAlignOpts =
- case platformArch (targetPlatform dflags) of
- ArchX86_64 | isAvxEnabled dflags -> ["-stack-alignment=32"]
- _ -> []
+ -- Note [Clamping of llc optimizations]
+ --
+ -- See #13724
+ --
+ -- we clamp the llc optimization between [1,2]. This is because passing -O0
+ -- to llc 3.9 or llc 4.0, the naive register allocator can fail with
+ --
+ -- Error while trying to spill R1 from class GPR: Cannot scavenge register
+ -- without an emergency spill slot!
+ --
+ -- Observed at least with target 'arm-unknown-linux-gnueabihf'.
+ --
+ --
+ -- With LLVM4, llc -O3 crashes when ghc-stage1 tries to compile
+ -- rts/HeapStackCheck.cmm
+ --
+ -- llc -O3 '-mtriple=arm-unknown-linux-gnueabihf' -enable-tbaa /var/folders/fv/xqjrpfj516n5xq_m_ljpsjx00000gn/T/ghc33674_0/ghc_6.bc -o /var/folders/fv/xqjrpfj516n5xq_m_ljpsjx00000gn/T/ghc33674_0/ghc_7.lm_s
+ -- 0 llc 0x0000000102ae63e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
+ -- 1 llc 0x0000000102ae69a6 SignalHandler(int) + 358
+ -- 2 libsystem_platform.dylib 0x00007fffc23f4b3a _sigtramp + 26
+ -- 3 libsystem_c.dylib 0x00007fffc226498b __vfprintf + 17876
+ -- 4 llc 0x00000001029d5123 llvm::SelectionDAGISel::LowerArguments(llvm::Function const&) + 5699
+ -- 5 llc 0x0000000102a21a35 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 3381
+ -- 6 llc 0x0000000102a202b1 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 1457
+ -- 7 llc 0x0000000101bdc474 (anonymous namespace)::ARMDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 20
+ -- 8 llc 0x00000001025573a6 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 134
+ -- 9 llc 0x000000010274fb12 llvm::FPPassManager::runOnFunction(llvm::Function&) + 498
+ -- 10 llc 0x000000010274fd23 llvm::FPPassManager::runOnModule(llvm::Module&) + 67
+ -- 11 llc 0x00000001027501b8 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 920
+ -- 12 llc 0x000000010195f075 compileModule(char**, llvm::LLVMContext&) + 12133
+ -- 13 llc 0x000000010195bf0b main + 491
+ -- 14 libdyld.dylib 0x00007fffc21e5235 start + 1
+ -- Stack dump:
+ -- 0. Program arguments: llc -O3 -mtriple=arm-unknown-linux-gnueabihf -enable-tbaa /var/folders/fv/xqjrpfj516n5xq_m_ljpsjx00000gn/T/ghc33674_0/ghc_6.bc -o /var/folders/fv/xqjrpfj516n5xq_m_ljpsjx00000gn/T/ghc33674_0/ghc_7.lm_s
+ -- 1. Running pass 'Function Pass Manager' on module '/var/folders/fv/xqjrpfj516n5xq_m_ljpsjx00000gn/T/ghc33674_0/ghc_6.bc'.
+ -- 2. Running pass 'ARM Instruction Selection' on function '@"stg_gc_f1$def"'
+ --
+ -- Observed at least with -mtriple=arm-unknown-linux-gnueabihf -enable-tbaa
+ --
+ llvmOpts = case optLevel dflags of
+ 0 -> "-O1" -- required to get the non-naive reg allocator. Passing -regalloc=greedy is not sufficient.
+ 1 -> "-O1"
+ _ -> "-O2"
+
+ optFlag = if null (getOpts dflags opt_lc)
+ then map SysTools.Option $ words llvmOpts
+ else []
+
+ defaultOptions = map SysTools.Option . concat . fmap words . snd
+ $ unzip (llvmOptions dflags)
+
-----------------------------------------------------------------------------
-- LlvmMangle phase
@@ -1892,22 +1943,19 @@ linkBinary' staticLink dflags o_files dep_packages = do
-- Here are some libs that need to be linked at the *end* of
-- the command line, because they contain symbols that are referred to
-- by the RTS. We can't therefore use the ordinary way opts for these.
- let
- debug_opts | WayDebug `elem` ways dflags = [
+ let debug_opts | WayDebug `elem` ways dflags = [
#if defined(HAVE_LIBBFD)
"-lbfd", "-liberty"
#endif
]
- | otherwise = []
+ | otherwise = []
- let thread_opts
- | WayThreaded `elem` ways dflags =
- let os = platformOS (targetPlatform dflags)
- in if os `elem` [OSMinGW32, OSFreeBSD, OSOpenBSD, OSAndroid,
- OSNetBSD, OSHaiku, OSQNXNTO, OSiOS, OSDarwin]
- then []
- else ["-lpthread"]
- | otherwise = []
+ thread_opts | WayThreaded `elem` ways dflags = [
+#if NEED_PTHREAD_LIB
+ "-lpthread"
+#endif
+ ]
+ | otherwise = []
rc_objs <- maybeCreateManifest dflags output_fn
@@ -1942,7 +1990,7 @@ linkBinary' staticLink dflags o_files dep_packages = do
-- on x86.
++ (if sLdSupportsCompactUnwind mySettings &&
not staticLink &&
- (platformOS platform == OSDarwin || platformOS platform == OSiOS) &&
+ (platformOS platform == OSDarwin) &&
case platformArch platform of
ArchX86 -> True
ArchX86_64 -> True
@@ -1952,13 +2000,6 @@ linkBinary' staticLink dflags o_files dep_packages = do
then ["-Wl,-no_compact_unwind"]
else [])
- -- '-no_pie'
- -- iOS uses 'dynamic-no-pic', so we must pass this to ld to suppress a warning; see #7722
- ++ (if platformOS platform == OSiOS &&
- not staticLink
- then ["-Wl,-no_pie"]
- else [])
-
-- '-Wl,-read_only_relocs,suppress'
-- ld gives loads of warnings like:
-- ld: warning: text reloc in _base_GHCziArr_unsafeArray_info to _base_GHCziArr_unsafeArray_closure
@@ -2073,10 +2114,7 @@ linkDynLibCheck dflags o_files dep_packages
linkStaticLibCheck :: DynFlags -> [String] -> [InstalledUnitId] -> IO ()
linkStaticLibCheck dflags o_files dep_packages
- = do
- when (platformOS (targetPlatform dflags) `notElem` [OSiOS, OSDarwin]) $
- throwGhcExceptionIO (ProgramError "Static archive creation only supported on Darwin/OS X/iOS")
- linkBinary' True dflags o_files dep_packages
+ = linkBinary' True dflags o_files dep_packages
-- -----------------------------------------------------------------------------
-- Running CPP
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index f5f5f00dd2..2cde3b7700 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -76,6 +76,9 @@ module DynFlags (
safeDirectImpsReq, safeImplicitImpsReq,
unsafeFlags, unsafeFlagsForInfer,
+ -- ** LLVM Targets
+ LlvmTarget(..), LlvmTargets,
+
-- ** System tool settings and locations
Settings(..),
targetPlatform, programName, projectVersion,
@@ -83,9 +86,9 @@ module DynFlags (
versionedAppDir,
extraGccViaCFlags, systemPackageConfig,
pgm_L, pgm_P, pgm_F, pgm_c, pgm_s, pgm_a, pgm_l, pgm_dll, pgm_T,
- pgm_windres, pgm_libtool, pgm_lo, pgm_lc, pgm_i,
+ pgm_windres, pgm_libtool, pgm_lo, pgm_lc, pgm_lcc, pgm_i,
opt_L, opt_P, opt_F, opt_c, opt_a, opt_l, opt_i,
- opt_windres, opt_lo, opt_lc,
+ opt_windres, opt_lo, opt_lc, opt_lcc,
-- ** Manipulating DynFlags
@@ -407,6 +410,7 @@ data GeneralFlag
| Opt_DoAsmLinting
| Opt_DoAnnotationLinting
| Opt_NoLlvmMangler -- hidden flag
+ | Opt_FastLlvm -- hidden flag
| Opt_WarnIsError -- -Werror; makes warnings fatal
| Opt_ShowWarnGroups -- Show the group a warning belongs to
@@ -695,6 +699,7 @@ data DynFlags = DynFlags {
ghcLink :: GhcLink,
hscTarget :: HscTarget,
settings :: Settings,
+ llvmTargets :: LlvmTargets,
verbosity :: Int, -- ^ Verbosity level: see Note [Verbosity levels]
optLevel :: Int, -- ^ Optimisation level
debugLevel :: Int, -- ^ How much debug information to produce
@@ -999,6 +1004,14 @@ data ProfAuto
| ProfAutoCalls -- ^ annotate call-sites
deriving (Eq,Enum)
+data LlvmTarget = LlvmTarget
+ { lDataLayout :: String
+ , lCPU :: String
+ , lAttributes :: [String]
+ }
+
+type LlvmTargets = [(String, LlvmTarget)]
+
data Settings = Settings {
sTargetPlatform :: Platform, -- Filled in by SysTools
sGhcUsagePath :: FilePath, -- Filled in by SysTools
@@ -1031,6 +1044,7 @@ data Settings = Settings {
sPgm_libtool :: String,
sPgm_lo :: (String,[Option]), -- LLVM: opt llvm optimiser
sPgm_lc :: (String,[Option]), -- LLVM: llc static compiler
+ sPgm_lcc :: (String,[Option]), -- LLVM: c compiler
sPgm_i :: String,
-- options for particular phases
sOpt_L :: [String],
@@ -1042,6 +1056,7 @@ data Settings = Settings {
sOpt_windres :: [String],
sOpt_lo :: [String], -- LLVM: llvm optimiser
sOpt_lc :: [String], -- LLVM: llc static compiler
+ sOpt_lcc :: [String], -- LLVM: c compiler
sOpt_i :: [String], -- iserv options
sPlatformConstants :: PlatformConstants
@@ -1089,6 +1104,8 @@ pgm_windres :: DynFlags -> String
pgm_windres dflags = sPgm_windres (settings dflags)
pgm_libtool :: DynFlags -> String
pgm_libtool dflags = sPgm_libtool (settings dflags)
+pgm_lcc :: DynFlags -> (String,[Option])
+pgm_lcc dflags = sPgm_lcc (settings dflags)
pgm_lo :: DynFlags -> (String,[Option])
pgm_lo dflags = sPgm_lo (settings dflags)
pgm_lc :: DynFlags -> (String,[Option])
@@ -1112,6 +1129,8 @@ opt_l dflags = concatMap (wayOptl (targetPlatform dflags)) (ways dflags)
++ sOpt_l (settings dflags)
opt_windres :: DynFlags -> [String]
opt_windres dflags = sOpt_windres (settings dflags)
+opt_lcc :: DynFlags -> [String]
+opt_lcc dflags = sOpt_lcc (settings dflags)
opt_lo :: DynFlags -> [String]
opt_lo dflags = sOpt_lo (settings dflags)
opt_lc :: DynFlags -> [String]
@@ -1547,8 +1566,8 @@ initDynFlags dflags = do
-- | The normal 'DynFlags'. Note that they are not suitable for use in this form
-- and must be fully initialized by 'GHC.runGhc' first.
-defaultDynFlags :: Settings -> DynFlags
-defaultDynFlags mySettings =
+defaultDynFlags :: Settings -> LlvmTargets -> DynFlags
+defaultDynFlags mySettings myLlvmTargets =
-- See Note [Updating flag description in the User's Guide]
DynFlags {
ghcMode = CompManager,
@@ -1641,6 +1660,8 @@ defaultDynFlags mySettings =
rtsBuildTag = mkBuildTag (defaultWays mySettings),
splitInfo = Nothing,
settings = mySettings,
+ llvmTargets = myLlvmTargets,
+
-- ghc -M values
depMakefile = "Makefile",
depIncludePkgDeps = False,
@@ -3067,6 +3088,8 @@ dynamic_flags_deps = [
(NoArg (setGeneralFlag Opt_D_faststring_stats))
, make_ord_flag defGhcFlag "dno-llvm-mangler"
(NoArg (setGeneralFlag Opt_NoLlvmMangler)) -- hidden flag
+ , make_ord_flag defGhcFlag "fast-llvm"
+ (NoArg (setGeneralFlag Opt_FastLlvm)) -- hidden flag
, make_ord_flag defGhcFlag "ddump-debug"
(setDumpFlag Opt_D_dump_debug)
, make_ord_flag defGhcFlag "ddump-json"
@@ -5244,9 +5267,10 @@ makeDynFlagsConsistent dflags
-- initialized.
defaultGlobalDynFlags :: DynFlags
defaultGlobalDynFlags =
- (defaultDynFlags settings) { verbosity = 2 }
+ (defaultDynFlags settings llvmTargets) { verbosity = 2 }
where
- settings = panic "v_unsafeGlobalDynFlags: not initialised"
+ settings = panic "v_unsafeGlobalDynFlags: settings not initialised"
+ llvmTargets = panic "v_unsafeGlobalDynFlags: llvmTargets not initialised"
#if STAGE < 2
GLOBAL_VAR(v_unsafeGlobalDynFlags, defaultGlobalDynFlags, DynFlags)
diff --git a/compiler/main/GHC.hs b/compiler/main/GHC.hs
index 8f508411b6..700e4826d1 100644
--- a/compiler/main/GHC.hs
+++ b/compiler/main/GHC.hs
@@ -489,7 +489,8 @@ initGhcMonad :: GhcMonad m => Maybe FilePath -> m ()
initGhcMonad mb_top_dir
= do { env <- liftIO $
do { mySettings <- initSysTools mb_top_dir
- ; dflags <- initDynFlags (defaultDynFlags mySettings)
+ ; myLlvmTargets <- initLlvmTargets mb_top_dir
+ ; dflags <- initDynFlags (defaultDynFlags mySettings myLlvmTargets)
; checkBrokenTablesNextToCode dflags
; setUnsafeGlobalDynFlags dflags
-- c.f. DynFlags.parseDynamicFlagsFull, which
diff --git a/compiler/main/HscTypes.hs b/compiler/main/HscTypes.hs
index 56d2ac5eb9..e16452bca1 100644
--- a/compiler/main/HscTypes.hs
+++ b/compiler/main/HscTypes.hs
@@ -2578,7 +2578,6 @@ soExt :: Platform -> FilePath
soExt platform
= case platformOS platform of
OSDarwin -> "dylib"
- OSiOS -> "dylib"
OSMinGW32 -> "dll"
_ -> "so"
diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs
index b2d85a782a..61cc24efcf 100644
--- a/compiler/main/SysTools.hs
+++ b/compiler/main/SysTools.hs
@@ -13,6 +13,7 @@
module SysTools (
-- Initialisation
initSysTools,
+ initLlvmTargets,
-- Interface to system tools
runUnlit, runCpp, runCc, -- [Option] -> IO ()
@@ -187,6 +188,20 @@ stuff.
************************************************************************
-}
+initLlvmTargets :: Maybe String
+ -> IO LlvmTargets
+initLlvmTargets mbMinusB
+ = do top_dir <- findTopDir mbMinusB
+ let llvmTargetsFile = top_dir </> "llvm-targets"
+ llvmTargetsStr <- readFile llvmTargetsFile
+ case maybeReadFuzzy llvmTargetsStr of
+ Just s -> return (fmap mkLlvmTarget <$> s)
+ Nothing -> pgmError ("Can't parse " ++ show llvmTargetsFile)
+ where
+ mkLlvmTarget :: (String, String, String) -> LlvmTarget
+ mkLlvmTarget (dl, cpu, attrs) = LlvmTarget dl cpu (words attrs)
+
+
initSysTools :: Maybe String -- Maybe TopDir path (without the '-B' prefix)
-> IO Settings -- Set all the mutable variables above, holding
-- (a) the system programs
@@ -322,6 +337,7 @@ initSysTools mbMinusB
-- We just assume on command line
lc_prog <- getSetting "LLVM llc command"
lo_prog <- getSetting "LLVM opt command"
+ lcc_prog <- getSetting "LLVM clang command"
let iserv_prog = libexec "ghc-iserv"
@@ -365,6 +381,7 @@ initSysTools mbMinusB
sPgm_libtool = libtool_path,
sPgm_lo = (lo_prog,[]),
sPgm_lc = (lc_prog,[]),
+ sPgm_lcc = (lcc_prog,[]),
sPgm_i = iserv_prog,
sOpt_L = [],
sOpt_P = [],
@@ -373,6 +390,7 @@ initSysTools mbMinusB
sOpt_a = [],
sOpt_l = [],
sOpt_windres = [],
+ sOpt_lcc = [],
sOpt_lo = [],
sOpt_lc = [],
sOpt_i = [],
@@ -587,8 +605,7 @@ runLlvmLlc dflags args = do
-- assembler)
runClang :: DynFlags -> [Option] -> IO ()
runClang dflags args = do
- -- we simply assume its available on the PATH
- let clang = "clang"
+ let (clang,_) = pgm_lcc dflags
-- be careful what options we call clang with
-- see #5903 and #7617 for bugs caused by this.
(_,args0) = pgm_a dflags
@@ -818,9 +835,6 @@ getLinkerInfo' dflags = do
-- that doesn't support --version. We can just assume that's
-- what we're using.
return $ DarwinLD []
- OSiOS ->
- -- Ditto for iOS
- return $ DarwinLD []
OSMinGW32 ->
-- GHC doesn't support anything but GNU ld on Windows anyway.
-- Process creation is also fairly expensive on win32, so
@@ -1666,7 +1680,7 @@ linkDynLib dflags0 o_files dep_packages
++ pkg_lib_path_opts
++ pkg_link_opts
))
- OSDarwin -> do
+ _ | os == OSDarwin -> do
-------------------------------------------------------------------
-- Making a darwin dylib
-------------------------------------------------------------------
@@ -1726,7 +1740,6 @@ linkDynLib dflags0 o_files dep_packages
++ map Option pkg_link_opts
++ map Option pkg_framework_opts
)
- OSiOS -> throwGhcExceptionIO (ProgramError "dynamic libraries are not supported on iOS target")
_ -> do
-------------------------------------------------------------------
-- Making a DSO
diff --git a/compiler/nativeGen/RegAlloc/Linear/Main.hs b/compiler/nativeGen/RegAlloc/Linear/Main.hs
index b7721880c3..c98a8e4773 100644
--- a/compiler/nativeGen/RegAlloc/Linear/Main.hs
+++ b/compiler/nativeGen/RegAlloc/Linear/Main.hs
@@ -496,7 +496,7 @@ genRaInsn block_live new_instrs block_id instr r_dying w_dying = do
-- debugging
{- freeregs <- getFreeRegsR
assig <- getAssigR
- pprDebugAndThen (defaultDynFlags Settings{ sTargetPlatform=platform }) trace "genRaInsn"
+ pprDebugAndThen (defaultDynFlags Settings{ sTargetPlatform=platform } undefined) trace "genRaInsn"
(ppr instr
$$ text "r_dying = " <+> ppr r_dying
$$ text "w_dying = " <+> ppr w_dying
diff --git a/compiler/specialise/SpecConstr.hs b/compiler/specialise/SpecConstr.hs
index f686f0fba1..647f696640 100644
--- a/compiler/specialise/SpecConstr.hs
+++ b/compiler/specialise/SpecConstr.hs
@@ -514,7 +514,7 @@ for nested bindings. (So really it should be passed around explicitly
and not stored in ScEnv.) Trac #14379 turned out to be caused by
f SPEC x = let g1 x = ...
in ...
-We force-specialise f (becuase of the SPEC), but that generates a specialised
+We force-specialise f (because of the SPEC), but that generates a specialised
copy of g1 (as well as the original). Alas g1 has a nested binding g2; and
in each copy of g1 we get an unspecialised and specialised copy of g2; and so
on. Result, exponential. So the force-spec flag now only applies to one
@@ -524,7 +524,7 @@ Mechanism for this one-level-only thing:
- Switch it on at the call to specRec, in scExpr and scTopBinds
- Switch it off when doing the RHSs;
- this can be done very conveneniently in decreaseSpecCount
+ this can be done very conveniently in decreaseSpecCount
What alternatives did I consider?
diff --git a/compiler/typecheck/TcCanonical.hs b/compiler/typecheck/TcCanonical.hs
index 0221a3e3ac..0635b4a0dd 100644
--- a/compiler/typecheck/TcCanonical.hs
+++ b/compiler/typecheck/TcCanonical.hs
@@ -1575,7 +1575,7 @@ canEqTyVarTyVar, are these
Note [Avoid unnecessary swaps]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-If we swap without actually improving matters, we can get an infnite loop.
+If we swap without actually improving matters, we can get an infinite loop.
Consider
work item: a ~ b
inert item: b ~ c
diff --git a/compiler/typecheck/TcInteract.hs b/compiler/typecheck/TcInteract.hs
index 5bbc5f86aa..9af719812a 100644
--- a/compiler/typecheck/TcInteract.hs
+++ b/compiler/typecheck/TcInteract.hs
@@ -2009,9 +2009,9 @@ favour of alpha. If we instead had
then we would unify alpha := gamma1; and kick out the wanted
constraint. But when we grough it back in, it'd look like
[W] TF (gamma1, beta) ~ fuv
-and exactly the same thing would happen again! Infnite loop.
+and exactly the same thing would happen again! Infinite loop.
-This all sesms fragile, and it might seem more robust to avoid
+This all seems fragile, and it might seem more robust to avoid
introducing gamma1 in the first place, in the case where the
actual argument (alpha, beta) partly matches the improvement
template. But that's a bit tricky, esp when we remember that the
diff --git a/compiler/utils/Platform.hs b/compiler/utils/Platform.hs
index 86c70a9789..8cd1fa75e3 100644
--- a/compiler/utils/Platform.hs
+++ b/compiler/utils/Platform.hs
@@ -16,7 +16,6 @@ module Platform (
osMachOTarget,
osSubsectionsViaSymbols,
platformUsesFrameworks,
- platformBinariesAreStaticLibs,
)
where
@@ -76,7 +75,6 @@ data OS
= OSUnknown
| OSLinux
| OSDarwin
- | OSiOS
| OSSolaris2
| OSMinGW32
| OSFreeBSD
@@ -86,7 +84,6 @@ data OS
| OSKFreeBSD
| OSHaiku
| OSQNXNTO
- | OSAndroid
| OSAIX
deriving (Read, Show, Eq)
@@ -132,12 +129,10 @@ osElfTarget OSOpenBSD = True
osElfTarget OSNetBSD = True
osElfTarget OSSolaris2 = True
osElfTarget OSDarwin = False
-osElfTarget OSiOS = False
osElfTarget OSMinGW32 = False
osElfTarget OSKFreeBSD = True
osElfTarget OSHaiku = True
osElfTarget OSQNXNTO = False
-osElfTarget OSAndroid = True
osElfTarget OSAIX = False
osElfTarget OSUnknown = False
-- Defaulting to False is safe; it means don't rely on any
@@ -152,21 +147,12 @@ osMachOTarget _ = False
osUsesFrameworks :: OS -> Bool
osUsesFrameworks OSDarwin = True
-osUsesFrameworks OSiOS = True
osUsesFrameworks _ = False
platformUsesFrameworks :: Platform -> Bool
platformUsesFrameworks = osUsesFrameworks . platformOS
-osBinariesAreStaticLibs :: OS -> Bool
-osBinariesAreStaticLibs OSiOS = True
-osBinariesAreStaticLibs _ = False
-
osSubsectionsViaSymbols :: OS -> Bool
osSubsectionsViaSymbols OSDarwin = True
-osSubsectionsViaSymbols OSiOS = True
osSubsectionsViaSymbols _ = False
-platformBinariesAreStaticLibs :: Platform -> Bool
-platformBinariesAreStaticLibs = osBinariesAreStaticLibs . platformOS
-
diff --git a/configure.ac b/configure.ac
index 846f5596f2..81de9812ed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -587,6 +587,12 @@ AC_SUBST([LlvmVersion])
sUPPORTED_LLVM_VERSION=$(echo \($LlvmVersion\) | sed 's/\./,/')
AC_DEFINE_UNQUOTED([sUPPORTED_LLVM_VERSION], ${sUPPORTED_LLVM_VERSION}, [The supported LLVM version number])
+dnl ** Which LLVM clang to use?
+dnl --------------------------------------------------------------
+AC_CHECK_TARGET_TOOL([CLANG], [clang])
+ClangCmd="$CLANG"
+AC_SUBST([ClangCmd])
+
dnl ** Which LLVM llc to use?
dnl --------------------------------------------------------------
FIND_LLVM_PROG([LLC], [llc], [llc], [$LlvmVersion])
@@ -1099,7 +1105,7 @@ case ${TargetOS} in
linux|linux-android|freebsd|dragonfly|netbsd|openbsd|kfreebsdgnu|gnu|solaris2)
RtsLinkerUseMmap=1
;;
- darwin)
+ darwin|ios|watchos|tvos)
# Don't use mmap on powerpc/darwin as the mmap there doesn't support
# reallocating. Reallocating is needed to allocate jump islands just
# after each object image. Jumps to these jump islands use relative
@@ -1263,6 +1269,7 @@ echo "\
xelatex : $XELATEX
Using LLVM tools
+ clang : $ClangCmd
llc : $LlcCmd
opt : $OptCmd"
diff --git a/docs/users_guide/phases.rst b/docs/users_guide/phases.rst
index afb3a8be5c..6288961b14 100644
--- a/docs/users_guide/phases.rst
+++ b/docs/users_guide/phases.rst
@@ -551,11 +551,9 @@ for example).
.. ghc-flag:: -staticlib
- On Darwin/OS X/iOS only, link all passed files into a static library
- suitable for linking into an iOS (when using a cross-compiler) or
- Mac Xcode project. To control the name, use the :ghc-flag:`-o ⟨file⟩` option
- as usual. The default name is ``liba.a``. This should nearly always
- be passed when compiling for iOS with a cross-compiler.
+ Link all passed files into a static library suitable for linking.
+ To control the name, use the :ghc-flag:`-o` ⟨name⟩ option
+ as usual. The default name is ``liba.a``.
.. ghc-flag:: -L ⟨dir⟩
diff --git a/ghc.mk b/ghc.mk
index 5b9cf22454..26d8535806 100644
--- a/ghc.mk
+++ b/ghc.mk
@@ -1035,6 +1035,7 @@ $(eval $(call bindist-list,.,\
INSTALL \
configure config.sub config.guess install-sh \
settings.in \
+ llvm-targets \
packages \
Makefile \
mk/config.mk.in \
@@ -1061,7 +1062,7 @@ $(eval $(call bindist-list,.,\
$(wildcard compiler/stage2/doc) \
$(wildcard libraries/*/dist-install/doc/) \
$(wildcard libraries/*/*/dist-install/doc/) \
- $(filter-out settings,$(INSTALL_LIBS)) \
+ $(filter-out settings llvm-targets,$(INSTALL_LIBS)) \
$(RTS_INSTALL_LIBS) \
$(filter-out %/project.mk mk/config.mk %/mk/install.mk,$(MAKEFILE_LIST)) \
mk/project.mk \
@@ -1094,7 +1095,7 @@ BIN_DIST_MK = $(BIN_DIST_PREP_DIR)/bindist.mk
unix-binary-dist-prep:
$(call removeTrees,bindistprep/)
"$(MKDIRHIER)" $(BIN_DIST_PREP_DIR)
- set -e; for i in packages LICENSE compiler ghc iserv rts libraries utils docs libffi includes driver mk rules Makefile aclocal.m4 config.sub config.guess install-sh settings.in ghc.mk inplace distrib/configure.ac distrib/README distrib/INSTALL; do ln -s ../../$$i $(BIN_DIST_PREP_DIR)/; done
+ set -e; for i in packages LICENSE compiler ghc iserv rts libraries utils docs libffi includes driver mk rules Makefile aclocal.m4 config.sub config.guess install-sh settings.in llvm-targets ghc.mk inplace distrib/configure.ac distrib/README distrib/INSTALL; do ln -s ../../$$i $(BIN_DIST_PREP_DIR)/; done
echo "HADDOCK_DOCS = $(HADDOCK_DOCS)" >> $(BIN_DIST_MK)
echo "BUILD_SPHINX_HTML = $(BUILD_SPHINX_HTML)" >> $(BIN_DIST_MK)
echo "BUILD_SPHINX_PDF = $(BUILD_SPHINX_PDF)" >> $(BIN_DIST_MK)
@@ -1192,7 +1193,7 @@ SRC_DIST_GHC_DIRS = mk rules docs distrib bindisttest libffi includes \
SRC_DIST_GHC_FILES += \
configure.ac config.guess config.sub configure \
aclocal.m4 README.md ANNOUNCE HACKING.md INSTALL.md LICENSE Makefile \
- install-sh settings.in VERSION GIT_COMMIT_ID \
+ install-sh settings.in llvm-targets VERSION GIT_COMMIT_ID \
boot packages ghc.mk MAKEHELP.md
.PHONY: VERSION
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs
index f677e995d0..47aa83baff 100644
--- a/ghc/GHCi/UI.hs
+++ b/ghc/GHCi/UI.hs
@@ -2519,7 +2519,7 @@ showDynFlags show_all dflags = do
is_on = test f dflags
quiet = not show_all && test f default_dflags == is_on
- default_dflags = defaultDynFlags (settings dflags)
+ default_dflags = defaultDynFlags (settings dflags) (llvmTargets dflags)
(ghciFlags,others) = partition (\f -> flagSpecFlag f `elem` flgs)
DynFlags.fFlags
@@ -2930,7 +2930,7 @@ showLanguages' show_all dflags =
quiet = not show_all && test f default_dflags == is_on
default_dflags =
- defaultDynFlags (settings dflags) `lang_set`
+ defaultDynFlags (settings dflags) (llvmTargets dflags) `lang_set`
case language dflags of
Nothing -> Just Haskell2010
other -> other
diff --git a/ghc/Main.hs b/ghc/Main.hs
index cc6d08ee45..5926718f3f 100644
--- a/ghc/Main.hs
+++ b/ghc/Main.hs
@@ -804,7 +804,7 @@ dumpFastStringStats dflags = do
])
-- we usually get more "has z-encoding" than "z-encoded", because
-- when we z-encode a string it might hash to the exact same string,
- -- which will is not counted as "z-encoded". Only strings whose
+ -- which is not counted as "z-encoded". Only strings whose
-- Z-encoding is different from the original string are counted in
-- the "z-encoded" total.
putMsg dflags msg
diff --git a/ghc/ghc.mk b/ghc/ghc.mk
index 8d4c1dfe8e..921e5666af 100644
--- a/ghc/ghc.mk
+++ b/ghc/ghc.mk
@@ -133,6 +133,9 @@ all_ghc_stage3 : $(GHC_STAGE3)
$(INPLACE_LIB)/settings : settings
"$(CP)" $< $@
+$(INPLACE_LIB)/llvm-targets : llvm-targets
+ "$(CP)" $< $@
+
$(INPLACE_LIB)/platformConstants: $(includes_GHCCONSTANTS_HASKELL_VALUE)
"$(CP)" $< $@
@@ -141,6 +144,7 @@ $(INPLACE_LIB)/platformConstants: $(includes_GHCCONSTANTS_HASKELL_VALUE)
GHC_DEPENDENCIES += $$(unlit_INPLACE)
GHC_DEPENDENCIES += $(INPLACE_LIB)/settings
+GHC_DEPENDENCIES += $(INPLACE_LIB)/llvm-targets
GHC_DEPENDENCIES += $(INPLACE_LIB)/platformConstants
$(GHC_STAGE1) : | $(GHC_DEPENDENCIES)
@@ -168,6 +172,7 @@ $(GHC_STAGE2) : $(foreach w,$(GhcLibWays),libraries/base/dist-install/build/GHC/
endif
INSTALL_LIBS += settings
+INSTALL_LIBS += llvm-targets
ifeq "$(Windows_Host)" "NO"
install: install_ghc_link
diff --git a/libraries/base/configure.ac b/libraries/base/configure.ac
index 69ea800a7f..f472319a7e 100644
--- a/libraries/base/configure.ac
+++ b/libraries/base/configure.ac
@@ -69,7 +69,7 @@ if test "$ac_cv_header_poll_h" = yes && test "$ac_cv_func_poll" = yes; then
AC_DEFINE([HAVE_POLL], [1], [Define if you have poll support.])
fi
-# Linux open file description locks
+# Linux open file descriptor locks
AC_CHECK_DECL([F_OFD_SETLK], [
AC_DEFINE([HAVE_OFD_LOCKING], [1], [Define if you have open file descriptor lock support.])
])
diff --git a/llvm-targets b/llvm-targets
new file mode 100644
index 0000000000..b67ee6ccfa
--- /dev/null
+++ b/llvm-targets
@@ -0,0 +1,25 @@
+[("i386-unknown-windows", ("e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32", "pentium4", ""))
+,("i686-unknown-windows", ("e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32", "pentium4", ""))
+,("x86_64-unknown-windows", ("e-m:w-i64:64-f80:128-n8:16:32:64-S128", "x86-64", ""))
+,("arm-unknown-linux-gnueabihf", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "arm1176jzf-s", "+strict-align"))
+,("armv6-unknown-linux-gnueabihf", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "arm1136jf-s", "+strict-align"))
+,("armv6l-unknown-linux-gnueabihf", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "arm1176jzf-s", "+strict-align"))
+,("armv7-unknown-linux-gnueabihf", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "generic", ""))
+,("armv7a-unknown-linux-gnueabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "generic", ""))
+,("armv7l-unknown-linux-gnueabihf", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "generic", ""))
+,("aarch64-unknown-linux-gnu", ("e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128", "generic", "+neon"))
+,("aarch64-unknown-linux", ("e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128", "generic", "+neon"))
+,("i386-unknown-linux-gnu", ("e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128", "pentium4", ""))
+,("i386-unknown-linux", ("e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128", "pentium4", ""))
+,("x86_64-unknown-linux-gnu", ("e-m:e-i64:64-f80:128-n8:16:32:64-S128", "x86-64", ""))
+,("x86_64-unknown-linux", ("e-m:e-i64:64-f80:128-n8:16:32:64-S128", "x86-64", ""))
+,("armv7-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "generic", ""))
+,("aarch64-unknown-linux-android", ("e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128", "generic", "+neon"))
+,("arm-unknown-nto-qnx-eabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "arm7tdmi", "+strict-align"))
+,("i386-apple-darwin", ("e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128", "yonah", ""))
+,("x86_64-apple-darwin", ("e-m:o-i64:64-f80:128-n8:16:32:64-S128", "core2", ""))
+,("armv7-apple-ios", ("e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32", "generic", ""))
+,("aarch64-apple-ios", ("e-m:o-i64:64-i128:128-n32:64-S128", "generic", "+neon"))
+,("i386-apple-ios", ("e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128", "yonah", ""))
+,("x86_64-apple-ios", ("e-m:o-i64:64-f80:128-n8:16:32:64-S128", "core2", ""))
+]
diff --git a/mk/config.mk.in b/mk/config.mk.in
index fcbc32d7df..c740f64e2e 100644
--- a/mk/config.mk.in
+++ b/mk/config.mk.in
@@ -745,6 +745,7 @@ NM = @NmCmd@
AR = @ArCmd@
OBJDUMP = @ObjdumpCmd@
+CLANG = @ClangCmd@
LLC = @LlcCmd@
OPT = @OptCmd@
diff --git a/mk/project.mk.in b/mk/project.mk.in
index 03bd7441cb..d620ed5a61 100644
--- a/mk/project.mk.in
+++ b/mk/project.mk.in
@@ -12,7 +12,7 @@
# Versioning scheme: A.B.C
# A: major version, decimal, any number of digits
# B: minor version, decimal, any number of digits
-# C: patchlevel, one digit, omitted if zero.
+# C: patchlevel, one digit, omitted if zero.
#
# ProjectVersionInt does *not* contain the patchlevel (rationale: this
# figure is used for conditional compilations, and library interfaces
@@ -35,7 +35,7 @@ ProjectGitCommitId = @ProjectGitCommitId@
################################################################################
#
-# Platform variables
+# Platform variables
#
################################################################################
@@ -81,24 +81,25 @@ ProjectGitCommitId = @ProjectGitCommitId@
# You have to do a lot of work by hand to cross compile: see the
# section on "Porting GHC" in the Building Guide.
-HOSTPLATFORM = @HostPlatform@
-TARGETPLATFORM = @TargetPlatform@
-BUILDPLATFORM = @BuildPlatform@
+HOSTPLATFORM = @HostPlatform@
+TARGETPLATFORM = @TargetPlatform@
+BUILDPLATFORM = @BuildPlatform@
-HostPlatform_CPP = @HostPlatform_CPP@
-HostArch_CPP = @HostArch_CPP@
-HostOS_CPP = @HostOS_CPP@
-HostVendor_CPP = @HostVendor_CPP@
+HostPlatform_CPP = @HostPlatform_CPP@
+HostArch_CPP = @HostArch_CPP@
+HostOS_CPP = @HostOS_CPP@
+HostVendor_CPP = @HostVendor_CPP@
-TargetPlatform_CPP = @TargetPlatform_CPP@
-TargetArch_CPP = @TargetArch_CPP@
-TargetOS_CPP = @TargetOS_CPP@
-TargetVendor_CPP = @TargetVendor_CPP@
+TargetPlatform_CPP = @TargetPlatform_CPP@
+TargetArch_CPP = @TargetArch_CPP@
+TargetOS_CPP = @TargetOS_CPP@
+TargetVendor_CPP = @TargetVendor_CPP@
+LLVMTarget_CPP = @LLVMTarget_CPP@
-BuildPlatform_CPP = @BuildPlatform_CPP@
-BuildArch_CPP = @BuildArch_CPP@
-BuildOS_CPP = @BuildOS_CPP@
-BuildVendor_CPP = @BuildVendor_CPP@
+BuildPlatform_CPP = @BuildPlatform_CPP@
+BuildArch_CPP = @BuildArch_CPP@
+BuildOS_CPP = @BuildOS_CPP@
+BuildVendor_CPP = @BuildVendor_CPP@
@HostPlatform_CPP@_HOST = 1
@TargetPlatform_CPP@_TARGET = 1
@@ -118,7 +119,7 @@ BuildVendor_CPP = @BuildVendor_CPP@
################################################################################
#
-# Global configuration options
+# Global configuration options
#
################################################################################
diff --git a/settings.in b/settings.in
index 04b913b86c..e4deb05b3c 100644
--- a/settings.in
+++ b/settings.in
@@ -29,6 +29,7 @@
("target has RTS linker", "@HaskellHaveRTSLinker@"),
("Unregisterised", "@Unregisterised@"),
("LLVM llc command", "@SettingsLlcCommand@"),
- ("LLVM opt command", "@SettingsOptCommand@")
+ ("LLVM opt command", "@SettingsOptCommand@"),
+ ("LLVM clang command", "@SettingsClangCommand@")
]
diff --git a/testsuite/mk/ghc-config.hs b/testsuite/mk/ghc-config.hs
index cf550082db..b0278bcfae 100644
--- a/testsuite/mk/ghc-config.hs
+++ b/testsuite/mk/ghc-config.hs
@@ -27,6 +27,7 @@ main = do
getGhcFieldOrDefault fields "GhcDynamic" "GHC Dynamic" "NO"
getGhcFieldOrDefault fields "GhcProfiled" "GHC Profiled" "NO"
getGhcFieldProgWithDefault fields "AR" "ar command" "ar"
+ getGhcFieldProgWithDefault fields "CLANG" "LLVM clang command" "clang"
getGhcFieldProgWithDefault fields "LLC" "LLVM llc command" "llc"
getGhcFieldProgWithDefault fields "TEST_CC" "C compiler command" "gcc"
diff --git a/testsuite/tests/perf/compiler/all.T b/testsuite/tests/perf/compiler/all.T
index 6fbde0d009..c14e808937 100644
--- a/testsuite/tests/perf/compiler/all.T
+++ b/testsuite/tests/perf/compiler/all.T
@@ -646,7 +646,7 @@ test('T5837',
# 2017-02-19 59161648 (x64/Windows) - Unknown
# 2017-03-14 53787192 (x64/Windows) - Unknown
- (wordsize(64), 52625920, 7)])
+ (wordsize(64), 56782344, 7)])
# sample: 3926235424 (amd64/Linux, 15/2/2012)
# 2012-10-02 81879216
# 2012-09-20 87254264 amd64/Linux
@@ -682,6 +682,7 @@ test('T5837',
# 2017-02-20 58648600 amd64/Linux Type-indexed Typeable
# 2017-02-28 54151864 amd64/Linux Likely drift due to recent simplifier improvements
# 2017-02-25 52625920 amd64/Linux Early inlining patch
+ # 2017-09-06 56782344 amd64/Linux Drift manifest in unrelated LLVM patch
],
compile, ['-freduction-depth=50'])
@@ -1009,13 +1010,14 @@ test('T12227',
test('T12425',
[ only_ways(['optasm']),
compiler_stats_num_field('bytes allocated',
- [(wordsize(64), 127500136, 5),
+ [(wordsize(64), 134780272, 5),
# initial: 125831400
# 2017-01-18: 133380960 Allow top-level string literals in Core
# 2017-02-17: 153611448 Type-indexed Typeable
# 2017-03-03: 142256192 Share Typeable KindReps
# 2017-03-21: 134334800 Unclear
# 2017-04-28: 127500136 Remove exponential behaviour in simplifier
+ # 2017-05-23: 134780272 Addition of llvm-targets in dynflags (D3352)
]),
],
compile,
diff --git a/utils/llvm-targets/gen-data-layout.sh b/utils/llvm-targets/gen-data-layout.sh
new file mode 100755
index 0000000000..3d9ded1a51
--- /dev/null
+++ b/utils/llvm-targets/gen-data-layout.sh
@@ -0,0 +1,104 @@
+#!/usr/bin/env bash
+#
+# llvm-target generator
+#
+# Author: Moritz Angermann <moritz.angermann@gmail.com>
+#
+# This file generates the `llvm-targets` file, which contains the
+# data-layout, cpu and attributes for the target. This is done by
+# querying `clang` for the data-layout, cpu and attributes based
+# on a given target.
+#
+# To utilize it run it as
+#
+# $ ./gen-data-layout.sh > llvm-targets
+#
+# Add missing targets to the list below to have them included in
+# llvm-targets file.
+
+# Target sets for which to generate the llvm-targets file
+TARGETS=(
+ # Windows x86
+ "i386-unknown-windows" "i686-unknown-windows" "x86_64-unknown-windows"
+
+ # Linux ARM
+ "arm-unknown-linux-gnueabihf" "armv6-unknown-linux-gnueabihf" "armv6l-unknown-linux-gnueabihf"
+ "armv7-unknown-linux-gnueabihf" "armv7a-unknown-linux-gnueabi" "armv7l-unknown-linux-gnueabihf"
+ "aarch64-unknown-linux-gnu" "aarch64-unknown-linux"
+ # Linux x86
+ "i386-unknown-linux-gnu" "i386-unknown-linux" "x86_64-unknown-linux-gnu" "x86_64-unknown-linux"
+ # Linux Android
+ "armv7-unknown-linux-androideabi" "aarch64-unknown-linux-android"
+
+ # QNX
+ "arm-unknown-nto-qnx-eabi"
+
+ # macOS
+ "i386-apple-darwin" "x86_64-apple-darwin"
+ # iOS
+ "armv7-apple-ios arm64-apple-ios" "i386-apple-ios x86_64-apple-ios"
+)
+
+# given the call to clang -c11 that clang --target -v generates,
+# parse the -target-cpu <CPU> and -target-feature <feature> from
+# the output.
+function get_cpu_and_attr() {
+ # echo $@
+ while [ "$#" -gt 0 ]; do
+ case "$1" in
+ -target-cpu) CPU=$2; shift 2;;
+ -target-feature)
+ # translate clang to opt/llc target features
+ case "$2" in
+ # we don't have support in GHC for proper soft-float.
+ # if we extend the `llvm-target` file to contain two
+ # additional columns for opt and llc flags, we could
+ # pass -float-abi=soft; However ghc will use float
+ # registers unconditionally on arm, and as such true
+ # soft float with the registerised llvm backend is
+ # currently not possible.
+ +soft-float-abi) shift 2;;
+ *) ATTR+=("$2"); shift 2;;
+ esac
+ ;;
+ *) shift 1;;
+ esac
+ done
+}
+
+# first marker to discrimiate the first line being outputted.
+FST=1
+# a dummy file to use for the clang invocation.
+FILE=_____dummy.c
+touch $FILE
+
+for target in "${TARGETS[@]}"; do
+ # find the cpu and attributes emitte by clang for the given $target
+ CPU=""
+ ATTR=()
+ args=$(clang --target=$target -S $FILE -o /dev/null -v 2>&1 |grep $FILE)
+ get_cpu_and_attr $args
+
+ # find the data-layout from the llvm code emitted by clang.
+ dl=$(clang --target=$target -S $FILE -emit-llvm -o -|grep datalayout |awk -F\ '{ print $4 }')
+ # GNU and Apple/LLVM can't agree on the aarch64 target.
+ # aarch64-apple-ios, is understood by autotools but not by LLVM.
+ # arm64-apple-ios, is understood by LLVM, but not by autotools.
+ #
+ # therefore, while we query clang with arm64-apple-ios, we put
+ # aarch64-apple-ios into the llvm-target list, as that is what
+ # we have to configure ghc with --target with anyway. Also we
+ # want to retain the GNU naming for compatibility with libraries
+ # that use autotools.
+ if [ "$target" == "arm64-apple-ios" ]; then
+ target="aarch64-apple-ios"
+ fi
+ if [ $FST -eq 1 ]; then
+ echo "[(\"${target}\", ($dl, \"$CPU\", \"${ATTR[*]}\"))"
+ FST=0
+ else
+ echo ",(\"${target}\", ($dl, \"$CPU\", \"${ATTR[*]}\"))"
+ fi
+done
+rm $FILE
+echo "]"
diff --git a/utils/mkUserGuidePart/Options/Linking.hs b/utils/mkUserGuidePart/Options/Linking.hs
index 23e32fac78..f0b6ea55d6 100644
--- a/utils/mkUserGuidePart/Options/Linking.hs
+++ b/utils/mkUserGuidePart/Options/Linking.hs
@@ -11,9 +11,10 @@ linkingOptions =
}
, flag { flagName = "-staticlib"
, flagDescription =
- "On Darwin/OS X/iOS only, generate a standalone static library " ++
- "(as opposed to an executable). This is the usual way to " ++
- "compile for iOS."
+ "Generate a standalone static library (as opposed to an " ++
+ "executable). This is useful when cross compiling. The " ++
+ "library together with all its dependencies ends up in in a " ++
+ "single static library that can be linked against."
, flagType = DynamicFlag
}
, flag { flagName = "-fPIC"