From patchwork Sun Jan 28 15:02:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 193139 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp84733dyb; Sun, 28 Jan 2024 07:03:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IGTtF4RP7j7eqnSfXofA+04ow8D9+S54D9c/mtFvTPuEwdwDMM6Wt5l+VoNDtVUr9gUOlWO X-Received: by 2002:ac8:5893:0:b0:42a:96ef:6deb with SMTP id t19-20020ac85893000000b0042a96ef6debmr3260039qta.61.1706454227049; Sun, 28 Jan 2024 07:03:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706454227; cv=pass; d=google.com; s=arc-20160816; b=L/JHt9ahkAlFxiF5qJx5ALfuopEjyLN5f1l/McgWySCM99RHfWx7cmk7AEGijX4EDi lrXt27+ihIRH6ggggT8R9DYt5T3LtQmUIkmFrwjB3SHCDn8PQkDK5bDfyKVdDW93i9fO D34Vgq5uPVdu6q8A+WoCVG3KO2GaUBm3wL+iv4ufbliN1jea/VkZ2DXYQ2TbITME0dlF feeMhdTfwQxWixd3AZ7LlR8uo3yUSccM7fTGmki/acnQjVFGu2lQAH0nIoZurlYfZy/M 5Bi/grvW/yVKc//D3ExGAI+ST23fh2Q8O6PQJhqLGIIlw3yfyABZgOh2dlHeOFIYQOwz Qclg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=fIe4SMy0Mbx2sZKMtc4s7XoDBv7PK2o06wveqL79uTQ=; fh=HpGyPhETBvl4zejgufl7c2nTNpZufIxjdWMis6jurMQ=; b=NS/a2N3Rjr3bTRP20udn6PYNuOGqtToxjnaYz9uR+9d+m6n27dKsZnw/u39aBVXw8L R3q/A35x+qddTXxYVDE61RSBBtvkPhQRNA41mXpkVRcTEjRwx8bmqBZt0WToX+rzZLqs fP2WXR7h5vm+lVfCoBbF6UXzgog0ePwXDlLOYTaayUuF8wZM6TvQysRknVLtyXmFfdsc PtuNe1DG3MFc/OgH3tM17KGMN3HJ4Y4ELq/v9biw339i67gfhZBIDLTAbPn87gDCSdhZ 4jUQRa0KPlKLu/wO+/rx5a62D9VQAxOJ8dCoW6CkmGNH7Quapfw8FSEFvsoAoxyxcX2I 10dA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Jnoxmold; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id w3-20020a05622a190300b0042a69a8784asi5474308qtc.278.2024.01.28.07.03.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 07:03:47 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Jnoxmold; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B9C033858289 for ; Sun, 28 Jan 2024 15:03:46 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by sourceware.org (Postfix) with ESMTPS id 3924C3858D20 for ; Sun, 28 Jan 2024 15:02:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3924C3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3924C3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::333 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706454178; cv=none; b=fXNU14iErzBsVTam73VFJM2iqBbCmdkm6nUWzxeO1Or96M3BIacxL9RUCQQLr3e8awDM1W5/s5esFaDQp7QJhooR6aXd1zG5qfmLjUOjsh1ziYtM34mTZKFUbEEKmNkYhTd0EVrz5m1tQ3Yf8u6GzVzf+GvFuE2q8M1l/LDHJLo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706454178; c=relaxed/simple; bh=X5tejVsE+eNrwYEZpZWsv7nct/I72WVAkXsD/92kows=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=O6/++SJ2OBaG9eZX45Zy/fHdsIuzVJLyn/X6q3COHBStIiLa3YfXJi2xljlBj8zSQrKtqXQpAQ8sYXunG7Y1n+cbOjOsJf0eXpXN1jEfnmvWtmKyLtP9EDhfwsgEwpbIK/Pp7L9MqOMyBXOlqUrs86vZH8Ghf3czbNsYEJsqhSg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-40e86a9fc4bso29462305e9.2 for ; Sun, 28 Jan 2024 07:02:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706454174; x=1707058974; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=fIe4SMy0Mbx2sZKMtc4s7XoDBv7PK2o06wveqL79uTQ=; b=JnoxmoldfBv8u0pK8+Xj0qYbKFgXqzr01B88yxj3JXCIxooQJBfQn+OmV5URck7l7y QVH2Ckvc1aOCwgrrGScT2y4JQsPHlXWG4xhiGiSsFraSERFxzcnkxIbF+9k8KtRwobMc 6s/rSUT3LriYFlKnN0ElC7rrm1g2mbxMpl9HoSMdIhDlzHWQUySTHf1+QDFJ6IARfZd8 Xdlak7pMorocnFUPxOCsS9Zp8dqYplXnzmnuPJ8KpomDR/F56HUCBc3Rqk/st/DLLRk2 rckpIZG5sB1o8cG+jA14Af3THnCXFA3IVXGmlXbr5SvNc5zYUSXh8VaW23a+Q7RYh11d eQxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706454174; x=1707058974; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=fIe4SMy0Mbx2sZKMtc4s7XoDBv7PK2o06wveqL79uTQ=; b=tHH4zSWLmXVYBHkHSbdJB46MG5fo7pLcVOPah7r/83ymbopgVAK7JqDarWFirx5nBD DMMgmeGyo3VtMIsm56RZ2aiT+3h+5fqoI2yZGPLtOe6lcfBvXnAj5bCUNMRucY6hX24U 8BZPqmwJVT0mhfIvmAvrOfpjYkkDp6ZhwDhCj+qQv0NNG3hQl7xXr5Jnj34Z+QskML9g 56iMCyzu/dXLMHFZIfaOFeeJFay0YDOcSYHKc1dhOTmxxGO/kjrzSQymD3z+RzJsf23l +K4bCg61CIiqxqAu+wixW01EarFkWyV063HvivgzMDQTCtAaIXa1rsZt1tT+dKv1wTaY ibDQ== X-Gm-Message-State: AOJu0YwCaUVAnbQuvPRsZ7bS+xWFvr289etCpuZE/FuKDJuJeht2TT0Q 2163Ktok7CPkCusJBoTqXK+3Uh371trRigZ6j3SqlaUp3RMxtwaFZU9L+2Hc X-Received: by 2002:a05:600c:1d1f:b0:40e:f52a:956d with SMTP id l31-20020a05600c1d1f00b0040ef52a956dmr1299586wms.0.1706454174276; Sun, 28 Jan 2024 07:02:54 -0800 (PST) Received: from localhost.localdomain (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.gmail.com with ESMTPSA id n6-20020a05600c500600b0040e3488f16dsm7440849wmr.12.2024.01.28.07.02.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 28 Jan 2024 07:02:53 -0800 (PST) From: Iain Sandoe X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Cc: ro@CeBiTec.Uni-Bielefeld.DE Subject: [PATCH] testsuite, GDC: Update link flags [PR112861]. Date: Sun, 28 Jan 2024 15:02:53 +0000 Message-Id: <20240128150253.21078-1-iain@sandoe.co.uk> X-Mailer: git-send-email 2.39.2 (Apple Git-143) MIME-Version: 1.0 X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: iain@sandoe.co.uk Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789346947796358668 X-GMAIL-MSGID: 1789346947796358668 Tested on i686, x86_64, aarch64 Darwin, x86_64, aarch64 Linux, OK for trunk? thanks, Iain --- 8< --- The regressions here are because we do not generate a runpath for the uninstalled libstdc++. This patch updates the link flags handling to simplify it. We need to add options to locate both libgphobos and libstdc++ Usually '-L' options are added to point to the relevant directories for the uninstalled libraries. In cases where libraries are available as both shared and convenience some additional checks are made. For some targets -static-xxxx options are handled by specs substitution and need a '-B' option rather than '-L'. For Darwin, when embedded runpaths are in use (the default for all versions after macOS 10.11), '-B' is also needed to provide the runpath. When '-B' is used, this results in a '-L' for each path that exists (so that appending a '-L' as well is a needless duplicate). There are also cases where tools warn for duplicates, leading to spurious fails. Therefore the objective is to add a single -B/-L option for each needed path. PR target/112861 gcc/testsuite/ChangeLog: * lib/gdc.exp: Decide on whether to present -B or -L to reference the paths to uninstalled libphobos and libstdc++ and use that to generate the link flags. --- gcc/testsuite/lib/gdc.exp | 40 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/lib/gdc.exp b/gcc/testsuite/lib/gdc.exp index 3045aa82918..3c284229609 100644 --- a/gcc/testsuite/lib/gdc.exp +++ b/gcc/testsuite/lib/gdc.exp @@ -133,6 +133,28 @@ proc gdc_link_flags { paths } { set include_cxx_flags 0 } + # We need to add options to locate libgphobos and libstdc++ + # Usually '-L' options are added to point to the relevant directories for + # the uninstalled libraries. + + # In cases where libraries are available as both shared and convenience + # some additional checks are made. + + # For some targets -static-xxxx options are handled by specs substitution + # and need a '-B' option rather than '-L'. For Darwin, when embedded + # runpaths are in use (the default for all versions after macOS 10.11), + # '-B' is also needed to provide the runpath. + # When '-B' is used, this results in a '-L' for each path that exists (so + # that appending a '-L' as well is a needless duplicate). There are also + # cases where tools warn for duplicates, leading to spurious fails. + # Therefore the objective of the code below is to add just one '-L' or + # '-B' for each of the libraries. + + set target_wants_B_option 0 + if { [istarget *-*-darwin9* ] || [istarget *-*-darwin\[12\]* ] } { + set target_wants_B_option 1 + } + if { $gccpath != "" } { # Path to libgphobos.spec. append flags "-B${gccpath}/libphobos/src " @@ -143,7 +165,11 @@ proc gdc_link_flags { paths } { if { [file exists "${gccpath}/libphobos/src/.libs/libgphobos.a"] \ || [file exists "${gccpath}/libphobos/src/.libs/libgphobos.${shlib_ext}"] } { - append flags "-L${gccpath}/libphobos/src/.libs " + if { $target_wants_B_option } { + append flags "-B${gccpath}/libphobos/src/.libs " + } else { + append flags "-L${gccpath}/libphobos/src/.libs " + } append ld_library_path ":${gccpath}/libphobos/src/.libs" } # Static linking is default. If only the shared lib is available adjust @@ -163,7 +189,11 @@ proc gdc_link_flags { paths } { if $include_cxx_flags { if { [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] \ || [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] } { - append flags "-L${gccpath}/libstdc++-v3/src/.libs " + if { $target_wants_B_option } { + append flags "-B${gccpath}/libstdc++-v3/src/.libs " + } else { + append flags "-L${gccpath}/libstdc++-v3/src/.libs " + } append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs" } } @@ -173,7 +203,11 @@ proc gdc_link_flags { paths } { set libphobos [lookfor_file ${tool_root_dir} libgphobos] if { $libphobos != "" } { - append flags "-B${libphobos} -L${libphobos} " + if { $target_wants_B_option } { + append flags "-B${libphobos} " + } else { + append flags " -L${libphobos} " + } append ld_library_path ":${libphobos}" } set libiberty [lookfor_file ${tool_root_dir} libiberty]