Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
38c8b565
Commit
38c8b565
authored
Oct 19, 2011
by
Ian Lynagh
Browse files
Put the target platform in the settings file
parent
013a3e3b
Changes
11
Hide whitespace changes
Inline
Side-by-side
aclocal.m4
View file @
38c8b565
...
...
@@ -101,9 +101,81 @@ AC_DEFUN([FPTOOLS_SET_PLATFORM_VARS],
;;
esac
BuildPlatform="$BuildArch-$BuildVendor-$BuildOS"
BuildPlatform_CPP=`echo "$BuildPlatform" | sed -e 's/\./_/g' -e 's/-/_/g'`
BuildArch_CPP=` echo "$BuildArch" | sed -e 's/\./_/g' -e 's/-/_/g'`
BuildVendor_CPP=` echo "$BuildVendor" | sed -e 's/\./_/g' -e 's/-/_/g'`
BuildOS_CPP=` echo "$BuildOS" | sed -e 's/\./_/g' -e 's/-/_/g'`
HostPlatform="$HostArch-$HostVendor-$HostOS"
HostPlatform_CPP=`echo "$HostPlatform" | sed -e 's/\./_/g' -e 's/-/_/g'`
HostArch_CPP=` echo "$HostArch" | sed -e 's/\./_/g' -e 's/-/_/g'`
HostVendor_CPP=` echo "$HostVendor" | sed -e 's/\./_/g' -e 's/-/_/g'`
HostOS_CPP=` echo "$HostOS" | sed -e 's/\./_/g' -e 's/-/_/g'`
TargetPlatform="$TargetArch-$TargetVendor-$TargetOS"
TargetPlatform_CPP=`echo "$TargetPlatform" | sed -e 's/\./_/g' -e 's/-/_/g'`
TargetArch_CPP=` echo "$TargetArch" | sed -e 's/\./_/g' -e 's/-/_/g'`
TargetVendor_CPP=` echo "$TargetVendor" | sed -e 's/\./_/g' -e 's/-/_/g'`
TargetOS_CPP=` echo "$TargetOS" | sed -e 's/\./_/g' -e 's/-/_/g'`
echo "GHC build : $BuildPlatform"
echo "GHC host : $HostPlatform"
echo "GHC target : $TargetPlatform"
AC_SUBST(BuildPlatform)
AC_SUBST(HostPlatform)
AC_SUBST(TargetPlatform)
AC_SUBST(HostPlatform_CPP)
AC_SUBST(BuildPlatform_CPP)
AC_SUBST(TargetPlatform_CPP)
AC_SUBST(HostArch_CPP)
AC_SUBST(BuildArch_CPP)
AC_SUBST(TargetArch_CPP)
AC_SUBST(HostOS_CPP)
AC_SUBST(BuildOS_CPP)
AC_SUBST(TargetOS_CPP)
AC_SUBST(HostVendor_CPP)
AC_SUBST(BuildVendor_CPP)
AC_SUBST(TargetVendor_CPP)
AC_SUBST(exeext)
AC_SUBST(soext)
])
# FPTOOLS_SET_HASKELL_PLATFORM_VARS
# ----------------------------------
# Set the Haskell platform variables
AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS],
[
checkArch() {
case [$]1 in
alpha|arm|hppa|hppa1_1|i386|ia64|m68k|mips|mipseb|mipsel|powerpc|powerpc64|rs6000|s390|s390x|sparc|sparc64|vax|x86_64)
i386)
test -z "[$]2" || eval "[$]2=ArchX86"
;;
x86_64)
GET_ARM_ISA()
test -z "[$]2" || eval "[$]2=ArchX86_64"
;;
powerpc)
test -z "[$]2" || eval "[$]2=ArchPPC"
;;
powerpc64)
test -z "[$]2" || eval "[$]2=ArchPPC_64"
;;
sparc)
test -z "[$]2" || eval "[$]2=ArchSPARC"
;;
arm)
GET_ARM_ISA()
test -z "[$]2" || eval "[$]2=\"ArchARM \$ARM_ISA \$ARM_ISA_EXT\""
;;
alpha|hppa|hppa1_1|ia64|m68k|mips|mipseb|mipsel|rs6000|s390|s390x|sparc64|vax)
test -z "[$]2" || eval "[$]2=ArchUnknown"
;;
*)
echo "Unknown arch [$]1"
...
...
@@ -125,71 +197,107 @@ AC_DEFUN([FPTOOLS_SET_PLATFORM_VARS],
checkOS() {
case [$]1 in
linux|freebsd|netbsd|openbsd|dragonfly|osf1|osf3|hpux|linuxaout|kfreebsdgnu|freebsd2|solaris2|cygwin32|mingw32|darwin|gnu|nextstep2|nextstep3|sunos4|ultrix|irix|aix|haiku)
linux)
test -z "[$]2" || eval "[$]2=OSLinux"
;;
darwin)
test -z "[$]2" || eval "[$]2=OSDarwin"
;;
solaris2)
test -z "[$]2" || eval "[$]2=OSSolaris2"
;;
mingw32)
test -z "[$]2" || eval "[$]2=OSMinGW32"
;;
freebsd)
test -z "[$]2" || eval "[$]2=OSFreeBSD"
;;
openbsd)
test -z "[$]2" || eval "[$]2=OSOpenBSD"
;;
netbsd|dragonfly|osf1|osf3|hpux|linuxaout|kfreebsdgnu|freebsd2|cygwin32|gnu|nextstep2|nextstep3|sunos4|ultrix|irix|aix|haiku)
test -z "[$]2" || eval "[$]2=OSUnknown"
;;
*)
echo "Unknown OS '[$]1'"
exit 1
;;
esac
}
}
checkArch "$BuildArch" ""
checkVendor "$BuildVendor"
checkOS "$BuildOS" ""
BuildPlatform="$BuildArch-$BuildVendor-$BuildOS"
BuildPlatform_CPP=`echo "$BuildPlatform" | sed -e 's/\./_/g' -e 's/-/_/g'`
BuildArch_CPP=` echo "$BuildArch" | sed -e 's/\./_/g' -e 's/-/_/g'`
BuildVendor_CPP=` echo "$BuildVendor" | sed -e 's/\./_/g' -e 's/-/_/g'`
BuildOS_CPP=` echo "$BuildOS" | sed -e 's/\./_/g' -e 's/-/_/g'`
checkArch "$BuildArch"
checkVendor "$BuildVendor"
checkOS "$BuildOS"
HostPlatform="$HostArch-$HostVendor-$HostOS"
HostPlatform_CPP=`echo "$HostPlatform" | sed -e 's/\./_/g' -e 's/-/_/g'`
HostArch_CPP=` echo "$HostArch" | sed -e 's/\./_/g' -e 's/-/_/g'`
HostVendor_CPP=` echo "$HostVendor" | sed -e 's/\./_/g' -e 's/-/_/g'`
HostOS_CPP=` echo "$HostOS" | sed -e 's/\./_/g' -e 's/-/_/g'`
checkArch "$HostArch"
checkVendor "$HostVendor"
checkOS "$HostOS"
TargetPlatform="$TargetArch-$TargetVendor-$TargetOS"
TargetPlatform_CPP=`echo "$TargetPlatform" | sed -e 's/\./_/g' -e 's/-/_/g'`
TargetArch_CPP=` echo "$TargetArch" | sed -e 's/\./_/g' -e 's/-/_/g'`
TargetVendor_CPP=` echo "$TargetVendor" | sed -e 's/\./_/g' -e 's/-/_/g'`
TargetOS_CPP=` echo "$TargetOS" | sed -e 's/\./_/g' -e 's/-/_/g'`
checkArch "$TargetArch"
checkVendor "$TargetVendor"
checkOS "$TargetOS"
echo "GHC build : $BuildPlatform"
echo "GHC host : $HostPlatform"
echo "GHC target : $TargetPlatform"
AC_SUBST(BuildPlatform)
AC_SUBST(HostPlatform)
AC_SUBST(TargetPlatform)
AC_SUBST(HostPlatform_CPP)
AC_SUBST(BuildPlatform_CPP)
AC_SUBST(TargetPlatform_CPP)
AC_SUBST(HostArch_CPP)
AC_SUBST(BuildArch_CPP)
AC_SUBST(TargetArch_CPP)
AC_SUBST(HostOS_CPP)
AC_SUBST(BuildOS_CPP)
AC_SUBST(TargetOS_CPP)
AC_SUBST(HostVendor_CPP)
AC_SUBST(BuildVendor_CPP)
AC_SUBST(TargetVendor_CPP)
AC_SUBST(exeext)
AC_SUBST(soext)
checkArch "$HostArch" ""
checkVendor "$HostVendor"
checkOS "$HostOS" ""
checkArch "$TargetArch" "HaskellTargetArch"
checkVendor "$TargetVendor"
checkOS "$TargetOS" "HaskellTargetOs"
AC_SUBST(HaskellTargetArch)
AC_SUBST(HaskellTargetOs)
])
# GET_ARM_ISA
# ----------------------------------
# Get info about the ISA on the Arm arch
AC_DEFUN([GET_ARM_ISA],
[
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM(
[],
[#if defined(__ARM_ARCH_2__) || \
defined(__ARM_ARCH_3__) || \
defined(__ARM_ARCH_3M__) || \
defined(__ARM_ARCH_4__) || \
defined(__ARM_ARCH_4T__) || \
defined(__ARM_ARCH_5__) || \
defined(__ARM_ARCH_5T__) || \
defined(__ARM_ARCH_5E__) || \
defined(__ARM_ARCH_5TE__)
return 0;
#else
not pre arm v6
#endif]
)],
[AC_DEFINE(arm_HOST_ARCH_PRE_ARMv6, 1, [ARM pre v6])
AC_DEFINE(arm_HOST_ARCH_PRE_ARMv7, 1, [ARM pre v7])
changequote(, )dnl
ARM_ISA=ARMv5
ARM_ISA_EXT="[]"
changequote([, ])dnl
],
[
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM(
[],
[#if defined(__ARM_ARCH_6__) || \
defined(__ARM_ARCH_6J__) || \
defined(__ARM_ARCH_6T2__) || \
defined(__ARM_ARCH_6Z__) || \
defined(__ARM_ARCH_6ZK__) || \
defined(__ARM_ARCH_6M__)
return 0;
#else
not pre arm v7
#endif]
)],
[AC_DEFINE(arm_HOST_ARCH_PRE_ARMv7, 1, [ARM pre v7])
changequote(, )dnl
ARM_ISA=ARMv6
ARM_ISA_EXT="[]"
changequote([, ])dnl
],
[changequote(, )dnl
ARM_ISA=ARMv7
ARM_ISA_EXT="[VFPv3, NEON]"
changequote([, ])dnl
])
])
])
...
...
compiler/HsVersions.h
View file @
38c8b565
...
...
@@ -15,7 +15,6 @@ you will screw up the layout where they are used in case expressions!
/* Pull in all the platform defines for this build (foo_TARGET_ARCH etc.) */
#include "ghc_boot_platform.h"
#include "../includes/stg/ArchSpecific.h"
/* This macro indicates that the target OS supports ELF-like shared libraries */
#if linux_TARGET_OS || freebsd_TARGET_OS || openbsd_TARGET_OS || solaris2_TARGET_OS
...
...
compiler/main/DynFlags.hs
View file @
38c8b565
...
...
@@ -45,6 +45,7 @@ module DynFlags (
-- ** System tool settings and locations
Settings
(
..
),
targetPlatform
,
ghcUsagePath
,
ghciUsagePath
,
topDir
,
tmpDir
,
rawSettings
,
extraGccViaCFlags
,
systemPackageConfig
,
pgm_L
,
pgm_P
,
pgm_F
,
pgm_c
,
pgm_s
,
pgm_a
,
pgm_l
,
pgm_dll
,
pgm_T
,
...
...
@@ -456,7 +457,6 @@ data DynFlags = DynFlags {
floatLamArgs
::
Maybe
Int
,
-- ^ Arg count for lambda floating
-- See CoreMonad.FloatOutSwitches
targetPlatform
::
Platform
.
Platform
,
-- ^ The platform we're compiling for. Used by the NCG.
cmdlineHcIncludes
::
[
String
],
-- ^ @\-\#includes@
importPaths
::
[
FilePath
],
mainModIs
::
Module
,
...
...
@@ -569,6 +569,7 @@ data DynFlags = DynFlags {
}
data
Settings
=
Settings
{
sTargetPlatform
::
Platform
,
-- Filled in by SysTools
sGhcUsagePath
::
FilePath
,
-- Filled in by SysTools
sGhciUsagePath
::
FilePath
,
-- ditto
sTopDir
::
FilePath
,
...
...
@@ -605,6 +606,9 @@ data Settings = Settings {
}
targetPlatform
::
DynFlags
->
Platform
targetPlatform
dflags
=
sTargetPlatform
(
settings
dflags
)
ghcUsagePath
::
DynFlags
->
FilePath
ghcUsagePath
dflags
=
sGhcUsagePath
(
settings
dflags
)
ghciUsagePath
::
DynFlags
->
FilePath
...
...
@@ -818,7 +822,6 @@ defaultDynFlags mySettings =
floatLamArgs
=
Just
0
,
-- Default: float only if no fvs
strictnessBefore
=
[]
,
targetPlatform
=
defaultTargetPlatform
,
cmdlineHcIncludes
=
[]
,
importPaths
=
[
"."
],
mainModIs
=
mAIN
,
...
...
compiler/main/SysTools.lhs
View file @
38c8b565
...
...
@@ -47,6 +47,7 @@ import Config
import Outputable
import ErrUtils
import Panic
import Platform
import Util
import DynFlags
import StaticFlags
...
...
@@ -182,6 +183,14 @@ initSysTools mbMinusB
_ ->
xs
Nothing -> pgmError ("No entry for " ++ show key ++ " in " ++ show settingsFile)
readSetting key = case lookup key mySettings of
Just xs ->
case maybeRead xs of
Just v -> return v
Nothing -> pgmError ("Failed to read " ++ show key ++ " value " ++ show xs)
Nothing -> pgmError ("No entry for " ++ show key ++ " in " ++ show settingsFile)
; targetArch <- readSetting "target arch"
; targetOS <- readSetting "target os"
; myExtraGccViaCFlags <- getSetting "GCC extra via C opts"
-- On Windows, mingw is distributed with GHC,
-- so we look in TopDir/../mingw/bin
...
...
@@ -241,6 +250,10 @@ initSysTools mbMinusB
lo_prog = "opt"
; return $ Settings {
sTargetPlatform = Platform {
platformArch = targetArch,
platformOS = targetOS
},
sTmpDir = normalise tmpdir,
sGhcUsagePath = ghc_usage_msg_path,
sGhciUsagePath = ghci_usage_msg_path,
...
...
compiler/utils/Platform.hs
View file @
38c8b565
-- | A description of the platform we're compiling for.
-- In the future, this module should be the only one that references
-- the evil #defines for each TARGET_ARCH and TARGET_OS
--
module
Platform
(
Platform
(
..
),
...
...
@@ -10,7 +8,6 @@ module Platform (
ArmISA
(
..
),
ArmISAExt
(
..
),
defaultTargetPlatform
,
target32Bit
,
osElfTarget
)
...
...
@@ -19,16 +16,13 @@ where
import
Panic
#
include
"HsVersions.h"
-- | Contains enough information for the native code generator to emit
-- code for this platform.
data
Platform
=
Platform
{
platformArch
::
Arch
,
platformOS
::
OS
}
deriving
(
Show
,
Eq
)
deriving
(
Read
,
Show
,
Eq
)
-- | Architectures that the native code generator knows about.
...
...
@@ -45,7 +39,7 @@ data Arch
|
ArchARM
{
armISA
::
ArmISA
,
armISAExt
::
[
ArmISAExt
]
}
deriving
(
Show
,
Eq
)
deriving
(
Read
,
Show
,
Eq
)
-- | Operating systems that the native code generator knows about.
...
...
@@ -58,7 +52,7 @@ data OS
|
OSMinGW32
|
OSFreeBSD
|
OSOpenBSD
deriving
(
Show
,
Eq
)
deriving
(
Read
,
Show
,
Eq
)
-- | ARM Instruction Set Architecture and Extensions
--
...
...
@@ -66,7 +60,7 @@ data ArmISA
=
ARMv5
|
ARMv6
|
ARMv7
deriving
(
Show
,
Eq
)
deriving
(
Read
,
Show
,
Eq
)
data
ArmISAExt
=
VFPv2
...
...
@@ -74,7 +68,7 @@ data ArmISAExt
|
VFPv3D16
|
NEON
|
IWMMX2
deriving
(
Show
,
Eq
)
deriving
(
Read
,
Show
,
Eq
)
target32Bit
::
Platform
->
Bool
...
...
@@ -98,69 +92,3 @@ osElfTarget OSDarwin = False
osElfTarget
OSMinGW32
=
False
osElfTarget
OSUnknown
=
panic
"Don't know if OSUnknown is elf"
-- | This is the target platform as far as the #ifdefs are concerned.
-- These are set in includes/ghcplatform.h by the autoconf scripts
defaultTargetPlatform
::
Platform
defaultTargetPlatform
=
Platform
defaultTargetArch
defaultTargetOS
-- | Move the evil TARGET_ARCH #ifdefs into Haskell land.
defaultTargetArch
::
Arch
#
if
i386_TARGET_ARCH
defaultTargetArch
=
ArchX86
#
elif
x86_64_TARGET_ARCH
defaultTargetArch
=
ArchX86_64
#
elif
powerpc_TARGET_ARCH
defaultTargetArch
=
ArchPPC
#
elif
powerpc64_TARGET_ARCH
defaultTargetArch
=
ArchPPC_64
#
elif
sparc_TARGET_ARCH
defaultTargetArch
=
ArchSPARC
#
elif
arm_TARGET_ARCH
defaultTargetArch
=
ArchARM
defaultTargetArmISA
defaultTargetArmISAExt
#
else
defaultTargetArch
=
ArchUnknown
#
endif
-- | Move the evil TARGET_OS #ifdefs into Haskell land.
defaultTargetOS
::
OS
#
if
linux_TARGET_OS
defaultTargetOS
=
OSLinux
#
elif
darwin_TARGET_OS
defaultTargetOS
=
OSDarwin
#
elif
solaris2_TARGET_OS
defaultTargetOS
=
OSSolaris2
#
elif
mingw32_TARGET_OS
defaultTargetOS
=
OSMinGW32
#
elif
freebsd_TARGET_OS
defaultTargetOS
=
OSFreeBSD
#
elif
kfreebsdgnu_TARGET_OS
defaultTargetOS
=
OSFreeBSD
#
elif
openbsd_TARGET_OS
defaultTargetOS
=
OSOpenBSD
#
else
defaultTargetOS
=
OSUnknown
#
endif
#
if
arm_TARGET_ARCH
defaultTargetArmISA
::
ArmISA
#
if
defined
(
arm_HOST_ARCH_PRE_ARMv6
)
defaultTargetArmISA
=
ARMv5
#
elif
defined
(
arm_HOST_ARCH_PRE_ARMv7
)
defaultTargetArmISA
=
ARMv6
#
else
defaultTargetArmISA
=
ARMv7
#
endif
defaultTargetArmISAExt
::
[
ArmISAExt
]
#
if
defined
(
arm_TARGET_ARCH
)
&&
!
defined
(
arm_HOST_ARCH_PRE_ARMv7
)
/*
wild
guess
really
,
in
case
of
ARMv7
we
assume
both
VFPv3
and
NEON
presented
however
this
is
not
true
for
SoCs
like
NVidia
Tegra2
and
Marvell
Dove
*/
defaultTargetArmISAExt
=
[
VFPv3
,
NEON
]
#
else
defaultTargetArmISAExt
=
[]
#
endif
#
endif
/*
arm_TARGET_ARCH
*/
compiler/utils/Util.lhs
View file @
38c8b565
...
...
@@ -69,7 +69,7 @@ module Util (
readRational,
-- * read helpers
maybeReadFuzzy,
maybeRead,
maybeReadFuzzy,
-- * IO-ish utilities
createDirectoryHierarchy,
...
...
@@ -989,6 +989,11 @@ readRational top_s
-----------------------------------------------------------------------------
-- read helpers
maybeRead :: Read a => String -> Maybe a
maybeRead str = case reads str of
[(x, "")] -> Just x
_ -> Nothing
maybeReadFuzzy :: Read a => String -> Maybe a
maybeReadFuzzy str = case reads str of
[(x, s)]
...
...
configure.ac
View file @
38c8b565
...
...
@@ -444,6 +444,11 @@ AC_SUBST(CONF_CPP_OPTS_STAGE0)
AC_SUBST(CONF_CPP_OPTS_STAGE1)
AC_SUBST(CONF_CPP_OPTS_STAGE2)
dnl ** Set up the variables for the platform in the settings file.
dnl May need to use gcc to find platform details.
dnl --------------------------------------------------------------
FPTOOLS_SET_HASKELL_PLATFORM_VARS
FP_SETTINGS
dnl ** figure out how to do context diffs
...
...
distrib/configure.ac.in
View file @
38c8b565
...
...
@@ -80,6 +80,11 @@ AC_SUBST(CONF_CPP_OPTS_STAGE0)
AC_SUBST(CONF_CPP_OPTS_STAGE1)
AC_SUBST(CONF_CPP_OPTS_STAGE2)
dnl ** Set up the variables for the platform in the settings file.
dnl May need to use gcc to find platform details.
dnl --------------------------------------------------------------
FPTOOLS_SET_HASKELL_PLATFORM_VARS
FP_SETTINGS
#
...
...
includes/Stg.h
View file @
38c8b565
...
...
@@ -225,8 +225,6 @@ typedef StgFunPtr F_;
Other Stg stuff...
-------------------------------------------------------------------------- */
#include "stg/ArchSpecific.h"
/* required by MachRegs.h and SMP.h */
#include "stg/DLL.h"
#include "stg/MachRegs.h"
#include "stg/Regs.h"
...
...
includes/stg/ArchSpecific.h
deleted
100644 → 0
View file @
013a3e3b
/* ----------------------------------------------------------------------------
*
* (c) The GHC Team, 2011
*
* Architecture-specific defines for ARM
*
* Do not #include this file directly: #include "Rts.h" instead.
*
* To understand the structure of the RTS headers, see the wiki:
* http://hackage.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
*
* -------------------------------------------------------------------------- */
#ifndef ARCH_ARM_H
#define ARCH_ARM_H
#if defined(__ARM_ARCH_2__) || defined(__ARM_ARCH_3__) || defined(__ARM_ARCH_3M__) || \
defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) || defined(__ARM_ARCH_5__) || \
defined(__ARM_ARCH_5T__) || defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__)
#define arm_HOST_ARCH_PRE_ARMv6
#endif
#if defined(arm_HOST_ARCH_PRE_ARMv6) || defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \
defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || \
defined(__ARM_ARCH_6M__)
#define arm_HOST_ARCH_PRE_ARMv7
#endif
#endif
settings.in
View file @
38c8b565
...
...
@@ -7,5 +7,8 @@
("touch command", "@SettingsTouchCommand@"),
("dllwrap command", "@SettingsDllWrapCommand@"),
("windres command", "@SettingsWindresCommand@"),
("perl command", "@SettingsPerlCommand@")]
("perl command", "@SettingsPerlCommand@"),
("target os", "@HaskellTargetOs@"),
("target arch", "@HaskellTargetArch@")
]
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment