+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.
+
 2020-12-14  Tom de Vries  <tdevries@suse.de>
 
        PR testsuite/26963
 
 set outdir [file dirname $binfile]
 
 # Create the shared library.
-if {[gdb_compile_shlib $srcfile2 $sofile \
-        {ada debug additional_flags=-fPIC}] != ""} {
+if {[gdb_compile_shlib $srcfile2 $sofile {ada debug}] != ""} {
     return -1
 }
 
 
 }
 set probes_bp "dl_main"
 
-if { [gdb_compile_shlib $srcfile_lib $binfile_lib \
-         [list additional_flags=-fPIC]] != "" } {
+if { [gdb_compile_shlib $srcfile_lib $binfile_lib {}] != "" } {
     untested "failed to compile shared library"
     return -1
 }
 
 set libobj1 [standard_output_file libctxobj1.so]
 set libobj2 [standard_output_file libctxobj2.so]
 
-set libobj1_opts { debug additional_flags=-fPIC
+set libobj1_opts { debug
                    additional_flags=-DVERSION=104
                    additional_flags=-DGET_VERSION=get_version_1 }
-set libobj2_opts { debug additional_flags=-fPIC
+set libobj2_opts { debug
                    additional_flags=-DVERSION=203
                    additional_flags=-DGET_VERSION=get_version_2 }
 
 
 set binfile_libdso1 [standard_output_file $libdso1.so]
 
 if { [gdb_compile_shlib $srcfile_libdso2 $binfile_libdso2 \
-       [list debug additional_flags=-fPIC]] != "" } {
+       [list debug]] != "" } {
   untested "failed to compile shared library 2"
   return -1
 }
 
 if { [gdb_compile_shlib $srcfile_libdso1 $binfile_libdso1 \
-       [list debug additional_flags=-fPIC]] != "" } {
+       [list debug]] != "" } {
   untested "failed to compile shared library 1"
   return -1
 }
 
 set binfile_lib2 [standard_output_file $lib2name.so]
 
 if { [gdb_compile_shlib $srcfile_lib1 $binfile_lib1 \
-       [list debug additional_flags=-fPIC]] != "" } {
+       [list debug]] != "" } {
   untested "failed to compile shared library 1"
   return -1
 }
 
 if { [gdb_compile_shlib $srcfile_lib2 $binfile_lib2 \
-       [list debug additional_flags=-fPIC]] != "" } {
+       [list debug]] != "" } {
   untested "failed to compile shared library 2"
   return -1
 }
 
 set binfile_lib2 [standard_output_file $lib2name.so]
 set define2 -DSHLIB2_NAME=\"$binfile_lib2\"
 
-if { [gdb_compile_shlib $srcfile_lib1 $binfile_lib1 \
-         [list additional_flags=-fPIC]] != "" } {
+if { [gdb_compile_shlib $srcfile_lib1 $binfile_lib1 {}] != "" } {
     untested "failed to compile shared library 1"
     return -1
 }
 
-if { [gdb_compile_shlib $srcfile_lib2 $binfile_lib2 \
-         [list additional_flags=-fPIC]] != "" } {
+if { [gdb_compile_shlib $srcfile_lib2 $binfile_lib2 {}] != "" } {
     untested "failed to compile shared library 2"
     return -1
 }
 
     global testfile
     global srcfile_lib binfile_lib binfile_lib2
 
-    lappend options "debug additional_flags=-fPIC"
+    lappend options "debug"
     if { [gdb_compile_shlib $srcfile_lib $binfile_lib $options] != "" } {
        return -1
     }
 
     set libobj1 [standard_output_file ${lib1}$suffix.so]
     set libobj2 [standard_output_file ${lib2}$suffix.so]
 
-    set lib_opts { debug additional_flags=-fPIC $lang }
+    set lib_opts { debug $lang }
     lappend lib_opts "additional_flags=-DHIDDEN=$hidden"
 
     if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib1}.c \
 
 # the main program.
 #
 
-if {[gdb_compile_shlib ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} [list debug additional_flags=-fPIC -Wl,-soname,${libname}.so]] != ""} {
+if {[gdb_compile_shlib ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} [list debug -Wl,-soname,${libname}.so]] != ""} {
     return -1
 }
 
 
 set srcfile_lib $srcdir/$subdir/$basename_lib.c
 set binfile_lib [standard_output_file $basename_lib.so]
 
-if { [gdb_compile_shlib $srcfile_lib $binfile_lib \
-         [list additional_flags=-fPIC]] != "" } {
+if { [gdb_compile_shlib $srcfile_lib $binfile_lib {}] != "" } {
     untested "failed to prepare shlib"
     return -1
 }
 
             lappend obj_options "additional_flags=-qpic"
         }
        "clang-*" {
-           if { !([istarget "*-*-cygwin*"]
-                  || [istarget "*-*-mingw*"]) } {
+           if { [istarget "*-*-cygwin*"]
+                || [istarget "*-*-mingw*"] } {
+               lappend obj_options "additional_flags=-fPIC"
+           } else {
                lappend obj_options "additional_flags=-fpic"
            }
        }
         "gcc-*" {
-            if { !([istarget "powerpc*-*-aix*"]
+            if { [istarget "powerpc*-*-aix*"]
                    || [istarget "rs6000*-*-aix*"]
                    || [istarget "*-*-cygwin*"]
                    || [istarget "*-*-mingw*"]
-                   || [istarget "*-*-pe*"]) } {
+                   || [istarget "*-*-pe*"] } {
+                lappend obj_options "additional_flags=-fPIC"
+           } else {
                 lappend obj_options "additional_flags=-fpic"
             }
         }
         }
         default {
            # don't know what the compiler is...
+           lappend obj_options "additional_flags=-fPIC"
         }
     }