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: 1830938 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=embecosm.com header.i=@embecosm.com header.a=rsa-sha256 header.s=google header.b=OOWNeaWJ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RhL4k4pz5z1ygc for ; Thu, 7 Sep 2023 23:41:42 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E765F385841A for ; Thu, 7 Sep 2023 13:41:04 +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-Google-Smtp-Source: AGHT+IHlxNmyLZWc633Sq7SSAeiBsYhlPoUV58VA0Dj+uy3rpJrSrV1eGM+TnZbS0eYPzyutGZK70Q== 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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)