Make gold testsuite work with CC and CXX specifying -B

Cary Coutant ccoutant@gmail.com
Wed Nov 7 18:39:00 GMT 2018


> This is a revised version of the patch I posted at
> https://sourceware.org/ml/binutils/2016-10/msg00039.html
> a patch that didn't receive any comment or review, perhaps due to
> using GNU make features.  This patch doesn't use any modern make
> features.

I went back and looked at that one, in the context of surrounding
email, and realized that I didn't comment on it because I carelessly
thought it was part of a series of patches that you had already
committed. I didn't notice the "OK to apply?" Sorry!

> The patch allows the gold testsuite to pass when using something like
> the following configure line, allowing me to test build binutils with
> some random gcc.  This works for the rest of the binutils testsuite.
> At least, it does if you don't configure your gcc with any of the
> options that force a particular path to as or ld.
>
> gccdir="/home/alan/build/gcc/prev-"
> gccsrc="/home/alan/src/gcc.git"
> gcctarg="x86_64-linux"
> CC="${gccdir}gcc/xgcc -B${gccdir}gcc/" \
> CXX="${gccdir}gcc/xg++ -B${gccdir}gcc/ -I${gccdir}$gcctarg/libstdc++-v3/include -I${gccdir}$gcctarg/libstdc++-v3/include/$gcctarg -I${gccsrc}/libstdc++-v3/libsupc++ -L${gccdir}$gcctarg/libstdc++-v3/src/.libs/" \
> ~/src/binutils-gdb/configure ...
>
> gold's -Bgcctestdir/ option must come before the -B supplied by $CC
> or $CXX, in order to pick up the linker we want to test.  Also when
> using a not-yet-installed gcc, it is necessary to provide a collect-ld
> in gcctestdir/ as otherwise a collect-ld script in -B${gccdir}gcc/
> will be used and the wrong linker tested.

I hate the sed-editing of the compile command line that we have in
there now. I've been wanting to get rid of it, not add to it.

The -D_FORTIFY_SOURCE option, it seems to me, could be undone with a
-U_FORTIFY_SOURCE option, rather than running the whole $(CC) through
sed. I posted a question about that a long time ago, but never got an
answer, and I didn't follow up. I didn't want to make the change
unilaterally since I don't use the option, so I couldn't be sure the
change would work.

The -static-libgcc and -static-libstdc++ options are handled via sed
because we couldn't use -shared-libxxx or -no-static-libxxx options --
I haven't checked whether one of those would work now.

I personally test with alternate gcc installations simply by setting
$PATH before running the test suite, but of course I want things to
work for your way as well. If we need to add another sed operation
into the works, so be it; I guess the points above are now moot.

> Besides this, the patch fixes some bugs: The $COMPILE -D_FORTIFY_SOURCE
> edit was wrong (but worked for usual values)

Ouch! Thanks for fixing that!

> Also, -Bgcctestdir/ in one place makes it less likely a new test will
> be added that accidentally lacks the option.

Agreed. That's been a problem more than once.

> -ld1_LDFLAGS = -Bgcctestdir1/
> +ld1_LINK = `echo $(CXXLD) | sed -e 's/\([^ ]*\)\(.*\)/\1 -Bgcctestdir1\/\2/'`\
> +       $(AM_CXXFLAGS) $(CXXFLAGS) $(ld1_LDFLAGS) $(LDFLAGS) -o $@

Can you use the $(editcc) model here that you used in testsuite/Makefile.am?

> +# Put our -B option before any other -B that might be in $CC or $CXX
> +editcc = sed -e 's/\([^ ]*\)\(.*\)/\1 -Bgcctestdir\/\2/'
> ...
> +editcc1 = $(editcc) -e 's/-Wp,-D_FORTIFY_SOURCE=[0-9][0-9]*//'

This makes me uncomfortable -- tacking on an additional -e option like
that. What if $(editcc) is changed so that you can't just add another
-e option to the end? How about taking "sed" out of editcc, and
defining these so you can write something like:

> +CCLD = `echo $(CC) | sed $(editcc1) $(editcc2)`

and

> +CXXLINK_S = `echo $(CXXLINK1) | sed $(editcc1) $(editcc2) $(editcc3)`

-cary



More information about the Binutils mailing list