diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2024-12-06 04:44:05 +0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2024-12-11 18:31:00 +0800 |
commit | b79f25753346a577c9ba0a3dca69bd9d9d72a020 (patch) | |
tree | b126cf018240a668e5bb8b742029fd9632745c15 /aclocal.m4 | |
parent | 4d9a4c02f9327338bb8dc890d26fbbeef956ba1b (diff) | |
download | glibc-b79f25753346a577c9ba0a3dca69bd9d9d72a020.zip glibc-b79f25753346a577c9ba0a3dca69bd9d9d72a020.tar.gz glibc-b79f25753346a577c9ba0a3dca69bd9d9d72a020.tar.bz2 |
Add TEST_CC and TEST_CXX support
Support testing glibc build with a different C compiler or a different
C++ compiler with
$ ../glibc-VERSION/configure TEST_CC="gcc-6.4.1" TEST_CXX="g++-6.4.1"
1. Add LIBC_TRY_CC_AND_TEST_CC_OPTION, LIBC_TRY_CC_AND_TEST_CC_COMMAND
and LIBC_TRY_CC_AND_TEST_LINK to test both CC and TEST_CC.
2. Add check and xcheck targets to Makefile.in and override build compiler
options with ones from TEST_CC and TEST_CXX.
Tested on Fedora 41/x86-64:
1. Building with GCC 14.2.1 and testing with GCC 6.4.1 and GCC 11.2.1.
2. Building with GCC 15 and testing with GCC 6.4.1.
Support for GCC versions older than GCC 6.2 may need to change the test
sources. Other targets may need to update configure.ac under sysdeps and
modify Makefile.in to override target build compiler options.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'aclocal.m4')
-rw-r--r-- | aclocal.m4 | 83 |
1 files changed, 83 insertions, 0 deletions
@@ -315,3 +315,86 @@ case "$prefix" in fi ;; esac]) + +dnl Run a test with TEST_CC. +dnl LIBC_CHECK_TEST_CC([commands]) +AC_DEFUN([LIBC_CHECK_TEST_CC], +[ +saved_CC="$CC" +CC="$TEST_CC" +[$1] +CC="$saved_CC" +]) + +dnl Test a CC and TEST_CC compiler option or options with an empty input +dnl file. +dnl LIBC_TRY_CC_AND_TEST_CC_OPTION([message], [options], +dnl [CC-cache-id], [CC-action-if-true], [CC-action-if-false] +dnl [TEST_CC-cache-id], [TEST_CC-action-if-true], [TEST_CC-action-if-false]) +AC_DEFUN([LIBC_TRY_CC_AND_TEST_CC_OPTION], +[ +AC_CACHE_CHECK([$1], $3, + [LIBC_TRY_CC_OPTION([$2], [$4], [$5])]) +if test "$TEST_CC" = "$CC"; then + $6=$[$3] +else + LIBC_CHECK_TEST_CC( + AC_CACHE_CHECK([$1 in testing], $6, + [LIBC_TRY_CC_OPTION([$2], [$7], [$8])]) + ) +fi +]) + +dnl Test a CC and TEST_CC compiler option or options with an input file. +dnl LIBC_TRY_CC_AND_TEST_CC_COMMAND([message], [code], [options], +dnl [CC-cache-id], [CC-action-if-true], [CC-action-if-false] +dnl [TEST_CC-cache-id], [TEST_CC-action-if-true], [TEST_CC-action-if-false]) +AC_DEFUN([LIBC_TRY_CC_AND_TEST_CC_COMMAND], +[ +cat > conftest.c <<EOF +$2 +EOF +AC_CACHE_CHECK([$1], $4, [dnl + if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $3 conftest.c -o conftest 1>&AS_MESSAGE_LOG_FD]) + then + [$5] + else + [$6] + fi +]) +if test "$TEST_CC" = "$CC"; then + $7=$[$4] +else + LIBC_CHECK_TEST_CC( + AC_CACHE_CHECK([$1 in testing], $7, [dnl + if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $3 conftest.c -o conftest 1>&AS_MESSAGE_LOG_FD]) + then + [$8] + else + [$9] + fi]) + ) +fi +rm -f conftest*]) + +dnl Test if CC and TEST_CC can link with an input file. +dnl LIBC_TRY_CC_AND_TEST_LINK([message], [code], +dnl [CC-cache-id], [CC-action-if-true], [CC-action-if-false] +dnl [TEST_CC-cache-id], [TEST_CC-action-if-true], [TEST_CC-action-if-false]) +AC_DEFUN([LIBC_TRY_CC_AND_TEST_LINK], +[ +AC_CACHE_CHECK([$1], $3, [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([], [$2])], + [$4], [$5]) +]) +if test "$TEST_CC" = "$CC"; then + $6=$[$3] +else + LIBC_CHECK_TEST_CC( + AC_CACHE_CHECK([$1 in testing], $6, [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([], [$2])], + [$7], [$8]) + ]) + ) +fi +]) |