From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 61993 invoked by alias); 31 Oct 2018 09:43:25 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 61974 invoked by uid 89); 31 Oct 2018 09:43:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,KAM_SHORT autolearn=ham version=3.3.2 spammy=fpq X-HELO: smtp.CeBiTec.Uni-Bielefeld.DE Received: from smtp.CeBiTec.Uni-Bielefeld.DE (HELO smtp.CeBiTec.Uni-Bielefeld.DE) (129.70.160.84) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 31 Oct 2018 09:43:22 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id 206356E6; Wed, 31 Oct 2018 10:43:20 +0100 (CET) Received: from smtp.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (malfoy.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 82rilJCALdqk; Wed, 31 Oct 2018 10:43:13 +0100 (CET) Received: from lokon.CeBiTec.Uni-Bielefeld.DE (lokon.CeBiTec.Uni-Bielefeld.DE [129.70.161.152]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPS id 0868B6E5; Wed, 31 Oct 2018 10:43:13 +0100 (CET) Received: (from ro@localhost) by lokon.CeBiTec.Uni-Bielefeld.DE (8.15.2+Sun/8.15.2/Submit) id w9V9hCqf006407; Wed, 31 Oct 2018 10:43:12 +0100 (MET) From: Rainer Orth To: Iain Buclaw Cc: gcc-patches Subject: Re: Fix D compilation on Solaris References: Date: Wed, 31 Oct 2018 10:03:00 -0000 In-Reply-To: (Rainer Orth's message of "Wed, 31 Oct 2018 10:40:32 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (usg-unix-v) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-IsSubscribed: yes X-SW-Source: 2018-10/txt/msg02008.txt.bz2 --=-=-= Content-Type: text/plain Content-length: 2180 Hi Iain, >> My first suspect here would be 'struct UnionExp', see d/dmd/expression.h >> >> Upstream dmd use a poor man's alignment, from what I recall to be >> compatible with the dmc compiler. >> >> // Ensure that the union is suitably aligned. >> real_t for_alignment_only; >> >> What happens if you were to replace that with marking the type as >> __attribute__ ((aligned (8))) ? > > thanks for the suggestion: this worked just fine. After a couple more > libphobos adjustments (described below), I was able to finish the build > on both sparc-sun-solaris2.11 and i386-pc-solaris2.11. > > The link tests still all fail as before, but sparc and x86 are now on > par here :-) and now with the updated patch ;-) Rainer -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University 2018-10-29 Iain Buclaw gcc/d: * dmd/expression.h (UnionExp.u): Remove for_alignment_only. Force 8-byte alignment. 2018-10-29 Rainer Orth gcc: * config/default-d.c: Include memmodel.h. * config/sol2-d.c: New file. * config/t-sol2 (sol2-d.o): New rule. * config.gcc <*-*-solaris2*>: Set d_target_objs, target_has_targetdm. libphobos: * libdruntime/core/stdc/fenv.d [SPARC, SPARC64]: Set SPARC_Any. [X86, X86_64]: Set X86_Any. [Solaris]: Provide FE_* constants. * libdruntime/core/sys/posix/aio.d [Solaris] (struct aio_result, struct aiocb): New types. * libdruntime/core/sys/posix/ucontext.d [SPARC64, SPARC] (_NGREG, greg_t): Define. [SPARC64, SPARC] (struct _fpq, struct fq, struct fpregset_t): New types. * libdruntime/core/thread.d (Class Thread) [Solaris] (m_isRTClass): Don't declare immutable. * libdruntime/rt/sections_solaris.d (SectionGroup.moduleGroup): Declare nothrow @nogc. (pinLoadedLibraries, unpinLoadedLibraries, inheritLoadedLibraries) (cleanupLoadedLibraries): New functions. * src/std/datetime/systime.d (class Clock) [Solaris] (clock_gettime): Import. * src/std/math.d [SPARC, SPARC64]: Set SPARC_Any. (struct FloatingPointControl): Use SPARC_Any for ExceptionMask, ControlState. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=sol2-d-build.patch Content-length: 10199 # HG changeset patch # Parent feb1bc98079b57185692621c744578b658d1fc1a Fix D compilation on Solaris diff --git a/gcc/config.gcc b/gcc/config.gcc --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -918,6 +918,7 @@ case ${target} in target_gtfiles="$target_gtfiles \$(srcdir)/config/sol2.c" c_target_objs="${c_target_objs} sol2-c.o" cxx_target_objs="${cxx_target_objs} sol2-c.o sol2-cxx.o" + d_target_objs="${d_target_objs} sol2-d.o" extra_objs="${extra_objs} sol2.o sol2-stubs.o" extra_options="${extra_options} sol2.opt" case ${enable_threads}:${have_pthread_h}:${have_thread_h} in @@ -925,6 +926,7 @@ case ${target} in thread_file=posix ;; esac + target_has_targetdm=yes ;; *-*-*vms*) extra_options="${extra_options} vms/vms.opt" diff --git a/gcc/config/default-d.c b/gcc/config/default-d.c --- a/gcc/config/default-d.c +++ b/gcc/config/default-d.c @@ -18,6 +18,7 @@ along with GCC; see the file COPYING3. #include "config.h" #include "system.h" #include "coretypes.h" +#include "memmodel.h" #include "tm_d.h" #include "d/d-target.h" #include "d/d-target-def.h" diff --git a/gcc/config/sol2-d.c b/gcc/config/sol2-d.c new file mode 100644 --- /dev/null +++ b/gcc/config/sol2-d.c @@ -0,0 +1,39 @@ +/* Solaris support needed only by D front-end. + Copyright (C) 2018 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 "memmodel.h" +#include "tm_p.h" +#include "d/d-target.h" +#include "d/d-target-def.h" + +/* Implement TARGET_D_OS_VERSIONS for Solaris targets. */ + +static void +solaris_d_os_builtins (void) +{ + d_add_builtin_version ("Posix"); + d_add_builtin_version ("Solaris"); \ +} + +#undef TARGET_D_OS_VERSIONS +#define TARGET_D_OS_VERSIONS solaris_d_os_builtins + +struct gcc_targetdm targetdm = TARGETDM_INITIALIZER; diff --git a/gcc/config/t-sol2 b/gcc/config/t-sol2 --- a/gcc/config/t-sol2 +++ b/gcc/config/t-sol2 @@ -16,7 +16,7 @@ # along with GCC; see the file COPYING3. If not see # . -# Solaris-specific format checking and pragmas +# Solaris-specific format checking and pragmas. sol2-c.o: $(srcdir)/config/sol2-c.c $(COMPILE) $< $(POSTCOMPILE) @@ -26,6 +26,11 @@ sol2-cxx.o: $(srcdir)/config/sol2-cxx.c $(COMPILE) $< $(POSTCOMPILE) +# Solaris-specific D support. +sol2-d.o: $(srcdir)/config/sol2-d.c + $(COMPILE) $< + $(POSTCOMPILE) + # Corresponding stub routines. sol2-stubs.o: $(srcdir)/config/sol2-stubs.c $(COMPILE) $< diff --git a/gcc/d/dmd/expression.h b/gcc/d/dmd/expression.h --- a/gcc/d/dmd/expression.h +++ b/gcc/d/dmd/expression.h @@ -1507,10 +1507,7 @@ private: char addrexp [sizeof(AddrExp)]; char indexexp [sizeof(IndexExp)]; char sliceexp [sizeof(SliceExp)]; - - // Ensure that the union is suitably aligned. - real_t for_alignment_only; - } u; + } u __attribute__ ((aligned (8))); }; /****************************************************************/ diff --git a/libphobos/libdruntime/core/stdc/fenv.d b/libphobos/libdruntime/core/stdc/fenv.d --- a/libphobos/libdruntime/core/stdc/fenv.d +++ b/libphobos/libdruntime/core/stdc/fenv.d @@ -33,6 +33,16 @@ version (PPC) else version (PPC64) version = PPC_Any; +version (SPARC) + version = SPARC_Any; +version (SPARC64) + version = SPARC_Any; + +version (X86) + version = X86_Any; +version (X86_64) + version = X86_Any; + version (MinGW) version = GNUFP; version (CRuntime_Glibc) @@ -451,6 +461,50 @@ version (CRuntime_Microsoft) FE_TOWARDZERO = 0x300, /// } } +else version (Solaris) +{ + version (SPARC_Any) + { + enum + { + FE_TONEAREST = 0, + FE_TOWARDZERO = 1, + FE_UPWARD = 2, + FE_DOWNWARD = 3, + } + + enum + { + FE_INEXACT = 0x01, + FE_DIVBYZERO = 0x02, + FE_UNDERFLOW = 0x04, + FE_OVERFLOW = 0x08, + FE_INVALID = 0x10, + FE_ALL_EXCEPT = 0x1f, + } + + } + else version (X86_Any) + { + enum + { + FE_TONEAREST = 0, + FE_DOWNWARD = 1, + FE_UPWARD = 2, + FE_TOWARDZERO = 3, + } + + enum + { + FE_INVALID = 0x01, + FE_DIVBYZERO = 0x04, + FE_OVERFLOW = 0x08, + FE_UNDERFLOW = 0x10, + FE_INEXACT = 0x20, + FE_ALL_EXCEPT = 0x3d, + } + } +} else { version (X86) diff --git a/libphobos/libdruntime/core/sys/posix/aio.d b/libphobos/libdruntime/core/sys/posix/aio.d --- a/libphobos/libdruntime/core/sys/posix/aio.d +++ b/libphobos/libdruntime/core/sys/posix/aio.d @@ -123,6 +123,32 @@ else version (DragonFlyBSD) version = BSD_Posix; } +else version (Solaris) +{ + struct aio_result_t + { + ssize_t aio_return; + int aio_errno; + }; + + struct aiocb + { + int aio_fildes; + void* aio_buf; // volatile + size_t aio_nbytes; + off_t aio_offset; + int aio_reqprio; + sigevent aio_sigevent; + int aio_lio_opcode; + aio_result_t aio_result; + byte aio_state; + byte aio_returned; + byte[2] aio__pad1; + int aio_flags; + } + + version = BSD_Posix; +} else static assert(false, "Unsupported platform"); diff --git a/libphobos/libdruntime/core/sys/posix/ucontext.d b/libphobos/libdruntime/core/sys/posix/ucontext.d --- a/libphobos/libdruntime/core/sys/posix/ucontext.d +++ b/libphobos/libdruntime/core/sys/posix/ucontext.d @@ -937,7 +937,17 @@ else version (Solaris) { alias uint[4] upad128_t; - version (X86_64) + version (SPARC64) + { + enum _NGREG = 21; + alias long greg_t; + } + else version (SPARC) + { + enum _NGREG = 19; + alias int greg_t; + } + else version (X86_64) { enum _NGREG = 28; alias long greg_t; @@ -950,7 +960,70 @@ else version (Solaris) alias greg_t[_NGREG] gregset_t; - version (X86_64) + version (SPARC64) + { + struct _fpq + { + uint *fpq_addr; + uint fpq_instr; + } + + struct fq + { + union FQu + { + double whole; + _fpq fpq; + }; + } + + struct fpregset_t + { + union fpu_fr + { + uint[32] fpu_regs; + double[32] fpu_dregs; + /* long double[16] fpu_qregs; */ + }; + fq *fpu_q; + ulong fpu_fsr; + ubyte fpu_qcnt; + ubyte fpu_q_entrysize; + ubyte fpu_en; + } + } + else version (SPARC) + { + struct _fpq + { + uint *fpq_addr; + uint fpq_instr; + } + + struct fq + { + union FQu + { + double whole; + _fpq fpq; + }; + } + + struct fpregset_t + { + union + { + uint[32] fpu_regs; + double[16] fpu_dregs; + }; + fq *fpu_q; + uint fpu_fsr; + ubyte fpu_qcnt; + ubyte fpu_q_entrysize; + ubyte fpu_en; + } + } + else version (X86_64) { union _u_st { diff --git a/libphobos/libdruntime/core/thread.d b/libphobos/libdruntime/core/thread.d --- a/libphobos/libdruntime/core/thread.d +++ b/libphobos/libdruntime/core/thread.d @@ -1547,7 +1547,7 @@ private: version (Solaris) { - __gshared immutable bool m_isRTClass; + __gshared bool m_isRTClass; } private: diff --git a/libphobos/libdruntime/rt/sections_solaris.d b/libphobos/libdruntime/rt/sections_solaris.d --- a/libphobos/libdruntime/rt/sections_solaris.d +++ b/libphobos/libdruntime/rt/sections_solaris.d @@ -34,7 +34,7 @@ struct SectionGroup return _moduleGroup.modules; } - @property ref inout(ModuleGroup) moduleGroup() inout + @property ref inout(ModuleGroup) moduleGroup() inout nothrow @nogc { return _moduleGroup; } @@ -87,6 +87,24 @@ void scanTLSRanges(void[] rng, scope voi dg(rng.ptr, rng.ptr + rng.length); } +// interface for core.thread to inherit loaded libraries +void* pinLoadedLibraries() nothrow @nogc +{ + return null; +} + +void unpinLoadedLibraries(void* p) nothrow @nogc +{ +} + +void inheritLoadedLibraries(void* p) nothrow @nogc +{ +} + +void cleanupLoadedLibraries() nothrow @nogc +{ +} + private: __gshared SectionGroup _sections; diff --git a/libphobos/src/std/datetime/systime.d b/libphobos/src/std/datetime/systime.d --- a/libphobos/src/std/datetime/systime.d +++ b/libphobos/src/std/datetime/systime.d @@ -221,6 +221,7 @@ public: else { import core.sys.solaris.time : CLOCK_REALTIME; + import core.sys.posix.time : clock_gettime; static if (clockType == ClockType.coarse) alias clockArg = CLOCK_REALTIME; else static if (clockType == ClockType.normal) alias clockArg = CLOCK_REALTIME; else static if (clockType == ClockType.precise) alias clockArg = CLOCK_REALTIME; diff --git a/libphobos/src/std/math.d b/libphobos/src/std/math.d --- a/libphobos/src/std/math.d +++ b/libphobos/src/std/math.d @@ -160,6 +160,8 @@ version (MIPS32) version = MIPS_Any; version (MIPS64) version = MIPS_Any; version (AArch64) version = ARM_Any; version (ARM) version = ARM_Any; +version (SPARC) version = SPARC_Any; +version (SPARC64) version = SPARC_Any; version (D_InlineAsm_X86) { @@ -5161,7 +5163,7 @@ struct FloatingPointControl | inexactException, } } - else version (SPARC64) + else version (SPARC_Any) { enum : ExceptionMask { @@ -5291,7 +5293,7 @@ private: { alias ControlState = uint; } - else version (SPARC64) + else version (SPARC_Any) { alias ControlState = ulong; } --=-=-=--