Make stage 1 GHC target independent
authorJohn Ericson <git@JohnEricson.me>
Mon, 8 Apr 2019 02:33:21 +0000 (22:33 -0400)
committerMarge Bot <ben+marge-bot@smart-cactus.org>
Wed, 24 Jul 2019 20:49:53 +0000 (16:49 -0400)
Now that the target macros are not being used, we remove them. This
prevents target hardcoding regressions.

compiler/ghc.mk
hadrian/src/Rules/Generate.hs
includes/ghc.mk
libraries/ghc-prim/GHC/Prim/Ext.hs

index f80d7b7..629a1ed 100644 (file)
@@ -101,28 +101,21 @@ compiler/stage1/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
        @echo                                                     >> $@
        @echo "#define $(BuildPlatform_CPP)_BUILD 1"              >> $@
        @echo "#define $(HostPlatform_CPP)_HOST 1"                >> $@
-       @echo "#define $(TargetPlatform_CPP)_TARGET 1"            >> $@
        @echo                                                     >> $@
        @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1"             >> $@
        @echo "#define $(HostArch_CPP)_HOST_ARCH 1"               >> $@
-       @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1"           >> $@
        @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\""           >> $@
        @echo "#define HOST_ARCH \"$(HostArch_CPP)\""             >> $@
-       @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\""         >> $@
        @echo                                                     >> $@
        @echo "#define $(BuildOS_CPP)_BUILD_OS 1"                 >> $@
        @echo "#define $(HostOS_CPP)_HOST_OS 1"                   >> $@
-       @echo "#define $(TargetOS_CPP)_TARGET_OS 1"               >> $@
        @echo "#define BUILD_OS \"$(BuildOS_CPP)\""               >> $@
        @echo "#define HOST_OS \"$(HostOS_CPP)\""                 >> $@
-       @echo "#define TARGET_OS \"$(TargetOS_CPP)\""             >> $@
        @echo                                                     >> $@
        @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1"         >> $@
        @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1"           >> $@
-       @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR  1"      >> $@
        @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\""       >> $@
        @echo "#define HOST_VENDOR \"$(HostVendor_CPP)\""         >> $@
-       @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\""     >> $@
        @echo                                                     >> $@
        @echo "#endif /* __PLATFORM_H__ */"                       >> $@
        @echo "Done."
@@ -141,28 +134,21 @@ compiler/stage2/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
        @echo                                                     >> $@
        @echo "#define $(HostPlatform_CPP)_BUILD 1"               >> $@
        @echo "#define $(TargetPlatform_CPP)_HOST 1"              >> $@
-       @echo "#define $(TargetPlatform_CPP)_TARGET 1"            >> $@
        @echo                                                     >> $@
        @echo "#define $(HostArch_CPP)_BUILD_ARCH 1"              >> $@
        @echo "#define $(TargetArch_CPP)_HOST_ARCH 1"             >> $@
-       @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1"           >> $@
        @echo "#define BUILD_ARCH \"$(HostArch_CPP)\""            >> $@
        @echo "#define HOST_ARCH \"$(TargetArch_CPP)\""           >> $@
-       @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\""         >> $@
        @echo                                                     >> $@
        @echo "#define $(HostOS_CPP)_BUILD_OS 1"                  >> $@
        @echo "#define $(TargetOS_CPP)_HOST_OS 1"                 >> $@
-       @echo "#define $(TargetOS_CPP)_TARGET_OS 1"               >> $@
        @echo "#define BUILD_OS \"$(HostOS_CPP)\""                >> $@
        @echo "#define HOST_OS \"$(TargetOS_CPP)\""               >> $@
-       @echo "#define TARGET_OS \"$(TargetOS_CPP)\""             >> $@
        @echo                                                     >> $@
        @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1"          >> $@
        @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1"         >> $@
-       @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR  1"      >> $@
        @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\""        >> $@
        @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\""       >> $@
-       @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\""     >> $@
        @echo                                                     >> $@
        @echo "#endif /* __PLATFORM_H__ */"                       >> $@
        @echo "Done."
@@ -204,7 +190,7 @@ compiler_HC_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS))
 
 define preprocessCompilerFiles
 # $0 = stage
-compiler/stage$1/build/primops.txt: compiler/prelude/primops.txt.pp compiler/stage$1/$$(PLATFORM_H)
+compiler/stage$1/build/primops.txt: compiler/prelude/primops.txt.pp
        $$(HS_CPP) -P $$(compiler_CPP_OPTS) -Icompiler/stage$1 -x c $$< | grep -v '^#pragma GCC' > $$@
 
 compiler/stage$1/build/primop-data-decl.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
index 7a58413..b14bccc 100644 (file)
@@ -258,18 +258,13 @@ generateGhcPlatformH = do
         , "#define BUILD_VENDOR " ++ show hostVendor
         , "#define HOST_VENDOR "  ++ show targetVendor
         , ""
