diff options
-rw-r--r-- | aclocal.m4 | 65 | ||||
-rw-r--r-- | configure.ac | 66 | ||||
-rw-r--r-- | hadrian/cfg/system.config.in | 4 | ||||
-rw-r--r-- | hadrian/src/Oracles/Flag.hs | 6 | ||||
-rw-r--r-- | hadrian/src/Oracles/Setting.hs | 4 | ||||
-rw-r--r-- | hadrian/src/Rules/Generate.hs | 10 | ||||
-rw-r--r-- | hadrian/src/Settings/Builders/Common.hs | 6 | ||||
-rw-r--r-- | hadrian/src/Settings/Packages.hs | 6 | ||||
-rw-r--r-- | hadrian/src/Settings/Warnings.hs | 4 | ||||
-rw-r--r-- | includes/Stg.h | 2 | ||||
-rw-r--r-- | includes/ghc.mk | 17 | ||||
-rw-r--r-- | mk/config.mk.in | 4 | ||||
-rw-r--r-- | mk/project.mk.in | 4 | ||||
-rw-r--r-- | mk/warnings.mk | 2 | ||||
-rw-r--r-- | rts/Task.h | 2 | ||||
-rw-r--r-- | rts/ghc.mk | 2 | ||||
-rw-r--r-- | rts/sm/GCTDecl.h | 6 | ||||
-rw-r--r-- | rts/sm/GCThread.h | 2 | ||||
-rw-r--r-- | rts/sm/Storage.c | 4 |
19 files changed, 101 insertions, 115 deletions
diff --git a/aclocal.m4 b/aclocal.m4 index 2072a33b36..1218203bfc 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -842,6 +842,48 @@ AC_DEFUN([FP_CHECK_SIZEOF_AND_ALIGNMENT], FP_CHECK_ALIGNMENT([$1]) ])# FP_CHECK_SIZEOF_AND_ALIGNMENT +# FP_DEFAULT_CHOICE_OVERRIDE_CHECK( +# flag, name, anti name, var name, help string, +# [var true val], [var false val], [flag true val]) +# --------------------------------------------------- +# Helper for when there is a automatic detection and an explicit flag for the +# user to override disable a feature, but not override enable a feature. +# +# $1 = flag of feature +# $2 = name of feature +# $3 = name of anti feature +# $4 = name of variable +# $5 = help string +# $6 = when true +# $7 = when false +# $8 = default explicit case (yes/no). Used for handle "backwards" legacy +# options where enabling makes fewer assumptions than disabling. +AC_DEFUN( + [FP_DEFAULT_CHOICE_OVERRIDE_CHECK], + [AC_ARG_ENABLE( + [$1], + [AC_HELP_STRING( + [--enable-$1], + [$5])], + [AS_IF( + [test x"$enableval" = x"m4_default([$8],yes)"], + [AS_CASE( + [x"$$4Default"], + [x"m4_default([$6],YES)"], + [AC_MSG_NOTICE([user chose $2 matching default for platform])], + [x"m4_default([$7],NO)"], + [AC_MSG_ERROR([user chose $2 overriding only supported option for platform])], + [AC_MSG_ERROR([invalid default])]) + $4=m4_default([$6],YES)], + [AS_CASE( + [x"$$4Default"], + [x"m4_default([$6],YES)"], + [AC_MSG_NOTICE([user chose $3 overriding for platform])], + [x"m4_default([$7],NO)"], + [AC_MSG_NOTICE([user chose $3 matching default for platform])], + [AC_MSG_ERROR([invalid default])]) + $4=m4_default([$7],NO)])], + [$4="$$4Default"])]) # FP_LEADING_UNDERSCORE # --------------------- @@ -1293,30 +1335,19 @@ AC_SUBST(GccLT46) dnl Check to see if the C compiler is clang or llvm-gcc dnl -GccIsClang=NO AC_DEFUN([FP_CC_LLVM_BACKEND], [AC_REQUIRE([AC_PROG_CC]) -AC_MSG_CHECKING([whether C compiler is clang]) +AC_MSG_CHECKING([whether C compiler has an LLVM back end]) $CC -x c /dev/null -dM -E > conftest.txt 2>&1 -if grep "__clang__" conftest.txt >/dev/null 2>&1; then - AC_SUBST([CC_CLANG_BACKEND], [1]) - AC_SUBST([CC_LLVM_BACKEND], [1]) - GccIsClang=YES +if grep "__llvm__" conftest.txt >/dev/null 2>&1; then + AC_DEFINE([CC_LLVM_BACKEND], [1], [Define (to 1) if C compiler has an LLVM back end]) + CcLlvmBackend=YES AC_MSG_RESULT([yes]) else + CcLlvmBackend=NO AC_MSG_RESULT([no]) - AC_MSG_CHECKING([whether C compiler has an LLVM back end]) - if grep "__llvm__" conftest.txt >/dev/null 2>&1; then - AC_SUBST([CC_CLANG_BACKEND], [0]) - AC_SUBST([CC_LLVM_BACKEND], [1]) - AC_MSG_RESULT([yes]) - else - AC_SUBST([CC_CLANG_BACKEND], [0]) - AC_SUBST([CC_LLVM_BACKEND], [0]) - AC_MSG_RESULT([no]) - fi fi -AC_SUBST(GccIsClang) +AC_SUBST(CcLlvmBackend) rm -f conftest.txt ]) diff --git a/configure.ac b/configure.ac index 6f1f0543d7..6fddd04bb0 100644 --- a/configure.ac +++ b/configure.ac @@ -241,25 +241,27 @@ AC_SUBST(SOLARIS_BROKEN_SHLD) dnl ** Do an unregisterised build? dnl -------------------------------------------------------------- + +AC_MSG_CHECKING(whether target supports a registerised ABI) case "$TargetArch" in i386|x86_64|powerpc|powerpc64|powerpc64le|arm|aarch64) UnregisterisedDefault=NO + AC_MSG_RESULT([yes]) ;; *) UnregisterisedDefault=YES + AC_MSG_RESULT([no]) ;; esac -AC_ARG_ENABLE(unregisterised, -[AC_HELP_STRING([--enable-unregisterised], -[Build an unregisterised compiler (enabled by default on platforms without registerised support) [default="$UnregisterisedDefault"]])], -[ if test x"$enableval" = x"yes"; then - Unregisterised=YES - else - Unregisterised=NO - fi -], -[Unregisterised="$UnregisterisedDefault"] -) +FP_DEFAULT_CHOICE_OVERRIDE_CHECK( + [unregisterised], + [unregisterised], + [registerised], + [Unregisterised], + [Build a toolchain with the unregisterised ABI (disabled by default on platforms with registerised support)], + [NO], + [YES], + [no]) AC_SUBST(Unregisterised) dnl ** Do a build with tables next to code? @@ -272,43 +274,35 @@ dnl decided by options to the compiler later. dnl dnl See https://gitlab.haskell.org/ghc/ghc/wikis/commentary/rts/storage/heap-objects#tables_next_to_code dnl -------------------------------------------------------------- + +AC_MSG_CHECKING(whether target supports tables next to code) case "$Unregisterised" in NO) case "$TargetArch" in ia64|powerpc64|powerpc64le) TablesNextToCodeDefault=NO + AC_MSG_RESULT([no]) ;; *) TablesNextToCodeDefault=YES + AC_MSG_RESULT([yes]) ;; esac ;; YES) TablesNextToCodeDefault=NO + AC_MSG_RESULT([no]) ;; esac -AC_ARG_ENABLE(tables-next-to-code, -[AC_HELP_STRING([--enable-tables-next-to-code], -[Build an tables-next-to-code compiler (enabled by default on platforms without registerised support) [default="$TablesNextToCodeDefault"]])], -[ if test x"$enableval" = x"yes"; then - TablesNextToCode=YES - else - TablesNextToCode=NO - fi -], -[TablesNextToCode="$TablesNextToCodeDefault"] -) - -fail() { - echo >&2 - echo "$1" >&2 - exit 1 -} - -if test "$TablesNextToCodeDefault" = "NO" && test "$TablesNextToCode" = "YES"; then - fail "Error: tables next to code was requested but is not supported" +FP_DEFAULT_CHOICE_OVERRIDE_CHECK( + [tables-next-to-code], + [tables next to code], + [tables apart from code], + [TablesNextToCode], + [Build a tool chain with info tables layed out next to code (enabled by default when using the registerised ABI, on platforms that support it)]) +if test x"$TablesNextToCode" = xYES; then + AC_DEFINE([TABLES_NEXT_TO_CODE], [1], [Define to 1 if info tables are layed out next to code]) fi - AC_SUBST(TablesNextToCode) dnl ** Does target have runtime linker support? @@ -389,7 +383,7 @@ set_up_tarballs() { find "${base_dir}" -name "*.tar.xz" -exec tar xfJ {} \; && rm ".MTREE" && rm ".PKGINFO" && - cd .. ) || fail "Error: Could not extract Windows toolchains." + cd .. ) || AC_MSG_ERROR([Could not extract Windows toolchains.]) mv "inplace/${tarball_mingw_dir}" inplace/mingw && touch inplace/mingw @@ -1373,11 +1367,7 @@ echo "\ " if test "x$CC_LLVM_BACKEND" = "x1"; then - if test "x$CC_CLANG_BACKEND" = "x1"; then - CompilerName="clang " - else - CompilerName="llvm-gcc " - fi + CompilerName="clang " else CompilerName="gcc " fi diff --git a/hadrian/cfg/system.config.in b/hadrian/cfg/system.config.in index 5d6d28d5f4..80fc3a3043 100644 --- a/hadrian/cfg/system.config.in +++ b/hadrian/cfg/system.config.in @@ -34,9 +34,7 @@ python = python3 #============================ ar-supports-at-file = @ArSupportsAtFile@ -cc-clang-backend = @CC_CLANG_BACKEND@ -cc-llvm-backend = @CC_LLVM_BACKEND@ -gcc-is-clang = @GccIsClang@ +cc-llvm-backend = @CcLlvmBackend@ hs-cpp-args = @HaskellCPPArgs@ # Build options: diff --git a/hadrian/src/Oracles/Flag.hs b/hadrian/src/Oracles/Flag.hs index 075a1bfe23..93babda794 100644 --- a/hadrian/src/Oracles/Flag.hs +++ b/hadrian/src/Oracles/Flag.hs @@ -11,7 +11,7 @@ import Oracles.Setting data Flag = ArSupportsAtFile | CrossCompiling - | GccIsClang + | CcLlvmBackend | GhcUnregisterised | TablesNextToCode | GmpInTree @@ -23,13 +23,13 @@ data Flag = ArSupportsAtFile | UseSystemFfi -- Note, if a flag is set to empty string we treat it as set to NO. This seems --- fragile, but some flags do behave like this, e.g. GccIsClang. +-- fragile, but some flags do behave like this. flag :: Flag -> Action Bool flag f = do let key = case f of ArSupportsAtFile -> "ar-supports-at-file" CrossCompiling -> "cross-compiling" - GccIsClang -> "gcc-is-clang" + CcLlvmBackend -> "cc-llvm-backend" GhcUnregisterised -> "ghc-unregisterised" TablesNextToCode -> "tables-next-to-code" GmpInTree -> "intree-gmp" diff --git a/hadrian/src/Oracles/Setting.hs b/hadrian/src/Oracles/Setting.hs index 2a4f5d0572..c84400ac69 100644 --- a/hadrian/src/Oracles/Setting.hs +++ b/hadrian/src/Oracles/Setting.hs @@ -25,8 +25,6 @@ data Setting = BuildArch | BuildOs | BuildPlatform | BuildVendor - | CcClangBackend - | CcLlvmBackend | CursesLibDir | DynamicExtension | FfiIncludeDir @@ -113,8 +111,6 @@ setting key = lookupValueOrError configFile $ case key of BuildOs -> "build-os" BuildPlatform -> "build-platform" BuildVendor -> "build-vendor" - CcClangBackend -> "cc-clang-backend" - CcLlvmBackend -> "cc-llvm-backend" CursesLibDir -> "curses-lib-dir" DynamicExtension -> "dynamic-extension" FfiIncludeDir -> "ffi-include-dir" diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs index 3faafbaaf7..e185a46ea5 100644 --- a/hadrian/src/Rules/Generate.hs +++ b/hadrian/src/Rules/Generate.hs @@ -379,20 +379,10 @@ generateGhcAutoconfH :: Expr String generateGhcAutoconfH = do trackGenerateHs configHContents <- expr $ map undefinePackage <$> readFileLines configH - tablesNextToCode <- getFlag TablesNextToCode - ghcUnreg <- getFlag GhcUnregisterised - ccLlvmBackend <- getSetting CcLlvmBackend - ccClangBackend <- getSetting CcClangBackend return . unlines $ [ "#if !defined(__GHCAUTOCONF_H__)" , "#define __GHCAUTOCONF_H__" ] ++ configHContents ++ - [ "\n#define TABLES_NEXT_TO_CODE 1" | tablesNextToCode && not ghcUnreg ] - ++ - [ "\n#define llvm_CC_FLAVOR 1" | ccLlvmBackend == "1" ] - ++ - [ "\n#define clang_CC_FLAVOR 1" | ccClangBackend == "1" ] - ++ [ "#endif /* __GHCAUTOCONF_H__ */" ] where undefinePackage s diff --git a/hadrian/src/Settings/Builders/Common.hs b/hadrian/src/Settings/Builders/Common.hs index 7d9e0fe716..2c41d92493 100644 --- a/hadrian/src/Settings/Builders/Common.hs +++ b/hadrian/src/Settings/Builders/Common.hs @@ -53,9 +53,9 @@ cArgs = mempty cWarnings :: Args cWarnings = mconcat [ arg "-Wall" - , flag GccIsClang ? arg "-Wno-unknown-pragmas" - , notM (flag GccIsClang) ? not windowsHost ? arg "-Werror=unused-but-set-variable" - , notM (flag GccIsClang) ? arg "-Wno-error=inline" ] + , flag CcLlvmBackend ? arg "-Wno-unknown-pragmas" + , notM (flag CcLlvmBackend) ? not windowsHost ? arg "-Werror=unused-but-set-variable" + , notM (flag CcLlvmBackend) ? arg "-Wno-error=inline" ] packageDatabaseArgs :: Args packageDatabaseArgs = do diff --git a/hadrian/src/Settings/Packages.hs b/hadrian/src/Settings/Packages.hs index 94a586444d..ac3c28404e 100644 --- a/hadrian/src/Settings/Packages.hs +++ b/hadrian/src/Settings/Packages.hs @@ -106,7 +106,7 @@ packageArgs = do , package ghcPrim ? mconcat [ builder (Cabal Flags) ? arg "include-ghc-prim" - , builder (Cc CompileC) ? (not <$> flag GccIsClang) ? + , builder (Cc CompileC) ? (not <$> flag CcLlvmBackend) ? input "**/cbits/atomic.c" ? arg "-Wno-sync-nand" ] --------------------------------- ghci --------------------------------- @@ -278,10 +278,10 @@ rtsPackageArgs = package rts ? do -- any warnings in the module. See: -- https://gitlab.haskell.org/ghc/ghc/wikis/working-conventions#Warnings - , (not <$> flag GccIsClang) ? + , (not <$> flag CcLlvmBackend) ? inputs ["**/Compact.c"] ? arg "-finline-limit=2500" - , input "**/RetainerProfile.c" ? flag GccIsClang ? + , input "**/RetainerProfile.c" ? flag CcLlvmBackend ? arg "-Wno-incompatible-pointer-types" , windowsHost ? arg ("-DWINVER=" ++ windowsVersion) diff --git a/hadrian/src/Settings/Warnings.hs b/hadrian/src/Settings/Warnings.hs index ea89fea3ef..0d654411c4 100644 --- a/hadrian/src/Settings/Warnings.hs +++ b/hadrian/src/Settings/Warnings.hs @@ -11,10 +11,10 @@ import Settings defaultGhcWarningsArgs :: Args defaultGhcWarningsArgs = mconcat [ notStage0 ? arg "-Wnoncanonical-monad-instances" - , (not <$> flag GccIsClang) ? mconcat + , (not <$> flag CcLlvmBackend) ? mconcat [ not windowsHost ? arg "-optc-Werror=unused-but-set-variable" , arg "-optc-Wno-error=inline" ] - , flag GccIsClang ? arg "-optc-Wno-unknown-pragmas" ] + , flag CcLlvmBackend ? arg "-optc-Wno-unknown-pragmas" ] -- | Package-specific warnings-related arguments, mostly suppressing various warnings. ghcWarningsArgs :: Args diff --git a/includes/Stg.h b/includes/Stg.h index 7f1764a944..73de97055f 100644 --- a/includes/Stg.h +++ b/includes/Stg.h @@ -61,7 +61,7 @@ # define _DEFAULT_SOURCE #endif -#if IN_STG_CODE == 0 || defined(llvm_CC_FLAVOR) +#if IN_STG_CODE == 0 || defined(CC_LLVM_BACKEND) // C compilers that use an LLVM back end (clang or llvm-gcc) do not // correctly support global register variables so we make sure that // we do not declare them for these compilers. diff --git a/includes/ghc.mk b/includes/ghc.mk index eee72128b0..f8da99abb6 100644 --- a/includes/ghc.mk +++ b/includes/ghc.mk @@ -114,23 +114,6 @@ $$(includes_$1_H_CONFIG) : mk/config.h mk/config.mk includes/ghc.mk | $$$$(dir $ # @sed 's,^\([ ]*\)#[ ]*define[ ][ ]*\(PACKAGE_[A-Z]*\)[ ][ ]*".*".*$$$$,\1/* #undef \2 */,' mk/config.h >> $$@ # -# Tack on some extra config information from the build system -# -ifeq "$$(TablesNextToCode)" "YES" - @echo >> $$@ - @echo "#define TABLES_NEXT_TO_CODE 1" >> $$@ -endif -# -ifeq "$$(CC_LLVM_BACKEND)" "1" - @echo >> $$@ - @echo "#define llvm_CC_FLAVOR 1" >> $$@ -endif -# -ifeq "$$(CC_CLANG_BACKEND)" "1" - @echo >> $$@ - @echo "#define clang_CC_FLAVOR 1" >> $$@ -endif -# @echo "#endif /* __GHCAUTOCONF_H__ */" >> $$@ @echo "Done." diff --git a/mk/config.mk.in b/mk/config.mk.in index a946b17bf9..8bbfde2e26 100644 --- a/mk/config.mk.in +++ b/mk/config.mk.in @@ -527,7 +527,9 @@ GccVersion = @GccVersion@ # the necessary format to pass to libffi's configure. TargetPlatformFull = @TargetPlatformFull@ GccLT46 = @GccLT46@ -GccIsClang = @GccIsClang@ + +# Do we have a C compiler using an LLVM back end? +CcLlvmBackend = @CcLlvmBackend@ CC = @CC@ CC_STAGE0 = @CC_STAGE0@ diff --git a/mk/project.mk.in b/mk/project.mk.in index 5cc2e4aeb1..9ee2eab59f 100644 --- a/mk/project.mk.in +++ b/mk/project.mk.in @@ -153,10 +153,6 @@ endif # linker or not? SOLARIS_BROKEN_SHLD=@SOLARIS_BROKEN_SHLD@ -# Do we have a C compiler using an LLVM back end? -CC_LLVM_BACKEND = @CC_LLVM_BACKEND@ -CC_CLANG_BACKEND = @CC_CLANG_BACKEND@ - # Is the stage0 compiler affected by Bug #9439? GHC_LLVM_AFFECTED_BY_9439 = @GHC_LLVM_AFFECTED_BY_9439@ diff --git a/mk/warnings.mk b/mk/warnings.mk index 323ea75898..cee408d061 100644 --- a/mk/warnings.mk +++ b/mk/warnings.mk @@ -17,7 +17,7 @@ GhcRtsHcOpts += -Wcpp-undef GhcStage1HcOpts += -Wcpp-undef GhcStage2HcOpts += -Wcpp-undef -ifneq "$(GccIsClang)" "YES" +ifneq "$(CcLlvmBackend)" "YES" # Debian doesn't turn -Werror=unused-but-set-variable on by default, so # we turn it on explicitly for consistency with other users diff --git a/rts/Task.h b/rts/Task.h index 88b567ab87..17bcbe2da4 100644 --- a/rts/Task.h +++ b/rts/Task.h @@ -271,7 +271,7 @@ extern uint32_t peakWorkerCount; #if ((defined(linux_HOST_OS) && \ (defined(i386_HOST_ARCH) || defined(x86_64_HOST_ARCH))) || \ (defined(mingw32_HOST_OS) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 4)) && \ - (!defined(llvm_CC_FLAVOR)) + (!defined(CC_LLVM_BACKEND)) #define MYTASK_USE_TLV extern __thread Task *my_task; #else diff --git a/rts/ghc.mk b/rts/ghc.mk index 26865b5bb7..c07cfaec86 100644 --- a/rts/ghc.mk +++ b/rts/ghc.mk @@ -523,7 +523,7 @@ rts/win32/ThrIOManager_CC_OPTS += -w # for details # Without this, thread_obj will not be inlined (at least on x86 with GCC 4.1.0) -ifneq "$(CC_CLANG_BACKEND)" "1" +ifneq "$(CcLlvmBackend)" "YES" rts/sm/Compact_CC_OPTS += -finline-limit=2500 endif diff --git a/rts/sm/GCTDecl.h b/rts/sm/GCTDecl.h index 8306795ade..e740392c15 100644 --- a/rts/sm/GCTDecl.h +++ b/rts/sm/GCTDecl.h @@ -52,11 +52,11 @@ extern StgWord8 the_gc_thread[]; /* Now, llvm-gcc and some older Clang compilers do not support __thread. So we have to fallback to the extremely slow case, - unfortunately. Note: clang_CC_FLAVOR implies llvm_CC_FLAVOR. + unfortunately. Also, the iOS Clang compiler doesn't support __thread either for some bizarre reason, so there's not much we can do about that... */ -#if defined(llvm_CC_FLAVOR) && (CC_SUPPORTS_TLS == 0) +#if defined(CC_LLVM_BACKEND) && (CC_SUPPORTS_TLS == 0) #define gct ((gc_thread *)(pthread_getspecific(gctKey))) #define SET_GCT(to) (pthread_setspecific(gctKey, to)) #define DECLARE_GCT ThreadLocalKey gctKey; @@ -66,7 +66,7 @@ extern StgWord8 the_gc_thread[]; /* However, if we *are* using an LLVM based compiler with __thread support, then use that (since LLVM doesn't support global register variables.) */ -#elif defined(llvm_CC_FLAVOR) && (CC_SUPPORTS_TLS == 1) +#elif defined(CC_LLVM_BACKEND) && (CC_SUPPORTS_TLS == 1) extern __thread gc_thread* gct; #define SET_GCT(to) gct = (to) #define DECLARE_GCT __thread gc_thread* gct; diff --git a/rts/sm/GCThread.h b/rts/sm/GCThread.h index 66f604d6cc..66f7a7f84f 100644 --- a/rts/sm/GCThread.h +++ b/rts/sm/GCThread.h @@ -208,7 +208,7 @@ extern uint32_t n_gc_threads; extern gc_thread **gc_threads; -#if defined(THREADED_RTS) && defined(llvm_CC_FLAVOR) +#if defined(THREADED_RTS) && defined(CC_LLVM_BACKEND) extern ThreadLocalKey gctKey; #endif diff --git a/rts/sm/Storage.c b/rts/sm/Storage.c index d4be531c73..0130a08f7c 100644 --- a/rts/sm/Storage.c +++ b/rts/sm/Storage.c @@ -271,7 +271,7 @@ void storageAddCapabilities (uint32_t from, uint32_t to) } } -#if defined(THREADED_RTS) && defined(llvm_CC_FLAVOR) && (CC_SUPPORTS_TLS == 0) +#if defined(THREADED_RTS) && defined(CC_LLVM_BACKEND) && (CC_SUPPORTS_TLS == 0) newThreadLocalKey(&gctKey); #endif @@ -295,7 +295,7 @@ freeStorage (bool free_heap) closeMutex(&sm_mutex); #endif stgFree(nurseries); -#if defined(THREADED_RTS) && defined(llvm_CC_FLAVOR) && (CC_SUPPORTS_TLS == 0) +#if defined(THREADED_RTS) && defined(CC_LLVM_BACKEND) && (CC_SUPPORTS_TLS == 0) freeThreadLocalKey(&gctKey); #endif freeGcThreads(); |