Skip to content

Commit

Permalink
[NEW PORT] d-lang reference compiler
Browse files Browse the repository at this point in the history
Updated to 2.089.0

Depends on:
- ldc or gdc for bootstrapping (druntime >2.079.1). Once initial bootstrap is done, it can use it-self for subsequent builds.
- USES=dlang will automatically take care of the bootstrap if no (compatible) d-compiler is found.

dependencies:
 - lang/ldc (Separate commit/PR) or lang/gdc (Separate commit/PR)
 - Mk/Uses/dlang.mk (Separate commit/PR) provides USES=dlang

MAINTAINER: [email protected]

Signed-off-by: ddegroot <[email protected]>
  • Loading branch information
dkgroot committed Nov 20, 2019
1 parent 6aee0c5 commit 4d01336
Show file tree
Hide file tree
Showing 9 changed files with 870 additions and 0 deletions.
1 change: 1 addition & 0 deletions ports/lang/dmd2/STATUS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PORT
3 changes: 3 additions & 0 deletions ports/lang/dmd2/diffs/REMOVE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Makefile
distinfo
pkg-plist
15 changes: 15 additions & 0 deletions ports/lang/dmd2/dragonfly/patch-druntime-dlfcn.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--- druntime/src/core/sys/dragonflybsd/dlfcn.d 2019-11-19 00:00:19.501296000 -0800
+++ druntime/src/core/sys/dragonflybsd/dlfcn.d 2019-11-19 00:01:29.490870000 -0800
@@ -90,8 +90,10 @@
/* XSI functions first. */
static assert(is(typeof(&dlclose) == __externC!(int, void*)));
static assert(is(typeof(&dlerror) == __externC!(char*)));
-static assert(is(typeof(&dlopen) == __externC!(void*, const char*, int)));
-static assert(is(typeof(&dlsym) == __externC!(void*, void*, const char*)));
+//static assert(is(typeof(&dlopen) == __externC!(void*, const char*, int)));
+static assert(is(typeof(&dlopen) == void* function(scope const(char*), int) nothrow @nogc ));
+//static assert(is(typeof(&dlsym) == __externC!(void*, void*, const char*)));
+static assert(is(typeof(&dlsym) == void* function(void *, scope const(char*)) nothrow @nogc));

void* fdlopen(int, int);
int dladdr(const(void)*, Dl_info*);
12 changes: 12 additions & 0 deletions ports/lang/dmd2/dragonfly/patch-druntime-locale.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# PR https://github.com/dlang/druntime/pull/2850 (accepted)
--- druntime/src/core/sys/posix/locale.d 2019-10-29 01:26:55.000000000 -0700
+++ druntime/src/core/sys/posix/locale.d 2019-11-19 00:06:59.548858000 -0800
@@ -22,7 +22,7 @@
version = OSXBSDLocale;
version (NetBSD)
version = OSXBSDLocale;
-version (DragonflyBSD)
+version (DragonFlyBSD)
version = OSXBSDLocale;


38 changes: 38 additions & 0 deletions ports/lang/dmd2/dragonfly/patch-phobos_std_file.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
--- phobos/std/file.d 2019-06-30 13:05:22.802439000 -0700
+++ phobos/std/file.d 2019-06-30 13:06:49.058711000 -0700
@@ -3437,7 +3437,7 @@
else version (FreeBSD)
private extern (C) int sysctl (const int* name, uint namelen, void* oldp,
size_t* oldlenp, const void* newp, size_t newlen);
-else version (NetBSD)
+else version (DragonFlyBSD)
private extern (C) int sysctl (const int* name, uint namelen, void* oldp,
size_t* oldlenp, const void* newp, size_t newlen);

