Bug 16406 - [Gtk] JavaScriptCore needs -lpthread
Summary: [Gtk] JavaScriptCore needs -lpthread
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
Depends on:
Blocks: 16411
  Show dependency treegraph
Reported: 2007-12-11 19:16 PST by Seo Sanghyeon
Modified: 2007-12-13 11:38 PST (History)
3 users (show)

See Also:

Include -lpthread (480 bytes, patch)
2007-12-11 19:24 PST, Seo Sanghyeon
mrowe: review-
Details | Formatted Diff | Diff
Remove kjs pthread dependency (1.75 KB, patch)
2007-12-11 20:20 PST, Alp Toker
mrowe: review-
Details | Formatted Diff | Diff
Prospective build fix (1.13 KB, patch)
2007-12-12 09:15 PST, Alp Toker
alp: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Seo Sanghyeon 2007-12-11 19:16:46 PST
JavaScriptCore build is missing -lpthread. This results in a build failure like:

tmp/collector.o: In function `KJS::currentThreadStackBase()':
collector.cpp:(.text+0x203): undefined reference to `pthread_getattr_np'
collector.cpp:(.text+0x21b): undefined reference to `pthread_attr_getstack'
tmp/collector.o: In function `KJS::Collector::markCurrentThreadConservatively()':
collector.cpp:(.text+0x825): undefined reference to `pthread_getattr_np'
collector.cpp:(.text+0x83d): undefined reference to `pthread_attr_getstack'
collect2: ld returned 1 exit status

In Gtk port, JavaScriptCore is built using compiler flags from icu-config. Normally, icu-config output includes -lpthread, like:

-lpthread -lm -L/usr/lib -licui18n -licuuc -licudata -lpthread -lm

But one doesn't need to link against libpthread when one is using only ICU functions. So as a part of general campaign to reduce spurious library dependency, Debian's icu-config doesn't output -lpthread starting from 3.8-5. Then the output looks like:

-lm -L/usr/lib -licui18n -licuuc -licudata -lm
Comment 1 Seo Sanghyeon 2007-12-11 19:24:37 PST
Created attachment 17858 [details]
Include -lpthread
Comment 2 Mark Rowe (bdash) 2007-12-11 19:50:46 PST
Comment on attachment 17858 [details]
Include -lpthread

You should set the review flag to ? if you'd like your patch looked at for review.  You should also include a description of your change in the ChangeLog at JavaScriptCore/ChangeLog.  See http://webkit.org/coding/contributing.html for more info.

The change looks fine to me.  It's not great to always add -lpthread as some platforms may not use pthreads, but as JavaScriptCore makes the assumption that they do when building multi-threaded I think it's fine for the meantime.

Marking as r- for now pending a ChangeLog entry.  Thanks for the patch!
Comment 3 Alp Toker 2007-12-11 20:20:17 PST
Created attachment 17859 [details]
Remove kjs pthread dependency

Proposed fix (needs review from someone who knows the collector and what correct behaviour is when threading is disabled)
Comment 4 Mark Rowe (bdash) 2007-12-11 21:06:58 PST
Comment on attachment 17859 [details]
Remove kjs pthread dependency

That will prevent the stack from being scanned at all, which is really bad.
Comment 5 Mike Hommey 2007-12-11 22:25:33 PST
Check out bug #15118, which is exactly the same issue, except that in the end, I couldn't reproduce with the icu not having -lpthread in its -config script.
Comment 6 Mike Hommey 2007-12-11 22:27:49 PST
(In reply to comment #5)
> Check out bug #15118, which is exactly the same issue, except that in the end,
> I couldn't reproduce with the icu not having -lpthread in its -config script.

It could actually be reproduced by debian buildds...

Comment 7 Alp Toker 2007-12-12 09:15:55 PST
Created attachment 17864 [details]
Prospective build fix

This patch links to pthread only when not building on Windows, and does it in JavaScriptCore.pri rather than testkjs.pro as proposed previously.

Untested since I can't reproduce the build breakage. Can someone try this?
Comment 8 Alp Toker 2007-12-13 11:37:42 PST
Comment on attachment 17864 [details]
Prospective build fix

Build fix; tested and works.
Comment 9 Alp Toker 2007-12-13 11:38:40 PST
Landed in r28692.