From patchwork Wed Nov 17 21:03:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 47851 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 6B50D385800C for ; Wed, 17 Nov 2021 21:03:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6B50D385800C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1637183036; bh=5nnkABHZJrYH7T/9UghblzzDjrXnp1kZqu/2IyIeFwk=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=COoU1MdehFu6zb10z+lnJyfNMUyizAHVFRYgTwlp5xnxvxPIwLPRaP77LHrKhsWfJ 62tkroO2jWuxoDq/UCk4Wim+TY6ApG6k9Fr67bmGXOw6WfRkri2OPwGr5/6pcav7Z/ +lf/FVRTYXtwTWCiccyLzekaNJd9ovNWBkDwPwDw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id 71D883858409 for ; Wed, 17 Nov 2021 21:03:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 71D883858409 Received: by mail-wm1-x334.google.com with SMTP id 137so467106wma.1 for ; Wed, 17 Nov 2021 13:03:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=5nnkABHZJrYH7T/9UghblzzDjrXnp1kZqu/2IyIeFwk=; b=ZOm8px98525L/w93zg1cRdzM1fvX5UrxH2DwfCr9x5UBhxxcq2MoI8DYPpPUq30tqZ GPuCOx05QRArc+Ju6N/3NhhERW23q0BFxyCsWOvm5kg0zGpbpNwJ+EkAdWGO1IhNNMZj C2P9kUZJ/5iij/1ih8rJ7rhs/imR4mf6+ieNxTOBpZuD0k2VzZrYbfB8l77glpHYcDjb 1vZeaGeRmMLYmlZkTaZHbLksnPx49lbLuHWDXDE+iawUEPzSiCTBAnEPsnYB+wwKHQHe gWMEP3vS1gok1atPIaUqISaTodc1mcUWGlTJd26YPG4b1/M6D28U4pwiguloDUJ2CSD3 pOFA== X-Gm-Message-State: AOAM533W2Dojhk1gCnWAIdDqFjkCBUGBSWG1naql/OB0mXzDT4cJz5dL /Qr0SJduRBAGSatXacRsjwPO9buJXp0= X-Google-Smtp-Source: ABdhPJwagY3b6lQqG+IHP4Bru/SD7kEjtkF8qgCI3HCJkcPrhAL+NteN9eXDyTPmN6lJtt/1PVwwKA== X-Received: by 2002:a7b:c7cb:: with SMTP id z11mr3292795wmk.152.1637183006279; Wed, 17 Nov 2021 13:03:26 -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 m17sm945118wrz.22.2021.11.17.13.03.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Nov 2021 13:03:26 -0800 (PST) X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/4] Driver : Provide a spec to insert rpaths for compiler lib dirs. Date: Wed, 17 Nov 2021 21:03:16 +0000 Message-Id: <20211117210319.92514-2-iain@sandoe.co.uk> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20211117210319.92514-1-iain@sandoe.co.uk> References: <20211117210319.92514-1-iain@sandoe.co.uk> 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 autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Sandoe via Gcc-patches From: Iain Sandoe Reply-To: iain@sandoe.co.uk Cc: Iain Sandoe , joseph@codesourcery.com Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This provides a spec to insert "-rpath DDD" for each DDD corresponding to a compiler startfile directory. This allows a target to use @rpath as the install path for libraries, and have the compiler provide the necessary rpath to handle this. gcc/ChangeLog: * gcc.c (RUNPATH_OPTION): New. (do_spec_1): Provide '%P' as a spec to insert rpaths for each compiler startfile path. --- gcc/gcc.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/gcc/gcc.c b/gcc/gcc.c index 506c2acc282..7b52d0bcbfd 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -572,6 +572,7 @@ or with constant text in a single argument. %l process LINK_SPEC as a spec. %L process LIB_SPEC as a spec. %M Output multilib_os_dir. + %P Output a RUNPATH_OPTION for each directory in startfile_prefixes. %G process LIBGCC_SPEC as a spec. %R Output the concatenation of target_system_root and target_sysroot_suffix. @@ -1191,6 +1192,10 @@ proper position among the other output files. */ # define SYSROOT_HEADERS_SUFFIX_SPEC "" #endif +#ifndef RUNPATH_OPTION +# define RUNPATH_OPTION "-rpath" +#endif + static const char *asm_debug = ASM_DEBUG_SPEC; static const char *asm_debug_option = ASM_DEBUG_OPTION_SPEC; static const char *cpp_spec = CPP_SPEC; @@ -6130,6 +6135,19 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) } break; + case 'P': + { + struct spec_path_info info; + + info.option = RUNPATH_OPTION; + info.append_len = 0; + info.omit_relative = false; + info.separate_options = true; + + for_each_path (&startfile_prefixes, true, 0, spec_path, &info); + } + break; + case 'e': /* %efoo means report an error with `foo' as error message and don't execute any more commands for this file. */