Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW PORT] lang/gdc : initial port for gcc-9.2.0 based d-compiler #920

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ports/lang/gdc/STATUS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DPORT
188 changes: 188 additions & 0 deletions ports/lang/gdc/newport/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
# Created by: Diederik de Groot <[email protected]>
# $FreeBSD$

# Based on: Gerald Pfeifer <[email protected]>

PORTNAME= gdc
PORTVERSION= 9.2.0
CATEGORIES= lang
MASTER_SITES= GCC
DISTNAME= gcc-${PORTVERSION}

MAINTAINER= [email protected]
#PORT_MAINTAINER= [email protected]
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 <bsd.port.pre.mk>

.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 <bsd.port.post.mk>
1 change: 1 addition & 0 deletions ports/lang/gdc/newport/Makefile.DragonFly
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ONLY_FOR_ARCHS= amd64
3 changes: 3 additions & 0 deletions ports/lang/gdc/newport/distinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
TIMESTAMP = 1574144270
SHA256 (gcc-9.2.0.tar.xz) = ea6ef08f121239da5695f76c9b33637a118dcf63e24164422231917fa61fb206
SIZE (gcc-9.2.0.tar.xz) = 70607648
28 changes: 28 additions & 0 deletions ports/lang/gdc/newport/dragonfly/patch-gcc_config.gcc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
gcc/ChangeLog:

2019-04-24 Iain Buclaw <[email protected]>

* 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 <[email protected]>

* 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
69 changes: 69 additions & 0 deletions ports/lang/gdc/newport/dragonfly/patch-gcc_config_dragonfly-d.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
gcc/ChangeLog:

2019-04-24 Iain Buclaw <[email protected]>

* 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 <[email protected]>

* 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
+<http://www.gnu.org/licenses/>. */
+
+#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;
41 changes: 41 additions & 0 deletions ports/lang/gdc/newport/dragonfly/patch-gcc_config_t-dragonfly
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
gcc/ChangeLog:

2019-04-24 Iain Buclaw <[email protected]>

* 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 <[email protected]>

* 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
+# <http://www.gnu.org/licenses/>.
+
+dragonfly-d.o: $(srcdir)/config/dragonfly-d.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
26 changes: 26 additions & 0 deletions ports/lang/gdc/newport/dragonfly/patch-libphobos_configure.tgt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
gcc/ChangeLog:

2019-04-24 Iain Buclaw <[email protected]>

* 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 <[email protected]>

* 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
;;
Loading