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/dmd2 : d-lang reference compiler #917

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/dmd2/STATUS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DPORT
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
15 changes: 15 additions & 0 deletions ports/lang/dmd2/newport/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/newport/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;


Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- druntime/src/core/sys/freebsd/sys/event.d 2019-02-15 17:20:40.000000000 +0000
+++ druntime/src/core/sys/freebsd/sys/event.d 2019-03-05 17:57:03.552667000 +0000
@@ -49,8 +49,9 @@
short filter; /* filter for event */
ushort flags;
uint fflags;
- intptr_t data;
- void *udata; /* opaque user data identifier */
+ long data;
+ void* udata; /* opaque user data identifier */
+ ulong[4] ext;
}

enum
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- druntime/src/core/sys/freebsd/sys/mount.d 2019-03-05 17:38:00.882617000 +0000
+++ druntime/src/core/sys/freebsd/sys/mount.d 2019-03-05 17:38:53.720464000 +0000
@@ -32,8 +32,8 @@
}

enum MFSNAMELEN = 16;
-enum MNAMELEN = 88;
-enum STATFS_VERSION = 0x20030518;
+enum MNAMELEN = 1024;
+enum STATFS_VERSION = 0x20140518;

struct statfs_t
{
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
--- druntime/src/core/sys/posix/sys/stat.d 2019-02-15 17:20:40.000000000 +0000
+++ druntime/src/core/sys/posix/sys/stat.d 2019-03-05 17:49:41.528876000 +0000
@@ -930,32 +930,41 @@

struct stat_t
{
- dev_t st_dev;
- ino_t st_ino;
- mode_t st_mode;
- nlink_t st_nlink;
- uid_t st_uid;
- gid_t st_gid;
- dev_t st_rdev;
+ dev_t st_dev;
+ ino_t st_ino;
+ nlink_t st_nlink;
+ mode_t st_mode;
+ short st_padding0;
+ uid_t st_uid;
+ gid_t st_gid;
+ int st_padding1;
+ dev_t st_rdev;

+ version(X86) int st_atim_ext;
time_t st_atime;
c_long __st_atimensec;
+
+ version(X86) int st_mtim_ext;
+
time_t st_mtime;
c_long __st_mtimensec;
+
+ version(X86) int st_ctim_ext;
+
time_t st_ctime;
c_long __st_ctimensec;

- off_t st_size;
- blkcnt_t st_blocks;
- blksize_t st_blksize;
- fflags_t st_flags;
- uint st_gen;
- int st_lspare;
+ version(X86) int st_btim_ext;

time_t st_birthtime;
c_long st_birthtimensec;

- ubyte[16 - timespec.sizeof] padding;
+ off_t st_size;
+ blkcnt_t st_blocks;
+ blksize_t st_blksize;
+ fflags_t st_flags;
+ ulong st_gen;
+ ulong[10] st_spare;
}

enum S_IRUSR = 0x100; // octal 0000400
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--- druntime/src/core/sys/posix/sys/types.d 2019-02-15 17:20:40.000000000 +0000
+++ druntime/src/core/sys/posix/sys/types.d 2019-03-05 17:51:58.972306000 +0000
@@ -145,14 +145,13 @@
}
else version (FreeBSD)
{
- // https://github.com/freebsd/freebsd/blob/master/sys/sys/_types.h
alias long blkcnt_t;
- alias uint blksize_t;
- alias uint dev_t;
+ alias ulong blksize_t;
+ alias ulong dev_t;
alias uint gid_t;
- alias uint ino_t;
+ alias ulong ino_t;
alias ushort mode_t;
- alias ushort nlink_t;
+ alias ulong nlink_t;
alias long off_t;
alias int pid_t;
//size_t (defined in core.stdc.stddef)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--- druntime/src/core/sys/posix/dirent.d.orig 2019-04-06 12:24:12.000000000 +0000
+++ druntime/src/core/sys/posix/dirent.d 2019-04-21 14:13:39.676998000 +0000
@@ -152,11 +152,13 @@
align(4)
struct dirent
{
- uint d_fileno;
+ ino_t d_fileno;
+ off_t d_off;
ushort d_reclen;
ubyte d_type;
- ubyte d_namlen;
- char[256] d_name = 0;
+ ushort d_namlen;
+ ushort d_pad1;
+ char[256] d_name;
}

alias void* DIR;
17 changes: 17 additions & 0 deletions ports/lang/dmd2/newport/files/patch-dmd-config.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--- dmd/config.d 2019-06-26 11:20:31.001091000 +0200
+++ dmd/config.d 2019-06-26 11:21:55.463494000 +0200
@@ -48,10 +48,13 @@
*/
string generateVersion(const string versionFile)
{
- import std.process : execute;
+ import std.process : execute, executeShell;
import std.file : readText;
import std.path : dirName;
import std.string : strip;
+
+ if (executeShell("which git").status != 0)
+ return versionFile.readText;

enum workDir = __FILE_FULL_PATH__.dirName;
const result = execute(["git", "-C", workDir, "describe", "--dirty"]);
38 changes: 38 additions & 0 deletions ports/lang/dmd2/newport/files/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)
{
Loading