Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failure trying to compile for arm64+android #7731

Closed
nadiasvertex opened this issue Jul 14, 2016 · 11 comments · Fixed by #7762
Closed

failure trying to compile for arm64+android #7731

nadiasvertex opened this issue Jul 14, 2016 · 11 comments · Fixed by #7762
Labels
arm Issues and PRs related to the ARM platform. build Issues and PRs related to build files or the CI.

Comments

@nadiasvertex
Copy link

nadiasvertex commented Jul 14, 2016

I am trying to compile the source for arm64 using ndk-12b. I modified the android-configure script to allow arm64 as a target, and pointed to the arm64 toolchain. After grinding for a while, the build aborted here:

  LD_LIBRARY_PATH=/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/lib.host:/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../tools/icu; mkdir -p /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/obj/gen/icutmp; python icutrim.py -P "/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release" -D ../../deps/icu-small/source/data/in/icudt57l.dat --delete-tmp -T "/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/obj/gen/icutmp" -F icu_small.json -O icudt57l.dat -v -L en,root
Options: {'verbose': 1, 'filterfile': 'icu_small.json', 'toolpath': '/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release', 'deltmpdir': 1, 'outfile': 'icudt57l.dat', 'datfile': '../../deps/icu-small/source/data/in/icudt57l.dat', 'locales': 'en,root', 'endian': 'little', 'tmpdir': '/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/obj/gen/icutmp'}
icu_small.json: icutrim.py config: Trim down ICU to just a certain locale set, needed for node.js use.
/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg: 1: /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg: �Ё.Ё/Ё/: not found
/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg: 1: /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg: cannot open - No such file
/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg: 1: /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg: ELF��G
                                                                                                                                     @�?@8: not found
/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg: 6: /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg: cannot open 
                                                                                                                                           {� No such file
/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg: 6: /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg: �ay��!2: not found
/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg: 7: /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg: ��=: not found
�M5g not foundns/jobs/j2v8/workspace/node/out/Release/icupkg: 8: /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg: 2P^�
/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg: 9: /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg: cannot open �=��f~D�LUn@�d
                                                                                                                                                         �u
                                                                                                                                                           ���:��: No such file
/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg: 9: /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg: U3�E5�5�ylZ: not found
/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg: 1: /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg: -o^����
                                                                                                                                      S48
                                                                                                                                         ���sF: not found
/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg: 10: /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg:�Hke8: not found
/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg: 11: /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg: Syntax error: ")" unexpected
FAILED: /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/icupkg -tl ../../deps/icu-small/source/data/in/icudt57l.dat /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/obj/gen/icutmp/icudt57l.dat
make[1]: *** [/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/obj/gen/icutmp/icudt57l.dat] Error 1
make[1]: Leaving directory `/var/lib/jenkins/jobs/j2v8/workspace/node/out'
make: *** [node] Error 2

The build itself is being done on:

Linux usmeps008 3.13.0-85-generic #129-Ubuntu SMP Thu Mar 17 20:50:15 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Using Android NDK 12b

Thanks for your help!

[edit bnoordhuis - fixed formatting]

@bnoordhuis bnoordhuis added build Issues and PRs related to build files or the CI. arm Issues and PRs related to the ARM platform. labels Jul 14, 2016
@bnoordhuis
Copy link
Member

What does file /path/to/icupkg print? I suspect it's built for the wrong architecture.

@nadiasvertex
Copy link
Author

nadiasvertex commented Jul 14, 2016

file out/Release/icupkg
out/Release/icupkg: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked (uses shared libs), not stripped

@bnoordhuis
Copy link
Member

That's indeed the wrong architecture. icupkg runs as part of the build so it should have been built for x86_64.

You probably need to compile with make CC.host=/usr/bin/cc CXX.host=/usr/bin/c++ or something like it to tell the build system where it can find compilers for the host system.

@nadiasvertex
Copy link
Author

nadiasvertex commented Jul 14, 2016

That got me a lot farther. However, it's now failing in another spot. It looks again like it is trying to use the wrong architecture, but this time during linking:

 ln -f "/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/obj.target/tools/icu/libicuucx.a" "/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/libicuucx.a" 2>/dev/null || (rm -rf "/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/libicuucx.a" && cp -af "/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/obj.target/tools/icu/libicuucx.a" "/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/libicuucx.a")
  /var/lib/jenkins/jobs/j2v8/workspace/node/android-toolchain/bin/aarch64-linux-android-g++ -rdynamic -fPIE -pie  -o /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/genccode /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/obj.host/genccode/deps/icu-small/source/tools/genccode/genccode.o /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/obj.host/genccode/tools/icu/no-op.o /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/obj.host/tools/icu/libicutools.a -llog
/var/lib/jenkins/jobs/j2v8/workspace/node/android-toolchain/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/obj.host/genccode/deps/icu-small/source/tools/genccode/genccode.o: Relocations in generic ELF (EM: 62)
/var/lib/jenkins/jobs/j2v8/workspace/node/android-toolchain/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/obj.host/genccode/deps/icu-small/source/tools/genccode/genccode.o: Relocations in generic ELF (EM: 62)
/var/lib/jenkins/jobs/j2v8/workspace/node/android-toolchain/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/obj.host/genccode/deps/icu-small/source/tools/genccode/genccode.o: Relocations in generic ELF (EM: 62)
/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/obj.host/genccode/deps/icu-small/source/tools/genccode/genccode.o: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
make[1]: *** [/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/genccode] Error 1
make[1]: Leaving directory `/var/lib/jenkins/jobs/j2v8/workspace/node/out'
make: *** [node] Error 2

@bnoordhuis
Copy link
Member

It's possible you also need to pass LINK.host=/usr/bin/c++ to make (although it defaults to CXX.host, IIRC.)

@nadiasvertex
Copy link
Author

nadiasvertex commented Jul 14, 2016

Making more progress. :-) After adding that override, it now aborts at:

