pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Add crystal.



Module Name:	pkgsrc-wip
Committed By:	nia <nia%netbsd.org@localhost>
Pushed By:	nee
Date:		Mon Jul 20 02:30:20 2020 +0100
Changeset:	814b64b2cab2ad6dc91bf51f59dda29352eef0f9

Modified Files:
	Makefile
Added Files:
	crystal/DESCR
	crystal/Makefile
	crystal/PLIST
	crystal/distinfo
	crystal/files/Makefile
	crystal/patches/patch-src_compiler_crystal_codegen_link.cr

Log Message:
Add crystal.

Crystal is a programming language with the following goals:

- Have a syntax similar to Ruby (but compatibility with it is not
  a goal)
- Statically type-checked but without having to specify the type
  of variables or method arguments.
- Be able to call C code by writing bindings to it in Crystal.
- Have compile-time evaluation and generation of code, to avoid
  boilerplate code.
- Compile to efficient native code.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=814b64b2cab2ad6dc91bf51f59dda29352eef0f9

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 Makefile                                           |   1 +
 crystal/DESCR                                      |  10 +
 crystal/Makefile                                   | 216 +++++++++++++++++++++
 crystal/PLIST                                      |   0
 crystal/distinfo                                   |  35 ++++
 crystal/files/Makefile                             |  30 +++
 .../patch-src_compiler_crystal_codegen_link.cr     |  15 ++
 7 files changed, 307 insertions(+)

diffs:
diff --git a/Makefile b/Makefile
index a05292fb0f..4d0f23eb1b 100644
--- a/Makefile
+++ b/Makefile
@@ -518,6 +518,7 @@ SUBDIR+=	crossroads-io
 SUBDIR+=	crrcsim
 SUBDIR+=	crust-firmware
 SUBDIR+=	cryptcat
+SUBDIR+=	crystal
 SUBDIR+=	crystal-bin
 SUBDIR+=	csmith
 SUBDIR+=	csoap
