Don't build libctf tests in source dir

Nick Alcock nick.alcock@oracle.com
Thu Oct 16 13:20:21 GMT 2025
On 13 Oct 2025, Alan Modra said:

> Running the libctf testsuite currently leaves big-struct-ctf.o in
> libctf/testsuite/libctf-lookup/.

Hmm. Yeah, that seems wrong. An oversight, sorry!

> It ought to be possible to make the binutils source dir read-only,
> and putting compiler output in the source dir leads to interesting
> effects when testing multiple binutils targets in parallel, as I
> found.
>
> 	* lib/ctf-lib.exp (run_lookup_test): For "link: objects" compile
> 	objects in tmpdir.

Absolutely! That's where everything else gets put anyway. At the very
least it should go into the objdir somewhere. The tmpdir is perhaps not
ideal, but it'll do -- it gets rebuilt whenever needed in any case.

> OK?

Go for it.

> diff --git a/libctf/testsuite/lib/ctf-lib.exp b/libctf/testsuite/lib/ctf-lib.exp
> index 7175e14c30a..da44396b162 100644
> --- a/libctf/testsuite/lib/ctf-lib.exp
> +++ b/libctf/testsuite/lib/ctf-lib.exp
> @@ -298,7 +298,7 @@ proc run_lookup_test { name } {
>  	    }
>  
>  	    if { $opts(link) == "objects" } {
> -		set obj "[file rootname $src].o"
> +		set obj "tmpdir/[file rootname [file tail $src]].o"
>  		set comp_output [prune_warnings [run_host_cmd "$CC_FOR_TARGET" "$CFLAGS_FOR_TARGET $lookup_flags $src -c -o $obj"]]
>  
>  		if { $comp_output != ""} {

I'm hoping to backport the big-struct fix to the 2.45 branch: I'll take
this fix with it.


More information about the Binutils mailing list