From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id 80EBD384F49B; Fri, 18 Nov 2022 11:46:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 80EBD384F49B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668771997; bh=d9DCEUdKz9ltz2CT5siWValfKYRVJXYuqt9w4LbvOkU=; h=From:To:Subject:Date:From; b=UEUyCP12i2NXl2FFsmfP57+Qf5wtJ4w4oPLt4bYWc3LyGXVIMNz/oWFfs2OonXzMc I59KjyJ4S1/S7FCzWeRpooYGtJdmLnMzzWmUzcUlTGSJhe9Gfw0BkGUnh/Br7P5a59 QkWBV4DZA5LKwND8blsC6fmRR+ycNtNbROraauhM= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite: add (and use) a new build-id compile option X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: ed64647b7f32b067e910ae7b24b477e11b268d5d X-Git-Newrev: f2509beef8d8c81f7bd6f61a1baab089a470626e Message-Id: <20221118114637.80EBD384F49B@sourceware.org> Date: Fri, 18 Nov 2022 11:46:37 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Df2509beef8d8= c81f7bd6f61a1baab089a470626e commit f2509beef8d8c81f7bd6f61a1baab089a470626e Author: Andrew Burgess Date: Fri Nov 11 15:51:34 2022 +0000 gdb/testsuite: add (and use) a new build-id compile option =20 I noticed that the gdb.debuginfod/fetch_src_and_symbols.exp test was failing when run with Clang as the compiler. =20 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. =20 When compiling with Clang though, the default is for no build-id. =20 I did consider *always* turning on the build-id feature when the compiler is Clang, but that felt a little weird. =20 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. =20 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. =20 Reviewed-By: Lancelot SIX Diff: --- gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp | 4 ++-- gdb/testsuite/lib/gdb.exp | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp b/gdb/t= estsuite/gdb.debuginfod/fetch_src_and_symbols.exp index 9bffb3397ec..b57b3201cf7 100644 --- a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp +++ b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp @@ -32,12 +32,12 @@ if { [catch {file copy -force ${srcdir}/${subdir}/${src= file} \ return -1 } =20 -if { [gdb_compile "$sourcetmp" "$binfile" executable {debug}] !=3D "" } { +if { [gdb_compile "$sourcetmp" "$binfile" executable {debug build-id}] != =3D "" } { untested "failed to compile" return -1 } =20 -if { [gdb_compile "$sourcetmp" "${binfile}2" executable {debug}] !=3D "" }= { +if { [gdb_compile "$sourcetmp" "${binfile}2" executable {debug build-id}] = !=3D "" } { fail "compile" return -1 } diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 042d7ade59f..a05b14b4b1c 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4685,6 +4685,7 @@ set gdb_saved_set_unbuffered_mode_obj "" # - macros: Add the required compiler flag to include macro information = in # debug information # - text_segment=3Daddr: Tell the linker to place the text segment at AD= DR. +# - build-id: Ensure the final binary includes a build-id. # # And here are some of the not too obscure options understood by DejaGnu t= hat # influence the compilation: @@ -4747,6 +4748,14 @@ proc gdb_compile {source dest type options} { } } =20 + # 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=3D-Wl,--build-id" + } + # Treating .c input files as C++ is deprecated in Clang, so # explicitly force C++ language. if { !$getting_compiler_info