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

unable to build therubyracer/libv8 on arm A10 #255

Closed
Lyann opened this issue May 13, 2013 · 19 comments
Closed

unable to build therubyracer/libv8 on arm A10 #255

Lyann opened this issue May 13, 2013 · 19 comments

Comments

@Lyann
Copy link

Lyann commented May 13, 2013

Hello,

currently having the problem to be unable to build therubyracer, because libv8 linking error. I tried to hack the compiler switch -fPIC into libv8/therubyracer, but without any success. Also there are a bit too much makefiles scons/rakefile/gby therefore not so easy to find the correct position where to add. Would be nice if someone could help me, I wasted already too much time into it. Setting up a qemu with an A10 vexpress image would be next step, but requires some time. Cannot use the system libv8 because it's very old, using currently the linaro quanta image on a cubieboard.

Thanks in advance

Copy & paste of the error at building:
Installing therubyracer (0.11.4)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /usr/bin/ruby1.9.1 extconf.rb

checking for main() in -lpthread... yes
creating Makefile

...

linking shared-object v8/init.so
/usr/bin/ld: /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/libv8-3.11.8.17/vendor/v8/out/arm.release/obj.target/tools/gyp/libv8_snapshot.a(libraries.o): relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/libv8-3.11.8.17/vendor/v8/out/arm.release/obj.target/tools/gyp/libv8_snapshot.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make: *** [init.so] Error 1

Gem files will remain installed in /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/therubyracer-0.11.4 for inspection.
Results logged to /home/git/gitlab/vendor/bundle/ruby/1.9.1/gems/therubyracer-0.11.4/ext/v8/gem_make.out
An error occurred while installing therubyracer (0.11.4), and Bundler cannot continue.
Make sure that gem install therubyracer -v '0.11.4' succeeds before bundling.

@ignisf
Copy link
Collaborator

ignisf commented May 13, 2013

What version of the libv8 gem are you using?

@Lyann
Copy link
Author

Lyann commented May 13, 2013

I am using libv8-3.11.8.17

@ignisf
Copy link
Collaborator

ignisf commented May 13, 2013

Sry I did not express myself clearly enough -- are you using the version from rubygems or did you clone the github repo and compile it manually? :)

@Lyann
Copy link
Author

Lyann commented May 13, 2013

No problem, I am doing a "bundle install --deployment --without development test mysql", therefore I would assume it downloads the version from rubygems or? I am just following the guide at https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/installation.md.

@ignisf
Copy link
Collaborator

ignisf commented May 13, 2013

Cannot use the system libv8 because it's very old
:/

Ok... Clone https://github.com/cowboyd/libv8, checkout the 3.11 branch and apply this patch to it. Then do a bundle exec rake build and gem install pkg/libv8-3.11.8.17.gem therubyracer. How much time did it take until this error was displayed btw?

diff --git a/patches/fPIC-on-x64.patch b/patches/fPIC-on-x64.patch
index 7388132..a95341a 100644
--- a/patches/fPIC-on-x64.patch
+++ b/patches/fPIC-on-x64.patch
@@ -6,7 +6,7 @@ index ebdf557..c7a59bc 100644
            [ 'OS=="linux"', {
              'cflags': [ '-ansi' ],
            }],
-+          [ '(OS=="linux" or OS=="freebsd" or OS=="solaris") and v8_target_arch=="x64" and component=="static_library"', {
++          [ '(OS=="linux" or OS=="freebsd" or OS=="solaris") and (v8_target_arch=="x64" or v8_target_arch=="arm") and component=="static_library"', {
 +            'cflags': [ '-fPIC' ],
 +          }],
            [ 'visibility=="hidden"', {

@Lyann
Copy link
Author

Lyann commented May 14, 2013

Same error, double checked the patch file (needed to apply patch file after bundle exec rake build, otherwise it was overwritten by some checkout). Build took nearly 45min.

Also applied the patch after the rake build manually "patch -N -p1 -d vendor/v8 < patches/fPIC-on-x64.patch", because it seems at bundle exec rake build the old patch will checkout and applied. But did not changed anything.

@Lyann
Copy link
Author

Lyann commented Jun 22, 2013

Any idea? Still not able to build gitlab with the libv8.

@Hrym
Copy link

Hrym commented Aug 24, 2013

Hi! I had the exact same problem as Lyann. Thanks ignisf for the patch, that worked great!

Though, to actually make use of the patch you can't simply run a bundle exec rake build, because the build-task seems to run a clean. I did the following, though I don't know if that's the simplest way:

git clone git://github.com/cowboyd/libv8.git
cd libv8
bundle install # install deps if you don't have them
bundle exec rake checkout

Apply ignisf's patch, I did that manually.

bundle exec rake compile
bundle exec rake binary
gem install pkg/libv8-3.11.8.17-arm-linux.gem therubyracer -v '0.11.4'

After this, it seems to run just fine! :)

@ignisf
Copy link
Collaborator

ignisf commented Aug 24, 2013

@Hrym, can you test if the newly released versions of therubyracer and libv8 compile correctly on your system, too?

@Hrym
Copy link

Hrym commented Aug 24, 2013

@ignisf, I have now tested the latest releases, therubyracer 0.12.0 and libv8 3.16.14.3. Both compile fine when v8_target_arch=="arm" is checked for.

@anomaly256
Copy link

I am still seeing this problem on libv8 3.16.14.3 and therubyracer 0.12.1

@edouardb
Copy link

You can try the following, it works for me on armv7

git clone https://github.com/cowboyd/libv8 libv8
cd libv8

In patches directory, edit the line in fPIC-for-static.patch [ 'component=="shared_library" or component=="static_library" and v8_target_arch=="x64"', {

+          [ 'component=="shared_library" or component=="static_library" and (v8_target_arch=="x64" or v8_target_arch=="arm")', {

Then

bundle exec rake checkout
patch -N -p1 -d vendor/v8 < patches/fPIC-for-static.patch

# Compile
bundle exec rake compile
# Generate binary
bundle exec rake binary
# Install GEM
cd pkg && bundle exec gem install libv8-3.16.14.3-xxx.gem

Installing therubyracer

git clone https://github.com/cowboyd/therubyracer /var/www/vendor/gems/therubyracer
cd therubyracer

In the rubyracer gemfile edit and add the following

#gem "rubysl", :platforms => :rbx
gem "libv8", :path => '<path_to_previous_libv8_dir>/libv8'
# Install necessary gems
bundle install
# Compile
bundle exec rake compile
# Generate binary
bundle exec rake build
# Install GEM
cd pkg && bundle exec gem install therubyracer-0.12.1.gem

@anomaly256
Copy link

Thanks I'll give that a try

@edouardb
Copy link

@anomaly256 Does it work ?

@anomaly256
Copy link

I will try it in the next day or 2 and report back, I've just been kept busy with a customer's project

@michaelarmstrong
Copy link

followed the instructions and it works for me flawlessly on armv7l debian jessi.

@edouardb
Copy link

edouardb commented Aug 1, 2014

Cool, Someone who can try on a Pi to validate this PR rubyjs/libv8#132 ?

@ghost
Copy link

ghost commented Apr 18, 2015

Here are the options to create a GitLab installation: https://about.gitlab.com/installation/

@cowboyd
Copy link
Collaborator

cowboyd commented Jul 12, 2015

resolved with #132

@cowboyd cowboyd closed this as completed Jul 12, 2015
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

7 participants