Skip to content

Commit

Permalink
upgrade erlang to 24.1.2 (#7738)
Browse files Browse the repository at this point in the history
  • Loading branch information
ian4hu authored Oct 27, 2021
1 parent 36d0153 commit 7c1cd8a
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 53 deletions.
27 changes: 11 additions & 16 deletions packages/erlang/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,31 @@ TERMUX_PKG_HOMEPAGE=https://www.erlang.org/
TERMUX_PKG_DESCRIPTION="General-purpose concurrent functional programming language"
TERMUX_PKG_LICENSE="Apache-2.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=22.3.4.22
TERMUX_PKG_VERSION=24.1.2
TERMUX_PKG_SRCURL=https://github.com/erlang/otp/archive/OTP-$TERMUX_PKG_VERSION.tar.gz
TERMUX_PKG_SHA256=dd306ac9987bbe80b20bf1efc8f94b7d6c0248c9fcb2dc761580c2c28d06cfba
TERMUX_PKG_SHA256=c141a046bb7184a7bb5c3d6da2ed013e465d1fbe4ff5cd16e0fbb7a0e786a152
TERMUX_PKG_AUTO_UPDATE=true
TERMUX_PKG_AUTO_UPDATE_TAG_REGEXP="\d+(\.\d+)+"
TERMUX_PKG_DEPENDS="openssl, ncurses, zlib"
TERMUX_PKG_NO_STATICSPLIT=true
TERMUX_PKG_HOSTBUILD=true
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--without-javac --with-ssl=${TERMUX_PREFIX} --with-termcap"
TERMUX_PKG_EXTRA_MAKE_ARGS="noboot"

termux_step_post_get_source() {
# We need a host build every time:
# We need a host build every time, because we dont know the full output of host build and have no idea to cache it.
rm -Rf "$TERMUX_PKG_HOSTBUILD_DIR"
./otp_build autoconf
}

termux_step_host_build() {
cd $TERMUX_PKG_SRCDIR
./configure --enable-bootstrap-only
make -j "$TERMUX_MAKE_PROCESSES"
cd $TERMUX_PKG_BUILDDIR
# Erlang cross compile reference: https://github.com/erlang/otp/blob/master/HOWTO/INSTALL-CROSS.md#building-a-bootstrap-system
# Build erlang bootstrap system.
./configure --enable-bootstrap-only --without-javac --without-ssl --without-termcap
make -j $TERMUX_MAKE_PROCESSES
}

termux_step_pre_configure() {
(cd erts && autoreconf)

# liblog is needed for syslog usage:
LDFLAGS+=" -llog"
# Put binaries built in termux_step_host_build at start of PATH:
cp bin/*/* $TERMUX_PKG_SRCDIR/bootstrap/bin
export PATH="$TERMUX_PKG_SRCDIR/bootstrap/bin:$PATH"
}
# Add --build flag for erlang cross build
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --build=$(./erts/autoconf/config.guess)"
}
60 changes: 60 additions & 0 deletions packages/erlang/emulator-asmjit-virtmem-shm.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
diff --git a/erts/emulator/asmjit/core/virtmem.cpp b/erts/emulator/asmjit/core/virtmem.cpp
index a1b0f95..d1eb1ad 100644
--- a/erts/emulator/asmjit/core/virtmem.cpp
+++ b/erts/emulator/asmjit/core/virtmem.cpp
@@ -62,12 +62,18 @@

#include <atomic>

-#if defined(__APPLE__)
+#if defined(__APPLE__) || defined(__ANDROID__)
#define ASMJIT_VM_SHM_DETECT 0
#else
#define ASMJIT_VM_SHM_DETECT 1
#endif

+#if defined(__ANDROID__)
+ #define ASMJIT_VM_SHM_AVAILABLE 0
+#else
+ #define ASMJIT_VM_SHM_AVAILABLE 1
+#endif
+
ASMJIT_BEGIN_NAMESPACE

// ============================================================================
@@ -258,8 +264,10 @@ public:

if (type == kFileTypeTmp)
return unlink(tmpName.data());
+#if ASMJIT_VM_SHM_AVAILABLE
else if (type == kFileTypeShm)
return shm_unlink(tmpName.data());
+#endif
else
return 0;
}
@@ -388,7 +396,7 @@ static ASMJIT_INLINE int VirtMem_appleSpecificMMapFlags(uint32_t flags) noexcept
#if !defined(SHM_ANON)
static const char* VirtMem_getTmpDir() noexcept {
const char* tmpDir = getenv("TMPDIR");
- return tmpDir ? tmpDir : "/tmp";
+ return tmpDir ? tmpDir : "@TERMUX_PREFIX@/tmp";
}
#endif

@@ -448,6 +456,7 @@ static Error VirtMem_openAnonymousMemory(AnonymousMemory* anonMem, bool preferTm
return kErrorOk;
}
}
+#if ASMJIT_VM_SHM_AVAILABLE
else {
anonMem->tmpName.assignFormat(kShmFormat, (unsigned long long)bits);
anonMem->fd = shm_open(anonMem->tmpName.data(), O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
@@ -456,6 +465,7 @@ static Error VirtMem_openAnonymousMemory(AnonymousMemory* anonMem, bool preferTm
return kErrorOk;
}
}
+#endif

int e = errno;
if (e != EEXIST)
104 changes: 72 additions & 32 deletions packages/erlang/erts-emulator-Makefile.in.patch
Original file line number Diff line number Diff line change
@@ -1,45 +1,85 @@
Based on the below change, updated for erlang 21:

From 85a3e5b4f65e5284e59dcdd90e92ea7d50ef6907 Mon Sep 17 00:00:00 2001
From: Romain Naour <romain.naour@openwide.fr>
Date: Sun, 8 Feb 2015 17:23:13 +0100
Subject: [PATCH] erts/emulator: reorder inclued headers paths

If the Perl Compatible Regular Expressions is installed on the
host and the path to the headers is added to the CFLAGS, the
pcre.h from the host is used instead of the one provided by
erlang.

Erlang use an old version of this file which is incompatible
with the upstream one.

Move INCLUDES before CFLAGS to use pcre.h from erlang.

http://autobuild.buildroot.net/results/cbd/cbd8b54eef535f19d7d400fd269af1b3571d6143/build-end.log

Signed-off-by: Romain Naour <romain.naour@openwide.fr>
---
erts/emulator/Makefile.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff -u -r ../otp-OTP-21.0.1/erts/emulator/Makefile.in ./erts/emulator/Makefile.in
--- ../otp-OTP-21.0.1/erts/emulator/Makefile.in 2018-06-25 13:19:47.000000000 +0200
+++ ./erts/emulator/Makefile.in 2018-07-01 18:06:51.931989663 +0200
@@ -712,7 +712,7 @@
diff --git a/erts/emulator/Makefile.in b/erts/emulator/Makefile.in
index c3449c5..7fb2a20 100644
--- a/erts/emulator/Makefile.in
+++ b/erts/emulator/Makefile.in
@@ -800,28 +800,28 @@ endif
# Usually the same as the default rule, but certain platforms (e.g. win32) mix
# different compilers
$(OBJDIR)/beam_emu.o: beam/beam_emu.c
$(OBJDIR)/beam_emu.o: beam/emu/beam_emu.c
- $(V_EMU_CC) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) $(INCLUDES) -c $< -o $@
+ $(V_EMU_CC) $(INCLUDES) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) -c $< -o $@

$(OBJDIR)/beam_emu.S: beam/beam_emu.c
$(V_EMU_CC) -S -fverbose-asm $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) $(INCLUDES) -c $< -o $@
@@ -765,7 +765,7 @@
$(OBJDIR)/beam_emu.S: beam/emu/beam_emu.c
- $(V_EMU_CC) -S -fverbose-asm $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) $(INCLUDES) -c $< -o $@
+ $(V_EMU_CC) -S -fverbose-asm $(INCLUDES) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) -c $< -o $@

$(OBJDIR)/%_pg.o: beam/%.c
- $(V_CC) $(PROFILE_GENERATE) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) $(INCLUDES) -c $< -o $@
+ $(V_CC) $(PROFILE_GENERATE) $(INCLUDES) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) -c $< -o $@

$(OBJDIR)/%_pg.o: beam/emu/%.c
- $(V_CC) $(PROFILE_GENERATE) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) $(INCLUDES) -c $< -o $@
+ $(V_CC) $(PROFILE_GENERATE) $(INCLUDES) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) -c $< -o $@

$(OBJDIR)/%_pu.o: beam/%.c $(PROFILE_USE_DEPS)
- $(V_CC) $(PROFILE_USE) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) $(INCLUDES) -c $< -o $@
+ $(V_CC) $(PROFILE_USE) $(INCLUDES) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) -c $< -o $@

$(OBJDIR)/%_pu.o: beam/emu/%.c $(PROFILE_USE_DEPS)
- $(V_CC) $(PROFILE_USE) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) $(INCLUDES) -c $< -o $@
+ $(V_CC) $(PROFILE_USE) $(INCLUDES) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) -c $< -o $@

$(OBJDIR)/%_pu.S: beam/%.c $(PROFILE_USE_DEPS)
- $(V_CC) -S -fverbose-asm $(PROFILE_USE) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) $(INCLUDES) -c $< -o $@
+ $(V_CC) -S -fverbose-asm $(PROFILE_USE) $(INCLUDES) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) -c $< -o $@

$(OBJDIR)/%_pu.S: beam/emu/%.c $(PROFILE_USE_DEPS)
- $(V_CC) -S -fverbose-asm $(PROFILE_USE) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) $(INCLUDES) -c $< -o $@
+ $(V_CC) -S -fverbose-asm $(PROFILE_USE) $(INCLUDES) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) -c $< -o $@

$(OBJDIR)/PROFILE: $(BINDIR)/$(PROFILE_EXECUTABLE)
$(V_at)echo " PROFILE ${PROFILE_EXECUTABLE}"
@@ -847,7 +847,7 @@ ifeq ($(ERTS_BUILD_FALLBACK_POLL),yes)
# Have to treat erl_poll differently as the same .c file is used
# twice for kernel poll builds.
$(OBJDIR)/erl_poll.o: sys/common/erl_poll.c
- $(V_CC) -DERTS_KERNEL_POLL_VERSION $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) $(INCLUDES) -c $< -o $@
+ $(V_CC) -DERTS_KERNEL_POLL_VERSION $(INCLUDES) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) -c $< -o $@

# Do a copy in order to make debuggers less confused
$(TTF_DIR)/erl_poll.flbk.c: sys/common/erl_poll.c
@@ -855,7 +855,7 @@ $(TTF_DIR)/erl_poll.flbk.c: sys/common/erl_poll.c
@touch $@

$(OBJDIR)/erl_poll.flbk.o: $(TTF_DIR)/erl_poll.flbk.c
- $(V_CC) -DERTS_NO_KERNEL_POLL_VERSION $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) $(INCLUDES) -c $< -o $@
+ $(V_CC) -DERTS_NO_KERNEL_POLL_VERSION $(INCLUDES) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) -c $< -o $@
endif


@@ -863,13 +863,13 @@ endif
# General targets
#
$(OBJDIR)/%.o: beam/%.c
- $(V_CC) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) $(INCLUDES) -c $< -o $@
+ $(V_CC) $(INCLUDES) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) -c $< -o $@

$(OBJDIR)/%.o: beam/emu/%.c
- $(V_CC) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) $(INCLUDES) -c $< -o $@
+ $(V_CC) $(INCLUDES) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) -c $< -o $@

$(OBJDIR)/%.o: beam/jit/%.c
- $(V_CC) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) $(INCLUDES) -c $< -o $@
+ $(V_CC) $(INCLUDES) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) -c $< -o $@

$(OBJDIR)/%.o: $(TARGET)/%.c
$(V_CC) $(CFLAGS) $(INCLUDES) -Idrivers/common -c $< -o $@
@@ -881,7 +881,7 @@ $(OBJDIR)/%.o: sys/$(ERLANG_OSTYPE)/%.c
$(V_CC) $(CFLAGS) $(INCLUDES) -c $< -o $@

$(OBJDIR)/%.o: sys/common/%.c
- $(V_CC) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) $(INCLUDES) -c $< -o $@
+ $(V_CC) $(INCLUDES) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) -c $< -o $@

$(OBJDIR)/%.o: drivers/common/%.c
$(V_CC) $(CFLAGS) -DLIBSCTP=$(LIBSCTP) $(INCLUDES) -Idrivers/common -Idrivers/$(ERLANG_OSTYPE) -c $< -o $@
10 changes: 5 additions & 5 deletions packages/erlang/prefix.patch
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
diff --git a/lib/kernel/src/os.erl b/lib/kernel/src/os.erl
index 29a26674ba..e6ab453a70 100644
index 96b5da9..e166e89 100644
--- a/lib/kernel/src/os.erl
+++ b/lib/kernel/src/os.erl
@@ -294,7 +294,7 @@ mk_cmd({win32,Wtype}, Cmd) ->
mk_cmd(_,Cmd) ->
%% Have to send command in like this in order to make sh commands like
%% cd and ulimit available
@@ -313,7 +313,7 @@ mk_cmd(_,Cmd) ->
%% We use an absolute path here because we do not want the path to be
%% searched in case a stale NFS handle is somewhere in the path before
%% the sh command.
- {"/bin/sh -s unix:cmd", [out],
+ {"@TERMUX_PREFIX@/bin/sh -s unix:cmd", [out],
%% We insert a new line after the command, in case the command
Expand Down

0 comments on commit 7c1cd8a

Please sign in to comment.