diff options
author | John Ericson <git@JohnEricson.me> | 2019-04-07 22:33:21 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-07-09 22:56:18 -0400 |
commit | 0472f0f6a92395d478e9644c0dbd12948518099f (patch) | |
tree | 811e61b4be392fbd68e7b3df24a82a6df74f89e5 /compiler | |
parent | fb43bddc771094632bd08a4eab28fd3e714affd0 (diff) | |
download | haskell-0472f0f6a92395d478e9644c0dbd12948518099f.tar.gz |
Remove most uses of TARGET platform macros
These prevent multi-target builds. They were gotten rid of in 3 ways:
1. In the compiler itself, replacing `#if` with runtime `if`. In these
cases, we care about the target platform still, but the target platform
is dynamic so we must delay the elimination to run time.
2. In the compiler itself, replacing `TARGET` with `HOST`. There was
just one bit of this, in some code splitting strings representing lists
of paths. These paths are used by GHC itself, and not by the compiled
binary. (They are compiler lookup paths, rather than RPATHS or something
that does matter to the compiled binary, and thus would legitamentally
be target-sensative.) As such, the path-splitting method only depends on
where GHC runs and not where code it produces runs. This should have
been `HOST` all along.
3. Changing the RTS. The RTS doesn't care about the target platform,
full stop.
4. `includes/stg/HaskellMachRegs.h` This file is also included in the
genapply executable. This is tricky because the RTS's host platform
really is that utility's target platform. so that utility really really
isn't multi-target either. But at least it isn't an installed part of
GHC, but just a one-off tool when building the RTS. Lying with the
`HOST` to a one-off program (genapply) that isn't installed doesn't seem so bad.
It's certainly better than the other way around of lying to the RTS
though not to genapply. The RTS is more important, and it is installed,
*and* this header is installed as part of the RTS.
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/HsVersions.h | 2 | ||||
-rw-r--r-- | compiler/main/DriverPipeline.hs | 6 | ||||
-rw-r--r-- | compiler/main/DynFlags.hs | 12 |
3 files changed, 12 insertions, 8 deletions
diff --git a/compiler/HsVersions.h b/compiler/HsVersions.h index a4ec3e4c40..992c4377cd 100644 --- a/compiler/HsVersions.h +++ b/compiler/HsVersions.h @@ -12,7 +12,7 @@ you will screw up the layout where they are used in case expressions! /* Useful in the headers that we share with the RTS */ #define COMPILING_GHC 1 -/* Pull in all the platform defines for this build (foo_TARGET_ARCH etc.) */ +/* Pull in all the platform defines for this build (foo_HOST_ARCH etc.) */ #include "ghc_boot_platform.h" /* Pull in the autoconf defines (HAVE_FOO), but don't include diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index 74bc64ede3..17c8f480d9 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -1962,11 +1962,13 @@ doCpp dflags raw input_fn output_fn = do let cpp_prog args | raw = SysTools.runCpp dflags args | otherwise = SysTools.runCc Nothing dflags (SysTools.Option "-E" : args) + let targetArch = stringEncodeArch $ platformArch $ targetPlatform dflags + targetOS = stringEncodeOS $ platformOS $ targetPlatform dflags let target_defs = [ "-D" ++ HOST_OS ++ "_BUILD_OS", "-D" ++ HOST_ARCH ++ "_BUILD_ARCH", - "-D" ++ TARGET_OS ++ "_HOST_OS", - "-D" ++ TARGET_ARCH ++ "_HOST_ARCH" ] + "-D" ++ targetOS ++ "_HOST_OS", + "-D" ++ targetArch ++ "_HOST_ARCH" ] -- remember, in code we *compile*, the HOST is the same our TARGET, -- and BUILD is the same as our HOST. diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index fcc5cfb1a0..2379f484e9 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -1503,9 +1503,11 @@ versionedAppDir dflags = do -- constructing platform-version-dependent files that need to co-exist. -- versionedFilePath :: DynFlags -> FilePath -versionedFilePath dflags = TARGET_ARCH - ++ '-':TARGET_OS - ++ '-':projectVersion dflags +versionedFilePath dflags = intercalate "-" + [ stringEncodeArch $ platformArch $ targetPlatform dflags + , stringEncodeOS $ platformOS $ targetPlatform dflags + , projectVersion dflags + ] -- NB: This functionality is reimplemented in Cabal, so if you -- change it, be sure to update Cabal. @@ -5503,7 +5505,7 @@ addIncludePath p = addFrameworkPath p = upd (\s -> s{frameworkPaths = frameworkPaths s ++ splitPathList p}) -#if !defined(mingw32_TARGET_OS) +#if !defined(mingw32_HOST_OS) split_marker :: Char split_marker = ':' -- not configurable (ToDo) #endif @@ -5515,7 +5517,7 @@ splitPathList s = filter notNull (splitUp s) -- cause confusion when they are translated into -I options -- for passing to gcc. where -#if !defined(mingw32_TARGET_OS) +#if !defined(mingw32_HOST_OS) splitUp xs = split split_marker xs #else -- Windows: 'hybrid' support for DOS-style paths in directory lists. |