From patchwork Sun Mar 21 11:58:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1456283 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; 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=GlM3p00b; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [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 4F3GPY4bjNz9sRf for ; Sun, 21 Mar 2021 22:58:55 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0D7113858C27; Sun, 21 Mar 2021 11:58:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0D7113858C27 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1616327929; bh=xmaMvb5/69C9EsHHc7CjivXWfvAt37ezv5nonmTQTr8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=GlM3p00b1f/3jm/sY24bJvSWTKM7dq45pcURaIM0PdsfQAjZVnMFNHpk731nuIwRd Dkq+7AYVlLBlSNQBHG5ADSv7LK/lOPA1F7srCoFghmIhHN4IeyGwRcPZ6jD1qy2E8X CkwpMFlE7TmxjKRKlyWGOlxpRZmimmXuY7ADBBME= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [IPv6:2001:67c:2050::465:101]) by sourceware.org (Postfix) with ESMTPS id 692233858D29 for ; Sun, 21 Mar 2021 11:58:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 692233858D29 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (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-101.mailbox.org (Postfix) with ESMTPS id 4F3GPG596gzQj5h; Sun, 21 Mar 2021 12:58:42 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter03.heinlein-hosting.de (spamfilter03.heinlein-hosting.de [80.241.56.117]) (amavisd-new, port 10030) with ESMTP id Pcb7DkdfLTBV; Sun, 21 Mar 2021 12:58:38 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [PATCH] d: Add windows support for D compiler (PR91595) Date: Sun, 21 Mar 2021 12:58:36 +0100 Message-Id: <20210321115836.102170-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-MBO-SPAM-Probability: X-Rspamd-Score: -0.07 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6E91F17EA X-Rspamd-UID: 7a8de4 X-Spam-Status: No, score=-16.0 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, 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 necessary backend support for MinGW/Cygwin targets so that all relevant predefined version conditions are available, a prerequesite for building most parts of libphobos. Tested gdc by building x86_64-pc-mingw64 as a cross compiler, before I commit it to mainline, is there anything glaringly missing in the configure file changes? Regards Iain --- gcc/ChangeLog: PR d/91595 * config.gcc (*-*-cygwin*): Add winnt-d.o (*-*-mingw*): Likewise. * config/i386/cygwin.h (EXTRA_TARGET_D_OS_VERSIONS): New macro. * config/i386/mingw32.h (EXTRA_TARGET_D_OS_VERSIONS): Likewise. * config/t-winnt: Add winnt-d.o. * config/winnt-d.c: New file. --- gcc/config.gcc | 6 ++++++ gcc/config/i386/cygwin.h | 8 ++++++++ gcc/config/i386/mingw32.h | 11 ++++++++++ gcc/config/t-winnt | 4 ++++ gcc/config/winnt-d.c | 43 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 72 insertions(+) create mode 100644 gcc/config/winnt-d.c diff --git a/gcc/config.gcc b/gcc/config.gcc index 9cecc140c83..b3b84374fd0 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -2121,6 +2121,8 @@ i[34567]86-*-cygwin*) extra_objs="${extra_objs} winnt.o winnt-stubs.o" c_target_objs="${c_target_objs} msformat-c.o" cxx_target_objs="${cxx_target_objs} winnt-cxx.o msformat-c.o" + d_target_objs="${d_target_objs} winnt-d.o" + target_has_targetdm="yes" if test x$enable_threads = xyes; then thread_file='posix' fi @@ -2137,6 +2139,8 @@ x86_64-*-cygwin*) extra_objs="${extra_objs} winnt.o winnt-stubs.o" c_target_objs="${c_target_objs} msformat-c.o" cxx_target_objs="${cxx_target_objs} winnt-cxx.o msformat-c.o" + d_target_objs="${d_target_objs} winnt-d.o" + target_has_targetdm="yes" if test x$enable_threads = xyes; then thread_file='posix' fi @@ -2149,7 +2153,9 @@ i[34567]86-*-mingw* | x86_64-*-mingw*) xm_file=i386/xm-mingw32.h c_target_objs="${c_target_objs} winnt-c.o" cxx_target_objs="${cxx_target_objs} winnt-c.o" + d_target_objs="${d_target_objs} winnt-d.o" target_has_targetcm="yes" + target_has_targetdm="yes" case ${target} in x86_64-*-* | *-w64-*) need_64bit_isa=yes diff --git a/gcc/config/i386/cygwin.h b/gcc/config/i386/cygwin.h index db0a3cc0b35..f28c6974cdc 100644 --- a/gcc/config/i386/cygwin.h +++ b/gcc/config/i386/cygwin.h @@ -29,6 +29,14 @@ along with GCC; see the file COPYING3. If not see } \ while (0) +#define EXTRA_TARGET_D_OS_VERSIONS() \ + do \ + { \ + builtin_version ("Cygwin"); \ + builtin_version ("Posix"); \ + } \ + while (0) + #undef CPP_SPEC #define CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} \ %{!ansi:-Dunix} \ diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h index 1a6a3a07ca6..0589d39230d 100644 --- a/gcc/config/i386/mingw32.h +++ b/gcc/config/i386/mingw32.h @@ -53,6 +53,17 @@ along with GCC; see the file COPYING3. If not see } \ while (0) +#define EXTRA_TARGET_D_OS_VERSIONS() \ + do \ + { \ + builtin_version ("MinGW"); \ + if (TARGET_64BIT && ix86_abi == MS_ABI) \ + builtin_version ("Win64"); \ + else if (!TARGET_64BIT) \ + builtin_version ("Win32"); \ + } \ + while (0) + #ifndef TARGET_USE_PTHREAD_BY_DEFAULT #define SPEC_PTHREAD1 "pthread" #define SPEC_PTHREAD2 "!no-pthread" diff --git a/gcc/config/t-winnt b/gcc/config/t-winnt index 9587f66b3db..00bd3c348b4 100644 --- a/gcc/config/t-winnt +++ b/gcc/config/t-winnt @@ -20,3 +20,7 @@ winnt-c.o: config/winnt-c.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ $(C_TARGET_H) $(C_TARGET_DEF_H) $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) \ $< $(OUTPUT_OPTION) + +winnt-d.o: config/winnt-d.c + $(COMPILE) $< + $(POSTCOMPILE) diff --git a/gcc/config/winnt-d.c b/gcc/config/winnt-d.c new file mode 100644 index 00000000000..f3a36c28293 --- /dev/null +++ b/gcc/config/winnt-d.c @@ -0,0 +1,43 @@ +/* Windows support needed only by D front-end. + Copyright (C) 2021 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 "target.h" +#include "d/d-target.h" +#include "d/d-target-def.h" +#include "tm_p.h" + +/* Implement TARGET_D_OS_VERSIONS for Windows targets. */ + +static void +winnt_d_os_builtins (void) +{ + d_add_builtin_version ("Windows"); + +#define builtin_version(TXT) d_add_builtin_version (TXT) + +#ifdef EXTRA_TARGET_D_OS_VERSIONS + EXTRA_TARGET_D_OS_VERSIONS (); +#endif +} + +#undef TARGET_D_OS_VERSIONS +#define TARGET_D_OS_VERSIONS winnt_d_os_builtins + +struct gcc_targetdm targetdm = TARGETDM_INITIALIZER;