Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

linking issues on gentoo-amd64 #8

Closed
cowboyd opened this issue Jun 2, 2011 · 34 comments
Closed

linking issues on gentoo-amd64 #8

cowboyd opened this issue Jun 2, 2011 · 34 comments

Comments

@cowboyd
Copy link
Collaborator

cowboyd commented Jun 2, 2011

see here

@gdelugre
Copy link

gdelugre commented Jun 2, 2011

The linking process works if I remove the statement -Wl,--no-undefined, but I have not tested whether this would cause problems at run-time.

@cowboyd
Copy link
Collaborator Author

cowboyd commented Jun 3, 2011

if you have the rubyracer installed you can run

therubyracer --selftest

and it should run it through its paces.

@kalabiyau
Copy link

Same for me.

x86_64-pc-linux-gnu-g++ -shared -o v8.so v8_value.o v8_script.o rr.o v8_external.o v8_context.o v8_try_catch.o v8_array.o v8_string.o v8_date.o v8_locker.o v8_function.o v8_callbacks.o v8_weakref.o v8_template.o v8_object.o v8_message.o v8_v8.o v8_exception.o v8_debug.o v8_handle.o v8.o -L/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8 -Wl,-R/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8 -L. -L/usr/lib64 -Wl,-R/usr/lib64 -L. -Wl,-O1 -Wl,--as-needed -rdynamic -Wl,-export-dynamic -Wl,--no-undefined   -Wl,-R -Wl,/usr/lib64 -L/usr/lib64 -lruby19 -lpthread  -lpthread -lrt -ldl -lcrypt -lm   -lc -lv8
/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8/libv8.a(platform-linux.o): In function `v8::internal::LinuxSemaphore::Signal()':
platform-linux.cc:(.text._ZN2v88internal14LinuxSemaphore6SignalEv[v8::internal::LinuxSemaphore::Signal()]+0x5): undefined reference to `sem_post'
/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8/libv8.a(platform-linux.o): In function `v8::internal::LinuxSemaphore::~LinuxSemaphore()':
platform-linux.cc:(.text._ZN2v88internal14LinuxSemaphoreD1Ev[v8::internal::LinuxSemaphore::~LinuxSemaphore()]+0x13): undefined reference to `sem_destroy'
/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8/libv8.a(platform-linux.o): In function `v8::internal::LinuxSemaphore::~LinuxSemaphore()':
platform-linux.cc:(.text._ZN2v88internal14LinuxSemaphoreD0Ev[v8::internal::LinuxSemaphore::~LinuxSemaphore()]+0x13): undefined reference to `sem_destroy'
/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8/libv8.a(platform-linux.o): In function `v8::internal::OS::CreateSemaphore(int)':
platform-linux.cc:(.text._ZN2v88internal2OS15CreateSemaphoreEi+0x30): undefined reference to `sem_init'
/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8/libv8.a(platform-linux.o): In function `v8::internal::LinuxSemaphore::Wait(int)':
platform-linux.cc:(.text._ZN2v88internal14LinuxSemaphore4WaitEi+0xb0): undefined reference to `sem_timedwait'
/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8/libv8.a(platform-linux.o): In function `v8::internal::LinuxSemaphore::Wait()':
platform-linux.cc:(.text._ZN2v88internal14LinuxSemaphore4WaitEv+0x35): undefined reference to `sem_wait'
platform-linux.cc:(.text._ZN2v88internal14LinuxSemaphore4WaitEv+0x56): undefined reference to `sem_wait'
/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8/libv8.a(platform-linux.o): In function `v8::internal::OS::CreateMutex()':
platform-linux.cc:(.text._ZN2v88internal2OS11CreateMutexEv+0x29): undefined reference to `pthread_mutexattr_init'
platform-linux.cc:(.text._ZN2v88internal2OS11CreateMutexEv+0x36): undefined reference to `pthread_mutexattr_settype'
/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8/libv8.a(platform-linux.o): In function `v8::internal::LinuxMutex::TryLock()':
platform-linux.cc:(.text._ZN2v88internal10LinuxMutex7TryLockEv[v8::internal::LinuxMutex::TryLock()]+0x9): undefined reference to `pthread_mutex_trylock'
/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8/libv8.a(platform-linux.o): In function `v8::internal::Thread::SetThreadLocal(v8::internal::Thread::LocalStorageKey, void*)':
platform-linux.cc:(.text._ZN2v88internal6Thread14SetThreadLocalENS1_15LocalStorageKeyEPv+0x1): undefined reference to `pthread_setspecific'
/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8/libv8.a(platform-linux.o): In function `v8::internal::Thread::GetThreadLocal(v8::internal::Thread::LocalStorageKey)':
platform-linux.cc:(.text._ZN2v88internal6Thread14GetThreadLocalENS1_15LocalStorageKeyE+0x1): undefined reference to `pthread_getspecific'
/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8/libv8.a(platform-linux.o): In function `v8::internal::Thread::DeleteThreadLocalKey(v8::internal::Thread::LocalStorageKey)':
platform-linux.cc:(.text._ZN2v88internal6Thread20DeleteThreadLocalKeyENS1_15LocalStorageKeyE+0x1): undefined reference to `pthread_key_delete'
/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8/libv8.a(platform-linux.o): In function `v8::internal::Thread::CreateThreadLocalKey()':
platform-linux.cc:(.text._ZN2v88internal6Thread20CreateThreadLocalKeyEv+0xc): undefined reference to `pthread_key_create'
/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8/libv8.a(platform-linux.o): In function `v8::internal::Thread::Join()':
platform-linux.cc:(.text._ZN2v88internal6Thread4JoinEv+0xa): undefined reference to `pthread_join'
/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8/libv8.a(platform-linux.o): In function `v8::internal::Thread::Start()':
platform-linux.cc:(.text._ZN2v88internal6Thread5StartEv+0x3a): undefined reference to `pthread_attr_setstacksize'
platform-linux.cc:(.text._ZN2v88internal6Thread5StartEv+0x50): undefined reference to `pthread_create'
/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8/libv8.a(platform-linux.o): In function `v8::internal::ThreadEntry(void*)':
platform-linux.cc:(.text._ZN2v88internalL11ThreadEntryEPv+0x35): undefined reference to `pthread_setspecific'
/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8/libv8.a(platform-linux.o): In function `v8::internal::ProfilerSignalHandler(int, siginfo*, void*)':
platform-linux.cc:(.text._ZN2v88internalL21ProfilerSignalHandlerEiP7siginfoPv+0x4f): undefined reference to `pthread_getspecific'
/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8/libv8.a(platform-linux.o): In function `v8::internal::OS::LogSharedLibraryAddresses()':
platform-linux.cc:(.text._ZN2v88internal2OS25LogSharedLibraryAddressesEv+0x5f): undefined reference to `pthread_getspecific'
/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8/libv8.a(platform-linux.o): In function `v8::internal::Sampler::Stop()':
platform-linux.cc:(.text._ZN2v88internal7Sampler4StopEv+0x5e): undefined reference to `pthread_join'
/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8/libv8.a(platform-linux.o): In function `v8::internal::OS::Allocate(unsigned long, unsigned long*, bool)':
platform-linux.cc:(.text._ZN2v88internal2OS8AllocateEmPmb+0xbd): undefined reference to `pthread_getspecific'
/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8/libv8.a(platform-linux.o): In function `global constructors keyed to platform_linux.cc':
platform-linux.cc:(.text._GLOBAL__I_platform_linux.cc+0x29): undefined reference to `pthread_mutexattr_init'
platform-linux.cc:(.text._GLOBAL__I_platform_linux.cc+0x36): undefined reference to `pthread_mutexattr_settype'
/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8/libv8.a(platform-linux.o): In function `v8::internal::OS::Setup()':
platform-linux.cc:(.text._ZN2v88internal2OS5SetupEv+0x3e): undefined reference to `pthread_mutexattr_init'
platform-linux.cc:(.text._ZN2v88internal2OS5SetupEv+0x4b): undefined reference to `pthread_mutexattr_settype'
/usr/lib64/ruby/gems/1.9.1/gems/libv8-3.3.10.2-x86_64-linux/lib/libv8/build/v8/libv8.a(platform-linux.o): In function `v8::internal::Sampler::Start()':
platform-linux.cc:(.text._ZN2v88internal7Sampler5StartEv+0x171): undefined reference to `pthread_attr_setstacksize'
platform-linux.cc:(.text._ZN2v88internal7Sampler5StartEv+0x187): undefined reference to `pthread_create'
collect2: ld returned 1 exit status
make: *** [v8.so] Error 1

