diff --git a/ports/lang/gdc/STATUS b/ports/lang/gdc/STATUS new file mode 100644 index 000000000000..383507395b62 --- /dev/null +++ b/ports/lang/gdc/STATUS @@ -0,0 +1 @@ +DPORT diff --git a/ports/lang/gdc/newport/Makefile b/ports/lang/gdc/newport/Makefile new file mode 100644 index 000000000000..85c5cc077072 --- /dev/null +++ b/ports/lang/gdc/newport/Makefile @@ -0,0 +1,188 @@ +# Created by: Diederik de Groot +# $FreeBSD$ + +# Based on: Gerald Pfeifer + +PORTNAME= gdc +PORTVERSION= 9.2.0 +CATEGORIES= lang +MASTER_SITES= GCC +DISTNAME= gcc-${PORTVERSION} + +MAINTAINER= ibuclaw@gdcproject.org +#PORT_MAINTAINER= ddegroot@talon.nl +COMMENT= GDC from GNU Compiler Collection 9 + +LICENSE= GPLv3 GPLv3RLE BSL +LICENSE_COMB= multi + +ONLY_FOR_ARCHS?= aarch64 amd64 arm armv6 armv7 i386 powerpc powerpc64 sparc64 +USES= compiler cpe gmake iconv libtool makeinfo perl5 tar:xz dlang:bootstrap tar:xz + +WRKSRC= ${WRKDIR}/gcc-${PORTVERSION} +PHOBOS_VERSION= 76 + +LIB_DEPENDS+= libgmp.so:math/gmp +LIB_DEPENDS+= libmpfr.so:math/mpfr +LIB_DEPENDS+= libmpc.so:math/mpc +BUILD_DEPENDS+= as:devel/binutils +RUN_DEPENDS+= as:devel/binutils + +.if defined(MAINTAINER_MODE) +BUILD_DEPENDS+= runtest:misc/dejagnu +.endif + +USE_BINUTILS= yes +USE_PERL5= build +FAVORITE_COMPILER= gcc + +#gcc_check!= ls /usr/local/bin/gcc[6-9] /usr/bin/gcc[6-9] 2>/dev/null || true +#.if !empty(gcc_check) +#USE_GCC= ${gcc_check:[-1]:C/.*gcc//}+ +#.endif + +PREFIX= ${LOCALBASE}/${PKGNAME} + +CPE_VENDOR= gnu + +GDC_VERSION= ${PORTVERSION} +SUFFIX= ${PORTVERSION:C/([0-9]+).*/\1/} +SSP_UNSAFE= yes +CFLAGS:= ${CFLAGS:N-mretpoline} +CXXFLAGS:= ${CXXFLAGS:N-mretpoline} + +OPTIONS_DEFINE= GOLD LTO SHARED QUADMATH DLANG FORCE_BOOTSTRAP +OPTIONS_DEFAULT= GOLD LTO SHARED QUADMATH DRUNTIME PHOBOS + +OPTIONS_GROUP= DLANG +OPTIONS_GROUP_DLANG= DRUNTIME PHOBOS +DLANG_DESC= D-lang related options + +GOLD_DESC= Enabled use of gold linker +GOLD_CONFIGURE_ENABLE= gold + +LTO_DESC= Use link time optimization +LTO_CONFIGURE_ENABLE= lto + +SHARED_DESC= Build shared libraries +SHARED_CONFIGURE_ENABLE=shared + +QUADMATH_DESC= Enable Quadmath support +QUADMATH_CONFIGURE_ENABLE=libquadmath + +FORCE_BOOTSTRAP_DESC= Force enable bootstrap build +FORCE_BOOTSTRAP_CONFIGURE_ENABLE=bootstrap + +DRUNTIME_DESC= Include d-runtime +DRUNTIME_ENABLE= druntime + +PHOBOS_DESC= Include phobos standard library +PHOBOS_ENABLE= phobos +DRUNTIME_IMPLIES= DRUNTIME + +OPTIONS_SUB= yes + +.if exists(/usr/lib32/libc.so) +MULTILIB_DESC= Build support for 32-bit and 64-bit targets +OPTIONS_DEFINE_amd64+= MULTILIB +OPTIONS_DEFINE_powerpc64+= MULTILIB +OPTIONS_DEFAULT_amd64+= MULTILIB +OPTIONS_DEFAULT_powerpc64+= MULTILIB +MULTILIB_CONFIGURE_ENABLE= multilib +USE_LDCONFIG32= yes +.else +CONFIGURE_ARGS+= --disable-multilib +.endif + +.include + +.if ${ARCH} == powerpc64 +CONFIGURE_ENV+= UNAME_m="powerpc64" +USE_GCC?= yes +.endif + +GNU_CONFIGURE= yes +GNU_CONFIGURE_PREFIX= ${PREFIX} +CONFIGURE_OUTSOURCE= yes +INSTALL_TARGET= install-strip + +.if ${UID} != 0 +BINMODE= 755 +.endif + +CONFIGURE_ARGS+= --disable-nls +CONFIGURE_ARGS+= --enable-gnu-indirect-function +CONFIGURE_ARGS+= --libdir=${TARGLIB} +CONFIGURE_ARGS+= --libexecdir=${LIBEXEC} +CONFIGURE_ARGS+= --with-as=${LOCALBASE}/bin/as +CONFIGURE_ARGS+= --with-ld=${LOCALBASE}/bin/ld +CONFIGURE_ARGS+= --with-gmp=${LOCALBASE} +CONFIGURE_ARGS+= --with-system-zlib +CONFIGURE_ARGS+= --enable-ld +CONFIGURE_ARGS+= --with-pkgversion="${OPSYS} Ports Collection -- DMD v2.0${PHOBOS_VERSION}.0" +CONFIGURE_ARGS+= --enable-languages=${LANGUAGES} +CONFIGURE_ARGS+= --prefix=${PKG_PREFIX:Q} +CONFIGURE_ARGS+= --enable-threads=posix +CONFIGURE_ARGS+= --enable-checking=release +#CONFIGURE_ARGS+= --build=${BLD_TARGET} + +MAKE_ARGS+= MAKEINFOFLAGS="--no-split" +USE_LDCONFIG= yes + +LANGUAGES:= d + +TARGBIN= ${CONFIGURE_TARGET}-${PKGNAME} +.if ${PREFIX} == ${LOCALBASE} +TARGLIB= ${PREFIX}/lib/gcc${SUFFIX} +TARGLIB32= ${PREFIX}/lib32 # The version information is during post-stage: +LIBEXEC= ${PREFIX}/libexec/gcc${SUFFIX} +.else +TARGLIB= ${PREFIX}/lib +TARGLIB32= ${PREFIX}/lib32 +LIBEXEC= ${PREFIX}/libexec +.endif + +PLIST_SUB+= GDC_VERSION=${GDC_VERSION} \ +PLIST_SUB+= SUFFIX=${SUFFIX} +PLIST_SUB+= TARGBIN=${TARGBIN} + +INFO= gdc +SUB_FILES= pkg-message +SUB_LIST+= TARGLIB=${TARGLIB} + +.if defined(MAINTAINER_MODE) +full-regression-test: build + cd ${TEST_WRKSRC}; ${MAKE_CMD} -sk check; ${WRKSRC}/contrib/test_summary +.endif + +pre-configure: + cd ${WRKSRC} ; contrib/gcc_update --touch + @${RM} ${WRKSRC}/gcc/*/*.info* + +post-stage: + ${RM} ${STAGEDIR}${PREFIX}/man/man7/* + ${RM} -r ${STAGEDIR}${PREFIX}/lib/gcc/${BLD_TARGET}/${GCC_VERSION}/include-fixed/ + ${RM} ${WRKDIR}/PLIST.lib + (cd ${STAGEDIR}${PREFIX}/bin && ${RM} cpp gcc-ar gcc-nm gcc-ranlib gcov* x86_64-portbld-dragonfly5.7-*) + (cd ${STAGEDIR}${PREFIX}/man/man1 && ${RM} cpp.1.gz gcc.1.gz gcov*.gz) + (cd ${STAGEDIR}${PREFIX}/share/info && ${RM} cpp.info cppinternals.info gcc*.info libgomp.info libquadmath.info) + ${INSTALL_PROGRAM} ${WRKSRC}/gdmd ${STAGEDIR}${PREFIX}/bin + + # Add 32-bit MULTILIB libries to destination +.if (${ARCH} == amd64 || ${ARCH} == powerpc64) && ${PORT_OPTIONS:MMULTILIB} + ${MKDIR} ${STAGEDIR}${TARGLIB32} + ${MV} ${STAGEDIR}${PREFIX}/lib/lib32 ${STAGEDIR}${TARGLIB32} +.endif + + # Add target libraries and include files to packaging list. +.for x in ${TARGLIB:S/^${PREFIX}\///} ${TARGLIB32:S/^${PREFIX}\///} ${LIBEXEC:S/^${PREFIX}\///} + cd ${STAGEDIR}${PREFIX} ; if [ -d $x ]; then \ + ${FIND} $x -type f -o -type l >>${WRKDIR}/PLIST.lib ;\ + fi +.endfor + cd ${WRKDIR} ; ${SED} -i -e "/PLIST.lib/ r PLIST.lib" ${TMPPLIST} + +post-install: + ${RM} ${PREFIX}/bin/${PKGNAME} + +.include diff --git a/ports/lang/gdc/newport/Makefile.DragonFly b/ports/lang/gdc/newport/Makefile.DragonFly new file mode 100644 index 000000000000..b67fd3135dbf --- /dev/null +++ b/ports/lang/gdc/newport/Makefile.DragonFly @@ -0,0 +1 @@ +ONLY_FOR_ARCHS= amd64 diff --git a/ports/lang/gdc/newport/distinfo b/ports/lang/gdc/newport/distinfo new file mode 100644 index 000000000000..ce0ad98fd2aa --- /dev/null +++ b/ports/lang/gdc/newport/distinfo @@ -0,0 +1,3 @@ +TIMESTAMP = 1574144270 +SHA256 (gcc-9.2.0.tar.xz) = ea6ef08f121239da5695f76c9b33637a118dcf63e24164422231917fa61fb206 +SIZE (gcc-9.2.0.tar.xz) = 70607648 diff --git a/ports/lang/gdc/newport/dragonfly/patch-gcc_config.gcc b/ports/lang/gdc/newport/dragonfly/patch-gcc_config.gcc new file mode 100644 index 000000000000..06ee0c277ee6 --- /dev/null +++ b/ports/lang/gdc/newport/dragonfly/patch-gcc_config.gcc @@ -0,0 +1,28 @@ +gcc/ChangeLog: + +2019-04-24 Iain Buclaw + + * config.gcc (*-*-dragonfly*): Add dragonfly-d.o + * config/dragonfly-d.c: New file. + * config/t-dragonfly: New file. + +libphobos/ChangeLog: + +2019-04-24 Iain Buclaw + + * configure.tgt: Add *-*-dragonfly* as a supported target. + +---diff --git gcc/config.gcc gcc/config.gcc +index 09fb9ecd2cd..14f0a1abbc8 100644 +--- gcc/config.gcc ++++ gcc/config.gcc +@@ -724,6 +724,9 @@ case ${target} in + extra_options="$extra_options rpath.opt dragonfly.opt" + default_use_cxa_atexit=yes + use_gcc_stdint=wrap ++ d_target_objs="${d_target_objs} dragonfly-d.o" ++ tmake_file="${tmake_file} t-dragonfly" ++ target_has_targetdm=yes + ;; + *-*-freebsd*) + # This is the generic ELF configuration of FreeBSD. Later diff --git a/ports/lang/gdc/newport/dragonfly/patch-gcc_config_dragonfly-d.c b/ports/lang/gdc/newport/dragonfly/patch-gcc_config_dragonfly-d.c new file mode 100644 index 000000000000..c49d7b1f50f7 --- /dev/null +++ b/ports/lang/gdc/newport/dragonfly/patch-gcc_config_dragonfly-d.c @@ -0,0 +1,69 @@ +gcc/ChangeLog: + +2019-04-24 Iain Buclaw + + * config.gcc (*-*-dragonfly*): Add dragonfly-d.o + * config/dragonfly-d.c: New file. + * config/t-dragonfly: New file. + +libphobos/ChangeLog: + +2019-04-24 Iain Buclaw + + * configure.tgt: Add *-*-dragonfly* as a supported target. + +diff --git gcc/config/dragonfly-d.c gcc/config/dragonfly-d.c +new file mode 100644 +index 00000000000..b8d4a9ff45d +--- /dev/null ++++ gcc/config/dragonfly-d.c +@@ -0,0 +1,49 @@ ++/* DragonFly 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_d.h" ++#include "d/d-target.h" ++#include "d/d-target-def.h" ++ ++/* Implement TARGET_D_OS_VERSIONS for DragonFly targets. */ ++ ++static void ++dragonfly_d_os_builtins (void) ++{ ++ d_add_builtin_version ("DragonFlyBSD"); ++ d_add_builtin_version ("Posix"); ++} ++ ++/* Implement TARGET_D_CRITSEC_SIZE for DragonFly targets. */ ++ ++static unsigned ++dragonfly_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 dragonfly_d_os_builtins ++ ++#undef TARGET_D_CRITSEC_SIZE ++#define TARGET_D_CRITSEC_SIZE dragonfly_d_critsec_size ++ ++struct gcc_targetdm targetdm = TARGETDM_INITIALIZER; diff --git a/ports/lang/gdc/newport/dragonfly/patch-gcc_config_t-dragonfly b/ports/lang/gdc/newport/dragonfly/patch-gcc_config_t-dragonfly new file mode 100644 index 000000000000..e728b21ec852 --- /dev/null +++ b/ports/lang/gdc/newport/dragonfly/patch-gcc_config_t-dragonfly @@ -0,0 +1,41 @@ +gcc/ChangeLog: + +2019-04-24 Iain Buclaw + + * config.gcc (*-*-dragonfly*): Add dragonfly-d.o + * config/dragonfly-d.c: New file. + * config/t-dragonfly: New file. + +libphobos/ChangeLog: + +2019-04-24 Iain Buclaw + + * configure.tgt: Add *-*-dragonfly* as a supported target. + +diff --git gcc/config/t-dragonfly gcc/config/t-dragonfly +new file mode 100644 +index 00000000000..34fc389d965 +--- /dev/null ++++ gcc/config/t-dragonfly +@@ -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 ++# . ++ ++dragonfly-d.o: $(srcdir)/config/dragonfly-d.c ++ $(COMPILE) $< ++ $(POSTCOMPILE) diff --git a/ports/lang/gdc/newport/dragonfly/patch-libphobos_configure.tgt b/ports/lang/gdc/newport/dragonfly/patch-libphobos_configure.tgt new file mode 100644 index 000000000000..ef54f28e4156 --- /dev/null +++ b/ports/lang/gdc/newport/dragonfly/patch-libphobos_configure.tgt @@ -0,0 +1,26 @@ +gcc/ChangeLog: + +2019-04-24 Iain Buclaw + + * config.gcc (*-*-dragonfly*): Add dragonfly-d.o + * config/dragonfly-d.c: New file. + * config/t-dragonfly: New file. + +libphobos/ChangeLog: + +2019-04-24 Iain Buclaw + + * configure.tgt: Add *-*-dragonfly* as a supported target. + +--- libphobos/configure.tgt 2019-06-28 18:28:59.000000000 -0700 ++++ libphobos/configure.tgt 2019-06-28 18:31:08.645273000 -0700 +@@ -23,6 +23,9 @@ + # broken systems. More targets shall be added after testing. + LIBPHOBOS_SUPPORTED=no + case "${target}" in ++ x86_64-*-dragonfly*) ++ LIBPHOBOS_SUPPORTED=yes ++ ;; + aarch64*-*-linux*) + LIBPHOBOS_SUPPORTED=yes + ;; diff --git a/ports/lang/gdc/newport/files/patch-arm-unwind-cxx-support b/ports/lang/gdc/newport/files/patch-arm-unwind-cxx-support new file mode 100644 index 000000000000..ec6959b9655c --- /dev/null +++ b/ports/lang/gdc/newport/files/patch-arm-unwind-cxx-support @@ -0,0 +1,106 @@ +--- UTC +Index: gcc/ginclude/unwind-arm-common.h +=================================================================== +--- gcc/ginclude/unwind-arm-common.h (revision 219113) ++++ gcc/ginclude/unwind-arm-common.h (working copy) +@@ -82,7 +82,11 @@ + + struct _Unwind_Control_Block + { ++#ifdef __FreeBSD__ ++ unsigned exception_class __attribute__((__mode__(__DI__))); ++#else + char exception_class[8]; ++#endif + void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block *); + /* Unwinder cache, private fields for the unwinder's use */ + struct +@@ -181,7 +185,11 @@ + + /* Support functions for the PR. */ + #define _Unwind_Exception _Unwind_Control_Block ++#ifdef __FreeBSD__ ++ typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__))); ++#else + typedef char _Unwind_Exception_Class[8]; ++#endif + + void * _Unwind_GetLanguageSpecificData (_Unwind_Context *); + _Unwind_Ptr _Unwind_GetRegionStart (_Unwind_Context *); +Index: libstdc++-v3/libsupc++/unwind-cxx.h +=================================================================== +--- libstdc++-v3/libsupc++/unwind-cxx.h (revision 219147) ++++ libstdc++-v3/libsupc++/unwind-cxx.h (working copy) +@@ -235,7 +235,7 @@ + return reinterpret_cast<__cxa_dependent_exception *>(exc + 1) - 1; + } + +-#ifdef __ARM_EABI_UNWINDER__ ++#if defined(__ARM_EABI_UNWINDER__) && !defined(__FreeBSD__) + static inline bool + __is_gxx_exception_class(_Unwind_Exception_Class c) + { +@@ -309,13 +309,7 @@ + c[6] = 'R'; + c[7] = '\0'; + } +- +-static inline void* +-__gxx_caught_object(_Unwind_Exception* eo) +-{ +- return (void*)eo->barrier_cache.bitpattern[0]; +-} +-#else // !__ARM_EABI_UNWINDER__ ++#else // !__ARM_EABI_UNWINDER__ || __FreeBSD__ + // This is the primary exception class we report -- "GNUCC++\0". + const _Unwind_Exception_Class __gxx_primary_exception_class + = ((((((((_Unwind_Exception_Class) 'G' +@@ -339,6 +333,16 @@ + << 8 | (_Unwind_Exception_Class) '+') + << 8 | (_Unwind_Exception_Class) '\x01'); + ++const _Unwind_Exception_Class __gxx_forced_unwind_class ++= ((((((((_Unwind_Exception_Class) 'G' ++ << 8 | (_Unwind_Exception_Class) 'N') ++ << 8 | (_Unwind_Exception_Class) 'U') ++ << 8 | (_Unwind_Exception_Class) 'C') ++ << 8 | (_Unwind_Exception_Class) 'F') ++ << 8 | (_Unwind_Exception_Class) 'O') ++ << 8 | (_Unwind_Exception_Class) 'R') ++ << 8 | (_Unwind_Exception_Class) '\0'); ++ + static inline bool + __is_gxx_exception_class(_Unwind_Exception_Class c) + { +@@ -346,6 +350,12 @@ + || c == __gxx_dependent_exception_class; + } + ++static inline bool ++__is_gxx_forced_unwind_class(_Unwind_Exception_Class c) ++{ ++ return c == __gxx_forced_unwind_class; ++} ++ + // Only checks for primary or dependent, but not that it is a C++ exception at + // all. + static inline bool +@@ -357,7 +367,18 @@ + #define __GXX_INIT_PRIMARY_EXCEPTION_CLASS(c) c = __gxx_primary_exception_class + #define __GXX_INIT_DEPENDENT_EXCEPTION_CLASS(c) \ + c = __gxx_dependent_exception_class ++#define __GXX_INIT_FORCED_UNWIND_CLASS(c) c = __gxx_forced_unwind_class ++#endif // __ARM_EABI_UNWINDER__ && !__FreeBSD__ + ++#ifdef __ARM_EABI_UNWINDER__ ++static inline void* ++__gxx_caught_object(_Unwind_Exception* eo) ++{ ++ return (void*)eo->barrier_cache.bitpattern[0]; ++} ++ ++#else // !__ARM_EABI_UNWINDER__ ++ + // GNU C++ personality routine, Version 0. + extern "C" _Unwind_Reason_Code __gxx_personality_v0 + (int, _Unwind_Action, _Unwind_Exception_Class, diff --git a/ports/lang/gdc/newport/files/patch-d-freebsd_PR87818 b/ports/lang/gdc/newport/files/patch-d-freebsd_PR87818 new file mode 100644 index 000000000000..f78a8c7458a5 --- /dev/null +++ b/ports/lang/gdc/newport/files/patch-d-freebsd_PR87818 @@ -0,0 +1,133 @@ +gcc/ChangeLog: + +2019-04-24 Iain Buclaw + + PR d/87818 + * config.gcc (*-*-freebsd*): Add freebsd-d.o + * config/freebsd-d.c: New file. + * config/t-freebsd: New file. + +libphobos/ChangeLog: + +2019-04-24 Iain Buclaw + + PR d/87818 + * configure.tgt: Add x86_64-*-freebsd* and i?86-*-freebsd* as + supported targets. + +--- +diff --git gcc/config.gcc gcc/config.gcc +index 14f0a1abbc8..7a286bbaa50 100644 +--- gcc/config.gcc ++++ 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 gcc/config/freebsd-d.c gcc/config/freebsd-d.c +new file mode 100644 +index 00000000000..cdff544d20c +--- /dev/null ++++ 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 gcc/config/t-freebsd gcc/config/t-freebsd +new file mode 100644 +index 00000000000..15fcf226d08 +--- /dev/null ++++ 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 libphobos/configure.tgt libphobos/configure.tgt +index f9c881a8418..2dc05e2cc51 100644 +--- libphobos/configure.tgt ++++ 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 + ;; diff --git a/ports/lang/gdc/newport/files/patch-gdmd b/ports/lang/gdc/newport/files/patch-gdmd new file mode 100644 index 000000000000..719ecfe8a242 --- /dev/null +++ b/ports/lang/gdc/newport/files/patch-gdmd @@ -0,0 +1,768 @@ +Imported from https://github.com/D-Programming-GDC/gdmd/ + +Changed hash bang line to use /usr/bin/env +Index: gdmd +=================================================================== +--- /dev/null 2019-07-08 03:21:38.532650395 -0700 ++++ gdmd 2019-07-08 03:25:19.001820000 -0700 +@@ -0,0 +1,760 @@ ++#!/usr/bin/env perl -w ++ ++# GDC -- D front-end for GCC ++# Copyright (C) 2011, 2012 Free Software Foundation, Inc. ++# ++# This program 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 of the License, or ++# (at your option) any later version. ++# ++# This program 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 ++# . ++ ++# This is a wrapper script for gdc that emulates the dmd command. ++# -f and -m options are passed to gdc. Extra options are: ++# ++# -vdmd Print commands executed by this wrapper script ++# -q,[,,,...] Pass the comma-separated arguments to gdc ++ ++ ++use strict; ++use warnings; ++use Cwd qw(abs_path); ++use FindBin qw($Bin); ++use File::Basename; ++use File::Spec; ++use File::Path; ++use File::Temp qw(tempdir); ++ ++my $output_directory; ++my $output_parents; ++my $output_file; ++my $header_directory; ++my $header_file; ++my $documentation_directory; ++my $documentation_file; ++my $debug = 0; ++my $link = 1; ++my $header = 0; ++my $documentation = 0; ++my $json = 0; ++my $json_file; ++my $map = 0; ++my $map_file; ++my $run = 0; ++my $verbose = 0; ++my $show_commands = 0; ++my $print_version = 0; ++my $seen_all_sources_flag = 0; ++my $first_input_file; ++my $combine = 0; # Compile multiple sources into a single object file ++my $lib = 0; ++my $tmpdir; ++my %tmpdir_objs; ++my $stdin = 0; ++ ++my @sources; ++my @objects; ++my @dobjects; ++ ++my @out; ++my @link_out; ++my @run_args; ++ ++# Use the gdc executable in the same directory as this script and account ++# for the target prefix. ++basename($0) =~ m/^(.*-)?g?dmd(-.*)?$/; ++my $target_prefix = $1?$1:""; ++my $gdc_dir = abs_path(dirname($0)); ++my $gdc = File::Spec->catfile( $gdc_dir, $target_prefix . "gdc" . ($2?$2:"")); ++ ++sub osHasEXE() { ++ return $^O =~ m/MS(DOS|Win32)|os2/i; # taken from File::Basename ++} ++ ++sub targetHasEXE() { ++ my $target = `$gdc -dumpmachine`; ++ return $target =~ m/mingw/ || $target =~ m/cygwin/; ++} ++ ++sub pathSep() { ++ return ";" if $^O =~ m/MS(DOS|Win32)/i; ++ return "," if $^O =~ m/MacOS/i; ++ return ":"; ++} ++ ++sub expandHome($) { ++ my ($path) = (@_); ++ if ( $^O !~ m/MS(DOS|Win32)|MacOS/i ) { ++ $path =~ s/^~/$ENV{HOME}/; ++ } ++ return $path; ++} ++ ++sub printUsage() { ++ print <= level ++ -version=ident compile in version code identified by ident ++ -vtls list all variables going into thread local storage ++ -w enable warnings ++ -wi enable informational warnings ++ -X generate JSON file ++ -Xffilename write JSON file to filename ++EOF ++; ++} ++ ++sub errorExit(@) { ++ print STDERR "gdmd: ", @_, "\n" if @_; ++ exit 1; ++} ++use subs qw(errorExit); ++ ++sub readINI { ++ # look for dmd.conf in the following sequence of directories: ++ # - current working directory ++ # - directory specified by the HOME environment variable ++ # - directory gdmd resides in ++ # - /etc directory ++ my @confpaths = ("./", "$ENV{HOME}/", "$Bin/", "/etc/"); ++ my $dmdconfpath = ""; ++ my $dmdconf = ""; ++ ++ foreach my $confpath (@confpaths) { ++ if (-e $confpath."dmd.conf") { ++ $dmdconfpath = $confpath; ++ $dmdconf = $confpath."dmd.conf"; ++ last; ++ } ++ } ++ ++ if (-e $dmdconf) { ++ open(DMDCONF, "<$dmdconf"); ++ my $envsection = 0; ++ ++ while() { ++ # Ignore all lines up to [Environment] section ++ if ($_ =~ /^\s*\[\s*Environment\s*\]\s*$/) { ++ $envsection = 1; ++ next; ++ } ++ next if (!$envsection); ++ ++ # Ignore comments ++ next if ($_ =~ /^\s*;/); ++ # Ignore empty lines ++ next if ($_ =~ /^\s*$/); ++ ++ # Check correct syntax ++ $_ =~ /^\s*(\S+?)\s*=\s*(.*)\s*$/; ++ if ($&) { ++ my $VAR = $1; ++ my $VAL = $2; ++ # The special name %@P% is replaced with the path to dmd.conf ++ $VAL =~ s/%\@P%/$dmdconfpath/g; ++ # Names enclosed by %% are searched for in the existing environment and inserted ++ while ($VAL =~ /%(\S+?)%/) { ++ my $envp = $1; ++ if ($ENV{$envp}) { ++ $VAL =~ s/%$envp%/$ENV{$envp}/g; ++ } else { ++ $VAL =~ s/%$envp%//g; ++ } ++ } ++ $ENV{$VAR} = "$VAL"; ++ } else { ++ errorExit "syntax error at line $. in file $dmdconf"; ++ } ++ } ++ close DMDCONF; ++ } ++} ++ ++my $gcc_version = `$gdc -dumpversion`; ++my $gcc_maj; ++my $gcc_min; ++ ++chomp $gcc_version; ++if ($gcc_version =~ m/^\d+$/) { ++ ($gcc_maj, $gcc_min) = ($gcc_version, 0); ++} else { ++ ($gcc_maj, $gcc_min) = ($gcc_version =~ m/^(\d+)\.(\d+)/); ++} ++ ++#my $target_machine = `$gdc -dumpmachine`; ++#chomp $target_machine; ++ ++sub addSourceFile($) { ++ my ($arg) = @_; ++ $first_input_file = $arg if ! $first_input_file; ++ push @sources, $arg; ++} ++ ++sub argCheck($$) { ++ my ($name,$arg) = @_; ++ errorExit "argument expected for switch '$name'" unless defined $arg; ++} ++ ++sub determineARexe() { ++ my $name = $target_prefix . 'ar'; ++ $name .= '.exe' if (osHasEXE()); ++ ++ # Prefer the 'ar' in the same directory as gdc even if there is no ++ # target prefix. ++ my $path = File::Spec->catfile( $gdc_dir, $name ); ++ return $path if -x $path; ++ ++ if ( length $target_prefix ) { ++ foreach my $dir (split pathSep, $ENV{PATH}) { ++ $path = File::Spec->catfile( $dir, $name ); ++ return $name if -x $path; # Could return $path, but this looks better ++ } ++ errorExit "Could not find archiver command '$name'."; ++ } else { ++ return "ar"; ++ } ++} ++ ++sub determineARcommand() { ++ my @exe = determineARexe(); ++ return (@exe, 'cru'); ++} ++ ++sub browse($) { ++ my ($url) = @_; ++ my @cmd; ++ ++ if ($^O =~ m/MSWin32/i) { ++ @cmd = qw(cmd /c start); ++ } elsif ($^O =~ m/darwin/i && ++ -x '/usr/bin/open') { # MacOS X vs. just Darwin ++ @cmd = 'open'; ++ } elsif ($ENV{KDE_FULL_SESSION} eq 'true') { ++ @cmd = qw(kfmclient exec); ++ } elsif ($ENV{GNOME_DESKTOP_SESSION_ID} ne '') { ++ @cmd = 'gnome-open'; ++ } else { ++ errorExit "Sorry, I do not know how to start your browser.\nManual URL: $url" ++ } ++ push @cmd, $url; ++ system @cmd; ++ print "Opening documentation page."; ++ exit 0; ++} ++ ++# Load dmd.conf before before parsing arguments. ++readINI(); ++ ++if ($ENV{DFLAGS}) { ++ push @ARGV, split /\s+/, $ENV{DFLAGS}; ++} ++ ++my $arg_i = 0; ++while ( $arg_i < scalar(@ARGV) ) { ++ my $arg = $ARGV[$arg_i++]; ++ ++ if ($arg eq '-arch' ) { ++ push @out, '-arch', $ARGV[$arg_i++]; ++ } elsif ( $arg =~ m/^-betterC$/ ) { ++ # ignored ++ } elsif ($arg =~ m/^-c$/ ) { ++ $link = 0; ++ } elsif ( $arg eq '-cov' ) { ++ push @out, '-fprofile-arcs', '-ftest-coverage'; ++ } elsif ( $arg =~ m/^-D$/ ) { ++ $documentation = 1; ++ } elsif ( $arg =~ m/^-Dd(.*)$/ ) { ++ $documentation = 1; ++ $documentation_directory = $1; ++ } elsif ( $arg =~ m/^-Df(.*)$/ ) { ++ $documentation = 1; ++ $documentation_file = $1; ++ } elsif ( $arg =~ m/^-d$/ ) { ++ push @out, '-Wno-deprecated'; ++ } elsif ( $arg =~ m/^-de$/ ) { ++ push @out, '-Wdeprecated', '-Werror'; ++ } elsif ( $arg =~ m/^-dw$/ ) { ++ push @out, '-Wdeprecated'; ++ } elsif ( $arg =~ m/^-debug(?:=(.*))?$/ ) { ++ push @out, (defined($1) ? "-fdebug=$1" : '-fdebug'); ++ } elsif ( $arg =~ m/^-debuglib=(.*)$/ ) { ++ push @link_out, '-debuglib', $1; ++ } elsif ( $arg =~ m/^-debug.*$/ ) { ++ # Passing this to gdc only gives warnings; exit with an error here ++ errorExit "unrecognized switch '$arg'"; ++ } elsif ( $arg =~ m/^-defaultlib=(.*)$/ ) { ++ push @link_out, '-defaultlib', $1; ++ } elsif ( $arg =~ m/^-deps=(.*)$/ ) { ++ push @out, (defined($1) ? "-fdeps=$1" : '-fdeps'); ++ } elsif ( $arg =~ m/^-g$|^-gc$/ ) { ++ $debug = 1; ++ push @out, '-g'; ++ } elsif ( $arg =~ m/^-gs$/ ) { ++ push @out, '-fno-omit-frame-pointer'; ++ } elsif ( $arg =~ m/^-gt$/ ) { ++ errorExit "use -profile instead of -gt"; ++ push @out, '-pg'; ++ } elsif ( $arg =~ m/^-gx$/ ) { ++ push @out, '-fstack-protector'; ++ } elsif ( $arg =~ m/^-H$/ ) { ++ $header = 1; ++ } elsif ( $arg =~ m/^-Hd(.*)$/ ) { ++ $header = 1; ++ $header_directory = $1; ++ } elsif ( $arg =~ m/^-Hf(.*)$/ ) { ++ $header = 1; ++ $header_file = $1; ++ } elsif ( $arg eq '--help' ) { ++ printUsage; ++ exit 0; ++ } elsif ($arg eq '-framework' ) { ++ push @link_out, '-framework', $ARGV[$arg_i++]; ++ } elsif ( $arg eq '-ignore' ) { ++ push @out, '-fignore-unknown-pragmas'; ++ } elsif ( $arg eq '-property' ) { ++ push @out, '-fproperty'; ++ } elsif ( $arg =~ m/^-inline$/ ) { ++ push @out, '-finline-functions'; ++ } elsif ( $arg =~ m/^-I(.*)$/ ) { ++ foreach my $i (split pathSep, $1) { ++ push @out, '-I', expandHome $i; ++ } ++ } elsif ( $arg =~ m/^-J(.*)$/ ) { ++ foreach my $i (split pathSep, $1) { ++ push @out, '-J', expandHome $i; ++ } ++ } elsif ( $arg =~ m/^-L(.*)$/ ) { ++ push @link_out, '-Wl,' . $1; ++ } elsif ( $arg eq '-lib' ) { ++ $lib = 1; ++ $link = 0; ++ $tmpdir = tempdir(CLEANUP => 1); ++ } elsif ( $arg =~ m/^-O$/ ) { ++ push @out, '-O2'; ++ } elsif ( $arg =~ m/^-o-$/ ) { ++ push @out, '-fsyntax-only'; ++ $link = 0; ++ } elsif ( $arg =~ m/^-od(.*)$/ ) { ++ $output_directory = $1; ++ } elsif ( $arg =~ m/^-of(.*)$/ ) { ++ $output_file = $1; ++ } elsif ( $arg =~ m/^-op$/ ) { ++ $output_parents = 1; ++ } elsif ( $arg =~ m/^-pipe$/ ) { ++ push @out, '-pipe'; ++ } elsif ( $arg =~ m/^-profile$/ ) { ++ # there is more to profiling than this ... -finstrument-functions? ++ push @out, '-pg'; ++ } elsif ( $arg =~ m/^-release$/ ) { ++ push @out, '-frelease'; ++ } elsif ( $arg eq '-run' ) { ++ $run = 1; ++ ++ $arg = $ARGV[$arg_i++]; ++ argCheck '-run', $arg; ++ ++ addSourceFile $arg; ++ ++ push @run_args, @ARGV[$arg_i..$#ARGV]; ++ last; ++ } elsif ( $arg =~ m/^-noboundscheck$/ ) { ++ push @out, '-fno-bounds-check'; ++ } elsif ( $arg =~ m/^-unittest$/ ) { ++ push @out, '-funittest'; ++ } elsif ( $arg =~ m/^-v$/ ) { ++ $verbose = 1; ++ if ($gcc_maj >= 8) { ++ push @out, '--verbose'; ++ } else { ++ push @out, '-fd-verbose'; ++ } ++ } elsif ( $arg =~ m/^-vtls$/ ) { ++ if ($gcc_maj >= 8) { ++ push @out, '-ftransition=tls'; ++ } else { ++ push @out, '-fd-vtls'; ++ } ++ } elsif ( $arg =~ m/^-v1$/ ) { ++ push @out, '-fd-version=1'; ++ } elsif ( $arg =~ m/^--version$/ ) { ++ $print_version = 1; ++ } elsif ( $arg =~ m/^-version=(.*)$/ ) { ++ push @out, "-fversion=$1"; ++ } elsif ( $arg =~ m/^-version.*$/ ) { ++ errorExit "unrecognized switch '$arg'"; ++ } elsif ( $arg =~ m/^-vdmd$/ ) { ++ $show_commands = 1; ++ } elsif ( $arg =~ m/^-w$/ ) { ++ push @out, "-Werror"; ++ } elsif ( $arg =~ m/^-wi$/ ) { ++ push @out, "-Wall"; ++ } elsif ( $arg =~ m/^-quiet$/ ) { ++ # ignored ++ } elsif ( $arg =~ m/^-q,(.*)$/ ) { ++ push @out, split(qr/,/, $1); ++ } elsif ( $arg =~ m/^-X$/ ) { ++ $json = 1; ++ } elsif ( $arg =~ m/^-Xf(.*)$/ ) { ++ $json = 1; ++ $json_file = $1; ++ } elsif ( $arg eq '-fall-sources' ) { ++ $seen_all_sources_flag = 1; ++ } elsif ( $arg =~ m/^-f.+/ ) { ++ # Pass -fxxx options ++ push @out, $arg; ++ } elsif ($arg eq '-man') { ++ browse("http://www.gdcproject.org/wiki/UserDocumentation"); ++ exit 0; ++ } elsif ( $arg =~ m/^-map$/ ) { ++ $map = 1; ++ if ($ARGV[$arg_i] =~ m/.map$/ ) { ++ $map_file = $ARGV[$arg_i++]; ++ } ++ } elsif ( $arg =~ m/^-m.+/ ) { ++ # Pass -mxxx options ++ push @out, $arg; ++ } elsif ( $arg =~ m/^-.+$/ ) { ++ errorExit "unrecognized switch '$arg'"; ++ } elsif ( $arg =~ m/^.+\.d$/i || ++ $arg =~ m/^.+\.dd$/i || ++ $arg =~ m/^.+\.di$/i) { ++ addSourceFile $arg; ++ } elsif ( $arg =~ m/^.+\.ddoc/i ) { ++ push @out, "-fdoc-inc=$arg"; ++ } elsif ( $arg eq '-' ) { ++ push @out, "-x"; ++ push @out, 'd'; ++ push @out, '-'; ++ $stdin = 1; ++ } elsif ( $arg !~ m/\./ ) { ++ addSourceFile $arg . ".d"; ++ } elsif ( $arg =~ m/^(.+)(\.exe)$/i ) { ++ $first_input_file = $arg if ! $first_input_file; ++ $output_file = $1; ++ if ( targetHasEXE() ) { ++ $output_file .= $2; ++ } ++ } elsif ( $arg =~ m/^\@(.+\.rsp)$/i ) { ++ # Append response file to end of ARGV. ++ open(RSP, $1) or die("Can't read response file: $!"); ++ my $rsp = ; ++ close(RSP); ++ ++ while (length $rsp) { ++ if ($rsp =~ m/^"(([^\\"]|\\.)*(\\\\)*)"\s*/ ) { ++ $arg = $1; ++ $rsp = $'; ++ $arg =~ s/\\"/"/g; ++ $arg =~ s/(\\)+\1$/$1/g; ++ } else { ++ $rsp =~ m/^(\S*)\s*/; ++ $arg = $1; ++ $rsp = $'; ++ } ++ push @ARGV, $arg; ++ } ++ } else { ++ push @objects, $arg ++ } ++} ++ ++if ($link || (! $lib && $output_file && scalar(@sources) > 1)) { ++ $combine = 1; ++} ++ ++if ( $run && ! $link ) { ++ errorExit "flags conflict with -run"; ++} ++ ++if ( $stdin && ! $output_file && $output_directory ) { ++ $output_file = "$output_directory/a.out" ++} ++ ++if ( $output_file ) { ++ my $dir = dirname( $output_file ); ++ eval { mkpath( $dir ) }; ++ if ($@) { ++ errorExit "could not create $dir: $@"; ++ } ++} ++ ++if ( ($link || $lib) && ! $output_file && $first_input_file ) { ++ $output_file = fileparse( $first_input_file, qr/\..*$/ ); ++ if ( $link && targetHasEXE() ) { ++ $output_file .= '.exe'; ++ } elsif ( $lib ) { ++ $output_file .= '.a'; ++ } ++} ++ ++if ( $print_version ) { ++ my @cmd = ($gdc, '--version', @out); ++ my $result = system(@cmd); ++ errorExit if $result & 0xff; # Give up if can't exec or gdc exited with a signal ++ exit 0; ++} elsif (! scalar(@sources) && ! $stdin && ! (($link || $lib) && scalar(@objects))) { ++ my @cmd = ($gdc, '--version', @out); ++ my $result = system(@cmd); ++ errorExit if $result & 0xff; # Give up if can't exec or gdc exited with a signal ++ printUsage; ++ exit 1; ++} ++ ++my $ok = 1; ++ ++foreach my $srcf_i (@sources) { ++ # Step 1: Determine the object file path ++ my $outf; ++ my $hdrd; ++ my $docd; ++ my $srcf = $srcf_i; # To avoid modifying elements of @sources ++ my @outbits; ++ my @hdrbits; ++ my @docbits; ++ ++ if ( $lib ) { ++ # Generate a unique name in the temporary directory. The -op argument ++ # is ignored in this case and there could very well be duplicate base ++ # names. ++ my $base = basename( $srcf, '.d' ); ++ my $i = 1; ++ $outf = $base . '.o'; ++ while ( defined $tmpdir_objs{$outf} ) { ++ $outf = $base . '-' . $i++ . '.o'; ++ } ++ $tmpdir_objs{$outf} = 1; ++ ++ $outf = File::Spec->catfile( $tmpdir, $outf ); ++ } elsif ( ! ($link || $lib) && $output_file ) { ++ $outf = $output_file; ++ } else { ++ if ( $output_directory ) { ++ push @outbits, $output_directory; ++ } ++ if ( $output_parents ) { ++ push @outbits, dirname( $srcf ); ++ } ++ ++ if ( scalar( @outbits )) { ++ my $dir = File::Spec->catfile( @outbits ); ++ eval { mkpath($dir) }; ++ if ($@) { ++ errorExit "could not create $dir: $@"; ++ } ++ } ++ ++ # Note: There is currently no ($combine && $lib) case to check ++ if ( $combine && $link) { ++ push @outbits, basename( $output_file, '.exe' ) . '.o'; ++ } else { ++ push @outbits, basename( $srcf, '.d' ) . '.o'; ++ } ++ $outf = File::Spec->catfile( @outbits ); ++ if ( $combine && $link && $outf eq $output_file) { ++ $outf .= '.o'; ++ } ++ } ++ ++ if ($header) { ++ if ( $header_directory ) { ++ push @hdrbits, $header_directory; ++ } ++ if ( $output_parents ) { ++ push @hdrbits, dirname( $srcf ); ++ } ++ ++ if ( scalar( @hdrbits )) { ++ $hdrd = File::Spec->catfile( @hdrbits ); ++ eval { mkpath($hdrd) }; ++ if ($@) { ++ errorExit "could not create $hdrd: $@"; ++ } ++ } ++ } ++ ++ if ($documentation) { ++ if ( $documentation_directory ) { ++ push @docbits, $documentation_directory; ++ } ++ if ( $output_parents ) { ++ push @docbits, dirname( $srcf ); ++ } ++ ++ if ( scalar( @docbits )) { ++ $docd = File::Spec->catfile( @docbits ); ++ eval { mkpath($docd) }; ++ if ($@) { ++ errorExit "could not create $docd: $@"; ++ } ++ } ++ } ++ ++ if ($json) { ++ if (! $json_file) { ++ $json_file = substr($first_input_file, 0, length($first_input_file)-2) . ".json"; ++ } ++ if ($gcc_maj >= 8) { ++ push @out, '-Xf' . $json_file; ++ } else { ++ push @out, '-fXf=' . $json_file; ++ } ++ } ++ ++ if ($map) { ++ if (! $map_file) { ++ $map_file = substr($first_input_file, 0, length($first_input_file)-2) . ".map"; ++ } ++ # Check for Mac (Untested) ++ if ($^O =~ m/darwin/i) { ++ push @link_out, '-Wl,-map=' . $map_file; ++ } else { ++ push @link_out, '-Wl,-Map=' . $map_file; ++ } ++ } ++ ++ push @dobjects, $outf; ++ ++ my @source_args; ++ if ( $combine ) { ++ if ($gcc_maj == 4 && $gcc_min <= 5) { ++ push @source_args, "-combine"; ++ } ++ push @source_args, @sources; ++ } elsif ( $seen_all_sources_flag ) { ++ @source_args = (@sources, "-fonly=$srcf"); ++ } else { ++ @source_args = $srcf; ++ } ++ ++ my @interface; ++ if ( $header ) { ++ push @interface, '-fintfc'; ++ push @interface, "-fintfc-dir=$hdrd" if $hdrd; ++ push @interface, "-fintfc-file=$header_file" if $header_file; ++ } ++ ++ my @documentation; ++ if ( $documentation ) { ++ push @documentation, '-fdoc'; ++ push @documentation, "-fdoc-dir=$docd" if $docd; ++ push @documentation, "-fdoc-file=$documentation_file" if $documentation_file; ++ } ++ ++ # Step 2: Run the compiler driver ++ my @cmd = ($gdc, @out, '-c', @source_args, '-o', $outf, @interface, @documentation); ++ if ( $show_commands ) { ++ print join(' ', @cmd), "\n"; ++ } ++ my $result = system(@cmd); ++ errorExit if $result & 0xff; # Give up if can't exec or gdc exited with a signal ++ $ok = $ok && $result == 0; ++ ++ last if $combine; ++} ++ ++if ($ok && ($link || $stdin)) { ++ my @cmd = ($gdc, @out, @dobjects, @objects, @link_out); ++ if ( $output_file ) { ++ push @cmd, '-o', $output_file; ++ } ++ if ( $show_commands ) { ++ print join(' ', @cmd), "\n"; ++ } ++ $ok = $ok && system(@cmd) == 0; ++} elsif ($ok && $lib) { ++ my @ar_cmd = determineARcommand(); ++ my $outf = $output_file; ++ if ( $output_directory ) { ++ $outf = File::Spec->catfile($output_directory, $output_file); ++ } ++ my @cmd = (@ar_cmd, $outf, @dobjects, @objects); ++ if ( $show_commands ) { ++ print join(' ', @cmd), "\n"; ++ } ++ $ok = $ok && system(@cmd) == 0; ++} ++ ++if ($ok && $run) { ++ my @cmd = (abs_path($output_file), @run_args); ++ if ($verbose) { ++ print join(' ', @cmd), "\n"; ++ } ++ my $result = system @cmd; ++ unlink ($output_file, @dobjects); ++ if ($result == -1) { ++ print STDERR "$output_file: $!\n"; ++ exit 127; ++ } elsif ($result & 127) { ++ exit 128 + ($result & 127); ++ } else { ++ exit $result >> 8; ++ } ++} ++ ++exit ($ok ? 0 : 1); diff --git a/ports/lang/gdc/newport/files/patch-gets-no-more b/ports/lang/gdc/newport/files/patch-gets-no-more new file mode 100644 index 000000000000..4b49aba3ca28 --- /dev/null +++ b/ports/lang/gdc/newport/files/patch-gets-no-more @@ -0,0 +1,47 @@ +Disable the build/use of libssp/gets-chk since FreeBSD 12 and later +do not feature gets() any longer. + +--- UTC +Index: libssp/Makefile.am +=================================================================== +--- libssp/Makefile.am (revision 263319) ++++ libssp/Makefile.am (working copy) +@@ -42,7 +42,7 @@ + nobase_libsubinclude_HEADERS = ssp/ssp.h ssp/string.h ssp/stdio.h ssp/unistd.h + + libssp_la_SOURCES = \ +- ssp.c gets-chk.c memcpy-chk.c memmove-chk.c mempcpy-chk.c \ ++ ssp.c memcpy-chk.c memmove-chk.c mempcpy-chk.c \ + memset-chk.c snprintf-chk.c sprintf-chk.c stpcpy-chk.c \ + strcat-chk.c strcpy-chk.c strncat-chk.c strncpy-chk.c \ + vsnprintf-chk.c vsprintf-chk.c +Index: libssp/Makefile.in +=================================================================== +--- libssp/Makefile.in (revision 263319) ++++ libssp/Makefile.in (working copy) +@@ -108,7 +108,7 @@ + am__installdirs = "$(DESTDIR)$(toolexeclibdir)" \ + "$(DESTDIR)$(libsubincludedir)" + LTLIBRARIES = $(toolexeclib_LTLIBRARIES) +-am_libssp_la_OBJECTS = ssp.lo gets-chk.lo memcpy-chk.lo memmove-chk.lo \ ++am_libssp_la_OBJECTS = ssp.lo memcpy-chk.lo memmove-chk.lo \ + mempcpy-chk.lo memset-chk.lo snprintf-chk.lo sprintf-chk.lo \ + stpcpy-chk.lo strcat-chk.lo strcpy-chk.lo strncat-chk.lo \ + strncpy-chk.lo vsnprintf-chk.lo vsprintf-chk.lo +@@ -291,7 +291,7 @@ + libsubincludedir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/include + nobase_libsubinclude_HEADERS = ssp/ssp.h ssp/string.h ssp/stdio.h ssp/unistd.h + libssp_la_SOURCES = \ +- ssp.c gets-chk.c memcpy-chk.c memmove-chk.c mempcpy-chk.c \ ++ ssp.c memcpy-chk.c memmove-chk.c mempcpy-chk.c \ + memset-chk.c snprintf-chk.c sprintf-chk.c stpcpy-chk.c \ + strcat-chk.c strcpy-chk.c strncat-chk.c strncpy-chk.c \ + vsnprintf-chk.c vsprintf-chk.c +@@ -452,7 +452,6 @@ + distclean-compile: + -rm -f *.tab.c + +-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gets-chk.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libssp_nonshared_la-ssp-local.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memcpy-chk.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memmove-chk.Plo@am__quote@ diff --git a/ports/lang/gdc/newport/files/patch-gfortran-libgcc b/ports/lang/gdc/newport/files/patch-gfortran-libgcc new file mode 100644 index 000000000000..89c6cb902c42 --- /dev/null +++ b/ports/lang/gdc/newport/files/patch-gfortran-libgcc @@ -0,0 +1,70 @@ +GCC has two runtime libraries: The static library libgcc.a (-lgcc) and +the shared library libgcc_s.so (-lgcc_s). Both implement many of the +same functions but they also each have their unique functions. When +gcc links programs and libraries there are three possibilities: + +1. gcc -static-libgcc or gcc -static: -lgcc + => Just use libgcc.a. + +2. gcc -shared-libgcc: -lgcc_s -lgcc + => Link with libgcc_s first, so libgcc.a is only used for its unique + functions. + +3. gcc: -lgcc -Wl,--as-needed -lgcc_s -Wl,--no-as-needed + => Link with libgcc.a first so libgcc_s is only used for its unique + functions (_Unwind_* functions). + +Approach 3 is the default for gcc and it's also what clang and clang++ use; +approach 2 is the default for gfortran, g++ and probably other front ends. + +This patch makes 3 the default for gfortran. It significantly reduces +the use of libgcc_s. The _Unwind_* functions are also available in the +old base system libgcc_s which means this reduces the need for +-rpath /usr/local/lib/gccN in ports that depend on libraries built with +gfortran. Consider a dependency tree like this: + + prog -> libA -> libgcc_s (old base system libgcc_s is fine) + -> libB -> libgcc_s (libB built with gfortran, needs new libgcc_s) + +Here prog needs to be linked with -rpath /usr/local/lib/gccN even if it's +a normal C program compiled with clang. Without -rpath it will fail to +start because it loads old libgcc_s first as a dependency of libA and then +it fails to load libB. With this patch libB works with old base system +libgcc_s or may not need libgcc_s at all, so prog does not need to be +linked with -rpath. + +Upstream is unlikely accept a patch like this because libgfortran calls +some _Unwind_* functions and so always needs libgcc_s. Also because +every Fortran program and library links to libgfortran it makes sense +that option 2 above is the default. On FreeBSD where clang and GCC +compiled code can be mixed and where multiple libgcc_s may be installed, +option 3 is just a lot easier to deal with. + +The bug that sparked this is PR 208120 (but note there's a lot of +misleading information in that bug. CMake is not actually doing +anything wrong.) + +--- UTC +--- gcc/fortran/gfortranspec.c.orig 2015-06-26 17:47:23 UTC ++++ gcc/fortran/gfortranspec.c +@@ -404,7 +404,7 @@ For more information about these matters + } + } + +-#ifdef ENABLE_SHARED_LIBGCC ++#if 0 + if (library) + { + unsigned int i; + +--- libgfortran/Makefile.in.orig 2019-02-22 14:22:13.000000000 +0000 ++++ libgfortran/Makefile.in 2019-02-27 16:27:08.856408000 +0000 +@@ -625,7 +625,7 @@ + $(LTLDFLAGS) $(LIBQUADLIB) ../libbacktrace/libbacktrace.la \ + $(HWCAP_LDFLAGS) \ + -lm $(extra_ldflags_libgfortran) \ +- $(version_arg) -Wc,-shared-libgcc ++ $(version_arg) + + libgfortran_la_DEPENDENCIES = $(version_dep) libgfortran.spec $(LIBQUADLIB_DEP) + cafexeclib_LTLIBRARIES = libcaf_single.la diff --git a/ports/lang/gdc/newport/files/pkg-message.in b/ports/lang/gdc/newport/files/pkg-message.in new file mode 100644 index 000000000000..433c37a3f89b --- /dev/null +++ b/ports/lang/gdc/newport/files/pkg-message.in @@ -0,0 +1,7 @@ +To ensure binaries built with this toolchain find appropriate versions +of the necessary run-time libraries, you may want to link using + + -Wl,-rpath=%%TARGLIB%% + +For ports leveraging USE_GCC, USES=compiler, or USES=fortran this happens +transparently. diff --git a/ports/lang/gdc/newport/pkg-descr b/ports/lang/gdc/newport/pkg-descr new file mode 100644 index 000000000000..63c91d3c263a --- /dev/null +++ b/ports/lang/gdc/newport/pkg-descr @@ -0,0 +1,24 @@ +GCC, the GNU Compiler Collection, supports a number of languages. +This port installs the GDC front ends as gdc9. + +GDC is the GCC-based dlang compiler, integrating the open source dmd front end +with gcc as the backend. The GNU D Compiler (GDC) project was originally +started by David Friedman in 2004 until early 2007 when he disappeared from the +D scene, and was no longer able to maintain GDC. Following a revival attempt in +2008, GDC is now under the lead of Iain Buclaw who has been steering the +project since 2009 with the assistance of its contributors, without them the +project would not have been nearly as successful as it has been. + +Any bugs or issues found with using GDC should be reported at the GCC bugzilla +site with the bug component set to `d`. For help with GDC, the D.gnu maillist- +list is the place to go with questions or problems. There's also a GDC IRC +channel at #d.gdc on FreeNode. Any questions which are related to +the D language, but not directly to the GDC compiler, can be asked in +the https://forum.dlang.org. You can find more information about D, including +example code, API documentation, tutorials and these forums at +the https://dlang.org website. + +WWW: https://gcc.gnu.org + +Ian Buclaw : GDC Maintainer +Diederik de Groot : Ports Maintainer diff --git a/ports/lang/gdc/newport/pkg-plist b/ports/lang/gdc/newport/pkg-plist new file mode 100644 index 000000000000..b2611265e5c4 --- /dev/null +++ b/ports/lang/gdc/newport/pkg-plist @@ -0,0 +1,14 @@ +bin/gdc +@(root,wheel,755) bin/gdmd +man/man1/gdc.1.gz +@postexec if [ ! -f %%LOCALBASE%%/bin/gdc ]; then ln -s %%PREFIX%%/bin/gdc %%LOCALBASE%%/bin/gdc && touch %%PREFIX%%/.gdc-alt-linked ;fi +@postexec if [ ! -f %%LOCALBASE%%/bin/gdmd ]; then ln -s %%PREFIX%%/bin/gdmd %%LOCALBASE%%/bin/gdmd && touch %%PREFIX%%/.gdmd-alt-linked ;fi +@postexec if [ ! -f %%LOCALBASE%%/man/man1/gdc.1.gz ]; then ln -s %%PREFIX%%/man/man1/gdc.1.gz %%LOCALBASE%%/man/man1/gdc.1.gz && touch %%PREFIX%%/.man_gdc9-alt-linked ;fi +@postexec if [ ! -f %%LOCALBASE%%/share/info/gdc.info ]; then ln -s %%PREFIX%%/share/info/gdc.info %%LOCALBASE%%/share/info/gdc.info && touch %%PREFIX%%/.share_info_gdc-alt-linked ;fi +@postexec if type ccache-update-links >/dev/null 2>&1; then ccache-update-links -v; fi +@preunexec if [ -f %%PREFIX%%/.gdc-alt-linked ]; then rm %%LOCALBASE%%/bin/gdc && rm %%PREFIX%%/.gdc-alt-linked;fi +@preunexec if [ -f %%PREFIX%%/.gdmd-alt-linked ]; then rm %%LOCALBASE%%/bin/gdmd && rm %%PREFIX%%/.gdmd-alt-linked;fi +@preunexec if [ -f %%PREFIX%%/.man_gdc9-alt-linked ]; then rm %%LOCALBASE%%/man/man1/gdc.1.gz && rm %%PREFIX%%/.man_gdc9-alt-linked;fi +@preunexec if [ -f %%PREFIX%%/.share_info_gdc-alt-linked ]; then rm %%LOCALBASE%%/share/info/gdc.info && rm %%PREFIX%%/.share_info_gdc-alt-linked;fi +@postunexec if type ccache-update-links >/dev/null 2>&1; then ccache-update-links -v; fi +@comment Insert PLIST.lib here