From patchwork Thu Sep 7 13:36:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 137642 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ab0a:0:b0:3f2:4152:657d with SMTP id m10csp2966799vqo; Thu, 7 Sep 2023 06:46:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHLV8g6TNt3FC2LWZHKK28blQnRVHLegg7fY/Kf+o7YSSOoaAa/G/4wDyNTgeufVTngpAaq X-Received: by 2002:a05:6512:36c3:b0:501:c0cf:ba0e with SMTP id e3-20020a05651236c300b00501c0cfba0emr4025993lfs.24.1694094410246; Thu, 07 Sep 2023 06:46:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694094410; cv=none; d=google.com; s=arc-20160816; b=aj3E/AEMl/sN+FkiKzKcM5/yFebAK2ptndt3IoZK2xq7okPMVWFxlXAvwL79y1M4jB YofO4wGhNKwG4UZx1Jm8+2oOSQREjjXeRCTPOwwoABkJWFG8srrf1cOg4vQamYD+33Jf jwzyYcQHtOHJbiBJh6U2H5a5ChTXzZwfgZp6xyrn1T0U6zhE5lXmA/f6FkeYtxhznnmL oxKrh6Pl89jw0NKXzDRVsute4rHu6/1L0QHYumqznbFWkCL7YviEsQGkeAeM5YKPV0ax 6Ukk+R0Er5eGX2GylfLEftuVrJ111Dg5CuOY4mc3RWY17gKoFTiYQgB3Xt/KISes2gNx Jvzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature:dmarc-filter :delivered-to; bh=Vl4L5kZzagtvQF6Pd/KEV9ilMkyzy+AuxRxxzKGH2gw=; fh=wFq7tT6aDoWtju83L9lDAhBMEFwd5hWtfnM+XVolLD0=; b=QpfbjoYEGOTbqw+WFOD7vidQg2eIIV3xs4C54bEMMYtSiyJSE+PE/YOuD8mHcA533x I5WMxoz6ALODqwzsFEoPrGnB9FBfiekjoVTD9eUW8Qb+5ZNhuLR4u+2eikZkSqudHhuT MH+qu/TUUjl+9XSvIXciCrUhtyfLzk3AHHkYlkknf//0DQ5DABoFbwrTcb/o5PSVcx1g ZlAj8s8D+AGlqIGDhfwhb7OSdhA6lOW0rg3OjDiMPTQkUlEBf3INvHD91VbBkwGKm3yt omcvsMLWoZJVB4P3HG5gKTULlr6GPlUYhjiJEBdE3yOeh/2kx2V0PJ3h8IOrhrfu/hqS 6ftw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embecosm.com header.s=google header.b=OOWNeaWJ; 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" Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id p17-20020a1709060dd100b0099307a5a755si221459eji.45.2023.09.07.06.46.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 06:46:50 -0700 (PDT) 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=fail header.i=@embecosm.com header.s=google header.b=OOWNeaWJ; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 73BEF3948A73 for ; Thu, 7 Sep 2023 13:41:19 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id A96373857438 for ; Thu, 7 Sep 2023 13:38:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A96373857438 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-402c1407139so11197535e9.1 for ; Thu, 07 Sep 2023 06:38:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1694093915; x=1694698715; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=Vl4L5kZzagtvQF6Pd/KEV9ilMkyzy+AuxRxxzKGH2gw=; b=OOWNeaWJ/aoSID3M3X+97+HadZq9uZJzkRLOhw8LowC0lUCrTllElrWkataUSwRM03 Gfenh62xjyXH++VMmXMUfS6cwWERWclBMIzT/Z1NsTfo2vrdhXmOQa8SwgnUhV+amh8u pt8ZsGVLSfArTS16BUYtkQlhqFDE5d0naf4LB9Pxxq4lMjO3tfIZOskCCku+Xzf319RY tmrQMdnj27Zp/mIwehZYN50VCy0xVYNIx2sajHUn3eyc+OfZoW++EyVob99zSNLuVQg+ WtEN4CLJXQYQ4hOQeZaU9fyHRD/hZ17XUOOWBD3pz4YeTrUZb3v7zwQhgABWsNRZ/iqS uQ4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1694093915; x=1694698715; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Vl4L5kZzagtvQF6Pd/KEV9ilMkyzy+AuxRxxzKGH2gw=; b=fQRWRFNGKx0ODQcuaTp2qoFXn9iWWIj4GDfwk47cU36BE0hTdOiq+6DsdOEKkHAn5/ fbfu2dowhxb1yb4iUFD4bQrkTQgmJuc/uOqZY8pS9xvcXkwl2NF3SnbuBmwTThK2ylXS 8DbJOV15lj5vZCIs3jdHGn3WsjD4NXV8ICvg3ym+5uToK8KMvq4wqH+ECZEckP6poxo/ M37Wu06cllwQRo9E6bVE0EU1XKHCmCpqIwRO5rLqh8g/S7/SrKhSG11mvUZb+6ulE/MA WCj991qEfNAki4DYT+x6XNzZ8Luonio/9xPaTN6H9LZCeDt41foiViuSPIHjQxnI/TUZ FqZw== X-Gm-Message-State: AOJu0YzsyZeweojxWC16PTZyS1Hp3THLns4JLMbwWFoCuZcVM0UaFIr3 4Tud0ex8tyQcJZmLQ1PIPM+zYutTmYYr57eFKw== X-Received: by 2002:a5d:4a0e:0:b0:30e:19a8:4b0a with SMTP id m14-20020a5d4a0e000000b0030e19a84b0amr4950840wrq.2.1694093915215; Thu, 07 Sep 2023 06:38:35 -0700 (PDT) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id bt12-20020a056000080c00b0031433443265sm17693052wrb.53.2023.09.07.06.38.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 06:38:34 -0700 (PDT) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Subject: [PATCH 14/14] rust: Implement TARGET_RUST_OS_INFO for *-*-*linux*. Date: Thu, 7 Sep 2023 15:36:40 +0200 Message-ID: <20230907133729.2518969-15-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230907133729.2518969-2-arthur.cohen@embecosm.com> References: <20230907133729.2518969-2-arthur.cohen@embecosm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-14.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable 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: arthur.cohen@embecosm.com Cc: gcc-rust@gcc.gnu.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776386739812220203 X-GMAIL-MSGID: 1776386739812220203 From: Iain Buclaw gcc/ChangeLog: * config.gcc (*linux*): Set rust target_objs, and target_has_targetrustm, * config/t-linux (linux-rust.o): New rule. * config/linux-rust.cc: New file. --- gcc/config.gcc | 2 ++ gcc/config/linux-rust.cc | 57 ++++++++++++++++++++++++++++++++++++++++ gcc/config/t-linux | 4 +++ 3 files changed, 63 insertions(+) create mode 100644 gcc/config/linux-rust.cc diff --git a/gcc/config.gcc b/gcc/config.gcc index a7a36fccd8d..0c8d756a895 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -944,6 +944,8 @@ case ${target} in *-*-*linux*) d_target_objs="${d_target_objs} linux-d.o" target_has_targetdm=yes + rust_target_objs="${rust_target_objs} linux-rust.o" + target_has_targetrustm=yes ;; *-*-kfreebsd*-gnu) d_target_objs="${d_target_objs} kfreebsd-d.o" diff --git a/gcc/config/linux-rust.cc b/gcc/config/linux-rust.cc new file mode 100644 index 00000000000..3eaa91818ff --- /dev/null +++ b/gcc/config/linux-rust.cc @@ -0,0 +1,57 @@ +/* Linux support needed only by Rust front-end. + Copyright (C) 2022 Free Software Foundation, Inc. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "tm_rust.h" +#include "rust/rust-target.h" +#include "rust/rust-target-def.h" + +/* `-mandroid' is not available as an command-line option. */ +#ifndef TARGET_ANDROID +#define TARGET_ANDROID 0 +#endif + +/* Implement TARGET_RUST_OS_INFO for Linux targets. */ + +static void +linux_rust_target_os_info (void) +{ + rust_add_target_info ("target_family", "unix"); + rust_add_target_info ("target_vendor", "unknown"); + + if (TARGET_ANDROID) + rust_add_target_info ("target_os", "android"); + else + rust_add_target_info ("target_os", "linux"); + + if (OPTION_GLIBC) + rust_add_target_info ("target_env", "gnu"); + else if (OPTION_MUSL) + rust_add_target_info ("target_env", "musl"); + else if (OPTION_UCLIBC) + rust_add_target_info ("target_env", "uclibc"); + else + rust_add_target_info ("target_env", ""); +} + +#undef TARGET_RUST_OS_INFO +#define TARGET_RUST_OS_INFO linux_rust_target_os_info + +struct gcc_targetrustm targetrustm = TARGETRUSTM_INITIALIZER; diff --git a/gcc/config/t-linux b/gcc/config/t-linux index 03966d5ce96..96593fbf27f 100644 --- a/gcc/config/t-linux +++ b/gcc/config/t-linux @@ -23,3 +23,7 @@ linux.o: $(srcdir)/config/linux.cc linux-d.o: $(srcdir)/config/linux-d.cc $(COMPILE) $< $(POSTCOMPILE) + +linux-rust.o: $(srcdir)/config/linux-rust.cc + $(COMPILE) $< + $(POSTCOMPILE)