From patchwork Mon Jan 2 10:38:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 38068 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4102668wrt; Mon, 2 Jan 2023 02:38:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXv1afQCXYzPzDy2Wsf5Ptx86g8du6fyLi3XPIH6QE1bo07kRIlydVP/ar+qkMLy1jd6RvzY X-Received: by 2002:a05:6402:501f:b0:461:5e1b:85b5 with SMTP id p31-20020a056402501f00b004615e1b85b5mr44483925eda.2.1672655932567; Mon, 02 Jan 2023 02:38:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672655932; cv=none; d=google.com; s=arc-20160816; b=eGlhUz8sp28qsE1N2pJLK+1mtuWW6wN0C13h3HMPhgZET35IM33M7Zc+YmkFeIYDMa JBopbFM/kYTyWBeo0asco8ieEjGR8uLACyWbaCeT+RITioxkXwBWmlqCnP6TvDgVoA1h 2mibYHuc7h8KMgawZCrBMdMhJJj255A0YrJcdrZv7MLkfO8W4zR7iCFMgWwgePKElxOF Y1FbkW+soAxtei5404vCC/IJNLrwCr4tqJNRlQAV0YPSm6BuijkD9FnH9+IkZJkj9vtk lEBrx5OMMIpwq/ml+kE8O8YCAGHoDc1oK6l+OGDNlxBH3skKYOLbQYN2e7X8gBoQPEu3 n1nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :delivered-to:dkim-signature:dkim-filter; bh=qK0sWb6QjKA8vf30upRRn7KsSChiUdRUdqEap27gw5s=; b=KMS6A6HE96Me5JkE0cNLrmQmzj+2IBvsF3LPY7xg2rl1TmzH+7jT7c5xE0+THbwKGk KuEyxoYukQJhX6+oFRlQyQspesE3EYuJzZr5Je22I0mHwrRVrs9ZzV5P9EJrWjEGYYLi rLzvR7idl2oPWNKPF+LpJQP5D1yDF9Uvle9mmOTKkRG8ESFPOFXGF1wuW0m5geuV1mXy sTC2Z0s76GnJtm5Kqn7SshkRGeDM++cwY5b9F3ecQHmAGBEh/9dUvBSY7z4jo1E+8uT9 Lzpy64jDkZ7RNVePjXuKl1NSM+H8ha/fVCLYDb01VfQP2vofmxbjvTHKIjatGqg4QcD2 8nZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=HZMeICGa; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id b23-20020a056402139700b0046cc0300c0fsi22369750edv.581.2023.01.02.02.38.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Jan 2023 02:38:52 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=HZMeICGa; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9C2283858421 for ; Mon, 2 Jan 2023 10:38:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9C2283858421 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672655931; bh=qK0sWb6QjKA8vf30upRRn7KsSChiUdRUdqEap27gw5s=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=HZMeICGaOJUfc87LKa4/P2cTLhjIr8cxp6lq3zf9Ojk1+QvxXnz5rYKl7Shsouiuq jIbWBbLkRcc+bj/7nf77+j/RPcby6SHz1neNxvSHDNj6Cjp+uKB+HEzTLV4k0cFcyd kbkyGa3sJ9R0ASG2tkXqgXKByGOxz+XmmIX0BKYE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id F41EA3858D38 for ; Mon, 2 Jan 2023 10:38:08 +0000 (GMT) Received: by mail-wm1-x32f.google.com with SMTP id k26-20020a05600c1c9a00b003d972646a7dso17302633wms.5 for ; Mon, 02 Jan 2023 02:38:08 -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:reply-to:message-id:date :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qK0sWb6QjKA8vf30upRRn7KsSChiUdRUdqEap27gw5s=; b=NbvhdUmucH2JD/dJIm9gCk85fqKFNyb45dheF4c42es4rCNFIp9ZClNs8+eZXurF+K sUiSWDzwDLmfb1kC9/PO09756Dmo8SSCwb+aBSL6o/A8jIUABiPsYsUWqqMbAoHU2iYa mQE5EhufSQZWw/MVMUTeu78xbXAKXg9apiPrAwUtRK9nyPRtE3CUBfT4Kb6oLuAd9MsG m7oTQGjDFdY8KnCtDSbWFRV3xnNULbam7UEo7sNVUUKgXIZzaRH9teDTa722LGwI9mr5 h3bnS1kKL+wi/vk6gLJ8hjtuaeYjYwuS/AGoDTI7X2L0MkrnIs8CrV44LhCXGCdDnAS/ Z/Lw== X-Gm-Message-State: AFqh2krvGkN8MLbMRF4j6pGQPEa7BH9uL2rPmE+OMiTyw0QffTD3KLdG LT0gn3hxysO8Izepp/5tW9Pyp29hyEA= X-Received: by 2002:a05:600c:3493:b0:3d2:370b:97f4 with SMTP id a19-20020a05600c349300b003d2370b97f4mr32342154wmq.16.1672655887634; Mon, 02 Jan 2023 02:38:07 -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 u9-20020a05600c19c900b003d9876aa04asm32110435wmq.41.2023.01.02.02.38.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 02 Jan 2023 02:38:06 -0800 (PST) X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Subject: [PATCH] modula-2, driver: Implement handling for -static-libgm2. Date: Mon, 2 Jan 2023 10:38:05 +0000 Message-Id: <20230102103805.4328-1-iain@sandoe.co.uk> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) MIME-Version: 1.0 X-Spam-Status: No, score=-8.3 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.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.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 , gaiusmod2@gmail.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753906867427589822?= X-GMAIL-MSGID: =?utf-8?q?1753906867427589822?= tested on x86_64-linux-gnu, x86_64,aarch64-darwin21, OK for trunk? thanks, Iain --- 8< --- This was unimplemented so far. gcc/ChangeLog: * common.opt: Add -static-libgm2. * config/darwin.h (LINK_SPEC): Handle static-libgm2. gcc/m2/ChangeLog: * gm2spec.cc (lang_specific_driver): Handle static-libgm2. --- gcc/common.opt | 4 ++++ gcc/config/darwin.h | 7 ++++++- gcc/m2/gm2spec.cc | 24 +++++++++++++++++++++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/gcc/common.opt b/gcc/common.opt index b01f7a7a4a2..0f3910cf5f6 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -3630,6 +3630,10 @@ static-libgfortran Driver ; Documented for Fortran, but always accepted by driver. +static-libgm2 +Driver +; Documented for Modula-2, but always accepted by driver. + static-libphobos Driver ; Documented for D, but always accepted by driver. diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index 0ec882ffb54..a3edd7c922b 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -476,7 +476,12 @@ extern GTY(()) int darwin_ms_struct; %{static|static-libgcc|static-libphobos:%:replace-outfile(-lgphobos libgphobos.a%s)}\ %{static|static-libgcc|static-libstdc++|static-libgfortran:%:replace-outfile(-lgomp libgomp.a%s)}\ %{static|static-libgcc|static-libstdc++:%:replace-outfile(-lstdc++ libstdc++.a%s)}\ - %{force_cpusubtype_ALL:-arch %(darwin_arch)} \ + %{static|static-libgm2:%:replace-outfile(-lm2pim libm2pim.a%s)}\ + %{static|static-libgm2:%:replace-outfile(-lm2iso libm2iso.a%s)}\ + %{static|static-libgm2:%:replace-outfile(-lm2min libm2min.a%s)}\ + %{static|static-libgm2:%:replace-outfile(-lm2log libm2log.a%s)}\ + %{static|static-libgm2:%:replace-outfile(-lm2cor libm2cor.a%s)}\ + %{force_cpusubtype_ALL:-arch %(darwin_arch)} \ %{!force_cpusubtype_ALL:-arch %(darwin_subarch)} "\ LINK_SYSROOT_SPEC \ "%{mmacosx-version-min=*:-macosx_version_min %*} \ diff --git a/gcc/m2/gm2spec.cc b/gcc/m2/gm2spec.cc index 4996fa49789..6a17114c9f3 100644 --- a/gcc/m2/gm2spec.cc +++ b/gcc/m2/gm2spec.cc @@ -585,6 +585,9 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, /* Should the driver perform a link? */ bool linking = true; + /* Should the driver link the shared gm2 libs? */ + bool shared_libgm2 = true; + /* "-lm" or "-lmath" if it appears on the command line. */ const struct cl_decoded_option *saw_math = NULL; @@ -594,7 +597,8 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, /* By default, we throw on the math library if we have one. */ int need_math = (MATH_LIBRARY[0] != '\0'); - /* 1 if we should add -lpthread to the command-line. */ + /* 1 if we should add -lpthread to the command-line. + FIXME: the default should be a configuration choice. */ int need_pthread = 1; /* True if we saw -static. */ @@ -774,6 +778,16 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, #endif break; + case OPT_static_libgm2: + shared_libgm2 = false; +#ifdef HAVE_LD_STATIC_DYNAMIC + /* Remove -static-libgm2 from the command only if target supports + LD_STATIC_DYNAMIC. When not supported, it is left in so that a + back-end target can use outfile substitution. */ + args[i] |= SKIPOPT; +#endif + break; + case OPT_stdlib_: which_library = (stdcxxlib_kind) decoded_options[i].value; break; @@ -877,8 +891,16 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options, if (linking) { +#ifdef HAVE_LD_STATIC_DYNAMIC + if (allow_libraries && !shared_libgm2) + append_option (OPT_Wl_, LD_STATIC_OPTION, 1); +#endif if (allow_libraries) add_default_archives (libpath, libraries); +#ifdef HAVE_LD_STATIC_DYNAMIC + if (allow_libraries && !shared_libgm2) + append_option (OPT_Wl_, LD_DYNAMIC_OPTION, 1); +#endif /* Add `-lstdc++' if we haven't already done so. */ #ifdef HAVE_LD_STATIC_DYNAMIC if (library > 1 && !static_link)