From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 246FA138334 for ; Sun, 26 May 2019 08:26:08 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 35B07E07DF; Sun, 26 May 2019 08:26:07 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 055EAE07DF for ; Sun, 26 May 2019 08:26:06 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 25B23344FA4 for ; Sun, 26 May 2019 08:26:04 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 89E3E566 for ; Sun, 26 May 2019 08:26:01 +0000 (UTC) From: "Sergei Trofimovich" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sergei Trofimovich" Message-ID: <1558859154.ac0ba596486e18bea03c0a59cc95b0c036443ebb.slyfox@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/erlang/, dev-lang/erlang/files/ X-VCS-Repository: repo/gentoo X-VCS-Files: dev-lang/erlang/erlang-21.3-r1.ebuild dev-lang/erlang/files/erlang-21.3-lto.patch X-VCS-Directories: dev-lang/erlang/ dev-lang/erlang/files/ X-VCS-Committer: slyfox X-VCS-Committer-Name: Sergei Trofimovich X-VCS-Revision: ac0ba596486e18bea03c0a59cc95b0c036443ebb X-VCS-Branch: master Date: Sun, 26 May 2019 08:26:01 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 64509837-74c9-4d7c-b665-99780d60a97e X-Archives-Hash: ae2f647270a6d94b527f5a95c76362c8 commit: ac0ba596486e18bea03c0a59cc95b0c036443ebb Author: Sergei Trofimovich gentoo org> AuthorDate: Sun May 26 08:20:45 2019 +0000 Commit: Sergei Trofimovich gentoo org> CommitDate: Sun May 26 08:25:54 2019 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ac0ba596 dev-lang/erlang: fix lto support, bug #681778 re:replace/4 used libpcre2 with a stack overflow check. lto was smart enough to inline the check too much to make it useless. The changes uninlines stack prober and fixes re:replace/4. Reported-by: Fabio Coatti Closes: https://bugs.gentoo.org/681778 Package-Manager: Portage-2.3.66, Repoman-2.3.12 Signed-off-by: Sergei Trofimovich gentoo.org> dev-lang/erlang/erlang-21.3-r1.ebuild | 161 ++++++++++++++++++++++++++++ dev-lang/erlang/files/erlang-21.3-lto.patch | 140 ++++++++++++++++++++++++ 2 files changed, 301 insertions(+) diff --git a/dev-lang/erlang/erlang-21.3-r1.ebuild b/dev-lang/erlang/erlang-21.3-r1.ebuild new file mode 100644 index 00000000000..75e06e5602b --- /dev/null +++ b/dev-lang/erlang/erlang-21.3-r1.ebuild @@ -0,0 +1,161 @@ +# Copyright 1999-2019 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 +WX_GTK_VER="3.0" + +inherit autotools eapi7-ver elisp-common java-pkg-opt-2 systemd wxwidgets + +# NOTE: If you need symlinks for binaries please tell maintainers or +# open up a bug to let it be created. + +UPSTREAM_V="$(ver_cut 1-2)" + +DESCRIPTION="Erlang programming language, runtime environment and libraries (OTP)" +HOMEPAGE="https://www.erlang.org/" +SRC_URI="https://github.com/erlang/otp/archive/OTP-${PV}.tar.gz -> ${P}.tar.gz + http://erlang.org/download/otp_doc_man_${UPSTREAM_V}.tar.gz -> ${PN}_doc_man_${UPSTREAM_V}.tar.gz + doc? ( http://erlang.org/download/otp_doc_html_${UPSTREAM_V}.tar.gz -> ${PN}_doc_html_${UPSTREAM_V}.tar.gz )" + +LICENSE="Apache-2.0" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~x64-solaris" +IUSE="doc emacs +hipe java +kpoll libressl odbc pgo sctp ssl systemd tk wxwidgets" + +RDEPEND=" + sys-libs/ncurses:0 + sys-libs/zlib + emacs? ( virtual/emacs ) + java? ( >=virtual/jdk-1.8:* ) + odbc? ( dev-db/unixODBC ) + sctp? ( net-misc/lksctp-tools ) + ssl? ( + !libressl? ( >=dev-libs/openssl-0.9.7d:0= ) + libressl? ( dev-libs/libressl:0= ) + ) + systemd? ( sys-apps/systemd ) + tk? ( dev-lang/tk:0 ) + wxwidgets? ( x11-libs/wxGTK:${WX_GTK_VER}[X,opengl] ) +" +DEPEND="${RDEPEND} + dev-lang/perl +" + +S="${WORKDIR}/otp-OTP-${PV}" + +PATCHES=( + "${FILESDIR}/18.2.1-wx3.0.patch" + "${FILESDIR}/${PN}-20.3.2-dont-ignore-LDFLAGS.patch" + "${FILESDIR}/${PN}-add-epmd-pid-file-creation-for-openrc.patch" + "${FILESDIR}/${PN}-custom-autoconf.patch" + "${FILESDIR}/${PN}-21.3-lto.patch" +) + +SITEFILE=50"${PN}"-gentoo.el + +src_prepare() { + default + + ./otp_build autoconf + find -name configure.in -execdir mv '{}' configure.ac \; || die "find failed" + eautoreconf +} + +src_configure() { + use wxwidgets && setup-wxwidgets + + local myconf=( + --disable-builtin-zlib + $(use_enable hipe) + $(use_enable kpoll kernel-poll) + $(use_with java javac) + $(use_with odbc) + $(use_enable sctp) + $(use_with ssl ssl "${EPREFIX}"/usr) + $(use_enable ssl dynamic-ssl-lib) + $(use_enable systemd) + $(use_enable pgo) + $(usex wxwidgets "--with-wx-config=${WX_CONFIG}" "--with-wxdir=/dev/null") + --enable-threads + ) + econf "${myconf[@]}" +} + +src_compile() { + if use pgo; then + # disable distcc and ccache + export DISTCC_HOSTS="" + export CCACHE_DISABLE=1 + fi + + emake + + if use emacs ; then + pushd lib/tools/emacs &>/dev/null || die + elisp-compile *.el + popd &>/dev/null || die + fi +} + +extract_version() { + local path="$1" + local var_name="$2" + sed -n -e "/^${var_name} = \(.*\)$/s::\1:p" "${S}/${path}/vsn.mk" || die "extract_version() failed" +} + +src_install() { + local erl_libdir_rel="$(get_libdir)/erlang" + local erl_libdir="/usr/${erl_libdir_rel}" + local erl_interface_ver="$(extract_version lib/erl_interface EI_VSN)" + local erl_erts_ver="$(extract_version erts VSN)" + local my_manpath="/usr/share/${PN}/man" + + [[ -z "${erl_erts_ver}" ]] && die "Couldn't determine erts version" + [[ -z "${erl_interface_ver}" ]] && die "Couldn't determine interface version" + + emake INSTALL_PREFIX="${D}" install + + if use doc ; then + local DOCS=( "AUTHORS" "HOWTO"/* "README.md" "CONTRIBUTING.md" "${WORKDIR}"/doc/. "${WORKDIR}"/lib/. "${WORKDIR}"/erts-* ) + docompress -x /usr/share/doc/${PF} + else + local DOCS=("README.md") + fi + + einstalldocs + + dosym "../${erl_libdir_rel}/bin/erl" /usr/bin/erl + dosym "../${erl_libdir_rel}/bin/erlc" /usr/bin/erlc + dosym "../${erl_libdir_rel}/bin/escript" /usr/bin/escript + dosym "../${erl_libdir_rel}/lib/erl_interface-${erl_interface_ver}/bin/erl_call" /usr/bin/erl_call + dosym "../${erl_libdir_rel}/erts-${erl_erts_ver}/bin/beam.smp" /usr/bin/beam.smp + + ## Clean up the no longer needed files + rm "${ED}/${erl_libdir}/Install" || die + + insinto "${my_manpath}" + doins -r "${WORKDIR}"/man/* + # extend MANPATH, so the normal man command can find it + # see bug 189639 + newenvd - "90erlang" <<-_EOF_ + MANPATH="${my_manpath}" + _EOF_ + + if use emacs ; then + elisp-install erlang lib/tools/emacs/*.{el,elc} + sed -e "s:/usr/share:${EPREFIX}/usr/share:g" \ + "${FILESDIR}/${SITEFILE}" > "${T}/${SITEFILE}" || die + elisp-site-file-install "${T}/${SITEFILE}" + fi + + newinitd "${FILESDIR}"/epmd.init epmd + use systemd && systemd_dounit "${FILESDIR}"/epmd.service +} + +pkg_postinst() { + use emacs && elisp-site-regen +} + +pkg_postrm() { + use emacs && elisp-site-regen +} diff --git a/dev-lang/erlang/files/erlang-21.3-lto.patch b/dev-lang/erlang/files/erlang-21.3-lto.patch new file mode 100644 index 00000000000..c41e89f42c6 --- /dev/null +++ b/dev-lang/erlang/files/erlang-21.3-lto.patch @@ -0,0 +1,140 @@ +https://github.com/erlang/otp/pull/2194 +https://bugs.gentoo.org/681778 + +From ed751968d8dc4c0b58210247e94409a8a52cc501 Mon Sep 17 00:00:00 2001 +From: Sergei Trofimovich +Date: Thu, 28 Mar 2019 08:38:56 +0000 +Subject: [PATCH] stdlib: fix re:replace on LTO builds + +Fabio Coatti reported elixir build failure in https://bugs.gentoo.org/681778. +The minimal reproducer looks like that (from otp git tree): + + $ ./configure CFLAGS='-O2 -flto' LDFLAGS='-O2 -flto=8' + $ make + $ ERL_TOP=$PWD \ + PATH=$ERL_TOP/bin:$PATH \ + \ + bin/erl \ + \ + -noshell -eval 're:replace("a","b","c",[{return,list}]).' \ + -s erlang halt + + {"init terminating in do_boot",{badarg,[{re,replace,["a","b","c",[{return,list}]], + [{file,"re.erl"},{line,362}]}, + {erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,680}]}, + {init,start_it,1,[]}, + {init,start_em,1,[]}, + {init,do_boot,3,[]}]}} + init terminating in do_boot ({badarg,[{re,replace,[[_],[_],[_],[_]],[{_},{_}]}, + {erl_eval,do_apply,6,[{_},{_}]},{init,start_it,1,[]},{init,start_em,1,[]},{init,do_boot,3,[]}]}) + Crash dump is being written to: erl_crash.dump...done + +The failure happens in libpcre2 where stack overflow is mis-identified +at function entry of + + erts_pcre_compile2() + compile_regex() + if (PUBL(stack_guard) != NULL && PUBL(stack_guard)()) + { + *errorcodeptr= ERR85; + return FALSE; + } + +The stack "overflow" detection happens in + + thr_wrapper() + ethr_set_stacklimit__() + +because the stack usage code relies on the fact that ethr_set_stacklimit__() +and similar functions don't get inlined into callers for stack growth +measurement. + +Before the change inlining avoidance was achieved by putting functions +into standalone translation units. LTO makes this technique inefficient. + +The change marks functions explicitly as __attribute__((__noinline__)) on gcc. + +Reported-by: Fabio Coatti +Bug: https://bugs.gentoo.org/681778 +Signed-off-by: Sergei Trofimovich +--- + erts/emulator/beam/global.h | 9 +++++---- + erts/emulator/beam/sys.h | 10 ++++++++++ + erts/include/internal/ethr_internal.h | 2 +- + erts/include/internal/ethread_inline.h | 3 +++ + 4 files changed, 19 insertions(+), 5 deletions(-) + +diff --git a/erts/emulator/beam/global.h b/erts/emulator/beam/global.h +index f9bbe4167f9..4c8d3d3dbe6 100644 +--- a/erts/emulator/beam/global.h ++++ b/erts/emulator/beam/global.h +@@ -1216,10 +1216,11 @@ Uint64 erts_timestamp_millis(void); + + Export* erts_find_function(Eterm, Eterm, unsigned int, ErtsCodeIndex); + +-void *erts_calc_stacklimit(char *prev_c, UWord stacksize); +-int erts_check_below_limit(char *ptr, char *limit); +-int erts_check_above_limit(char *ptr, char *limit); +-void *erts_ptr_id(void *ptr); ++/* ERTS_NOINLINE prevents link-time optimization across modules */ ++void *erts_calc_stacklimit(char *prev_c, UWord stacksize) ERTS_NOINLINE; ++int erts_check_below_limit(char *ptr, char *limit) ERTS_NOINLINE; ++int erts_check_above_limit(char *ptr, char *limit) ERTS_NOINLINE; ++void *erts_ptr_id(void *ptr) ERTS_NOINLINE; + + Eterm store_external_or_ref_in_proc_(Process *, Eterm); + Eterm store_external_or_ref_(Uint **, ErlOffHeap*, Eterm); +diff --git a/erts/emulator/beam/sys.h b/erts/emulator/beam/sys.h +index a6312293cc8..24b6738e082 100644 +--- a/erts/emulator/beam/sys.h ++++ b/erts/emulator/beam/sys.h +@@ -63,6 +63,16 @@ + # endif + #endif + ++#ifndef ERTS_NOINLINE ++# if ERTS_AT_LEAST_GCC_VSN__(3,1,1) ++# define ERTS_NOINLINE __attribute__((__noinline__)) ++# elif defined(__WIN32__) ++# define ERTS_NOINLINE __declspec(noinline) ++# else ++# define ERTS_NOINLINE ++# endif ++#endif ++ + #if defined(DEBUG) || defined(ERTS_ENABLE_LOCK_CHECK) + # undef ERTS_CAN_INLINE + # define ERTS_CAN_INLINE 0 +diff --git a/erts/include/internal/ethr_internal.h b/erts/include/internal/ethr_internal.h +index ac27ff2ed09..17ec84c52b6 100644 +--- a/erts/include/internal/ethr_internal.h ++++ b/erts/include/internal/ethr_internal.h +@@ -90,7 +90,7 @@ int ethr_init_common__(ethr_init_data *id); + int ethr_late_init_common__(ethr_late_init_data *lid); + void ethr_run_exit_handlers__(void); + void ethr_ts_event_destructor__(void *vtsep); +-void ethr_set_stacklimit__(char *prev_c, size_t stacksize); ++void ethr_set_stacklimit__(char *prev_c, size_t stacksize) ETHR_NOINLINE; + + #if defined(ETHR_X86_RUNTIME_CONF__) + void ethr_x86_cpuid__(int *eax, int *ebx, int *ecx, int *edx); +diff --git a/erts/include/internal/ethread_inline.h b/erts/include/internal/ethread_inline.h +index 8e6bcfc4a8c..f25ba4ae721 100644 +--- a/erts/include/internal/ethread_inline.h ++++ b/erts/include/internal/ethread_inline.h +@@ -62,12 +62,15 @@ + # define ETHR_INLINE __inline__ + # if ETHR_AT_LEAST_GCC_VSN__(3, 1, 1) + # define ETHR_FORCE_INLINE __inline__ __attribute__((__always_inline__)) ++# define ETHR_NOINLINE __attribute__((__noinline__)) + # else + # define ETHR_FORCE_INLINE __inline__ ++# define ETHR_NOINLINE + # endif + #elif defined(__WIN32__) + # define ETHR_INLINE __forceinline + # define ETHR_FORCE_INLINE __forceinline ++# define ETHR_NOINLINE __declspec(noinline) + #endif + + #endif /* #ifndef ETHREAD_INLINE_H__ */