@cowboyd
Copy link
Collaborator Author

cowboyd commented Sep 16, 2011

two questions:

  1. are you able to compile v8 manually
  2. when you run the selftest, does it work?

@kalabiyau
Copy link

  1. Manual compile was long about 5 minutes, but ends with no errors
  2. Where i can find it ?

@cowboyd
Copy link
Collaborator Author

cowboyd commented Sep 16, 2011

therubyracer --selftest

@kalabiyau
Copy link

{ ...byracer-0.9.4/bin }$ ./therubyracer
/usr/lib64/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in require': no such file to load -- v8 (LoadError) from /usr/lib64/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:inrequire'
from ./therubyracer:7:in rescue in <main>' from ./therubyracer:3:in

'

but i have v8.so in therubyracer ext directory

@kalabiyau
Copy link

root@mail { ...uby/gems/1.9.1/gems/therubyracer-0.9.4/bin }$ ./therubyracer 
/usr/lib64/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- v8 (LoadError)
    from /usr/lib64/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from ./therubyracer:7:in `rescue in <main>'
    from ./therubyracer:3:in `<main>'

root@mail { ...uby/gems/1.9.1/gems/therubyracer-0.9.4/bin }$ find / -name v8.so
/usr/lib64/v8.so

@kalabiyau
Copy link

My problem totally solved - it is only gentoo ruby portage problem.
It is located in ruby make opts.
LDFLAGS used in resulting of ruby rbconfig.rb are wrong - using --no-undefined.
Therefore linkage is not completed successful.

Handy solution is to fix Config::CONFIG['LDFLAGS'] in rbconfig.rb to appropriate value.

I think this is not related to the project and therefore must be closed.

Thanks!

@kalabiyau
Copy link

What is a PR ? Tell me please and i'll do it )

@cowboyd
Copy link
Collaborator Author

cowboyd commented Sep 19, 2011

PR == 'pull request'. Actually, it sounds like there is nothing that we can tweak in this project to make it just magically work, right? In that case, I am just going to add an entry in the README to this issue for future Gentoo users who may come across this issue.

@kalabiyau
Copy link

I have this line in rbconfig.rb

CONFIG["LDFLAGS"] = "-L. -Wl,-O1 -Wl,--as-needed -rdynamic -Wl,-export-dynamic -Wl,--no-undefined"

With your extconf lib will not build up, but with
next line in extconf.rb

$LIBS << ' -lv8 -lpthread'

All is compiled successfully.
Maybe you should add this to the extconf.rb ??

Before we have in make file:

LIBS = $(LIBRUBYARG_SHARED) -lpthread  -lpthread -lrt -ldl -lcrypt -lm   -lc -lv8

and after

LIBS = $(LIBRUBYARG_SHARED) -lpthread  -lpthread -lrt -ldl -lcrypt -lm   -lc -lv8 -lpthread
linux-vdso.so.1 =>  (0x00007fff620f6000)
    libruby19.so.1.9 => /usr/lib64/libruby19.so.1.9 (0x00007f33e8e4d000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f33e8c23000)
    libstdc++.so.6 => /usr/lib/gcc/x86_64-pc-linux-gnu/4.4.5/libstdc++.so.6 (0x00007f33e890f000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f33e868e000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f33e8327000)
    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f33e8110000)
    librt.so.1 => /lib64/librt.so.1 (0x00007f33e7f07000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f33e7d02000)
    libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007f33e7acb000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f33e97fc000)

And one more - i think that #have_library('pthread') is explicit in extconf.rb in this case.

I test it on ubuntu and gentoo (see above)

on ubuntu with this ruby ldflags

CONFIG["LDFLAGS"] = "-L.  -rdynamic -Wl,-export-dynamic"

i have working v8.so

        linux-vdso.so.1 =>  (0x00007fff5dbff000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f2f74344000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f2f7413c000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f2f73f37000)
    libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f2f73cfe000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f2f739f8000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f2f73772000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2f733de000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f2f731c8000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f2f74b47000)

Thanks for Yurial - the best C++ programmer i ever know

@gdelugre
Copy link

I can now compile on Gentoo without error. I have not touched anything in my configuration, so I suppose the problem is now fixed?

Anyway, the gem is working fine when I use it, but I cannot use --selftest:

$ therubyracer --selftest
/usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- spec_helper (LoadError)
    from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from /usr/local/lib64/ruby/gems/1.8/gems/therubyracer-0.9.4/spec/ext/array_spec.rb:1
    from /usr/local/lib64/ruby/gems/1.8/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load'
    from /usr/local/lib64/ruby/gems/1.8/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load_spec_files'
    from /usr/local/lib64/ruby/gems/1.8/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `map'
    from /usr/local/lib64/ruby/gems/1.8/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load_spec_files'
    from /usr/local/lib64/ruby/gems/1.8/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:18:in `run'
    from /usr/local/lib64/ruby/gems/1.8/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:80:in `run_in_process'
    from /usr/local/lib64/ruby/gems/1.8/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:69:in `run'
    from /usr/local/lib64/ruby/gems/1.8/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:11:in `autorun'
    from /usr/local/bin/therubyracer:19

I have rspec installed.

@kalabiyau
Copy link

gdelugre, please do selftest at gem_localtion folder where spec subfolder is situated.

@gdelugre
Copy link

Thank you.
Everything is working fine.

@alexbhr
Copy link

alexbhr commented Oct 6, 2011

Hey guys,
this problem still persists on gentoo-amd64, any plans on incorporating a fix?

@cowboyd
Copy link
Collaborator Author

cowboyd commented Oct 6, 2011

according to @kalabiyau and @gdelugre, it is working fine for them, and they are using gentoo-amd64

@kalabiyau
Copy link

I confirm, U can test my fork of therubyracer https://github.com/kalabiyau/therubyracer

Please try and tell us what kind of problems will you have

@alexbhr
Copy link

alexbhr commented Oct 6, 2011

@cowboyd with the upstream gem I get the same error as above:
https://gist.github.com/86f8ed09775a8e18d4c8

@kalabiyau 's fork works like a charm, any plans on merging his changes in?

I have a large amount of servers that need building and deploying of all the gems automatically, so fiddling the gem is not an option and I would like to avoid cloning @kalabiyau's version in order to keep up to date.

@alexbhr
Copy link

alexbhr commented Oct 6, 2011

@kalabiyau sounds to me like you can submit a pull request for this commit:
kalabiyau/therubyracer@1964f87

@cowboyd feel like accepting this in exchange for beer? :P

@kalabiyau
Copy link

U can use it in gemfile like others but with git source, or U can make one gem builded on one server and deploy to anothers

About merging - maybe @cowboyd will check my PR :)

@kalabiyau
Copy link

rubyjs/therubyracer#108 this one is done, but needs testing on other platforms - MacOS and freebsd

@cowboyd
Copy link
Collaborator Author

cowboyd commented Oct 6, 2011

ok, v0.9.6 released

@cowboyd cowboyd closed this as completed Oct 6, 2011
@alexbhr
Copy link

alexbhr commented Oct 6, 2011

I am still having the same build problem on 0.9.6 under.

EDIT: Installing directly from gems still fails with the same error. "bundle install" in my Rails dir still fails to link as above.

@Metallord
Copy link

Same here.
@kalabiyau 's fork works though.

@cowboyd cowboyd reopened this Oct 6, 2011
@cowboyd
Copy link
Collaborator Author

cowboyd commented Oct 6, 2011

weird. I merged his PR. What if you try this:

rubyjs/therubyracer@ff1abe7

@alexbhr
Copy link

alexbhr commented Oct 6, 2011

Well, the following reproduces it reliably:

git clone git://github.com/cowboyd/therubyracer.git; cd therubyracer
gem build therubyracer.gemspec
gem install therubyracer-0.9.6.gem

Also, this Gentoo build was made from stage3-amd64-20110929.tar.bz2 and a portage snapshot of 20110930. Ruby 1.9.2 installed via portage.

EDIT: Same thing works for @kalabiyau's fork.

@cowboyd
Copy link
Collaborator Author

cowboyd commented Oct 6, 2011

As mentioned, I have in fact merged his fork into master, so I'm not sure what exactly the problem is. @kalabiyau, can you tell why master is not building? I don't have a gentoo box available for testing

@kalabiyau
Copy link

I have tested it. IMHO We must use -lpthread after the lv8 linkage
If we make

LIBS = $(LIBRUBYARG_SHARED)   -lrt -ldl -lcrypt -lm   -lc -lv8 -lpthread

Only one include of -lpthread after -lv8 usage - all is compiled well, but with your

$LIBS << ' -lpthread' unless $LIBS =~ /-lpthread/

It will fail because of undefined errors

It is save to append one pthread to the end and the first one to delete ?

@cowboyd
Copy link
Collaborator Author

cowboyd commented Oct 6, 2011

Ok, well we'll just revert my "optimization" have a look at 0.9.7

@cowboyd cowboyd closed this as completed Oct 6, 2011
@Metallord
Copy link

Now I get this on installation (through bundler):

Installing therubyracer (0.9.7) with native extensions Invalid gemspec in 
[/home/lord/gems/bank/ruby/1.9.1/specifications/therubyracer-0.9.7.gemspec]: Illformed requirement ["#
<Syck::DefaultKey:0x00000004fa6500> 0.8.7"]

@Metallord
Copy link

It prevents the gem from being installed I should add.

@cowboyd
Copy link
Collaborator Author

cowboyd commented Oct 6, 2011

I believe that is a bug in either rubygems or in bundler

@Metallord
Copy link

Well I removed the Syck::DefaultKey things from the gemspec and it works now.
Thank you for caring enough to fix problems of the gentoo minority :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants