Skip to content
Commit 4a2b9808 authored by Andrew Burgess's avatar Andrew Burgess
Browse files

gdb/testsuite: fix build-id compile option when used with clang

It was pointed out in this message:

  https://inbox.sourceware.org/gdb-patches/5d7a514b-5dad-446f-a021-444ea88ecf07@redhat.com



That the test gdb.base/build-id-seqno.exp I added recently was FAILing
when using Clang as the compiler.

The problem was that I had failed to add 'build-id' as a compile
option in the call to build_executable within the test script.  For
GCC this is fine as build-ids are included by default.  For Clang
though this meant the build-id was not included and the test would
fail.

So I added build-id to the compiler options.... and the test still
didn't pass!  Now the test fails to compile and I see this error from
the compiler:

  gdb compile failed, clang-15: warning: -Wl,--build-id: 'linker' \
        input unused [-Wunused-command-line-argument]

It turns out that the build-id compile option causes our gdb.exp to
add the '-Wl,--build-id' option into the compiler flags, which means
its used when building the object file AND during the final link.
However this option is unnecessary when creating the object file and
Clang warns about this, which causes the build to fail.

The solution is to change gdb.exp, instead of adding the build-id
flags like this:

  lappend new_options "additional_flags=-Wl,--build-id"

we should instead add them like:

  lappend new_options "ldflags=-Wl,--build-id"

Now the flag is only appended during the link phase and Clang is
happy.  The gdb.base/build-id-seqno.exp test now passes with Clang.

The same problem (adding to additional_flags instead of ldflags)
exists for the no-build-id compile option, so I've fixed that too.

While investigating this I also spotted two test scripts,
gdb.base/index-cache.exp and gdb.dwarf2/per-bfd-sharing.exp which were
setting ldflag directly rather than using the build-id compile option
so I've updated these two tests to use the compile option which I
think is neater.

I've checked that all these tests still pass with both GCC and Clang.

There should be no changes in what is actually tested after this
commit.

Approved-By: default avatarSimon Marchi <simon.marchi@efficios.com>
parent b8b1a438
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment