Bug 157875 - www/node: node.js fails build of native modules with Undefined Symbol
Summary: www/node: node.js fails build of native modules with Undefined Symbol
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: Vanilla I. Shu
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-14 15:20 UTC by Brett Kiefer
Modified: 2011-06-20 08:20 UTC (History)
0 users

See Also:


Attachments
lang-v8-Makefile.txt (262 bytes, text/plain; charset=US-ASCII)
2011-06-15 03:24 UTC, L Campbell
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Brett Kiefer 2011-06-14 15:20:15 UTC
When building native npm packages with a node.js built from /usr/ports/www/node, and a v8 built from /usr/ports/lang/v8, running gives a an Undefined symbol "_ZN2v811HandleScopeC1Ev".

How-To-Repeat: This is an example using the 'hiredis' package, but any npm module that builds a native package should have the same effect (I get the same thing with 'node-mongodb-native' and 'forever').

Install node from /usr/ports/www/node.

Then:
$ cd ~
$ curl http://npmjs.org/install.sh | sudo sh
$ npm install hiredis
$ node reader.js
/libexec/ld-elf.so.1: /usr/home/brett/node_modules/hiredis/build/default/hiredis.node: Undefined symbol "_ZN2v811HandleScopeC1Ev"
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2011-06-14 15:27:39 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-ports-bugs

ports PR.
Comment 2 Brett Kiefer 2011-06-14 16:04:59 UTC
This issue was created for one of the packages, but it looks like it's
a general linkage problem:
https://github.com/christkv/node-mongodb-native/issues/235

On Tue, Jun 14, 2011 at 10:20 AM,  <FreeBSD-gnats-submit@freebsd.org> wrote=
:
> Thank you very much for your problem report.
> It has the internal identification `misc/157875'.
> The individual assigned to look at your
> report is: freebsd-bugs.
>
> You can access the state of your problem report at any time
> via this link:
>
> http://www.freebsd.org/cgi/query-pr.cgi?pr=3D157875
>
>>Category: =A0 =A0 =A0 misc
>>Responsible: =A0 =A0freebsd-bugs
>>Synopsis: =A0 =A0 =A0 Ports node.js fails build of native modules with Un=
defined Symbol
>>Arrival-Date: =A0 Tue Jun 14 14:20:15 UTC 2011
>
Comment 3 L Campbell 2011-06-15 03:24:08 UTC
The issue is that the binary built by lang/v8 is compiled with
-fvisibility=hidden during compilation. This directive tells GCC to
exclude all symbols from the resultant object file except those which
are explicitly annotated otherwise; unfortunately, some of the hidden
symbols used in every node addon (things like v8::HandleScope, which
is going to always be the first function called in any
properly-written addon) are hidden by the directive. When you attempt
to `require` a node addon (which is just a shared object file), the
dynamic linker can't figure out how to link it in because all the
necessary symbols aren't exposed.

Reading through www/node/work/*/wscript revealed this in the bits
where it compiles the version of V8 it comes bundled with, and I just
happened to stumble across it while trying to debug this today:

 535   # NOTE: We want to compile V8 to export its symbols. I.E. Do not want
 536   # -fvisibility=hidden. When using dlopen() it seems that the loaded DSO
 537   # cannot see symbols in the executable which are hidden, even if the
 538   # executable is statically linked together...

Anyway, attached is a patch to lang/v8/Makefile which sets the scons
argument to remove the -fvisibility=hidden directive. If you apply the
patch, recompile lang/v8, then recompile www/node, addons should work
again (shouldn't need to recompile the addons).

:D
Comment 4 Vanilla I. Shu freebsd_committer freebsd_triage 2011-06-15 08:17:46 UTC
Responsible Changed
From-To: freebsd-ports-bugs->vanilla

I will handle this one.
Comment 5 Brett Kiefer 2011-06-15 18:59:44 UTC
lcampbell's patch works for me. Thanks!

On Tue, Jun 14, 2011 at 11:04 AM, Brett Kiefer <brett@fogcreek.com> wrote:
> This issue was created for one of the packages, but it looks like it's
> a general linkage problem:
> https://github.com/christkv/node-mongodb-native/issues/235
>
> On Tue, Jun 14, 2011 at 10:20 AM, =A0<FreeBSD-gnats-submit@freebsd.org> w=
rote:
>> Thank you very much for your problem report.
>> It has the internal identification `misc/157875'.
>> The individual assigned to look at your
>> report is: freebsd-bugs.
>>
>> You can access the state of your problem report at any time
>> via this link:
>>
>> http://www.freebsd.org/cgi/query-pr.cgi?pr=3D157875
>>
>>>Category: =A0 =A0 =A0 misc
>>>Responsible: =A0 =A0freebsd-bugs
>>>Synopsis: =A0 =A0 =A0 Ports node.js fails build of native modules with U=
ndefined Symbol
>>>Arrival-Date: =A0 Tue Jun 14 14:20:15 UTC 2011
>>
>
Comment 6 dfilter service freebsd_committer freebsd_triage 2011-06-20 08:16:45 UTC
vanilla     2011-06-20 07:16:31 UTC

  FreeBSD ports repository

  Modified files:
    lang/v8              Makefile distinfo pkg-plist 
    lang/v8/files        patch-SConstruct 
  Log:
  1: Upgrade to 3.4.4
  2: install shared library by default.
  3: resolv undefined symbol.
  
  PR:             ports/157875
  Submitted by:   Brett Kiefer <brett at fogcreek.com>, L Campbell <lcampbell at ironclad.mobi> [3]
  
  Revision  Changes    Path
  1.6       +12 -7     ports/lang/v8/Makefile
  1.4       +2 -2      ports/lang/v8/distinfo
  1.2       +8 -4      ports/lang/v8/files/patch-SConstruct
  1.3       +4 -0      ports/lang/v8/pkg-plist
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 7 Vanilla I. Shu freebsd_committer freebsd_triage 2011-06-20 08:18:05 UTC
State Changed
From-To: open->closed

Committed, thanks.