diff options
author | Ben Gamari <ben@smart-cactus.org> | 2021-07-25 16:46:48 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-09-23 16:00:18 -0400 |
commit | ee7bdc5c96d469092b5e2751cfeecfe9cd5a5495 (patch) | |
tree | eefed43afb96a70def56c2925985dbb3f9349ab8 /m4 | |
parent | f48d747dd647111b2e78679eaf572006908a7a5a (diff) | |
download | haskell-ee7bdc5c96d469092b5e2751cfeecfe9cd5a5495.tar.gz |
configure: Add check for whether CC supports --target
Diffstat (limited to 'm4')
-rw-r--r-- | m4/fp_cc_supports_target.m4 | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/m4/fp_cc_supports_target.m4 b/m4/fp_cc_supports_target.m4 new file mode 100644 index 0000000000..b99b5bf194 --- /dev/null +++ b/m4/fp_cc_supports_target.m4 @@ -0,0 +1,33 @@ +# FP_CC_SUPPORTS_TARGET +# --------------------- +# Does CC support the --target=<triple> option? If so, we should pass it +# whenever possible to avoid ambiguity and potential compile-time errors (e.g. +# see #20162). +# +# The primary effect of this is updating CONF_CC_OPTS_STAGE[12] to +# explicitly ask the compiler to generate code for the $TargetPlatform. +AC_DEFUN([FP_CC_SUPPORTS_TARGET], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([FPTOOLS_SET_PLATFORM_VARS]) + AC_MSG_CHECKING([whether $1 CC supports --target]) + echo 'int main() { return 0; }' > conftest.c + if $CC --target=$LlvmTarget -Werror conftest.c > /dev/null ; then + CONF_CC_SUPPORTS_TARGET=YES + AC_MSG_RESULT([yes]) + else + CONF_CC_SUPPORTS_TARGET=NO + AC_MSG_RESULT([no]) + fi + rm -f conftest.c conftest + + if test $CONF_CC_SUPPORTS_TARGET = YES ; then + CONF_CC_OPTS_STAGE1="--target=$LlvmTarget $CONF_CC_OPTS_STAGE1" + CONF_CC_OPTS_STAGE2="--target=$LlvmTarget $CONF_CC_OPTS_STAGE2" + CONF_CXX_OPTS_STAGE1="--target=$LlvmTarget $CONF_CXX_OPTS_STAGE1" + CONF_CXX_OPTS_STAGE2="--target=$LlvmTarget $CONF_CXX_OPTS_STAGE2" + CONF_GCC_LINKER_OPTS_STAGE1="--target=$LlvmTarget $CONF_GCC_LINKER_OPTS_STAGE1" + CONF_GCC_LINKER_OPTS_STAGE2="--target=$LlvmTarget $CONF_GCC_LINKER_OPTS_STAGE2" + fi +]) + |