From patchwork Fri Nov 11 16:36:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 60435 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8358D3886C49 for ; Fri, 11 Nov 2022 16:37:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8358D3886C49 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668184657; bh=6W6G1pIwD1ptpJXrB+TrrHJRsVrqT67twZuRevrbTBk=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=yEK13RVIZMsihkhCTT/NOsRC2iJrHzPCaRxXSkYBdddVj/cDx2A2dRwhVuLEf4ENR 1RWgtD4ifrGRj5ThOjbXAmdVgZ6iuurU05nri695D8+NCj2B4xGXAU+dk24+ZX1HFL fJMWCPcXnldhlRL8R3nMGtnTj8+9uIOHex8yfuvs= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 8CD063858C00 for ; Fri, 11 Nov 2022 16:36:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8CD063858C00 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-338-erEphBI9PQOz2cta4XrUHw-1; Fri, 11 Nov 2022 11:36:40 -0500 X-MC-Unique: erEphBI9PQOz2cta4XrUHw-1 Received: by mail-qt1-f199.google.com with SMTP id s14-20020a05622a1a8e00b00397eacd9c1aso3966949qtc.21 for ; Fri, 11 Nov 2022 08:36:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6W6G1pIwD1ptpJXrB+TrrHJRsVrqT67twZuRevrbTBk=; b=WVfMm0pkClrdtSW94AoFepXCHem1qBYuqCchSSVmo+cpAoUEnb0LPIDcWYdz7GGfA3 sZDnqqaWZ/4GPXLusmWu1yGN6tEa7TXf+Z5NSnHvl4TQwiYHAEpgFYy874zEL4UyD8wF Annwf6bFK949+/yWDqL0/gzB/6Q1zBODfDge+hVfod+p4kRV/C2ZYR4zGzukzK1hiobO atZardeT6Q4IUJMuvdifbkvJkpj21K3OakQQV9qGU7+XKP3KAjF7sbfD0/HOs4ayQlPh LrmNfMGJTuV4+4BAQbhIaEqx7+V5pLPAHFEdl+cVpahrCzCvOT5hATHlruVX3O15qsmm M9Cg== X-Gm-Message-State: ANoB5plqdpwgVkf5gVYkEIu219FJ0QZsgEWJslSulC5Pz569So1OLYGV /Rfk7sivW2XVvURsvpyONloaANVEA26a8GTuwhvr/q+2tKhKycswoUzKrWB/++YTAcjEL7Opuha d9vDd1Uz7kkZXvXfCuuwwMgwGQD145xERQCzsNFDfCK7mpCM9XzKt/aoZ6MlR7I+4zY8L3TpLXw == X-Received: by 2002:a05:622a:2595:b0:3a5:62e4:b972 with SMTP id cj21-20020a05622a259500b003a562e4b972mr2002948qtb.198.1668184600249; Fri, 11 Nov 2022 08:36:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf5bDHSsfdGEyjRN3ewumxOsRtCUDouXOjUevq0Q69+p3YQpb0uLZ8mMf07HR0fsW/91HOr+gg== X-Received: by 2002:a05:622a:2595:b0:3a5:62e4:b972 with SMTP id cj21-20020a05622a259500b003a562e4b972mr2002918qtb.198.1668184599915; Fri, 11 Nov 2022 08:36:39 -0800 (PST) Received: from localhost ([31.111.84.238]) by smtp.gmail.com with ESMTPSA id r17-20020ae9d611000000b006ee7e223bb8sm1687975qkk.39.2022.11.11.08.36.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 08:36:39 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 4/6] gdb/testsuite: add (and use) a new build-id compile option Date: Fri, 11 Nov 2022 16:36:23 +0000 Message-Id: <1d74d73394e4c2b97ea6a0009ace830ac7399db7.1668184173.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" 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. --- 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/testsuite/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}/${srcfile} \ return -1 } -if { [gdb_compile "$sourcetmp" "$binfile" executable {debug}] != "" } { +if { [gdb_compile "$sourcetmp" "$binfile" executable {debug build-id}] != "" } { untested "failed to compile" return -1 } -if { [gdb_compile "$sourcetmp" "${binfile}2" executable {debug}] != "" } { +if { [gdb_compile "$sourcetmp" "${binfile}2" executable {debug build-id}] != "" } { fail "compile" return -1 } diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 3e0a46445ca..b006d0fe855 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4684,6 +4684,7 @@ set gdb_saved_set_unbuffered_mode_obj "" # - macros: Add the required compiler flag to include macro information in # debug information # - 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 # influence the compilation: @@ -4746,6 +4747,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 # explicitly force C++ language. if { !$getting_compiler_info