Commit c2290596 authored by John Ericson's avatar John Ericson Committed by Marge Bot

Simplify Configure in a few ways

 - No need to distinguish between gcc-llvm and clang. First of all,
   gcc-llvm is quite old and surely unmaintained by now. Second of all,
   none of the code actually care about that distinction!

   Now, it does make sense to consider C multiple frontends for LLVMs in
   the form of clang vs clang-cl (same clang, yes, but tweaked
   interface). But this is better handled in terms of "gccish vs
   mvscish" and "is LLVM", yielding 4 combinations. Therefore, I don't
   think it is useful saving the existing code for that.

 - Get the remaining CC_LLVM_BACKEND, and also TABLES_NEXT_TO_CODE in
   mk/config.h the normal way, rather than hacking it post-hoc. No point
   keeping these special cases around for now reason.

 - Get rid of hand-rolled `die` function and just use `AC_MSG_ERROR`.

 - Abstract check + flag override for unregisterised and tables next to
   code.

Oh, and as part of the above I also renamed/combined some variables
where it felt appropriate.

 - GccIsClang -> CcLlvmBackend. This is for `AC_SUBST`, like the other
 Camal case ones. It was never about gcc-llvm, or Apple's renamed clang,
 to be clear.

 - llvm_CC_FLAVOR -> CC_LLVM_BACKEND. This is for `AC_DEFINE`, like the
 other all-caps snake case ones. llvm_CC_FLAVOR was just silly
 indirection *and* an odd name to boot.
parent 166e1c2a
Pipeline #11283 passed with stages
in 455 minutes and 52 seconds
......@@ -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
])
......
......@@ -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
......
......@@ -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:
......
......@@ -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"
......
......@@ -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"
......
......@@ -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
......
......@@ -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
......
......@@ -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)
......
......@@ -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
......
......@@ -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.
......
......@@ -113,23 +113,6 @@ $$(includes_$1_H_CONFIG) : mk/config.h mk/config.mk includes/ghc.mk | $$$$(dir $
# "blah"' into '/* #undef PACKAGE_FOO */' to avoid clashes.
#
@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."
......
......@@ -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@
......
......@@ -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@
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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;
......
......@@ -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
......
......@@ -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();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment