Commit 34f7e9a3 authored by Carter Schonwald's avatar Carter Schonwald Committed by Austin Seipp

Control CPP through settings file (#8683)

Summary:
Allow the CPP program and flag choices for GHC
be configured via the the ghc settings file

Test Plan: ran validate yesterday

Reviewers: hvr, austin, mzero, simonmar

Reviewed By: austin, mzero, simonmar

Subscribers: mzero, simonmar, relrod, carter

Differential Revision: https://phabricator.haskell.org/D26
parent 8afe616d
......@@ -454,6 +454,7 @@ AC_DEFUN([FP_SETTINGS],
then
mingw_bin_prefix=mingw/bin/
SettingsCCompilerCommand="\$topdir/../${mingw_bin_prefix}gcc.exe"
SettingsHaskellCPPCommand="\$topdir/../${mingw_bin_prefix}gcc.exe"
SettingsLdCommand="\$topdir/../${mingw_bin_prefix}ld.exe"
SettingsArCommand="\$topdir/../${mingw_bin_prefix}ar.exe"
SettingsPerlCommand='$topdir/../perl/perl.exe'
......@@ -462,6 +463,8 @@ AC_DEFUN([FP_SETTINGS],
SettingsTouchCommand='$topdir/touchy.exe'
else
SettingsCCompilerCommand="$WhatGccIsCalled"
SettingsHaskellCPPCommand="$HaskellCPPCmd"
SettingsHaskellCPPFlags="$HaskellCPPArgs"
SettingsLdCommand="$LdCmd"
SettingsArCommand="$ArCmd"
SettingsPerlCommand="$PerlCmd"
......@@ -486,6 +489,8 @@ AC_DEFUN([FP_SETTINGS],
SettingsCCompilerLinkFlags="$CONF_GCC_LINKER_OPTS_STAGE2"
SettingsLdFlags="$CONF_LD_LINKER_OPTS_STAGE2"
AC_SUBST(SettingsCCompilerCommand)
AC_SUBST(SettingsHaskellCPPCommand)
AC_SUBST(SettingsHaskellCPPFlags)
AC_SUBST(SettingsCCompilerFlags)
AC_SUBST(SettingsCCompilerLinkFlags)
AC_SUBST(SettingsLdCommand)
......@@ -706,6 +711,8 @@ AC_ARG_WITH($2,
)
]) # FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL
# FP_PROG_CONTEXT_DIFF
# --------------------
# Figure out how to do context diffs. Sets the output variable ContextDiffCmd.
......@@ -2101,4 +2108,6 @@ AC_DEFUN([MAYBE_OVERRIDE_STAGE0],[
fi
])
# LocalWords: fi
......@@ -99,8 +99,6 @@ endif
@echo 'cGhcEnableTablesNextToCode = "$(GhcEnableTablesNextToCode)"' >> $@
@echo 'cLeadingUnderscore :: String' >> $@
@echo 'cLeadingUnderscore = "$(LeadingUnderscore)"' >> $@
@echo 'cRAWCPP_FLAGS :: String' >> $@
@echo 'cRAWCPP_FLAGS = "$(RAWCPP_FLAGS)"' >> $@
@echo 'cGHC_UNLIT_PGM :: String' >> $@
@echo 'cGHC_UNLIT_PGM = "$(utils/unlit_dist_PROG)"' >> $@
@echo 'cGHC_SPLIT_PGM :: String' >> $@
......
......@@ -235,6 +235,8 @@ initSysTools mbMinusB
-- to make that possible, so for now you can't.
gcc_prog <- getSetting "C compiler command"
gcc_args_str <- getSetting "C compiler flags"
cpp_prog <- getSetting "Haskell CPP command"
cpp_args_str <- getSetting "Haskell CPP flags"
let unreg_gcc_args = if targetUnregisterised
then ["-DNO_REGS", "-DUSE_MINIINTERPRETER"]
else []
......@@ -243,6 +245,7 @@ initSysTools mbMinusB
| mkTablesNextToCode targetUnregisterised
= ["-DTABLES_NEXT_TO_CODE"]
| otherwise = []
cpp_args= map Option (words cpp_args_str)
gcc_args = map Option (words gcc_args_str
++ unreg_gcc_args
++ tntc_gcc_args)
......@@ -285,10 +288,7 @@ initSysTools mbMinusB
-- cpp is derived from gcc on all platforms
-- HACK, see setPgmP below. We keep 'words' here to remember to fix
-- Config.hs one day.
let cpp_prog = gcc_prog
cpp_args = Option "-E"
: map Option (words cRAWCPP_FLAGS)
++ gcc_args
-- Other things being equal, as and ld are simply gcc
gcc_link_args_str <- getSetting "C compiler link flags"
......
......@@ -34,7 +34,7 @@ fi
AC_SUBST([CONFIGURE_ARGS], [$ac_configure_args])
dnl ----------------------------------------------------------
dnl ** Find unixy sort and find commands,
dnl ** Find unixy sort and find commands,
dnl ** which are needed by FP_SETUP_PROJECT_VERSION
dnl ** Find find command (for Win32's benefit)
......@@ -91,7 +91,7 @@ AC_ARG_WITH([ghc],
WithGhc="$GHC"])
dnl ** Tell the make system which OS we are using
dnl $OSTYPE is set by the operating system to "msys" or "cygwin" or something
dnl $OSTYPE is set by the operating system to "msys" or "cygwin" or something
AC_SUBST(OSTYPE)
AC_ARG_ENABLE(bootstrap-with-devel-snapshot,
......@@ -479,6 +479,64 @@ export CC
MAYBE_OVERRIDE_STAGE0([gcc],[CC_STAGE0])
MAYBE_OVERRIDE_STAGE0([ar],[AR_STAGE0])
dnl ** what cpp to use?
dnl --------------------------------------------------------------
AC_ARG_WITH(hs-cpp,
[AC_HELP_STRING([--with-hs-cpp=ARG],
[Use ARG as the path to cpp [default=autodetect]])],
[
if test "$HostOS" = "mingw32"
then
AC_MSG_WARN([Request to use $withval will be ignored])
else
HaskellCPPCmd=$withval
fi
],
[
if test "$HostOS" != "mingw32"
then
HaskellCPPCmd=$WhatGccIsCalled
fi
]
)
dnl ** what cpp flags to use?
dnl -----------------------------------------------------------
AC_ARG_WITH(hs-cpp-flags,
[AC_HELP_STRING([--with-hs-cpp-flags=ARG],
[Use ARG as the path to hs cpp [default=autodetect]])],
[
if test "$HostOS" = "mingw32"
then
AC_MSG_WARN([Request to use $withval will be ignored])
else
HaskellCPPArgs=$withval
fi
],
[
$HaskellCPPCmd -x c /dev/null -dM -E > conftest.txt 2>&1
if grep "__clang__" conftest.txt >/dev/null 2>&1; then
HaskellCPPArgs="-E -undef -traditional -Wno-invalid-pp-token -Wno-unicode -Wno-trigraphs "
else
$HaskellCPPCmd -v > conftest.txt 2>&1
if grep "gcc" conftest.txt >/dev/null 2>&1; then
HaskellCPPArgs="-E -undef -traditional "
else
$HaskellCPPCmd --version > conftest.txt 2>&1
if grep "cpphs" conftest.txt >/dev/null 2>&1; then
HaskellCPPArgs="--cpp -traditional"
else
AC_MSG_WARN([configure can't recognize your CPP program, you may need to set --with-hs-cpp-flags=FLAGS explicitly])
HaskellCPPArgs=""
fi
fi
fi
]
)
dnl ** Which ld to use?
dnl --------------------------------------------------------------
FP_ARG_WITH_PATH_GNU_PROG([LD], [ld], [ld])
......@@ -991,13 +1049,14 @@ echo ["\
Using $CompilerName : $WhatGccIsCalled
which is version : $GccVersion
Building a cross compiler : $CrossCompiling
ld : $LdCmd
Happy : $HappyCmd ($HappyVersion)
Alex : $AlexCmd ($AlexVersion)
Perl : $PerlCmd
dblatex : $DblatexCmd
xsltproc : $XsltprocCmd
cpp : $HaskellCPPCmd
cpp-flags : $HaskellCPPArgs
ld : $LdCmd
Happy : $HappyCmd ($HappyVersion)
Alex : $AlexCmd ($AlexVersion)
Perl : $PerlCmd
dblatex : $DblatexCmd
xsltproc : $XsltprocCmd
Using LLVM tools
llc : $LlcCmd
......
......@@ -63,6 +63,65 @@ FIND_GCC([WhatGccIsCalled], [gcc], [gcc])
CC="$WhatGccIsCalled"
export CC
dnl ** what cpp to use?
dnl --------------------------------------------------------------
AC_ARG_WITH(hs-cpp,
[AC_HELP_STRING([--with-hs-cpp=ARG],
[Use ARG as the path to cpp [default=autodetect]])],
[
if test "$HostOS" = "mingw32"
then
AC_MSG_WARN([Request to use $withval will be ignored])
else
HaskellCPPCmd=$withval
fi
],
[
if test "$HostOS" != "mingw32"
then
HaskellCPPCmd=$WhatGccIsCalled
fi
]
)
dnl ** what cpp flags to use?
dnl -----------------------------------------------------------
AC_ARG_WITH(hs-cpp-flags,
[AC_HELP_STRING([--with-hs-cpp-flags=ARG],
[Use ARG as the path to hs cpp [default=autodetect]])],
[
if test "$HostOS" = "mingw32"
then
AC_MSG_WARN([Request to use $withval will be ignored])
else
HaskellCPPArgs=$withval
fi
],
[
$HaskellCPPCmd -x c /dev/null -dM -E > conftest.txt 2>&1
if grep "__clang__" conftest.txt >/dev/null 2>&1; then
HaskellCPPArgs="-E -undef -traditional -Wno-invalid-pp-token -Wno-unicode -Wno-trigraphs "
else
$HaskellCPPCmd -v > conftest.txt 2>&1
if grep "gcc" conftest.txt >/dev/null 2>&1; then
HaskellCPPArgs="-E -undef -traditional "
else
$HaskellCPPCmd --version > conftest.txt 2>&1
if grep "cpphs" conftest.txt >/dev/null 2>&1; then
HaskellCPPArgs="--cpp -traditional"
else
AC_MSG_WARN([configure can't recognize your CPP program, you may need to set --with-hs-cpp-flags=FLAGS explicitly])
HaskellCPPArgs=""
fi
fi
fi
]
)
dnl ** Which ld to use?
dnl --------------------------------------------------------------
FP_ARG_WITH_PATH_GNU_PROG([LD], [ld], [ld])
......
......@@ -2,6 +2,8 @@
("C compiler command", "@SettingsCCompilerCommand@"),
("C compiler flags", "@SettingsCCompilerFlags@"),
("C compiler link flags", "@SettingsCCompilerLinkFlags@"),
("Haskell CPP command","@SettingsHaskellCPPCommand@"),
("Haskell CPP flags","@SettingsHaskellCPPFlags@"),
("ld command", "@SettingsLdCommand@"),
("ld flags", "@SettingsLdFlags@"),
("ld supports compact unwind", "@LdHasNoCompactUnwind@"),
......
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