diff --git a/crystal/DESCR b/crystal/DESCR
new file mode 100644
index 0000000000..e583c3bd16
--- /dev/null
+++ b/crystal/DESCR
@@ -0,0 +1,10 @@
+Crystal is a programming language with the following goals:
+
+- Have a syntax similar to Ruby (but compatibility with it is not
+  a goal)
+- Statically type-checked but without having to specify the type
+  of variables or method arguments.
+- Be able to call C code by writing bindings to it in Crystal.
+- Have compile-time evaluation and generation of code, to avoid
+  boilerplate code.
+- Compile to efficient native code.
diff --git a/crystal/Makefile b/crystal/Makefile
new file mode 100644
index 0000000000..8a15934328
--- /dev/null
+++ b/crystal/Makefile
@@ -0,0 +1,216 @@
+# $NetBSD$
+
+DISTNAME=	crystal-0.35.0
+CATEGORIES=	lang
+DISTFILES+=	${PKGNAME_NOREV}.tar.gz
+
+# TODO: Update when they put out a release with NetBSD support.
+# Do not trust nia@
+MASTER_SITES=	${MASTER_SITE_GITHUB:=niacat/}
+MASTER_SITES+=	https://cdn.NetBSD.org/pub/pkgsrc/misc/nia/crystal/
+GITHUB_PROJECT=	crystal
+GITHUB_TAG=	00380c0038aae81be22e8128d5a092d66b2fdffb
+
+MAINTAINER=	nia%NetBSD.org@localhost
+HOMEPAGE=	https://crystal-lang.org/
+COMMENT=	Statically typed, compiled language, with Ruby-like syntax
+LICENSE=	apache-2.0
+
+DEPENDS+=	mime-types-[0-9]*:../../misc/mime-types
+
+USE_TOOLS+=	gmake pkg-config xz xzcat pax
+USE_LANGUAGES=	c c++
+
+# C++14 for LLVM extension
+GCC_REQD+=	5
+
+BUILD_DIRS=	.build .
+TEST_DIRS=	.
+TEST_TARGET=	std_spec
+
+MAKE_FLAGS+=	release=1
+MAKE_FLAGS+=	progress=1
+MAKE_FLAGS+=	verbose=1
+MAKE_FLAGS+=	threads=${MAKE_JOBS}
+
+# XXX: Remove this once they start using pkg-config for all libs.
+# XXX: This is awful.
+MAKE_ENV+=	CRYSTAL_LIBRARY_PATH=${PREFIX}/lib:/usr/lib
+MAKE_ENV+=	LD_LIBRARY_PATH=${PREFIX}/lib:/usr/lib
+
+#
+# Crystal has significant memory requirements to build itself
+# and the compiler is probably not suitable for archs with low
+# amounts of available address space.
+#
+# Otherwise, it should be easy to add support for POSIXy platforms
+# with support in LLVM by writing some libc bindings and
+# cross-compiling.
+#
+ONLY_FOR_PLATFORM+=	Darwin-*-x86_64
+ONLY_FOR_PLATFORM+=	DragonFly-*-x86_64
+ONLY_FOR_PLATFORM+=	FreeBSD-*-x86_64
+#ONLY_FOR_PLATFORM+=	NetBSD-*-aarch64 TODO: get this working.
+ONLY_FOR_PLATFORM+=	NetBSD-*-x86_64
+#ONLY_FOR_PLATFORM+=	Linux-*-aarch64 TODO: get this working.
+ONLY_FOR_PLATFORM+=	Linux-*-i386
+ONLY_FOR_PLATFORM+=	Linux-*-x86_64
+
+#
+# On NetBSD the default ulimit -s of 4096 is not high enough to produce
+# a working Crystal compiler (ulimit -s 6000 works).
+#
+# Can use 30+ minutes of CPU time.
+#
+UNLIMIT_RESOURCES+=	cputime stacksize
+
+SUBST_CLASSES+=		mime
+SUBST_STAGE.mime=	pre-build
+SUBST_FILES.mime+=	src/crystal/system/unix/mime.cr
+SUBST_SED.mime+=	-e 's,/usr/local,${PREFIX},g'
+
+SUBST_CLASSES+=		prefix
+SUBST_STAGE.prefix=	pre-build
+SUBST_FILES.prefix+=	src/compiler/crystal/codegen/link.cr
+SUBST_VARS.prefix+=	PREFIX
+
+.include "../../mk/bsd.prefs.mk"
+
+#
+# Crystal unfortunately requires itself to build.
+#
+# An object file for the Crystal parts of the compiler can be cross-compiled
+# using any working Crystal compiler, and then linked with the required
+# libraries and C/C++ parts by pkgsrc, then used to build you a new Crystal.
+#
+# These binaries were cross-compiled on a NetBSD/amd64 machine by nia@.
+# The NetBSD/amd64 compiler was originally produced by cross-compiling
+# from an Alpine Linux VM's crystal package.
+#
+# Therefore, the chain of trust is:
+# - nia%NetBSD.org@localhost
+# - Alpine Linux packages in early 2020, roughly when the
+#   NetBSD port was being privately worked on.
+# - crystal-lang maintainers
+# - Intel, etc
+#
+DISTFILES:=		${DEFAULT_DISTFILES}
+.if !empty(MACHINE_PLATFORM:MDarwin-*-x86_64) || make(distinfo) || make (makesum) || make(mdi)
+CRYSTAL_ARCH=		x86_64-darwin
+CRYSTAL_BOOT_VER=	0.34.0
+CRYSTAL_BOOT_OBJ=	crystal-${CRYSTAL_BOOT_VER}-${CRYSTAL_ARCH}.o
+DISTFILES:=		${DISTFILES} ${CRYSTAL_BOOT_OBJ}.xz
+.endif
+.if !empty(MACHINE_PLATFORM:MDragonFly-*-x86_64) || make(distinfo) || make (makesum) || make(mdi)
+CRYSTAL_ARCH=		x86_64-darwin
+CRYSTAL_BOOT_VER=	0.34.0
+CRYSTAL_BOOT_OBJ=	crystal-${CRYSTAL_BOOT_VER}-${CRYSTAL_ARCH}.o
+DISTFILES:=		${DISTFILES} ${CRYSTAL_BOOT_OBJ}.xz
+.endif
+.if !empty(MACHINE_PLATFORM:MFreeBSD-*-x86_64) || make(distinfo) || make (makesum) || make(mdi)
+CRYSTAL_ARCH=		x86_64-freebsd
+CRYSTAL_BOOT_VER=	0.34.0
+CRYSTAL_BOOT_OBJ=	crystal-${CRYSTAL_BOOT_VER}-${CRYSTAL_ARCH}.o
+DISTFILES:=		${DISTFILES} ${CRYSTAL_BOOT_OBJ}.xz
+.endif
+#.if !empty(MACHINE_PLATFORM:MNetBSD-*-aarch64) || make(distinfo) || make (makesum) || make(mdi)
+#CRYSTAL_ARCH=		aarch64-netbsd
+#CRYSTAL_BOOT_VER=	0.34.0
+#CRYSTAL_BOOT_OBJ=	crystal-${CRYSTAL_BOOT_VER}-${CRYSTAL_ARCH}.o.xz
+#DISTFILES:=		${DISTFILES} ${CRYSTAL_BOOT_OBJ}.xz
+#.endif
+.if !empty(MACHINE_PLATFORM:MNetBSD-*-x86_64) || make(distinfo) || make (makesum) || make(mdi)
+CRYSTAL_ARCH=		x86_64-netbsd
+CRYSTAL_BOOT_VER=	0.34.0
+CRYSTAL_BOOT_OBJ=	crystal-${CRYSTAL_BOOT_VER}-${CRYSTAL_ARCH}.o
+DISTFILES:=		${DISTFILES} ${CRYSTAL_BOOT_OBJ}.xz
+.endif
+#.if (!empty(MACHINE_PLATFORM:MLinux-*-aarch64) && !empty(GLIBC_VERSION)) || make(distinfo) || make (makesum) || make(mdi)
+#CRYSTAL_ARCH=		aarch64-linux-gnu
+#CRYSTAL_BOOT_VER=	0.34.0
+#CRYSTAL_BOOT_OBJ=	crystal-${CRYSTAL_BOOT_VER}-${CRYSTAL_ARCH}.o
+#DISTFILES:=		${DISTFILES} ${CRYSTAL_BOOT_OBJ}.xz
+#.endif
+#.if (!empty(MACHINE_PLATFORM:MLinux-*-aarch64) && empty(GLIBC_VERSION)) || make(distinfo) || make (makesum) || make(mdi)
+#CRYSTAL_ARCH=		aarch64-linux-musl
+#CRYSTAL_BOOT_VER=	0.34.0
+#CRYSTAL_BOOT_OBJ=	crystal-${CRYSTAL_BOOT_VER}-${CRYSTAL_ARCH}.o
+#DISTFILES:=		${DISTFILES} ${CRYSTAL_BOOT_OBJ}.xz
+#.endif
+.if (!empty(MACHINE_PLATFORM:MLinux-*-i386) && !empty(GLIBC_VERSION)) || make(distinfo) || make (makesum) || make(mdi)
+CRYSTAL_ARCH=		i386-linux-gnu
+CRYSTAL_BOOT_VER=	0.34.0
+CRYSTAL_BOOT_OBJ=	crystal-${CRYSTAL_BOOT_VER}-${CRYSTAL_ARCH}.o
+DISTFILES:=		${DISTFILES} ${CRYSTAL_BOOT_OBJ}.xz
+.endif
+.if (!empty(MACHINE_PLATFORM:MLinux-*-i386) && empty(GLIBC_VERSION)) || make(distinfo) || make (makesum) || make(mdi)
+CRYSTAL_ARCH=		i386-linux-musl
+CRYSTAL_BOOT_VER=	0.34.0
+CRYSTAL_BOOT_OBJ=	crystal-${CRYSTAL_BOOT_VER}-${CRYSTAL_ARCH}.o
+DISTFILES:=		${DISTFILES} ${CRYSTAL_BOOT_OBJ}.xz
+.endif
+.if (!empty(MACHINE_PLATFORM:MLinux-*-x86_64) && !empty(GLIBC_VERSION)) || make(distinfo) || make (makesum) || make(mdi)
+CRYSTAL_ARCH=		x86_64-linux-gnu
+CRYSTAL_BOOT_VER=	0.34.0
+CRYSTAL_BOOT_OBJ=	crystal-${CRYSTAL_BOOT_VER}-${CRYSTAL_ARCH}.o
+DISTFILES:=		${DISTFILES} ${CRYSTAL_BOOT_OBJ}.xz
+.endif
+.if (!empty(MACHINE_PLATFORM:MLinux-*-x86_64) && empty(GLIBC_VERSION)) || make(distinfo) || make (makesum) || make(mdi)
+CRYSTAL_ARCH=		x86_64-linux-musl
+CRYSTAL_BOOT_VER=	0.34.0
+CRYSTAL_BOOT_OBJ=	crystal-${CRYSTAL_BOOT_VER}-${CRYSTAL_ARCH}.o
+DISTFILES:=		${DISTFILES} ${CRYSTAL_BOOT_OBJ}.xz
+.endif
+
+.PHONY: build-cross-targets
+
+build-cross-targets:
+.for target in \
+    i386-linux-gnu \
+    i386-linux-musl \
+    x86_64-darwin \
+    x86_64-dragonfly \
+    x86_64-freebsd \
+    x86_64-netbsd \
+    x86_64-linux-gnu \
+    x86_64-linux-musl
+	LIBRARY_PATH=${PREFIX}/lib:/usr/lib \
+	cd ${WKSRC} && ${WRKSRC}/.build/crystal build \
+		-o crystal-${PKGVERSION_NOREV}-${target} \
+		--cross-compile --target ${target} \
+		--progress --threads ${MAKE_JOBS} \
+		src/compiler/crystal.cr \
+		-D without_openssl \
+		-D without_zlib \
+		-D i_know_what_im_doing # do I?
+	xz -0 crystal-${PKGVERSION_NOREV}-${target}.o
+.endfor
+
+pre-build:
+	${MKDIR} ${WRKSRC}/.build
+	${XZCAT} ${WRKDIR}/${CRYSTAL_BOOT_OBJ}.xz > ${WRKSRC}/.build/crystal.o
+	${CP} -f ${FILESDIR}/Makefile ${WRKSRC}/.build/Makefile
+
+INSTALLATION_DIRS+=	bin
+INSTALLATION_DIRS+=	lib/crystal
+INSTALLATION_DIRS+=	${PKGMANDIR}/man1
+INSTALLATION_DIRS+=	share/bash-completion/completions
+INSTALLATION_DIRS+=	share/zsh/site-functions
+
+do-install:
+	${INSTALL_PROGRAM} ${WRKSRC}/.build/crystal \
+		${DESTDIR}${PREFIX}/bin/crystal
+	${INSTALL_MAN} ${WRKSRC}/man/crystal.1 \
+		${DESTDIR}${PREFIX}/${PKGMANDIR}/man1/crystal.1
+	${INSTALL_DATA} ${WRKSRC}/etc/completion.bash \
+		${DESTDIR}${PREFIX}/share/bash-completion/completions/crystal
+	${INSTALL_DATA} ${WRKSRC}/etc/completion.zsh \
+		${DESTDIR}${PREFIX}/share/zsh/site-functions/_crystal
+	cd ${WRKSRC}/src && ${PAX} -rw -pp . ${DESTDIR}${PREFIX}/lib/crystal
+	${FIND} ${DESTDIR}${PREFIX}/lib/crystal -name '*.o' -or -name '*.a' -exec rm -f '{}' ';'
+
+.include "../../devel/boehm-gc/buildlink3.mk"
+.include "../../devel/libevent/buildlink3.mk"
+.include "../../devel/pcre/buildlink3.mk"
+.include "../../lang/llvm/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/crystal/PLIST b/crystal/PLIST
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/crystal/distinfo b/crystal/distinfo
new file mode 100644
index 0000000000..37e1144a02
--- /dev/null
+++ b/crystal/distinfo
@@ -0,0 +1,35 @@
+$NetBSD$
+
+SHA1 (crystal-0.34.0-i386-linux-gnu.o.xz) = 8adf4ee2c0c2c0d630b2d5e046270874c9d46b2c
+RMD160 (crystal-0.34.0-i386-linux-gnu.o.xz) = 25534804617110243a3dea1ddda8efd5674ac970
+SHA512 (crystal-0.34.0-i386-linux-gnu.o.xz) = f61e7f444cacb007d61bf0d8b02f7d37799be37d9fc6b6ef20ba4b2ba5c7fd21646b9a59c4e2adbe0bed2488656ebbbb5de945837bbcb055bfc8f5cce816c300
+Size (crystal-0.34.0-i386-linux-gnu.o.xz) = 5981280 bytes
+SHA1 (crystal-0.34.0-i386-linux-musl.o.xz) = a4219b4fdb203142f1cde327ba2d7cffb281b002
+RMD160 (crystal-0.34.0-i386-linux-musl.o.xz) = 194549c3bb45c512228b0cae7e4c13b3c1867ff9
+SHA512 (crystal-0.34.0-i386-linux-musl.o.xz) = 04f59d8685b3beb9c016c4b35d5df18752e62c322795efa01fcebf7e99e66fb1494685ace2d322e4cd10a3c5b6ca128ce96c6bcacfd3fb11d81e61f9952920d0
+Size (crystal-0.34.0-i386-linux-musl.o.xz) = 5982556 bytes
+SHA1 (crystal-0.34.0-x86_64-darwin.o.xz) = d08dea07a2c6c02f2e5e4f9d1150ff884b6bfc7a
+RMD160 (crystal-0.34.0-x86_64-darwin.o.xz) = d0f5be7d9b5803f199f4ddff7188cd9d43c9d807
+SHA512 (crystal-0.34.0-x86_64-darwin.o.xz) = 8248ca539c981721d5ea073eb7e5c35cdbfff1a50ee04d529c0254ca48d356184223a0ff6ef9c8c52bbd1449ebc5bfe5de78325c60b39472a931b667c5f3bc8a
+Size (crystal-0.34.0-x86_64-darwin.o.xz) = 5093296 bytes
+SHA1 (crystal-0.34.0-x86_64-freebsd.o.xz) = 8c2ee3f754fcfa27e412752df67131a3793b355a
+RMD160 (crystal-0.34.0-x86_64-freebsd.o.xz) = 60eb5727a2cae6dc0405378f58299e2ebffa854a
+SHA512 (crystal-0.34.0-x86_64-freebsd.o.xz) = e5398d9c5e62f35c53c50626df4c395a76a96546496d144895aad6433f381012ba69a25c591aff9e0906c925c5280d379baa6b3e1ffd4cda7de6c86487f34d38
+Size (crystal-0.34.0-x86_64-freebsd.o.xz) = 5472288 bytes
+SHA1 (crystal-0.34.0-x86_64-linux-gnu.o.xz) = 105bae3670169fe323a69dcbfb25266c60b9ab20
+RMD160 (crystal-0.34.0-x86_64-linux-gnu.o.xz) = 3f5ccdf6056c221daa898dfa7a45562f17654a08
+SHA512 (crystal-0.34.0-x86_64-linux-gnu.o.xz) = c7277fa9a79fe529b93bbb21fed4338ea39e6bdfec70dc3e1ade689e5c8964c2b7f865587ebb874f17c76ff2ba004f651b5b32ceaa6b42455ef0338a97e7b1c1
+Size (crystal-0.34.0-x86_64-linux-gnu.o.xz) = 5468252 bytes
+SHA1 (crystal-0.34.0-x86_64-linux-musl.o.xz) = 658786696ed60c864ac76e7805aa3d920222f13c
+RMD160 (crystal-0.34.0-x86_64-linux-musl.o.xz) = 42cb74982acec786d4e3b5997cd7918c1235c18a
+SHA512 (crystal-0.34.0-x86_64-linux-musl.o.xz) = 268ebfcb9a7e99d58d6964fd100a1b3e26b15d19fec0385269a35d32dc14a980be218e32919d909d87be9d08a99ba1c10eca1dc9528fd7720d9fb117d7c5da38
+Size (crystal-0.34.0-x86_64-linux-musl.o.xz) = 5468232 bytes
+SHA1 (crystal-0.34.0-x86_64-netbsd.o.xz) = ff593e4096d9754c8d8d3847cd939d5a73d59916
+RMD160 (crystal-0.34.0-x86_64-netbsd.o.xz) = 5c484616a9fbfb930df0b2b5a5c72dee129e574d
+SHA512 (crystal-0.34.0-x86_64-netbsd.o.xz) = b2fd639f87e9a2b1d21c0d228e4bef9fc377bf75b3c632c648a334317c9dc4a24144e18192620a70b9ed5116f537e760e24bcc203429e994dc54eb32f140d03c
+Size (crystal-0.34.0-x86_64-netbsd.o.xz) = 5464816 bytes
+SHA1 (crystal-0.35.0-00380c0038aae81be22e8128d5a092d66b2fdffb.tar.gz) = 3354f4e2146054cd61aebe05e46d16836266164b
+RMD160 (crystal-0.35.0-00380c0038aae81be22e8128d5a092d66b2fdffb.tar.gz) = 22c4adbbd2712042dd0c659870e2ac55b7c8f56c
+SHA512 (crystal-0.35.0-00380c0038aae81be22e8128d5a092d66b2fdffb.tar.gz) = 3c1a2dde43506f5d5446ed9c9aeb142d7e636c4aa49f7352f4abe16ff05398b666477fe81b99c4990adad68b7ceb9371d879eccc57f1254cd8f104cf7c0bde9b
+Size (crystal-0.35.0-00380c0038aae81be22e8128d5a092d66b2fdffb.tar.gz) = 2346211 bytes
+SHA1 (patch-src_compiler_crystal_codegen_link.cr) = 3178a9fa01b82bc450d1b49f74ada40968ad7ff5
diff --git a/crystal/files/Makefile b/crystal/files/Makefile
new file mode 100644
index 0000000000..a5a5ceb8bd
--- /dev/null
+++ b/crystal/files/Makefile
@@ -0,0 +1,30 @@
+# $NetBSD$
+#
+# This file produces a Crystal compiler for bootstrapping by building
+# the C/C++ components of Crystal, and linking them with the parts of
+# the Crystal compiler written in Crystal (provided as a cross-built
+# object).
+#
+# The standard Crystal build system expects a bootstrap compiler to
+# exist in .build, so this Makefile gets used there.
+#
+
+LLVM_CFLAGS!=	llvm-config --cflags
+LLVM_LIBS!=	llvm-config --libs
+
+PKG_LIBS!=	pkg-config --libs bdw-gc \
+			--libs libevent \
+			--libs libpcre
+
+CXXFLAGS+=	-std=c++14
+
+all: crystal
+
+crystal: crystal.o llvm_ext.o sigfault.o
+	$(CC) $(LDFLAGS) $(LLVM_LIBS) $(PKG_LIBS) -o crystal crystal.o llvm_ext.o sigfault.o
+
+llvm_ext.o: ../src/llvm/ext/llvm_ext.cc
+	$(CXX) $(CXXFLAGS) $(LLVM_CFLAGS) -o llvm_ext.o -c ../src/llvm/ext/llvm_ext.cc
+
+sigfault.o: ../src/ext/sigfault.c
+	$(CC) $(CFLAGS) -o sigfault.o -c ../src/ext/sigfault.c
diff --git a/crystal/patches/patch-src_compiler_crystal_codegen_link.cr b/crystal/patches/patch-src_compiler_crystal_codegen_link.cr
new file mode 100644
index 0000000000..0ecb731d9f
--- /dev/null
+++ b/crystal/patches/patch-src_compiler_crystal_codegen_link.cr
@@ -0,0 +1,15 @@
+$NetBSD$
+
+Add pkgsrc's PREFIX to the library search path.
+
+--- src/compiler/crystal/codegen/link.cr.orig	2020-06-04 12:01:14.000000000 +0000
++++ src/compiler/crystal/codegen/link.cr
+@@ -110,7 +110,7 @@ module Crystal
+ 
+     private def lib_flags_posix
+       library_path = ENV["LIBRARY_PATH"]?.try(&.split(':', remove_empty: true)) ||
+-                     ["/usr/lib", "/usr/local/lib"]
++                     ["/usr/lib", "@PREFIX@/lib", "/usr/local/lib"]
+       has_pkg_config = nil
+ 
+       String.build do |flags|


Home | Main Index | Thread Index | Old Index