From patchwork Tue Oct 26 12:44:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Purdie X-Patchwork-Id: 46663 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 D456F3857C40 for ; Tue, 26 Oct 2021 12:47:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D456F3857C40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635252478; bh=yluJz1Zit088aYQ51yeNWYMFq0i6yV4PPxw6Fl1+WXE=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=frBZR7M6aLj/hk2Q00zqZLjrYnfFKAfH7d4+lNsWuivv2Zivm335euSzC0vSe3tD8 RIzpmfwsb8exlD5pcKplX595qkf2fz8cgCOUcYGZDPrNFElMrSRVzCHXdOKc2DqAt3 tv0n38ftqwjZtCQJ0IDX9NtrfGuJ07X7l9jzSa2o= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 6535C3858415 for ; Tue, 26 Oct 2021 12:44:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6535C3858415 Received: by mail-wr1-x431.google.com with SMTP id v17so17696482wrv.9 for ; Tue, 26 Oct 2021 05:44:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yluJz1Zit088aYQ51yeNWYMFq0i6yV4PPxw6Fl1+WXE=; b=MjWoU316o7iPtN+ddEkHVQgKEQFFdyrauptvdInfGI1yCaghSwYsvGEioh5X8oHzpx YQGUGln4/ji/6NqJ2k44kzLbivNsXfgfRuLR5YsiQJIxyfxV8RxavC8K5rs3d9syJSS5 ryduoo0aC+KErU4ntwJP0p+CNs6znp9XzI9Zgi6JdvCSpQoDsKXQVs2J2pNoHg7rK39o b1bDZ/EMXwJjvaPbA2TFeYyV0CIT3ixW3c97Lg+TZly8kU9nXZsq3sertSyYDNA8Ap3P IRqmGSqW+rWcU5WrnJBN/rcjdRYmUFffuE5eWXJjv9QSKoa6QuhMq0DblprF9qGnzW4y A8HA== X-Gm-Message-State: AOAM532KvIHAvj4KMY44q8nPHAoD7NMMnVVTwbVv9O9ovt4GPy7K5lOH GwVvsP14mxGjNvxZdZMG3r1auFe3iBPb0A== X-Google-Smtp-Source: ABdhPJxVClGx1xdFUgzlHt+RcbFNFAKCIXmW6PhudKHPOAm+KFO6eLhku8OaufZ/VA9zFloVURVLWQ== X-Received: by 2002:adf:f1d2:: with SMTP id z18mr22543966wro.160.1635252279282; Tue, 26 Oct 2021 05:44:39 -0700 (PDT) Received: from hex.int.rpsys.net ([2001:8b0:aba:5f3c:6b9e:385e:1583:4f40]) by smtp.gmail.com with ESMTPSA id n68sm496146wmn.13.2021.10.26.05.44.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Oct 2021 05:44:38 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH 3/4] gcc: Add --nostdlib++ option Date: Tue, 26 Oct 2021 13:44:36 +0100 Message-Id: <20211026124437.3301773-3-richard.purdie@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211026124437.3301773-1-richard.purdie@linuxfoundation.org> References: <20211026124437.3301773-1-richard.purdie@linuxfoundation.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 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, 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: Richard Purdie via Gcc-patches From: Richard Purdie Reply-To: Richard Purdie Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" OpenEmbedded/Yocto Project builds libgcc and the other gcc runtime libraries separately from the compiler and slightly differently to the standard gcc build. In general this works well but in trying to build them separately we run into an issue since we're using our gcc, not xgcc and there is no way to tell configure to use libgcc but not look for libstdc++. This adds such an option allowing such configurations to work. 2021-10-26 Richard Purdie gcc/c-family/ChangeLog: * c.opt: Add --nostdlib++ option gcc/cp/ChangeLog: * g++spec.c (lang_specific_driver): Add --nostdlib++ option gcc/ChangeLog: * doc/invoke.texi: Document --nostdlib++ option * gcc.c: Add --nostdlib++ option Signed-off-by: Richard Purdie --- gcc/c-family/c.opt | 4 ++++ gcc/cp/g++spec.c | 1 + gcc/doc/invoke.texi | 8 ++++++-- gcc/gcc.c | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 06457ac739e..ee742c831fd 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -2190,6 +2190,10 @@ nostdinc++ C++ ObjC++ Do not search standard system include directories for C++. +nostdlib++ +Driver +Do not link standard C++ runtime library + o C ObjC C++ ObjC++ Joined Separate ; Documented in common.opt diff --git a/gcc/cp/g++spec.c b/gcc/cp/g++spec.c index 3c9bd1490b4..818beb61cee 100644 --- a/gcc/cp/g++spec.c +++ b/gcc/cp/g++spec.c @@ -159,6 +159,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, switch (decoded_options[i].opt_index) { case OPT_nostdlib: + case OPT_nostdlib__: case OPT_nodefaultlibs: library = -1; break; diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 71992b8c597..b30b79ebdc0 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -236,7 +236,7 @@ in the following sections. -ftemplate-backtrace-limit=@var{n} @gol -ftemplate-depth=@var{n} @gol -fno-threadsafe-statics -fuse-cxa-atexit @gol --fno-weak -nostdinc++ @gol +-fno-weak -nostdinc++ -nostdlib++ @gol -fvisibility-inlines-hidden @gol -fvisibility-ms-compat @gol -fext-numeric-literals @gol @@ -633,7 +633,7 @@ Objective-C and Objective-C++ Dialects}. @item Linker Options @xref{Link Options,,Options for Linking}. @gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library} @gol --nostartfiles -nodefaultlibs -nolibc -nostdlib @gol +-nostartfiles -nodefaultlibs -nolibc -nostdlib -nostdlib++ @gol -e @var{entry} --entry=@var{entry} @gol -pie -pthread -r -rdynamic @gol -s -static -static-pie -static-libgcc -static-libstdc++ @gol @@ -16125,6 +16125,10 @@ library subroutines. constructors are called; @pxref{Collect2,,@code{collect2}, gccint, GNU Compiler Collection (GCC) Internals}.) +@item -nostdlib++ +@opindex nostdlib++ +Do not use the standard system C++ runtime libraries when linking. + @item -e @var{entry} @itemx --entry=@var{entry} @opindex e diff --git a/gcc/gcc.c b/gcc/gcc.c index 506c2acc282..abb900a4247 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -1167,6 +1167,7 @@ proper position among the other output files. */ %(mflib) " STACK_SPLIT_SPEC "\ %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} " SANITIZER_SPEC " \ %{!nostdlib:%{!r:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}}\ + %{!nostdlib++:}\ %{!nostdlib:%{!r:%{!nostartfiles:%E}}} %{T*} \n%(post_link) }}}}}}" #endif