[PATCH] 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: * gcc/testsuite/lib/target-supports.exp (dg-require-python-h): Test whether Python.h can really be used. --- gcc/testsuite/lib/target-supports.exp | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 92b6f69730e9..5b5f86551844 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 + 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"] base-commit: 1eb2433ff9e85008a289db03ff7eb802d51c42a8
Re: [PATCH] testsuite: Improve test in dg-require-python-h
On Thu, 2023-08-17 at 23:30 -0300, Thiago Jung Bauermann wrote: > 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: > * gcc/testsuite/lib/target-supports.exp (dg-require-python- > h): Test > whether Python.h can really be used. > --- > gcc/testsuite/lib/target-supports.exp | 14 -- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/gcc/testsuite/lib/target-supports.exp > b/gcc/testsuite/lib/target-supports.exp > index 92b6f69730e9..5b5f86551844 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 > + 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"] > > ba
Re: [PATCH] testsuite: Improve test in dg-require-python-h
Thanks for the patch, Thiago. I've pushed it to trunk: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=6785917c9103e18bba0d718ac3b65a386d9a14f7. Best, Eric On Fri, Aug 18, 2023 at 2:11 PM David Malcolm wrote: > > On Thu, 2023-08-17 at 23:30 -0300, Thiago Jung Bauermann wrote: > > 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: > > * gcc/testsuite/lib/target-supports.exp (dg-require-python- > > h): Test > > whether Python.h can really be used. > > --- > > gcc/testsuite/lib/target-supports.exp | 14 -- > > 1 file changed, 12 insertions(+), 2 deletions(-) > > > > diff --git a/gcc/testsuite/lib/target-supports.exp > > b/gcc/testsuite/lib/target-supports.exp > > index 92b6f69730e9..5b5f86551844 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]] > >
Re: [PATCH] testsuite: Improve test in dg-require-python-h
Eric Feng writes: > Thanks for the patch, Thiago. I've pushed it to trunk: > https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=6785917c9103e18bba0d718ac3b65a386d9a14f7. Thank you, Eric and Dave. > On Fri, Aug 18, 2023 at 2:11 PM David Malcolm wrote: >> >> On Thu, 2023-08-17 at 23:30 -0300, Thiago Jung Bauermann wrote: >> > 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: >> > * gcc/testsuite/lib/target-supports.exp (dg-require-python- >> > h): Test >> > whether Python.h can really be used. >> > --- >> > gcc/testsuite/lib/target-supports.exp | 14 -- >> > 1 file changed, 12 insertions(+), 2 deletions(-) >> > >> > diff --git a/gcc/testsuite/lib/target-supports.exp >> > b/gcc/testsuite/lib/target-supports.exp >> > index 92b6f69730e9..5b5f86551844 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] >> > -