Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use MAP_STACK for mmap, add bash #12

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lang/crystal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ V_SHARDS = 0.7.2
COMMENT = statically typed object oriented language
DISTNAME = crystal-${V}
CATEGORIES = lang
REVISION = 0

HOMEPAGE = https://crystal-lang.org/
MAINTAINER = Wesley Moxam <wes@wmoxam.com>
Expand All @@ -29,7 +30,8 @@ DISTFILES = crystal-${V}{${V}}.tar.gz \
# Only builds with clang
COMPILER = base-clang ports-clang

BUILD_DEPENDS = devel/llvm
BUILD_DEPENDS = devel/llvm \
shells/bash

LIB_DEPENDS = converters/libiconv \
devel/boehm-gc \
Expand Down
20 changes: 20 additions & 0 deletions lang/crystal/patches/patch-src_fiber_cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
$OpenBSD$

Index: src/fiber.cr
--- src/fiber.cr.orig
+++ src/fiber.cr
@@ -90,9 +90,13 @@ class Fiber
end

protected def self.allocate_stack
+ flags = LibC::MAP_PRIVATE | LibC::MAP_ANON
+ {% if flag?(:openbsd) %}
+ flags |= LibC::MAP_STACK
+ {% end %}
@@stack_pool.pop? || LibC.mmap(nil, Fiber::STACK_SIZE,
LibC::PROT_READ | LibC::PROT_WRITE,
- LibC::MAP_PRIVATE | LibC::MAP_ANON,
+ flags,
-1, 0
).tap do |pointer|
raise Errno.new("Cannot allocate new fiber stack") if pointer == LibC::MAP_FAILED
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$OpenBSD$

Index: src/lib_c/amd64-unknown-openbsd/c/sys/mman.cr
--- src/lib_c/amd64-unknown-openbsd/c/sys/mman.cr.orig
+++ src/lib_c/amd64-unknown-openbsd/c/sys/mman.cr
@@ -11,6 +11,7 @@ lib LibC
MAP_ANON = 0x1000
MAP_ANONYMOUS = LibC::MAP_ANON
MAP_FAILED = Pointer(Void).new(-1)
+ MAP_STACK = 0x4000
POSIX_MADV_DONTNEED = 4
POSIX_MADV_NORMAL = 0
POSIX_MADV_RANDOM = 1