aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Jung Bauermann <thiago.bauermann@linaro.org>2023-08-17 23:30:50 -0300
committerEric Feng <ef2648@columbia.edu>2023-08-18 15:53:13 -0400
commit6785917c9103e18bba0d718ac3b65a386d9a14f7 (patch)
treeed68154843d6189d32124ce1d12680f73d7d9994
parent4123b5609da53c8f8ac01c90aef127ad6375e9df (diff)
downloadgcc-6785917c9103e18bba0d718ac3b65a386d9a14f7.zip
gcc-6785917c9103e18bba0d718ac3b65a386d9a14f7.tar.gz
gcc-6785917c9103e18bba0d718ac3b65a386d9a14f7.tar.bz2
testsuite: Improve test in dg-require-python-h
If GCC is tested with a sysroot which doesn't contain a Python installation (e.g., with a command such as "make check-gcc-c FLAGS_UNDER_TEST="--sysroot=/some/path"), but there's a python3-config in $PATH, then the testsuite will pick up the host's Python.h which can't actually be used: Executing on host: python3-config --includes (timeout = 300) spawn -ignore SIGHUP python3-config --includes -I/usr/include/python3.10 -I/usr/include/python3.10 Executing on host: /some/sysroot/bin/aarch64-unknown-linux-gnu-gcc --sysroot=/some/sysroot/libc -Wl,-dynamic-linker=/some/sysroot/libc/lib/ld-linux-aarch64.so.1 -Wl,-rpath=/some/sysroot/libc/lib /some/src/gcc.git/gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-2.c -fdiagnostics-plain-output -fplugin=./analyzer_cpython_plugin.so -fanalyzer -I/usr/include/python3.10 -I/usr/include/python3.10 -S -o cpython-plugin-test-2.s (timeout = 600) spawn -ignore SIGHUP /some/sysroot/bin/aarch64-unknown-linux-gnu-gcc --sysroot=/some/sysroot/libc -Wl,-dynamic-linker=/some/sysroot/libc/lib/ld-linux-aarch64.so.1 -Wl,-rpath=/some/sysroot/libc/lib /some/src/gcc.git/gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-2.c -fdiagnostics-plain-output -fplugin=./analyzer_cpython_plugin.so -fanalyzer -I/usr/include/python3.10 -I/usr/include/python3.10 -S -o cpython-plugin-test-2.s In file included from /usr/include/python3.10/Python.h:8, from /some/src/gcc.git/gcc/testsuite/gcc.dg/plugin/cpython-plugin-test-2.c:8: /usr/include/python3.10/pyconfig.h:9:12: fatal error: aarch64-linux-gnu/python3.10/pyconfig.h: No such file or directory compilation terminated. compiler exited with status 1 This problem causes these testsuite failures: FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 17) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 18) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 21) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 31) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 32) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 35) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 45) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 55) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 63) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 66) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 68) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for warnings, line 69) FAIL: gcc.dg/plugin/cpython-plugin-test-2.c -fplugin=./analyzer_cpython_plugin.so (test for excess errors) Excess errors: /usr/include/python3.10/pyconfig.h:9:12: fatal error: aarch64-linux-gnu/python3.10/pyconfig.h: No such file or directory compilation terminated. So try to compile a test file so that the testcase can be marked as unsupported instead. gcc/testsuite/ChangeLog: * lib/target-supports.exp (dg-require-python-h): Test whether Python.h can really be used.
-rw-r--r--gcc/testsuite/lib/target-supports.exp14
1 files changed, 12 insertions, 2 deletions
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 92b6f69..5b5f865 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -12570,11 +12570,21 @@ proc dg-require-python-h { args } {
verbose "ENTER dg-require-python-h" 2
+ set supported 0
set result [remote_exec host "python3-config --includes"]
set status [lindex $result 0]
if { $status == 0 } {
- set python_flags [lindex $result 1]
- } else {
+ # Remove trailing newline from python3-config output.
+ set python_flags [string trim [lindex $result 1]]
+ if [check_no_compiler_messages python_h assembly {
+ #include <Python.h>
+ int main (void) { return 0; }
+ } $python_flags] {
+ set supported 1
+ }
+ }
+
+ if { $supported == 0 } {
verbose "Python.h not supported" 2
upvar dg-do-what dg-do-what
set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]