-        , "/* These TARGET macros are for backwards compatibility... DO NOT USE! */"
-        , "#define TargetPlatform_TYPE " ++ cppify targetPlatform
-        , "#define " ++ cppify targetPlatform ++ "_TARGET 1"
-        , "#define " ++ targetArch ++ "_TARGET_ARCH 1"
-        , "#define TARGET_ARCH " ++ show targetArch
-        , "#define " ++ targetOs ++ "_TARGET_OS 1"
-        , "#define TARGET_OS " ++ show targetOs
-        , "#define " ++ targetVendor ++ "_TARGET_VENDOR 1" ]
+        ]
         ++
         [ "#define UnregisterisedCompiler 1" | ghcUnreg ]
         ++
-        [ "\n#endif /* __GHCPLATFORM_H__ */" ]
+        [ ""
+        , "#endif /* __GHCPLATFORM_H__ */"
+        ]
 
 generateSettings :: Expr String
 generateSettings = do
@@ -413,10 +408,6 @@ generateGhcBootPlatformH = do
     hostArch       <- chooseSetting HostArch      TargetArch
     hostOs         <- chooseSetting HostOs        TargetOs
     hostVendor     <- chooseSetting HostVendor    TargetVendor
-    targetPlatform <- getSetting TargetPlatform
-    targetArch     <- getSetting TargetArch
-    targetOs       <- getSetting TargetOs
-    targetVendor   <- getSetting TargetVendor
     return $ unlines
         [ "#if !defined(__PLATFORM_H__)"
         , "#define __PLATFORM_H__"
@@ -426,28 +417,21 @@ generateGhcBootPlatformH = do
         , ""
         , "#define " ++ cppify buildPlatform  ++ "_BUILD 1"
         , "#define " ++ cppify hostPlatform   ++ "_HOST 1"
-        , "#define " ++ cppify targetPlatform ++ "_TARGET 1"
         , ""
         , "#define " ++ buildArch  ++ "_BUILD_ARCH 1"
         , "#define " ++ hostArch   ++ "_HOST_ARCH 1"
-        , "#define " ++ targetArch ++ "_TARGET_ARCH 1"
         , "#define BUILD_ARCH "  ++ show buildArch
         , "#define HOST_ARCH "   ++ show hostArch
-        , "#define TARGET_ARCH " ++ show targetArch
         , ""
         , "#define " ++ buildOs  ++ "_BUILD_OS 1"
         , "#define " ++ hostOs   ++ "_HOST_OS 1"
-        , "#define " ++ targetOs ++ "_TARGET_OS 1"
         , "#define BUILD_OS "  ++ show buildOs
         , "#define HOST_OS "   ++ show hostOs
-        , "#define TARGET_OS " ++ show targetOs
         , ""
         , "#define " ++ buildVendor  ++ "_BUILD_VENDOR 1"
         , "#define " ++ hostVendor   ++ "_HOST_VENDOR 1"
-        , "#define " ++ targetVendor ++ "_TARGET_VENDOR  1"
         , "#define BUILD_VENDOR "  ++ show buildVendor
         , "#define HOST_VENDOR "   ++ show hostVendor
-        , "#define TARGET_VENDOR " ++ show targetVendor
         , ""
         , "#endif /* __PLATFORM_H__ */" ]
 
index ccbd8ab..7ad63ba 100644 (file)
@@ -149,14 +149,6 @@ $(includes_H_PLATFORM) : includes/Makefile | $$(dir $$@)/.
        @echo "#define BUILD_VENDOR  \"$(HostVendor_CPP)\"" >> $@
        @echo "#define HOST_VENDOR  \"$(TargetVendor_CPP)\"" >> $@
        @echo >> $@
-       @echo "/* These TARGET macros are for backwards compatibility... DO NOT USE! */" >> $@
-       @echo "#define TargetPlatform_TYPE $(TargetPlatform_CPP)" >> $@
-       @echo "#define $(TargetPlatform_CPP)_TARGET  1" >> $@
-       @echo "#define $(TargetArch_CPP)_TARGET_ARCH  1" >> $@
-       @echo "#define TARGET_ARCH  \"$(TargetArch_CPP)\"" >> $@
-       @echo "#define $(TargetOS_CPP)_TARGET_OS  1" >> $@  
-       @echo "#define TARGET_OS  \"$(TargetOS_CPP)\"" >> $@
-       @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR  1" >> $@
 ifeq "$(GhcUnregisterised)" "YES"
        @echo "#define UnregisterisedCompiler 1" >> $@
 endif
index 402d572..b9f644e 100644 (file)
@@ -30,7 +30,7 @@ module GHC.Prim.Ext
     INT64
   , WORD64
   -- * Delay\/wait operations
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
   , asyncRead#
   , asyncWrite#
   , asyncDoProc#
@@ -66,7 +66,7 @@ type WORD64 =
 -- Delay/wait operations
 ------------------------------------------------------------------------
 
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
 
 -- | Asynchronously read bytes from specified file descriptor.
 foreign import prim "stg_asyncReadzh" asyncRead#