[gdb/testsuite] Don't pass -fPIC to gdb_compile_shlib
authorTom de Vries <tdevries@suse.de>
Mon, 14 Dec 2020 17:16:40 +0000 (18:16 +0100)
committerTom de Vries <tdevries@suse.de>
Mon, 14 Dec 2020 17:16:40 +0000 (18:16 +0100)
commit2f4132646d8dbf8c1a82d63cacbb36ee46a289bb
tree07f08e58b9b458cf56003a2ecc0c50e0d8b5f1f7
parenta6f3c8a1a8353424f00946f073e11c321119a719
[gdb/testsuite] Don't pass -fPIC to gdb_compile_shlib

When running test-case gdb.base/info-shared.exp, I see in gdb.log:
...
Executing on host: \
  gcc ... -fPIC -fpic -c -o info-shared-solib1.c.o info-shared-solib1.c
...

The -fPIC comes from the test-case:
...
if { [gdb_compile_shlib $srcfile_lib1 $binfile_lib1 \
         [list additional_flags=-fPIC]] != "" } {
...
but the -fpic, which overrides the -fPIC comes from gdb_compile_shlib.

The proc gdb_compile_shlib adds the -fpic or similar dependent on platform
and compiler.  However, in some cases it doesn't add anything, which is
probably why all those test-case pass -fPIC.

Fix this by removing -fPIC from all the calls to gdb_compile_shlib, and
ensuring that gdb_compile_shlib takes care of adding it, if required.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-12-14  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (gdb_compile_shlib): Make sure it's not necessary to
pass -fPIC.
* gdb.ada/catch_ex_std.exp: Don't pass -fPIC to gdb_compile_shlib.
* gdb.base/break-probes.exp: Same.
* gdb.base/ctxobj.exp: Same.
* gdb.base/dso2dso.exp: Same.
* gdb.base/global-var-nested-by-dso.exp: Same.
* gdb.base/info-shared.exp: Same.
* gdb.base/jit-reader-simple.exp: Same.
* gdb.base/print-file-var.exp: Same.
* gdb.base/skip-solib.exp: Same.
* gdb.btrace/dlopen.exp: Same.
12 files changed:
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.ada/catch_ex_std.exp
gdb/testsuite/gdb.base/break-probes.exp
gdb/testsuite/gdb.base/ctxobj.exp
gdb/testsuite/gdb.base/dso2dso.exp
gdb/testsuite/gdb.base/global-var-nested-by-dso.exp
gdb/testsuite/gdb.base/info-shared.exp
gdb/testsuite/gdb.base/jit-reader-simple.exp
gdb/testsuite/gdb.base/print-file-var.exp
gdb/testsuite/gdb.base/skip-solib.exp
gdb/testsuite/gdb.btrace/dlopen.exp
gdb/testsuite/lib/gdb.exp