From patchwork Tue Apr 23 23:20:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1089825 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-499574-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=gdcproject.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="brg5PBt2"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44pfZQ1fx8z9s55 for ; Wed, 24 Apr 2019 09:20:44 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=UwTVLXG/LF18POsxuI5N9pOoIsyy5F8QCSqh4bUXNeTDBz SKmHzjmsY9QdSSul4MjDArU+k5QJqFUKXCbVi7KMdgofmrGJeNhj6cyH+PJ9a3Yl iOxZAxa7frNxXjg1jxu28hPfDnHBeSuKcOihg5vRCvxVxHPCaIXkGQV4Y/wYg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=K8KpIIkDs6Eg0vcjsVx5N10QwyE=; b=brg5PBt2EPQmZRXPuYTK ahVi1bEdOvIkf/dQUtOstY2EZ5ZbXm01ZN3qLVOWrjCp/29ozT9/eWU7GQ5XkxYA AkxQgDWswZfOE5sFDzsihutiio70fQTCtFpJ9KN0vSGj77fzUBitgosukG6d62yE 1pbnE+nXlEeaWlPGyi6fFko= Received: (qmail 76708 invoked by alias); 23 Apr 2019 23:20:37 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 76699 invoked by uid 89); 23 Apr 2019 23:20:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qt1-f178.google.com Received: from mail-qt1-f178.google.com (HELO mail-qt1-f178.google.com) (209.85.160.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 23 Apr 2019 23:20:35 +0000 Received: by mail-qt1-f178.google.com with SMTP id c35so3465479qtk.3 for ; Tue, 23 Apr 2019 16:20:35 -0700 (PDT) MIME-Version: 1.0 From: Iain Buclaw Date: Wed, 24 Apr 2019 01:20:22 +0200 Message-ID: Subject: [PATCH, PR d/87818] Add D language support for FreeBSD x86 To: gcc-patches X-IsSubscribed: yes Hi, This patch adds necessary FreeBSD support code, which allows libphobos to compile cleanly. OK for trunk? diff --git a/gcc/config.gcc b/gcc/config.gcc index 14f0a1abbc8..7a286bbaa50 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -775,6 +775,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..cdff544d20c --- /dev/null +++ b/gcc/config/freebsd-d.c @@ -0,0 +1,54 @@ +/* FreeBSD support needed only by D front-end. + Copyright (C) 2019 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"); +} + +/* Implement TARGET_D_CRITSEC_SIZE for FreeBSD targets. */ + +static unsigned +freebsd_d_critsec_size (void) +{ + /* This is the sizeof pthread_mutex_t, an opaque pointer. */ + return POINTER_SIZE_UNITS; +} + +#undef TARGET_D_OS_VERSIONS +#define TARGET_D_OS_VERSIONS freebsd_d_os_builtins + +#undef TARGET_D_CRITSEC_SIZE +#define TARGET_D_CRITSEC_SIZE freebsd_d_critsec_size + +struct gcc_targetdm targetdm = TARGETDM_INITIALIZER; diff --git a/gcc/config/t-freebsd b/gcc/config/t-freebsd new file mode 100644 index 00000000000..15fcf226d08 --- /dev/null +++ b/gcc/config/t-freebsd @@ -0,0 +1,21 @@ +# Copyright (C) 2019 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 f9c881a8418..2dc05e2cc51 100644 --- a/libphobos/configure.tgt +++ b/libphobos/configure.tgt @@ -38,6 +38,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 ;;