GNU Binutils with patches for OS216
修訂 | 6181e9c2c5ba252ac016f51903dc35d7bfbbca71 (tree) |
---|---|
時間 | 2018-01-12 11:08:23 |
作者 | Simon Marchi <simon.marchi@eric...> |
Commiter | Simon Marchi |
gdb_compile_shlib: Only consider shlib= options when building executables
Trying to use gdb_compile_shlib with the shlib= option to build a shared
library that depends on another shared library does not work as of
today. See:
The problem is that building the lib is done in two steps, compilation
(.c -> .o) and linking (.o -> .so) and the shlib= options are passed to
both steps. When compiling the object file (.o), it results in gcc
complaining:
The first solution I came up with was to filter the options inside
gdb_compile_shlib to remove the shlib= options from the options we pass
when compiling the .o file.
I then thought it would be simpler to ignore the shlib= options in
gdb_compile when not building an executable (the executable category
includes the shared libraries). For other compilation types (object
file, preprocess and generate assembly), it doesn't make sense to add
shared libraries to the source file list.
Regtested on the buildbot.
gdb/testsuite/ChangeLog:
* lib/gdb.exp (gdb_compile): Ignore shlib= and shlib_load
options when not creating an executable.
@@ -1,3 +1,8 @@ | ||
1 | +2018-01-11 Simon Marchi <simon.marchi@ericsson.com> | |
2 | + | |
3 | + * lib/gdb.exp (gdb_compile): Ignore shlib= and shlib_load | |
4 | + options when not creating an executable. | |
5 | + | |
1 | 6 | 2018-01-11 Pedro Alves <palves@redhat.com> |
2 | 7 | |
3 | 8 | PR remote/22597 |
@@ -3513,7 +3513,8 @@ proc gdb_compile {source dest type options} { | ||
3513 | 3513 | set shlib_found 0 |
3514 | 3514 | set shlib_load 0 |
3515 | 3515 | foreach opt $options { |
3516 | - if [regexp {^shlib=(.*)} $opt dummy_var shlib_name] { | |
3516 | + if {[regexp {^shlib=(.*)} $opt dummy_var shlib_name] | |
3517 | + && $type == "executable"} { | |
3517 | 3518 | if [test_compiler_info "xlc-*"] { |
3518 | 3519 | # IBM xlc compiler doesn't accept shared library named other |
3519 | 3520 | # than .so: use "-Wl," to bypass this |
@@ -3539,7 +3540,7 @@ proc gdb_compile {source dest type options} { | ||
3539 | 3540 | lappend new_options "early_flags=-Wl,--no-as-needed" |
3540 | 3541 | } |
3541 | 3542 | } |
3542 | - } elseif { $opt == "shlib_load" } { | |
3543 | + } elseif { $opt == "shlib_load" && $type == "executable" } { | |
3543 | 3544 | set shlib_load 1 |
3544 | 3545 | } else { |
3545 | 3546 | lappend new_options $opt |