@@ -3524,7 +3524,25 @@
}
else version (DragonFlyBSD)
{
- return readLink("/proc/curproc/file");
+ import std.exception : errnoEnforce, assumeUnique;
+ enum
+ {
+ CTL_KERN = 1,
+ KERN_PROC = 14,
+ KERN_PROC_PATHNAME = 9
+ }
+
+ int[4] mib = [CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1];
+ size_t len;
+
+ auto result = sysctl(mib.ptr, mib.length, null, &len, null, 0); // get the length of the path
+ errnoEnforce(result == 0);
+
+ auto buffer = new char[len - 1];
+ result = sysctl(mib.ptr, mib.length, buffer.ptr, &len, null, 0);
+ errnoEnforce(result == 0);
+
+ return buffer.assumeUnique;
}
else version (Solaris)
{
149 changes: 149 additions & 0 deletions ports/lang/dmd2/newport/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# Created by: Diederik de Groot <[email protected]>
# $FreeBSD: head/lang/dmd2/Makefile 498264 2019-04-07 07:43:37Z antoine $

PORTNAME= dmd
PORTVERSION= ${DMD_VERSION}
DISTVERSIONPREFIX= v
CATEGORIES= lang
PKGNAMESUFFIX= 2

MAINTAINER= [email protected]
COMMENT= D 2.0 compiler

LICENSE= ART10 BSL
LICENSE_COMB= multi

NOT_FOR_ARCHS= aarch64 armv6 armv7 mips64 powerpc64 sparc64
NOT_FOR_ARCHS_REASON= dmd only supports i386 and x86_64, use ldc or gdc instead

BUILD_DEPENDS= bash:shells/bash

USES= gmake compiler dlang:bootstrap

# dcompiler arguments/variables
DRT_MINVER= 20791
DRT_MAXVER= 20881

DMD_MAJOR= 2
DMD_MINOR= 0
DMD_PATCHLEVEL= 89
DMD_REV= 0
DMD_VERSION= ${DMD_MAJOR}.${DMD_MINOR}${DMD_PATCHLEVEL}.${DMD_REV}
DMD_LIBVER= 0.${DMD_PATCHLEVEL}.${DMD_REV}

USE_GITHUB= nodefault
GH_ACCOUNT= dlang
GH_PROJECT= dmd:dmd druntime:druntime phobos:phobos

# DOCS should be build from github.com/dlang/dlang.org in a seperate package
# because it is dependent on lang/dlang-tools:rdmd
OPTIONS_DEFINE= EXAMPLES LTO FORCE_BOOTSTRAP SHARED
OPTIONS_DEFAULT= EXAMPLES LTO SHARED
OPTIONS_SUB= yes

LTO_DESC= Enable Link Time Optimizations
FORCE_BOOTSTRAP_DESC= Override search for suitable bootstrap d-compiler
FORCE_BOOTSTRAP_BUILD_DEPENDS=${LOCALBASE}/bin/ldmd2:lang/ldc
SHARED_DESC= Enable shared libraries

PREFIX?= ${LOCALBASE}/dmd2
MAKEFILE= posix.mak
EXAMPLESDIR= ${PREFIX}/share/examples/dmd2
DOCSDIR= ${PREFIX}/share/doc/dmd2
WRKSRC= ${WRKDIR}
MODULEDIR= ${PREFIX}/include/d

PLIST_SUB+= DMD_PATCHLEVEL=${DMD_PATCHLEVEL} \
DMD_LIBVER=${DMD_LIBVER} \

.include <bsd.port.options.mk>

.if ${OPSYS} == FreeBSD && ${OSVERSION} >= 1200031
EXTRA_PATCHES= ${PATCHDIR}/ino64-*
.endif

OSMODEL?= ${OPSYS:tl}

MAKE_ARGS+= SHELL=${LOCALBASE}/bin/bash HOST_DMD=${DCOMPILER_DMD}

.if ${ARCH} == amd64 || ${ARCH} == x86_64
MAKE_ARGS+= MODEL=64 PIC=1
MODEL= 64
CFLAGS+= -fPIC
.else
MAKE_ARGS+= MODEL=32
MODEL= 32
.endif

.if ${PORT_OPTIONS:MFORCE_BOOTSTRAP}
DCOMPILER_DMD= ${LOCALBASE}/bin/ldmd2
.endif

.if ${PORT_OPTIONS:MSHARED}
MAKE_ARGS+= SHARED=1
.endif

.if ${PORT_OPTIONS:MLTO}
MAKE_ARGS+= ENABLE_LTO=1
.endif

.if defined(WITH_DEBUG)
MAKE_ARGS+= ENABLE_DEBUG=1 DEBUG_FLAGS=-g -DDEBUG=1 -DUNITTEST BUILD=debug
.else
MAKE_ARGS+= ENABLE_RELEASE=1 BUILD=release
.endif

post-extract:
@${MV} ${WRKSRC_dmd} ${WRKSRC}/dmd
@${MV} ${WRKSRC_druntime} ${WRKSRC}/druntime
@${MV} ${WRKSRC_phobos} ${WRKSRC}/phobos

post-patch:
@${REINPLACE_CMD} -e "s|g++|${CXX}|" \
-e "s|/etc|${PREFIX}/etc|" \
${WRKSRC}/dmd/src/posix.mak
@${REINPLACE_CMD} -e "s|cc|${CC}|" ${WRKSRC}/phobos/posix.mak
@${REINPLACE_CMD} -e "s|/etc|${PREFIX}/etc|" \
-e "s|\(dmd\)|\12|gI" \
-e "s|\\\BR|.BR|" \
${WRKDIR}/dmd/docs/man/man5/dmd.conf.5
@${REINPLACE_CMD} -e "s|%@P%/../../src/phobos|${MODULEDIR}/phobos|" \
-e "s|%@P%/../../src/druntime|${MODULEDIR}/druntime|" \
-e "s|%@P%/../lib32|${PREFIX}/lib|" \
-e "s|%@P%/../lib64|${PREFIX}/lib|" \
${WRKDIR}/dmd/ini/${OSMODEL}/bin${MODEL}/dmd.conf
@${ECHO_CMD} >> ${WRKDIR}/dmd/ini/${OSMODEL}/bin${MODEL}/dmd.conf

make-phobos: make-druntime
cd ${WRKSRC}/phobos && ${MAKE_ENV} ${MAKE_CMD} -f ${MAKEFILE} ${MAKE_ARGS} ${BUILD}

make-druntime: make-dmd
cd ${WRKSRC}/druntime && ${MAKE_ENV} ${MAKE_CMD} -f ${MAKEFILE} ${MAKE_ARGS} ${BUILD}

make-dmd:
cd ${WRKSRC}/dmd && ${MAKE_ENV} ${MAKE_CMD} -f ${MAKEFILE} -j${MAKE_JOBS_NUMBER} ${MAKE_ARGS} ${BUILD}

do-build: make-dmd make-phobos make-druntime

do-install:
${INSTALL_MAN} ${WRKDIR}/dmd/docs/man/man5/dmd.conf.5 ${STAGEDIR}${MANPREFIX}/man/man5/dmd.conf.5
${INSTALL_DATA} ${WRKSRC}/dmd/generated/${OSMODEL}/release/${MODEL}/dmd.conf ${STAGEDIR}${PREFIX}/etc/dmd.conf
${INSTALL_PROGRAM} ${WRKSRC}/dmd/generated/${OSMODEL}/release/${MODEL}/dmd ${STAGEDIR}${PREFIX}/bin/dmd
${INSTALL_DATA} ${WRKSRC}/phobos/generated/${OSMODEL}/release/${MODEL}/libphobos2.a ${STAGEDIR}${PREFIX}/lib/libphobos2.a
.if ${PORT_OPTIONS:MSHARED}
${INSTALL_LIB} ${WRKSRC}/phobos/generated/${OSMODEL}/release/${MODEL}/libphobos2.so.${DMD_LIBVER} ${STAGEDIR}${PREFIX}/lib/libphobos2.so.${DMD_LIBVER}
${RLN} ${STAGEDIR}${PREFIX}/lib/libphobos2.so.${DMD_LIBVER} ${STAGEDIR}${PREFIX}/lib/libphobos2.so.0.${DMD_PATCHLEVEL}
${RLN} ${STAGEDIR}${PREFIX}/lib/libphobos2.so.${DMD_LIBVER} ${STAGEDIR}${PREFIX}/lib/libphobos2.so
.endif
${INSTALL_DATA} ${WRKDIR}/dmd/ini/${OSMODEL}/bin${MODEL}/dmd.conf ${STAGEDIR}${PREFIX}/etc/dmd.conf.sample
cd ${WRKDIR}/druntime/import && ${COPYTREE_SHARE} . ${STAGEDIR}${MODULEDIR}/druntime/import
cd ${WRKSRC}/phobos && ${COPYTREE_SHARE} std ${STAGEDIR}${MODULEDIR}/phobos
cd ${WRKSRC}/phobos && ${COPYTREE_SHARE} etc ${STAGEDIR}${MODULEDIR}/phobos

post-install-EXAMPLES-on:
${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
cd ${WRKDIR}/dmd && ${COPYTREE_SHARE} samples ${STAGEDIR}${EXAMPLESDIR}
${INSTALL_DATA} ${WRKDIR}/dmd/ini/${OSMODEL}/bin32/dmd.conf ${STAGEDIR}${EXAMPLESDIR}/dmd32.conf
${INSTALL_DATA} ${WRKDIR}/dmd/ini/${OSMODEL}/bin64/dmd.conf ${STAGEDIR}${EXAMPLESDIR}/dmd64.conf

.include <bsd.port.mk>
1 change: 1 addition & 0 deletions ports/lang/dmd2/newport/Makefile.DragonFly
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
OSMODEL=dragonflybsd
7 changes: 7 additions & 0 deletions ports/lang/dmd2/newport/distinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
TIMESTAMP = 1574148869
SHA256 (dlang-dmd-v2.089.0_GH0.tar.gz) = e86b147c356788299794088bac6d872fd844c74551b4a09411b0408b03e59524
SIZE (dlang-dmd-v2.089.0_GH0.tar.gz) = 3323343
SHA256 (dlang-druntime-v2.089.0_GH0.tar.gz) = 1ad3bdaebe0957a2678453bd9bb3eddbebae6babc564544c6f3ad07026e4bff3
SIZE (dlang-druntime-v2.089.0_GH0.tar.gz) = 1746634
SHA256 (dlang-phobos-v2.089.0_GH0.tar.gz) = 42c0a1581c8d66980aee4a73fc37d6b60d110a2139d8c00944a66bfa4868eafe
SIZE (dlang-phobos-v2.089.0_GH0.tar.gz) = 2376909
Loading

0 comments on commit 4d01336

Please sign in to comment.