From patchwork Tue May 14 10:38:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 90105 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 852243870C25 for ; Tue, 14 May 2024 10:48:40 +0000 (GMT) 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.129.124]) by sourceware.org (Postfix) with ESMTPS id 66EFC3849AD8 for ; Tue, 14 May 2024 10:48:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 66EFC3849AD8 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 66EFC3849AD8 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715683693; cv=none; b=w+YRHGer7vy+LAHGte2dhRTMVjOVc2CzgGZArliL9sNRUHxOdhfZ7RTrCvAxpetL1X35yjXCpjDIOTCtTxlyoAfDmWMLxfp02fcqelYhTPP+wlFXn3Okm0zHNMPhLuV1DlM0ZJtOlAPLEsnM9OdA4zUpPvi1RZr0gzAEXo94g2Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715683693; c=relaxed/simple; bh=HGwNKwveJYEMh4V0yW9MLzyJLaVyx2IpXEwlLmCrarc=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=WZBBupUzsvmH+49hrkGduATWONHSZCXj/AnL07whGwkGKRPG9zwhpCRKmSX25kDCS/5GYD6DVwXq0J0AbFgbSmFI0ozi9wHS/HrLxMvS+MAxniHy5bEEOFosJb79VdZxbggSXbo3/qcOlRCGxvKDIOIbfOsc19fN69t/daoFXZw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715683688; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AqUupOYiedKpAIqb/vCEc868SAovB64OW4Gh+JtHbBM=; b=gy/TQYYiKH0U/qCwBLUo8+4TGwQCJL5j4f4SlQvnr/+8tq2B4i71DfVyFr0R49eo8PBuXB 0HxfLLGnnCcL//yHWnD8qSp+z9H1jSb868VPqIu7SLRnZAZsZhPJEW3Ia9wK9RScwWm49d Y9fjfNCj6lUCnOtQoEYnEJSRD2xFsC0= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-271-E0Lb_kQRO2iinH1G0S9t1Q-1; Tue, 14 May 2024 06:41:55 -0400 X-MC-Unique: E0Lb_kQRO2iinH1G0S9t1Q-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a592c35ac06so533589766b.0 for ; Tue, 14 May 2024 03:41:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715683313; x=1716288113; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AqUupOYiedKpAIqb/vCEc868SAovB64OW4Gh+JtHbBM=; b=GCKzROxHof5s/tIR/wvoeLnYGomeJVNeCiLPlkt2ITLzQtb+rrxq358aTDBvb95i/D EtUm/e0hbN7ZY7dt6ZF8weDkdqfl8ysg+Y06epxKUfiZf1YxTGJMQdS5xADy64p4yPed Da2uJwLXErsbdjoZ1Gl3+WdERSxJXoWrXkh21gtpSVCNkrA2M90q95D5ob9W+daFOIBt BZrKHgmpvWF1MFwcoaftAJxD/yiVS4B/7B3ut4lp4z7xWddObKqxpwuMQD5/ZUVyd5DY z8DErBIulpVDOecWeYvNYry1K/huW2P4UT6FJxFpqkm5LJNwce9slouC8bxCOGepJxll 4mQw== X-Gm-Message-State: AOJu0Yx4jfkRHwRTHYQ49BEr8eYDi2k+mpIq5oyRiuWjzd4D61rAHDKF h4AU2EULp6gHQ4M29DoIIK9tPrKJFqnjD8bmCWn8TdgBC3Lqj2gmFurFuLgVvqI5tQDDTqnaeNe 6q5hK/1zqTnngXVuo3L8u21oTM5+VelWan8wK4LPWfiO1c8dSEj3nwPiRP2bOS4/brIum7lhq+D 75c/G3ceL6Ow6VadREDx8gvnGthsbIuFM3xERqcc+c+3I= X-Received: by 2002:a17:906:c416:b0:a59:cd1e:2012 with SMTP id a640c23a62f3a-a5a11844737mr1183670066b.23.1715683313293; Tue, 14 May 2024 03:41:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH5RXn1UELWbkOSD6C7DkiVUDdQnp21JXdGfjZnEmMWNxEFkRVX/ZhR/5ft8/WS2YlKYrW2mg== X-Received: by 2002:a17:906:c416:b0:a59:cd1e:2012 with SMTP id a640c23a62f3a-a5a11844737mr1183668566b.23.1715683312576; Tue, 14 May 2024 03:41:52 -0700 (PDT) Received: from localhost ([31.111.84.240]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a1781d207sm701867966b.22.2024.05.14.03.41.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 03:41:52 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH] gdb/testsuite: remove unnecessary -Wl, -soname, NAME build flags Date: Tue, 14 May 2024 11:38:58 +0100 Message-Id: <2e371161684b164bee01c82dfd47b5210d60c482.1715683125.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 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_H4, RCVD_IN_MSPIKE_WL, 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.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org While working on another patch I needed to pass -Wl,-soname,NAME as a compiler flag. I initially looked for other tests that did this, and found a few examples, so I copied what they did. But when I checked the gdb.log file I noticed that we were actually getting -Wl,-soname passed twice. I tracked the repeated option to 'proc gdb_compile_shlib_1' in lib/gdb.exp. It turns out that we always add -Wl,-soname when compiling a shared library. Here's an example of a build command from gdb.base/prelink.exp: builtin_spawn -ignore SIGHUP gcc -fno-stack-protector \ /tmp/build/gdb/testsuite/outputs/gdb.base/prelink/prelink-lib.c.o \ -fdiagnostics-color=never -shared -g \ -Wl,-soname,prelink.so -Wl,-soname,prelink.so -lm \ -o /tmp/build/gdb/testsuite/outputs/gdb.base/prelink/prelink.so Notice that '-Wl,-soname,prelink.so' is repeated. I believe that all of the places where tests add '-Wl,-soname,NAME' as a build option, are unnecessary. In this commit I propose we remove them all. As part of this change I've switched from calling gdb_compile_shlib directly, to instead call build_executable and adding the 'shlib' flag. I've tested with gcc and clang and see no changes in the test results after this commit. All the compile commands still have -Wl,-soname added, but now it's only added once, from within lib/gdb.exp. There should be no change in what is tested after this commit. --- gdb/testsuite/gdb.base/break-interp.exp | 5 ++--- gdb/testsuite/gdb.base/prelink.exp | 6 ++---- gdb/testsuite/gdb.base/solib-nodir.exp | 3 ++- gdb/testsuite/gdb.threads/tls-sepdebug.exp | 8 ++------ 4 files changed, 8 insertions(+), 14 deletions(-) base-commit: 83b972fc272db31ab48aa5cde84f47c98868d7c8 diff --git a/gdb/testsuite/gdb.base/break-interp.exp b/gdb/testsuite/gdb.base/break-interp.exp index d7f84db4770..98f67eee227 100644 --- a/gdb/testsuite/gdb.base/break-interp.exp +++ b/gdb/testsuite/gdb.base/break-interp.exp @@ -29,9 +29,8 @@ set binfile_lib ${binprefix}.so set srcfile "${test}-main.c" set srcfile_lib "${test}-lib.c" -# Use -soname so that the new library gets copied by build_executable_own_libs. - -if {[gdb_compile_shlib ${srcdir}/${subdir}/${srcfile_lib} ${binfile_lib} [list debug ldflags=-Wl,-soname,${test}.so]] != ""} { +if {[build_executable "build library" ${binfile_lib} ${srcfile_lib} \ + {debug shlib}] == -1} { return -1 } diff --git a/gdb/testsuite/gdb.base/prelink.exp b/gdb/testsuite/gdb.base/prelink.exp index 50f7367d9d7..6b4790e6003 100644 --- a/gdb/testsuite/gdb.base/prelink.exp +++ b/gdb/testsuite/gdb.base/prelink.exp @@ -29,10 +29,8 @@ set testfile "prelink" set libsrcfile ${testfile}-lib.c set libfile [standard_output_file ${testfile}.so] -# Use -soname so that the new library gets copied by build_executable_own_libs. - -if { [gdb_compile_shlib "${srcdir}/${subdir}/${libsrcfile}" "${libfile}" [list debug "ldflags=-Wl,-soname,[file tail ${libfile}]"]] != ""} { - # If creating the shared library fails, maybe we don't have the right tools +if {[build_executable "build library" ${libfile} ${libsrcfile} \ + {debug shlib}] == -1} { return -1 } diff --git a/gdb/testsuite/gdb.base/solib-nodir.exp b/gdb/testsuite/gdb.base/solib-nodir.exp index 625f06f3a9d..fe3439613df 100644 --- a/gdb/testsuite/gdb.base/solib-nodir.exp +++ b/gdb/testsuite/gdb.base/solib-nodir.exp @@ -36,7 +36,8 @@ set objfile [standard_output_file ${executable}.o] set binfile [standard_output_file ${executable}] # build the first test case -if { [gdb_compile_shlib "${srcdir}/${subdir}/${srclibfile}" "${binlibfile}" [list debug ldflags=-Wl,-soname,${binlibfilebase}]] != "" +if { [build_executable "build library" ${binlibfile} ${srclibfile} \ + {debug shlib}] == -1 || [gdb_gnu_strip_debug $binlibfile] || [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}] != "" || [gdb_compile "${objfile} ${binlibfile}" "${binfile}" executable {}] != "" } { diff --git a/gdb/testsuite/gdb.threads/tls-sepdebug.exp b/gdb/testsuite/gdb.threads/tls-sepdebug.exp index 182a3f289d3..14a0c45c7d9 100644 --- a/gdb/testsuite/gdb.threads/tls-sepdebug.exp +++ b/gdb/testsuite/gdb.threads/tls-sepdebug.exp @@ -43,12 +43,8 @@ set binsharedfile [standard_output_file ${binsharedbase}] # The compile flag -std=c11 is required because the test case uses # 'thread_local' to indicate thread local storage. This is available # as a macro starting in C11 and became a C-language keyword in C23. -if { [gdb_compile_shlib \ - "${srcdir}/${subdir}/${srcsharedfile}" "${binsharedfile}" \ - [list debug \ - ldflags=-Wl,-soname=${binsharedbase} \ - additional_flags=-std=c11]] \ - != "" } { +if { [build_executable "build library" ${binsharedfile} ${srcsharedfile} \ + {debug shlib additional_flags=-std=c11}] == -1 } { untested "Couldn't compile test library" return -1 }