git: c653021c5cb7 - main - lang/lfortran: adding LFortran, a modern Fortran compiler built on top of LLVM

From: Thierry Thomas <thierry_at_FreeBSD.org>
Date: Tue, 01 Nov 2022 16:24:57 UTC
The branch main has been updated by thierry:

URL: https://cgit.FreeBSD.org/ports/commit/?id=c653021c5cb7a1501d9491e96d4ae0e8e94e6c3f

commit c653021c5cb7a1501d9491e96d4ae0e8e94e6c3f
Author:     Thierry Thomas <thierry@FreeBSD.org>
AuthorDate: 2022-10-31 22:33:55 +0000
Commit:     Thierry Thomas <thierry@FreeBSD.org>
CommitDate: 2022-11-01 16:24:53 +0000

    lang/lfortran: adding LFortran, a modern Fortran compiler built on top of LLVM
    
    /!\ This is an experimental prototype, not ready for end users.
---
 lang/Makefile                       |  1 +
 lang/lfortran/Makefile              | 43 +++++++++++++++++++++++++++++++++++++
 lang/lfortran/distinfo              |  3 +++
 lang/lfortran/files/patch-build0.sh | 20 +++++++++++++++++
 lang/lfortran/pkg-descr             |  9 ++++++++
 lang/lfortran/pkg-plist             | 17 +++++++++++++++
 6 files changed, 93 insertions(+)

diff --git a/lang/Makefile b/lang/Makefile
index 1cebf2597b27..622dc1c1ac58 100644
--- a/lang/Makefile
+++ b/lang/Makefile
@@ -154,6 +154,7 @@
     SUBDIR += lci
     SUBDIR += ldc
     SUBDIR += lfe
+    SUBDIR += lfortran
     SUBDIR += libhx
     SUBDIR += libobjc2
     SUBDIR += librep