ln -f "/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/obj.target/tools/icu/libicuucx.a" "/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/libicuucx.a" 2>/dev/null || (rm -rf "/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/libicuucx.a" && cp -af "/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/obj.target/tools/icu/libicuucx.a" "/var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/libicuucx.a")
  /usr/bin/g++ -rdynamic -fPIE -pie  -o /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/genccode /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/obj.host/genccode/deps/icu-small/source/tools/genccode/genccode.o /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/obj.host/genccode/tools/icu/no-op.o /var/lib/jenkins/jobs/j2v8/workspace/node/out/Release/obj.host/tools/icu/libicutools.a -llog
/usr/bin/ld: cannot find -llog

@bnoordhuis
Copy link
Member

What happens when you apply this patch?

diff --git a/common.gypi b/common.gypi
index 646db0d..7c535ce 100644
--- a/common.gypi
+++ b/common.gypi
@@ -301,9 +301,13 @@
           }],
         ],
       }],
-      [ 'OS=="android"', {
-        'defines': ['_GLIBCXX_USE_C99_MATH'],
-        'libraries': [ '-llog' ],
+      ['OS=="android"', {
+        'target_conditions': [
+          ['_toolset="target"', {
+            'defines': [ '_GLIBCXX_USE_C99_MATH' ],
+            'libraries': [ '-llog' ],
+          }],
+        ],
       }],
       ['OS=="mac"', {
         'defines': ['_DARWIN_USE_64_BIT_INODE=1'],

@nadiasvertex
Copy link
Author

nadiasvertex commented Jul 14, 2016

creating ./config.gypi
creating ./config.mk

Traceback (most recent call last):
  File "tools/gyp_node.py", line 67, in <module>
    run_gyp(gyp_args)
  File "tools/gyp_node.py", line 16, in run_gyp
    rc = gyp.main(args)
  File "./tools/gyp/pylib/gyp/__init__.py", line 538, in main
    return gyp_main(args)
  File "./tools/gyp/pylib/gyp/__init__.py", line 514, in gyp_main
    options.duplicate_basename_check)
  File "./tools/gyp/pylib/gyp/__init__.py", line 130, in Load
    params['parallel'], params['root_targets'])
  File "./tools/gyp/pylib/gyp/input.py", line 2849, in Load
    target_dict, PHASE_LATE, variables, build_file)
  File "./tools/gyp/pylib/gyp/input.py", line 1261, in ProcessVariablesAndConditionsInDict
    ProcessConditionsInDict(the_dict, phase, variables, build_file)
  File "./tools/gyp/pylib/gyp/input.py", line 1134, in ProcessConditionsInDict
    build_file)
  File "./tools/gyp/pylib/gyp/input.py", line 1058, in EvalCondition
    cond_expr, true_dict, false_dict, phase, variables, build_file)
  File "./tools/gyp/pylib/gyp/input.py", line 1092, in EvalSingleCondition
    raise syntax_error
SyntaxError: invalid syntax while evaluating condition '_toolset="target"' in /var/lib/jenkins/jobs/j2v8/workspace/node/deps/v8_inspector/platform/v8_inspector/v8_inspector.gyp at character 9.

@nadiasvertex
Copy link
Author

I am not familiar with GYP, but I thought that _toolset="target" might ought to be _toolset=="target". I made that change and am currently building. This is the end of my work day, but I will report back tomorrow with my findings.

Thanks so much for your help!

@bnoordhuis
Copy link
Member

Ai, I don't know how that typo ended up in there but it should indeed read _toolset=="target".

@nadiasvertex
Copy link
Author

With this patch I got a successful compile this morning. Thank you!

bnoordhuis added a commit to bnoordhuis/io.js that referenced this issue Aug 1, 2016
Don't link binaries that run on the host system against liblog, it
breaks cross-compiling for android.

Fixes: nodejs#7731
PR-URL: nodejs#7762
Reviewed-By: Anna Henningsen <anna@addaleax.net>
cjihrig pushed a commit that referenced this issue Aug 10, 2016
Don't link binaries that run on the host system against liblog, it
breaks cross-compiling for android.

Fixes: #7731
PR-URL: #7762
Reviewed-By: Anna Henningsen <anna@addaleax.net>
MylesBorins pushed a commit that referenced this issue Oct 10, 2016
Don't link binaries that run on the host system against liblog, it
breaks cross-compiling for android.

Fixes: #7731
PR-URL: #7762
Reviewed-By: Anna Henningsen <anna@addaleax.net>
rvagg pushed a commit that referenced this issue Oct 18, 2016
Don't link binaries that run on the host system against liblog, it
breaks cross-compiling for android.

Fixes: #7731
PR-URL: #7762
Reviewed-By: Anna Henningsen <anna@addaleax.net>
MylesBorins pushed a commit that referenced this issue Oct 26, 2016
Don't link binaries that run on the host system against liblog, it
breaks cross-compiling for android.

Fixes: #7731
PR-URL: #7762
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arm Issues and PRs related to the ARM platform. build Issues and PRs related to build files or the CI.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants