rubyjs / libv8-node

Package libv8 from Node
MIT License
14 stars 27 forks source link

Relocation error on ruby 2.0, 2.1, and 2.2 #12

Closed lloeki closed 3 years ago

lloeki commented 4 years ago
linking shared-object sq_mini_racer_extension.so
65
/usr/bin/ld: /__w/AgentRuby/AgentRuby/vendor/bundle/ruby/2.0.0/gems/sq_mini_racer-0.3.1.0.0/ext/mini_racer_extension/vendor/libv8-node-14.14.0.0.beta2-x86_64-linux/vendor/v8/out.gn/libv8/obj/libv8_monolith.a(api.o): unrecognized relocation (0x2a) in section `.text._ZN2v89ExtensionD2Ev[_ZN2v89ExtensionD5Ev]'
lloeki commented 4 years ago

Probable cause is a ld too recent for older ld to link against the resulting lib.

Indeed ld versions:

for i in `seq 0 7`; do docker run --rm -it ruby:2.$i ld --version | grep ld; done 
GNU ld (GNU Binutils for Debian) 2.25
GNU ld (GNU Binutils for Debian) 2.25
GNU ld (GNU Binutils for Debian) 2.25
GNU ld (GNU Binutils for Debian) 2.28
GNU ld (GNU Binutils for Debian) 2.31.1
GNU ld (GNU Binutils for Debian) 2.31.1
GNU ld (GNU Binutils for Debian) 2.31.1
GNU ld (GNU Binutils for Debian) 2.31.1

Debian versions:

for i in `seq 0 7`; do docker run --rm -it ruby:2.$i cat /etc/debian_version; done
8.3
8.8
8.10
9.8
10.3
10.6
10.6
10.6
lloeki commented 4 years ago

Attempting a downgrade of the image to ruby:2.2, but there are other options listed here:

Currently we have this:

$ find . -path './obj.target/icu*/**/*.o' | while read -r f; do readelf -r "$f" | grep R_X86_64_REX_GOTP; done | head
000000000003  00170000002a R_X86_64_REX_GOTP 0000000000000000 _ZTVN6icu_6712SharedOb - 4
000000000043  001d0000002a R_X86_64_REX_GOTP 0000000000000000 _ZTVN6icu_6716UnifiedC - 4
0000000000e3  00230000002a R_X86_64_REX_GOTP 0000000000000000 _ZTVN6icu_6724WholeStr - 4
000000000275  00230000002a R_X86_64_REX_GOTP 0000000000000000 _ZTVN6icu_6724WholeStr - 4
000000001a3f  00370000002a R_X86_64_REX_GOTP 0000000000000000 _ZTVN6icu_6713UnicodeS - 4
000000001c2a  00390000002a R_X86_64_REX_GOTP 0000000000000000 uhash_compareUnicodeSt - 4
000000001c37  003a0000002a R_X86_64_REX_GOTP 0000000000000000 uprv_deleteUObject_67 - 4
000000001cec  00390000002a R_X86_64_REX_GOTP 0000000000000000 uhash_compareUnicodeSt - 4
000000001cf9  003a0000002a R_X86_64_REX_GOTP 0000000000000000 uprv_deleteUObject_67 - 4
000000000359  002f0000002a R_X86_64_REX_GOTP 0000000000000000 _UTF16v2Data_67 - 4
lloeki commented 4 years ago

Use older ld by moving to ruby:2.2:

./build-libv8: 15: ./build-libv8: python3: not found

Install python3 as a system dependency:

Please use python3.9 or python3.8 or python3.7 or python3.6 or python3.5 or python2.7.
6
Node.js configure: Found Python 3.4.2...

Go back to python2, taking care of patching broken icutrim.py:

--- a/tools/icu/icutrim.py  2020-11-03 16:54:23.000000000 +0100
+++ b/tools/icu/icutrim.py  2020-11-03 16:54:27.000000000 +0100
@@ -316,7 +316,10 @@
             erritems = fi.readlines()
             fi.close()
             #Item zone/zh_Hant_TW.res depends on missing item zone/zh_Hant.res
-            pat = re.compile(bytes(r"^Item ([^ ]+) depends on missing item ([^ ]+).*", 'utf-8'))
+            if str == bytes:
+              pat = re.compile(bytes(r"^Item ([^ ]+) depends on missing item ([^ ]+).*"))
+            else:
+              pat = re.compile(bytes(r"^Item ([^ ]+) depends on missing item ([^ ]+).*", 'utf-8'))
             for i in range(len(erritems)):
                 line = erritems[i].strip()
                 m = pat.match(line)

But no dice:

WARNING: C++ compiler (CXX=g++, 4.9.2) too old, need g++ 6.3.0 or clang++ 8.0.0

This Debian 8 platform is dead. I'll try the clang route on a more recent image.

lloeki commented 3 years ago

This is very painful, libv8-node will support these only via node 10.x (later ones requiring GCC 6 or Clang 8 at build time, and the matching C++ libs at runtime).