diff --git a/lang/lfortran/Makefile b/lang/lfortran/Makefile
new file mode 100644
index 000000000000..957ce30def53
--- /dev/null
+++ b/lang/lfortran/Makefile
@@ -0,0 +1,43 @@
+PORTNAME=	lfortran
+DISTVERSIONPREFIX=	v
+DISTVERSION=	0.18.0
+CATEGORIES=	lang
+
+MAINTAINER=	fortran@FreeBSD.org
+COMMENT=	Modern interactive Fortran compiler built on top of LLVM
+WWW=		https://lfortran.org/
+
+LICENSE=	BSD3CLAUSE
+
+BUILD_DEPENDS=	bash:shells/bash		\
+		re2c>0:devel/re2c		\
+		dwarfdump:devel/dwarfdump	\
+		rapidjson>0:devel/rapidjson
+LIB_DEPENDS=	libfmt.so:devel/libfmt	\
+		libunwind.so:devel/libunwind	\
+		libLLVM-${LLVM_VERSION}.so:devel/llvm${LLVM_VERSION}
+RUN_DEPENDS=	dwarfdump:devel/dwarfdump
+
+USE_GITHUB=	yes
+
+USES=		bison cmake:testing compiler:c++17-lang python:build shebangfix
+SHEBANG_FILES=	*.sh
+BINARY_ALIAS=	python=${PYTHON_CMD}
+CMAKE_ON=	LFORTRAN_BUILD_ALL WITH_DWARFDUMP WITH_FMT WITH_JSON WITH_LINKH WITH_LLVM WITH_UNWIND
+
+LLVM_VERSION=	11
+
+OPTIONS_DEFINE=	DOCS
+
+# Xeus: version 2.4.1 is required
+#LIB_DEPENDS+=	libxeus.so:devel/xeus
+#CMAKE_ON+=	WITH_XEUS
+
+# BFD: /usr/local/include/bfd.h:2108:3: error: unknown type name 'ENUM_BITFIELD'
+#USE_BINUTILS=	yes
+#CMAKE_ON+=	WITH_BFD
+
+pre-configure:
+	${ECHO_CMD} ${PORTVERSION} > ${WRKSRC}/version
+
+.include <bsd.port.mk>
diff --git a/lang/lfortran/distinfo b/lang/lfortran/distinfo
new file mode 100644
index 000000000000..d8da96995604
--- /dev/null
+++ b/lang/lfortran/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1667243059
+SHA256 (lfortran-lfortran-v0.18.0_GH0.tar.gz) = 6ec636580cb7e49e1cd68003850bba77dc4372d2eda3e3591d4bff6dffa31e7c
+SIZE (lfortran-lfortran-v0.18.0_GH0.tar.gz) = 1713018
diff --git a/lang/lfortran/files/patch-build0.sh b/lang/lfortran/files/patch-build0.sh
new file mode 100644
index 000000000000..0f96d2b720b7
--- /dev/null
+++ b/lang/lfortran/files/patch-build0.sh
@@ -0,0 +1,20 @@
+--- build0.sh.orig	2022-11-01 11:12:16 UTC
++++ build0.sh
+@@ -4,7 +4,7 @@ set -e
+ set -x
+ 
+ # Generate the `version` file
+-ci/version.sh
++#ci/version.sh
+ 
+ # Generate a Fortran AST from AST.asdl (C++)
+ python src/libasr/asdl_cpp.py grammar/AST.asdl src/lfortran/ast.h
+@@ -16,7 +16,7 @@ python src/libasr/wasm_instructions_visitor.py
+ # Generate the tokenizer and parser
+ (cd src/lfortran/parser && re2c -W -b tokenizer.re -o tokenizer.cpp)
+ (cd src/lfortran/parser && re2c -W -b preprocessor.re -o preprocessor.cpp)
+-(cd src/lfortran/parser && bison -Wall -d -r all parser.yy)
++(cd src/lfortran/parser && bison -Wall -d -v -r all parser.yy)
+ 
+ grep -n "'" src/lfortran/parser/parser.yy && echo "Single quote not allowed" && exit 1
+ echo "OK"
diff --git a/lang/lfortran/pkg-descr b/lang/lfortran/pkg-descr
new file mode 100644
index 000000000000..77cd3da51f74
--- /dev/null
+++ b/lang/lfortran/pkg-descr
@@ -0,0 +1,9 @@
+LFortran is a modern open-source (BSD licensed) interactive Fortran compiler
+built on top of LLVM. It can execute user's code interactively to allow
+exploratory work (much like Python, MATLAB or Julia) as well as compile to
+binaries with the goal to run user's code on modern architectures such as
+multi-core CPUs and GPUs.
+
+Try online: https://dev.lfortran.org/
+
+See also: https://github.com/lfortran/lfortran
diff --git a/lang/lfortran/pkg-plist b/lang/lfortran/pkg-plist
new file mode 100644
index 000000000000..d5f4b83e65de
--- /dev/null
+++ b/lang/lfortran/pkg-plist
@@ -0,0 +1,17 @@
+bin/lfortran
+%%DATADIR%%/lib/impure/lfortran_intrinsics.h
+%%DATADIR%%/lib/lfortran_intrinsic_bit.mod
+%%DATADIR%%/lib/lfortran_intrinsic_builtin.mod
+%%DATADIR%%/lib/lfortran_intrinsic_ieee_arithmetic.mod
+%%DATADIR%%/lib/lfortran_intrinsic_iso_c_binding.mod
+%%DATADIR%%/lib/lfortran_intrinsic_iso_fortran_env.mod
+%%DATADIR%%/lib/lfortran_intrinsic_kind.mod
+%%DATADIR%%/lib/lfortran_intrinsic_math.mod
+%%DATADIR%%/lib/lfortran_intrinsic_math2.mod
+%%DATADIR%%/lib/lfortran_intrinsic_math3.mod
+%%DATADIR%%/lib/lfortran_intrinsic_optimization.mod
+%%DATADIR%%/lib/lfortran_intrinsic_sin.mod
+%%DATADIR%%/lib/lfortran_intrinsic_string.mod
+%%DATADIR%%/lib/lfortran_intrinsic_trig.mod
+%%DATADIR%%/lib/liblfortran_runtime.so
+%%DATADIR%%/lib/liblfortran_runtime_static.a