From patchwork Sat Nov 28 16:04:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1407567 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=kDjall73; dkim-atps=neutral Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CjxCT2QQCz9s0b for ; Sun, 29 Nov 2020 03:04:51 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7AB1C385801A; Sat, 28 Nov 2020 16:04:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7AB1C385801A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1606579486; bh=3Xkxx8wgDv5BnueUZr0kJFi78UiECIedQlZBG8KvdPM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=kDjall73VmYv2+xBrQ3ihebk1/0d09FnsGBKnlR8mGh59kPz9uhx8kaQa0BLxmJM2 QpQqnRTlYwVLlLrG+kVJJZux8yilbLHl0W+WYJoKtUT1S+qK936/2Q/vSxMDe9gvGo Wn5G/W2sKoqUgAF7LFwV1gkEoMkSPYIc6qFe9CxE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by sourceware.org (Postfix) with ESMTPS id 96EDE3858C27 for ; Sat, 28 Nov 2020 16:04:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 96EDE3858C27 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4CjxCF6q7nzQl34; Sat, 28 Nov 2020 17:04:41 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter05.heinlein-hosting.de (spamfilter05.heinlein-hosting.de [80.241.56.123]) (amavisd-new, port 10030) with ESMTP id EE6q4niimujo; Sat, 28 Nov 2020 17:04:38 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [PATCH] d: Add freebsd support for D compiler and runtime Date: Sat, 28 Nov 2020 17:04:35 +0100 Message-Id: <20201128160435.72906-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-MBO-SPAM-Probability: X-Rspamd-Score: -0.53 / 15.00 / 15.00 X-Rspamd-Queue-Id: B580E1721 X-Rspamd-UID: 9f6671 X-Spam-Status: No, score=-16.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_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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 Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi, This patch adds the necessary version conditions and configure rules in place to allow building the D compiler on FreeBSD. Running the testsuite on both i386 and x86_64, all tests except for one passes (gdc.test/runnable/test17338.d, though the problem appears to be the linker producing a corrupt object). OK for mainline? Regards Iain --- gcc/ChangeLog: * config.gcc (*-*-freebsd*): Add freebsd-d.o and t-freebsd. * config/freebsd-d.c: New file. * config/t-freebsd: New file. libphobos/ChangeLog: * configure.tgt: Add x86_64-*-freebsd* and i?86-*-freebsd* as supported targets. --- gcc/config.gcc | 3 +++ gcc/config/freebsd-d.c | 42 +++++++++++++++++++++++++++++++++++++++++ gcc/config/t-freebsd | 21 +++++++++++++++++++++ libphobos/configure.tgt | 3 +++ 4 files changed, 69 insertions(+) create mode 100644 gcc/config/freebsd-d.c create mode 100644 gcc/config/t-freebsd diff --git a/gcc/config.gcc b/gcc/config.gcc index 0ae58482657..71209268aeb 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -782,6 +782,9 @@ case ${target} in default_use_cxa_atexit=yes;; esac use_gcc_stdint=wrap + d_target_objs="${d_target_objs} freebsd-d.o" + tmake_file="${tmake_file} t-freebsd" + target_has_targetdm=yes ;; *-*-fuchsia*) native_system_header_dir=/include diff --git a/gcc/config/freebsd-d.c b/gcc/config/freebsd-d.c new file mode 100644 index 00000000000..d79d82b5aa4 --- /dev/null +++ b/gcc/config/freebsd-d.c @@ -0,0 +1,42 @@ +/* FreeBSD support needed only by D front-end. + Copyright (C) 2020 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_p.h" +#include "d/d-target.h" +#include "d/d-target-def.h" + +/* Implement TARGET_D_OS_VERSIONS for FreeBSD targets. */ + +static void +freebsd_d_os_builtins (void) +{ + char buf[16]; + snprintf (buf, sizeof (buf), "FreeBSD_%d", FBSD_MAJOR); + + d_add_builtin_version ("FreeBSD"); + d_add_builtin_version (xstrdup (buf)); + d_add_builtin_version ("Posix"); +} + +#undef TARGET_D_OS_VERSIONS +#define TARGET_D_OS_VERSIONS freebsd_d_os_builtins + +struct gcc_targetdm targetdm = TARGETDM_INITIALIZER; diff --git a/gcc/config/t-freebsd b/gcc/config/t-freebsd new file mode 100644 index 00000000000..ca0cb2e60a8 --- /dev/null +++ b/gcc/config/t-freebsd @@ -0,0 +1,21 @@ +# Copyright (C) 2020 Free Software Foundation, Inc. +# +# This file is part of GCC. +# +# 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 +# . + +freebsd-d.o: $(srcdir)/config/freebsd-d.c + $(COMPILE) $< + $(POSTCOMPILE) diff --git a/libphobos/configure.tgt b/libphobos/configure.tgt index 1ea9e0c804c..7d9c6bc0c92 100644 --- a/libphobos/configure.tgt +++ b/libphobos/configure.tgt @@ -49,6 +49,9 @@ case "${target}" in s390*-linux*) LIBPHOBOS_SUPPORTED=yes ;; + x86_64-*-freebsd* | i?86-*-freebsd*) + LIBPHOBOS_SUPPORTED=yes + ;; x86_64-*-kfreebsd*-gnu | i?86-*-kfreebsd*-gnu) LIBPHOBOS_SUPPORTED=yes ;;