Bug 97765 - lang/ruby18 default make without pthread, but link -lpthread
Summary: lang/ruby18 default make without pthread, but link -lpthread
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-24 05:10 UTC by Takeshi MUTOH
Modified: 2006-05-29 05:00 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Takeshi MUTOH 2006-05-24 05:10:20 UTC
Currently, lang/ruby make without pthread library by default.
But CONFIGURE_ARGS have pthread related entry without pthread related knob,
 so binary create with -lpthread.

Fix: Please apply patch below.



--
Takeshi MUTOH	<mutoh@openedu.org>--zgDa1wZCOyGzBjxQLG6U7pMlaoEtMTtkTruj3gy9vHmCWPKh
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

--- Makefile.org	Wed May 24 09:02:28 2006
+++ Makefile	Wed May 24 12:24:21 2006
@@ -43,6 +43,8 @@
 .if defined(WITH_PTHREADS)
 CONFIGURE_ARGS+=--enable-pthread
 PKGNAMESUFFIX:=	${PKGNAMESUFFIX}+pthreads
+CFLAGS+=${PTHREAD_CFLAGS}
+LIBS+=${PTHREAD_LIBS}
 .else
 CONFIGURE_ARGS+=--disable-pthread
 .endif
@@ -70,8 +72,8 @@
 CONFIGURE_ARGS+=	--enable-ipv6
 .endif
 
-CONFIGURE_ENV=	CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}" \
-		LIBS="${LIBS} ${PTHREAD_LIBS}"
+CONFIGURE_ENV=	CFLAGS="${CFLAGS}" \
+		LIBS="${LIBS}"
 
 .if ${RUBY_VER} == ${RUBY_DEFAULT_VER}
 MLINKS=		${RUBY_NAME}.1 ruby.1
How-To-Repeat: 
% cd /usr/ports/lang/ruby18
% make
% ldd work/ruby-1.8.4/ruby18 
work/ruby-1.8.4/ruby18:
        libruby18.so.18 => /usr/local/lib/libruby18.so.18 (0x28074000)
        libcrypt.so.3 => /lib/libcrypt.so.3 (0x2812e000)
        libm.so.4 => /lib/libm.so.4 (0x28146000)
        libpthread.so.2 => /usr/lib/libpthread.so.2 (0x2815c000)
        libc.so.6 => /lib/libc.so.6 (0x28181000)

See build log at
	http://mutoh.dyndns.org/tmp/ruby-build-old-20060524.log
Comment 1 Pav Lucistnik freebsd_committer freebsd_triage 2006-05-24 09:06:58 UTC
State Changed
From-To: open->closed

Committed, thanks!
Comment 2 kasahara 2006-05-29 04:56:23 UTC
The proposed patch was reverted by 1.8.4_8,1, but '-lpthread' causes
ruby scripts to have very limited stack size (again... see PR:
port/81464).  It was the point of introducing WITH_PTHREADS knob.

AFAIK, pthread's stack size is specified in libpthread/thread/thr_private.h.

------------------------
/*
 * Miscellaneous definitions.
 */
#define THR_STACK32_DEFAULT                     (1 * 1024 * 1024)
#define THR_STACK64_DEFAULT                     (2 * 1024 * 1024)

/*
 * Maximum size of initial thread's stack.  This perhaps deserves to be larger
 * than the stacks of other threads, since many applications are likely to run
 * almost entirely on this stack.
 */
#define THR_STACK32_INITIAL                     (2 * 1024 * 1024)
#define THR_STACK64_INITIAL                     (4 * 1024 * 1024)
------------------------

It seems that '-lpthread' causes every programs to have this limited
stacksize.  getrlimit() doesn't report the reduced stacksize (which
Ruby interpreter expects), so Ruby crashes without raising exception
when its stack is exhausted.  In my opinion, always linking libpthread
is overkill for only supporting ruby-gtk2....  Is it a issue of
pthread implementation?

I don't have a good solution though... Some of my scripts needs much
more stack size than pthread allows, and recently I need to use
ruby-gtk2, too.  Maybe I'll install two binaries (with and without
pthread).