mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-24 04:00:07 +08:00
gdb/testsuite: add (and use) a new build-id compile option
I noticed that the gdb.debuginfod/fetch_src_and_symbols.exp test was failing when run with Clang as the compiler. This test relies on the compiled binaries having a build-id within them. For GCC, really GNU ld, the default is to always include a build-id. When compiling with Clang though, the default is for no build-id. I did consider *always* turning on the build-id feature when the compiler is Clang, but that felt a little weird. Instead, I propose that we add a new 'build-id' compiler option to gdb_compile, this flag indicates that the test _requires_ a build-id. In gcc_compile we can then add the required flags if the compiler is Clang so that we do get a build-id. With this change the gdb.debuginfod/fetch_src_and_symbols.exp test now (mostly) passes with Clang 9.0.1 and 15.0.2, and still passes with gcc. The 'mostly' part is an unrelated issue, and will be addressed in a later commit in this series. Reviewed-By: Lancelot SIX <lancelot.six@amd.com>
This commit is contained in:
@ -32,12 +32,12 @@ if { [catch {file copy -force ${srcdir}/${subdir}/${srcfile} \
|
|||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
if { [gdb_compile "$sourcetmp" "$binfile" executable {debug}] != "" } {
|
if { [gdb_compile "$sourcetmp" "$binfile" executable {debug build-id}] != "" } {
|
||||||
untested "failed to compile"
|
untested "failed to compile"
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
if { [gdb_compile "$sourcetmp" "${binfile}2" executable {debug}] != "" } {
|
if { [gdb_compile "$sourcetmp" "${binfile}2" executable {debug build-id}] != "" } {
|
||||||
fail "compile"
|
fail "compile"
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
@ -4685,6 +4685,7 @@ set gdb_saved_set_unbuffered_mode_obj ""
|
|||||||
# - macros: Add the required compiler flag to include macro information in
|
# - macros: Add the required compiler flag to include macro information in
|
||||||
# debug information
|
# debug information
|
||||||
# - text_segment=addr: Tell the linker to place the text segment at ADDR.
|
# - text_segment=addr: Tell the linker to place the text segment at ADDR.
|
||||||
|
# - build-id: Ensure the final binary includes a build-id.
|
||||||
#
|
#
|
||||||
# And here are some of the not too obscure options understood by DejaGnu that
|
# And here are some of the not too obscure options understood by DejaGnu that
|
||||||
# influence the compilation:
|
# influence the compilation:
|
||||||
@ -4747,6 +4748,14 @@ proc gdb_compile {source dest type options} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# If the 'build-id' option is used, then ensure that we generate a
|
||||||
|
# build-id. GCC does this by default, but Clang does not, so
|
||||||
|
# enable it now.
|
||||||
|
if {[lsearch -exact $options build-id] > 0
|
||||||
|
&& [test_compiler_info "clang-*"]} {
|
||||||
|
lappend new_options "additional_flags=-Wl,--build-id"
|
||||||
|
}
|
||||||
|
|
||||||
# Treating .c input files as C++ is deprecated in Clang, so
|
# Treating .c input files as C++ is deprecated in Clang, so
|
||||||
# explicitly force C++ language.
|
# explicitly force C++ language.
|
||||||
if { !$getting_compiler_info
|
if { !$getting_compiler_info
|
||||||
|
Reference in New Issue
Block a user