From 3cf9beab238c015964bb1c8193d9a4394fce3a21 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Sun, 23 Apr 2017 22:39:02 +0100 Subject: dev-lang/crystal: Workaround tty corruption in crystal, bug #616256 Patch restores blocking mode of file desriptors in exchange of potential runtime deadlocks when dealing with stdio. As it's a potentially invasive patch it's not enabled by default and is available only under USE=blocking-stdio-hack Reported-by: Renich Bon Ciric Bug: https://github.com/crystal-lang/crystal/issues/2065 Bug: https://bugs.gentoo.org/616256 Package-Manager: Portage-2.3.5, Repoman-2.3.2 --- dev-lang/crystal/crystal-0.22.0.ebuild | 8 +++++++- .../files/crystal-0.22.0-blocking-stdio-hack.patch | 20 ++++++++++++++++++++ dev-lang/crystal/metadata.xml | 3 +++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 dev-lang/crystal/files/crystal-0.22.0-blocking-stdio-hack.patch diff --git a/dev-lang/crystal/crystal-0.22.0.ebuild b/dev-lang/crystal/crystal-0.22.0.ebuild index 91cd89b0f5af..219789c6b1cd 100644 --- a/dev-lang/crystal/crystal-0.22.0.ebuild +++ b/dev-lang/crystal/crystal-0.22.0.ebuild @@ -18,7 +18,7 @@ SRC_URI="https://github.com/crystal-lang/crystal/archive/${PV}.tar.gz -> ${P}.ta LICENSE="Apache-2.0" SLOT="0" KEYWORDS="~amd64" -IUSE="doc debug examples +xml +yaml" +IUSE="doc debug examples blocking-stdio-hack +xml +yaml" # dev-libs/boehm-gc[static-libs] dependency problem, check the issue: https://github.com/manastech/crystal/issues/1382 DEPEND=" @@ -41,6 +41,12 @@ PATCHES=( "${FILESDIR}"/${PN}-0.20.5-LDFLAGS.patch ) +src_prepare() { + default + + use blocking-stdio-hack && eapply "${FILESDIR}"/"${PN}"-0.22.0-blocking-stdio-hack.patch +} + src_compile() { emake \ $(usex debug "" release=1) \ diff --git a/dev-lang/crystal/files/crystal-0.22.0-blocking-stdio-hack.patch b/dev-lang/crystal/files/crystal-0.22.0-blocking-stdio-hack.patch new file mode 100644 index 000000000000..07b7dba7be65 --- /dev/null +++ b/dev-lang/crystal/files/crystal-0.22.0-blocking-stdio-hack.patch @@ -0,0 +1,20 @@ +Workaround tty corruption in crystal. + +Patch restores blocking mode of file desriptors +in exchange of potential runtime deadlocks +when dealing with stdio. + +Reported-by: Renich Bon Ciric +Bug: https://github.com/crystal-lang/crystal/issues/2065 +Bug: https://bugs.gentoo.org/616256 +diff --git a/src/compiler/crystal/stdio.cr b/src/compiler/crystal/stdio.cr +new file mode 100644 +index 000000000..e65f65089 +--- /dev/null ++++ b/src/compiler/crystal/stdio.cr +@@ -0,0 +1,5 @@ ++module Crystal ++ STDIN.blocking = true ++ STDOUT.blocking=true ++ STDERR.blocking = true ++end diff --git a/dev-lang/crystal/metadata.xml b/dev-lang/crystal/metadata.xml index 80b55be2293e..8c0dacece652 100644 --- a/dev-lang/crystal/metadata.xml +++ b/dev-lang/crystal/metadata.xml @@ -22,6 +22,9 @@ Build each module as a separate object file. Speeds build up. + + Keep STDIO file descriptors in blocking mode. + Use the dev-libs/libyaml library to enable Crystal yaml module -- cgit v1.2.3-65-gdbad