Hi, The recent changes to the MIPS GCC Linux sysroot (https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01014.html) have meant that the include directory is now not global and is provided only for each multi-lib configuration. This means that for any test in the MIPS GCC Testsuite that requires standard library support we need to check if there is a multi-lib support for the test options, otherwise it might fail to compile.
This patch adds this support to the testsuite and mips.exp files. Firstly any test that requires standard library support has the implicit option "(REQUIRES_STDLIB)" added to its dg-options. Secondly in mips.exp a pre-processor check is performed to ensure that when expanding a testcase containing a "#include <stdlib.h>" using the current set of test options we do not get file not found errors. If this happens we mark the testcase as unsupported. The patch has been tested on the mti/img elf/linux-gnu toolchains, and there have been no new regressions. The patch and ChangeLog are below. Ok to commit? Many thanks, Andrew testsuite/ gcc.target/mips/memcpy-1.c (dg-options): Add (REQUIRES_STDLIB). gcc.target/mips/loongson-simd.c: Ditto. gcc.target/mips/loongson-shift-count-truncated-1.c: Ditto gcc.target/mips/mips-3d-1.c: Ditto gcc.target/mips/mips-3d-2.c: Ditto gcc.target/mips/mips-3d-3.c: Ditto gcc.target/mips/mips-3d-4.c: Ditto gcc.target/mips/mips-3d-5.c: Ditto gcc.target/mips/mips-3d-6.c: Ditto gcc.target/mips/mips-3d-7.c: Ditto gcc.target/mips/mips-3d-8.c: Ditto gcc.target/mips/mips-3d-9.c: Ditto gcc.target/mips/mips-ps-1.c: Ditto gcc.target/mips/mips-ps-2.c: Ditto gcc.target/mips/mips-ps-3.c: Ditto gcc.target/mips/mips-ps-4.c: Ditto gcc.target/mips/mips-ps-6.c: Ditto gcc.target/mips/mips16-attributes.c: Ditto gcc.target/mips/mips32-dsp-run.c: Ditto gcc.target/mips/mips32-dsp.c: Ditto gcc.target/mips/save-restore-1.c: Ditto gcc.target/mips/va-arg-1.c: Ditto gcc.target/mips/mips.exp (mips_option_groups): Add stdlib. (mips-dg-options): Check if a test having test option (REQUIRES_STDLIB) has the required sysroot support for the current test options. diff --git a/gcc/testsuite/gcc.target/mips/loongson-shift-count-truncated-1.c b/gcc/testsuite/gcc.target/mips/loongson-shift-count-truncated-1.c index f57a18c..baed48c 100644 --- a/gcc/testsuite/gcc.target/mips/loongson-shift-count-truncated-1.c +++ b/gcc/testsuite/gcc.target/mips/loongson-shift-count-truncated-1.c @@ -4,7 +4,7 @@ /* loongson.h does not handle or check for MIPS16ness. There doesn't seem any good reason for it to, given that the Loongson processors do not support MIPS16. */ -/* { dg-options "isa=loongson -mhard-float -mno-mips16" } */ +/* { dg-options "isa=loongson -mhard-float -mno-mips16 (REQUIRES_STDLIB)" } */ /* See PR 52155. */ /* { dg-options "isa=loongson -mhard-float -mno-mips16 -mlong64" { mips*-*-elf* && ilp32 } } */ diff --git a/gcc/testsuite/gcc.target/mips/loongson-simd.c b/gcc/testsuite/gcc.target/mips/loongson-simd.c index 6d2ceb6..f263b43 100644 --- a/gcc/testsuite/gcc.target/mips/loongson-simd.c +++ b/gcc/testsuite/gcc.target/mips/loongson-simd.c @@ -26,7 +26,7 @@ along with GCC; see the file COPYING3. If not see because inclusion of some system headers e.g. stdint.h will fail due to not finding stubs-o32_hard.h. */ /* { dg-require-effective-target mips_nanlegacy } */ -/* { dg-options "isa=loongson -mhard-float -mno-micromips -mno-mips16 -flax-vector-conversions" } */ +/* { dg-options "isa=loongson -mhard-float -mno-micromips -mno-mips16 -flax-vector-conversions (REQUIRES_STDLIB)" } */ #include "loongson.h" #include <stdio.h> diff --git a/gcc/testsuite/gcc.target/mips/memcpy-1.c b/gcc/testsuite/gcc.target/mips/memcpy-1.c index 94786a7..bd8519f 100644 --- a/gcc/testsuite/gcc.target/mips/memcpy-1.c +++ b/gcc/testsuite/gcc.target/mips/memcpy-1.c @@ -1,4 +1,4 @@ -/* { dg-options "-fno-common" } */ +/* { dg-options "-fno-common (REQUIRES_STDLIB)" } */ /* { dg-skip-if "code quality test" { *-*-* } { "-O0" } { "" } } */ /* { dg-final { scan-assembler-not "\tlbu\t" } } */ diff --git a/gcc/testsuite/gcc.target/mips/mips-3d-1.c b/gcc/testsuite/gcc.target/mips/mips-3d-1.c index f11ffc5..3a3318d 100644 --- a/gcc/testsuite/gcc.target/mips/mips-3d-1.c +++ b/gcc/testsuite/gcc.target/mips/mips-3d-1.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-mips3d" } */ +/* { dg-options "-mips3d (REQUIRES_STDLIB)" } */ /* Test MIPS-3D builtin functions */ #include <stdlib.h> diff --git a/gcc/testsuite/gcc.target/mips/mips-3d-2.c b/gcc/testsuite/gcc.target/mips/mips-3d-2.c index b04c3bf..3464ed4 100644 --- a/gcc/testsuite/gcc.target/mips/mips-3d-2.c +++ b/gcc/testsuite/gcc.target/mips/mips-3d-2.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-mips3d" } */ +/* { dg-options "-mips3d (REQUIRES_STDLIB)" } */ /* Test MIPS-3D branch-if-any-two builtin functions */ #include <stdlib.h> diff --git a/gcc/testsuite/gcc.target/mips/mips-3d-3.c b/gcc/testsuite/gcc.target/mips/mips-3d-3.c index e4de8fb..1051afd 100644 --- a/gcc/testsuite/gcc.target/mips/mips-3d-3.c +++ b/gcc/testsuite/gcc.target/mips/mips-3d-3.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-mips3d" } */ +/* { dg-options "-mips3d (REQUIRES_STDLIB)" } */ /* Test MIPS-3D absolute compare builtin functions */ #include <stdlib.h> diff --git a/gcc/testsuite/gcc.target/mips/mips-3d-4.c b/gcc/testsuite/gcc.target/mips/mips-3d-4.c index 3d28d7f..f898346 100644 --- a/gcc/testsuite/gcc.target/mips/mips-3d-4.c +++ b/gcc/testsuite/gcc.target/mips/mips-3d-4.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-mips3d" } */ +/* { dg-options "-mips3d (REQUIRES_STDLIB)" } */ /* Test MIPS-3D branch-if-any-four builtin functions */ #include <stdlib.h> diff --git a/gcc/testsuite/gcc.target/mips/mips-3d-5.c b/gcc/testsuite/gcc.target/mips/mips-3d-5.c index a433675..21638f1 100644 --- a/gcc/testsuite/gcc.target/mips/mips-3d-5.c +++ b/gcc/testsuite/gcc.target/mips/mips-3d-5.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-mips3d" } */ +/* { dg-options "-mips3d (REQUIRES_STDLIB)" } */ /* Test MIPS-3D absolute-compare & branch-if-any-four builtin functions */ #include <stdlib.h> diff --git a/gcc/testsuite/gcc.target/mips/mips-3d-6.c b/gcc/testsuite/gcc.target/mips/mips-3d-6.c index e6b44f0..2b2417c 100644 --- a/gcc/testsuite/gcc.target/mips/mips-3d-6.c +++ b/gcc/testsuite/gcc.target/mips/mips-3d-6.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-mips3d" } */ +/* { dg-options "-mips3d (REQUIRES_STDLIB)" } */ /* Test MIPS-3D absolute compare (floats) builtin functions */ #include <stdlib.h> diff --git a/gcc/testsuite/gcc.target/mips/mips-3d-7.c b/gcc/testsuite/gcc.target/mips/mips-3d-7.c index 2531ddf..0370bfb 100644 --- a/gcc/testsuite/gcc.target/mips/mips-3d-7.c +++ b/gcc/testsuite/gcc.target/mips/mips-3d-7.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-mips3d" } */ +/* { dg-options "-mips3d (REQUIRES_STDLIB)" } */ /* Test MIPS-3D absolute compare (doubles) builtin functions */ #include <stdlib.h> diff --git a/gcc/testsuite/gcc.target/mips/mips-3d-8.c b/gcc/testsuite/gcc.target/mips/mips-3d-8.c index 1d199d7..8780f0b 100644 --- a/gcc/testsuite/gcc.target/mips/mips-3d-8.c +++ b/gcc/testsuite/gcc.target/mips/mips-3d-8.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-mips3d" } */ +/* { dg-options "-mips3d (REQUIRES_STDLIB)" } */ /* Test MIPS-3D absolute compare and conditional move builtin functions */ #include <stdlib.h> diff --git a/gcc/testsuite/gcc.target/mips/mips-3d-9.c b/gcc/testsuite/gcc.target/mips/mips-3d-9.c index d697efd..021a404 100644 --- a/gcc/testsuite/gcc.target/mips/mips-3d-9.c +++ b/gcc/testsuite/gcc.target/mips/mips-3d-9.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-mips3d" } */ +/* { dg-options "-mips3d (REQUIRES_STDLIB)" } */ /* Matrix Multiplications */ #include <stdlib.h> diff --git a/gcc/testsuite/gcc.target/mips/mips-ps-1.c b/gcc/testsuite/gcc.target/mips/mips-ps-1.c index 73598a8..fcd9448 100644 --- a/gcc/testsuite/gcc.target/mips/mips-ps-1.c +++ b/gcc/testsuite/gcc.target/mips/mips-ps-1.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-mpaired-single" } */ +/* { dg-options "-mpaired-single (REQUIRES_STDLIB)" } */ /* Test v2sf calculations */ #include <stdlib.h> diff --git a/gcc/testsuite/gcc.target/mips/mips-ps-2.c b/gcc/testsuite/gcc.target/mips/mips-ps-2.c index 5264255..85cf29e 100644 --- a/gcc/testsuite/gcc.target/mips/mips-ps-2.c +++ b/gcc/testsuite/gcc.target/mips/mips-ps-2.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-mpaired-single" } */ +/* { dg-options "-mpaired-single (REQUIRES_STDLIB)" } */ /* Test MIPS paired-single builtin functions */ #include <stdlib.h> diff --git a/gcc/testsuite/gcc.target/mips/mips-ps-3.c b/gcc/testsuite/gcc.target/mips/mips-ps-3.c index 7e6ffd0..e498a42 100644 --- a/gcc/testsuite/gcc.target/mips/mips-ps-3.c +++ b/gcc/testsuite/gcc.target/mips/mips-ps-3.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-mpaired-single" } */ +/* { dg-options "-mpaired-single (REQUIRES_STDLIB)" } */ /* Test MIPS paired-single conditional move */ #include <stdlib.h> diff --git a/gcc/testsuite/gcc.target/mips/mips-ps-4.c b/gcc/testsuite/gcc.target/mips/mips-ps-4.c index 06850ad..472f382 100644 --- a/gcc/testsuite/gcc.target/mips/mips-ps-4.c +++ b/gcc/testsuite/gcc.target/mips/mips-ps-4.c @@ -1,5 +1,5 @@ /* { dg-do run } */ -/* { dg-options "-mpaired-single" } */ +/* { dg-options "-mpaired-single (REQUIRES_STDLIB)" } */ /* Test MIPS paired-single comparisons */ #include <stdlib.h> diff --git a/gcc/testsuite/gcc.target/mips/mips-ps-6.c b/gcc/testsuite/gcc.target/mips/mips-ps-6.c index 5bdfe43..fd82d72 100644 --- a/gcc/testsuite/gcc.target/mips/mips-ps-6.c +++ b/gcc/testsuite/gcc.target/mips/mips-ps-6.c @@ -1,7 +1,7 @@ /* mips-ps-2.c with an extra -ffinite-math-only option. This option changes the way that abs.ps is handled. */ /* { dg-do run } */ -/* { dg-options "-mpaired-single -ffinite-math-only" } */ +/* { dg-options "-mpaired-single -ffinite-math-only (REQUIRES_STDLIB)" } */ /* Test MIPS paired-single builtin functions */ #include <stdlib.h> diff --git a/gcc/testsuite/gcc.target/mips/mips.exp b/gcc/testsuite/gcc.target/mips/mips.exp index b3617e4..38594f3 100644 --- a/gcc/testsuite/gcc.target/mips/mips.exp +++ b/gcc/testsuite/gcc.target/mips/mips.exp @@ -254,6 +254,7 @@ set mips_option_groups { madd "HAS_MADD" maddps "HAS_MADDPS" lsa "(|!)HAS_LSA" + stdlib "REQUIRES_STDLIB" section_start "-Wl,--section-start=.*" } @@ -1389,6 +1390,21 @@ proc mips-dg-options { args } { } } + # If the test is marked as requiring standard libraries check + # that the sysroot has support for the current set of test options. + if { [mips_have_test_option_p options "REQUIRES_STDLIB"] } { + mips_push_test_options saved_options $extra_tool_flags + set output [mips_preprocess "" { + #include <stdlib.h> + }] + mips_pop_test_options saved_options + + # If the stdlib.h file is not found mark the test as unsupported. + if { [regexp "stdlib.h: No such file or directory" $output] } { + set do_what [lreplace $do_what 1 1 "N"] + } + } + # If the test is MIPS16-compatible, provide a counterpart to the # NOMIPS16 convenience macro. if { [mips_have_test_option_p options "-mips16"] } { diff --git a/gcc/testsuite/gcc.target/mips/mips16-attributes.c b/gcc/testsuite/gcc.target/mips/mips16-attributes.c index 28bb9aa..421aa77 100644 --- a/gcc/testsuite/gcc.target/mips/mips16-attributes.c +++ b/gcc/testsuite/gcc.target/mips/mips16-attributes.c @@ -2,7 +2,7 @@ of calling a nomips16/mips16/default function from a nomips16/mips16/default function. */ /* { dg-do run } */ -/* { dg-options "(-mips16)" } */ +/* { dg-options "(-mips16) (REQUIRES_STDLIB)" } */ #include <stdlib.h> diff --git a/gcc/testsuite/gcc.target/mips/mips32-dsp-run.c b/gcc/testsuite/gcc.target/mips/mips32-dsp-run.c index ccd9d38..ca12d04 100644 --- a/gcc/testsuite/gcc.target/mips/mips32-dsp-run.c +++ b/gcc/testsuite/gcc.target/mips/mips32-dsp-run.c @@ -1,6 +1,6 @@ /* Test MIPS32 DSP instructions */ /* { dg-do run } */ -/* { dg-options "-mdsp" } */ +/* { dg-options "-mdsp (REQUIRES_STDLIB)" } */ #include <stdlib.h> #include <stdio.h> diff --git a/gcc/testsuite/gcc.target/mips/mips32-dsp.c b/gcc/testsuite/gcc.target/mips/mips32-dsp.c index 9aaf120..d212bcf 100644 --- a/gcc/testsuite/gcc.target/mips/mips32-dsp.c +++ b/gcc/testsuite/gcc.target/mips/mips32-dsp.c @@ -1,6 +1,6 @@ /* Test MIPS32 DSP instructions */ /* { dg-do compile } */ -/* { dg-options "-mgp32 -mdsp" } */ +/* { dg-options "-mgp32 -mdsp (REQUIRES_STDLIB)" } */ /* { dg-final { scan-assembler "\taddq.ph\t" } } */ /* { dg-final { scan-assembler "\taddq_s.ph\t" } } */ /* { dg-final { scan-assembler "\taddq_s.w\t" } } */ diff --git a/gcc/testsuite/gcc.target/mips/save-restore-1.c b/gcc/testsuite/gcc.target/mips/save-restore-1.c index b3ce1b1..5e1e838 100644 --- a/gcc/testsuite/gcc.target/mips/save-restore-1.c +++ b/gcc/testsuite/gcc.target/mips/save-restore-1.c @@ -1,5 +1,5 @@ /* Check that we can use the save instruction to save varargs. */ -/* { dg-options "(-mips16) isa_rev>=1 -mabi=32" } */ +/* { dg-options "(-mips16) isa_rev>=1 -mabi=32 (REQUIRES_STDLIB)" } */ #include <stdarg.h> diff --git a/gcc/testsuite/gcc.target/mips/va-arg-1.c b/gcc/testsuite/gcc.target/mips/va-arg-1.c index 87c95f5..cee7e89 100644 --- a/gcc/testsuite/gcc.target/mips/va-arg-1.c +++ b/gcc/testsuite/gcc.target/mips/va-arg-1.c @@ -1,5 +1,6 @@ /* See PR 52154 for the xfail. */ /* { dg-do run { xfail { mips_eabi && { hard_float && ilp32 } } } } */ +/* { dg-options "(REQUIRES_STDLIB)" } */ #include <stdarg.h> -- 2.4.1