Skip to content

Cross-compiling Node for Mips32/OpenWRT fails with "assembler.cc:(.text._ZN2v88internalL23f32_nearest_int_wrapperEPf+0x18): undefined reference to `nearbyintf'" #7316

Description

@kmandov

I am trying to cross-compile Node for Mips32 using the OpenWRT toolchain. The target architecture is ar71xx with NAND. I am following the instructions here.

I am using the following config:

./configure --without-snapshot --without-npm --without-intl --dest-cpu=mips --dest-os=linux

I get the following error:

...
/root/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/lib/gcc/mips-openwrt-linux-uclibc/4.8.3/../../../../mips-openwrt-linux-uclibc/bin/ld: Warning: /root/node/out/Release/node uses -msoft-float (set by /root/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/lib/gcc/mips-openwrt-linux-uclibc/4.8.3/crtbegin.o), /root/node/out/Release/obj.target/deps/v8/tools/gyp/libv8_nosnapshot.a(experimental-extras-libraries.o) uses -mhard-float
/root/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/lib/gcc/mips-openwrt-linux-uclibc/4.8.3/../../../../mips-openwrt-linux-uclibc/bin/ld: Warning: /root/node/out/Release/node uses -msoft-float (set by /root/openwrt/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/lib/gcc/mips-openwrt-linux-uclibc/4.8.3/crtbegin.o), /root/node/out/Release/obj.target/deps/v8/tools/gyp/libv8_nosnapshot.a(snapshot-empty.o) uses -mhard-float
/root/node/out/Release/obj.target/deps/v8/tools/gyp/libv8_base.a(assembler.o): In function v8::internal::f32_nearest_int_wrapper(float*)': assembler.cc:(.text._ZN2v88internalL23f32_nearest_int_wrapperEPf+0x18): undefined reference tonearbyintf'
collect2: error: ld returned 1 exit status
node.target.mk:206: recipe for target '/root/node/out/Release/node' failed
make[1]: *** [/root/node/out/Release/node] Error 1
rm _root_node_deps_v8_inspector_platform_inspector_protocol_protocol_gyp_protocol_sources_target_generateInspectorProtocolBackendSources.intermediate
make[1]: Leaving directory '/root/node/out'
Makefile:66: recipe for target 'node' failed
make: *** [node] Error 2

Here are the contents of config.gypi:

{ 'target_defaults': { 'cflags': [],
'default_configuration': 'Release',
'defines': [],
'include_dirs': [],
'libraries': []},
'variables': { 'asan': 0,
'gas_version': '2.24',
'host_arch': 'mips',
'icu_small': 'false',
'mips_arch_variant': 'r2',
'mips_fpu_mode': 'fp32',
'node_byteorder': 'little',
'node_enable_v8_vtunejit': 'false',
'node_install_npm': 'false',
'node_no_browser_globals': 'false',
'node_prefix': '/usr/local',
'node_release_urlbase': '',
'node_shared_cares': 'false',
'node_shared_http_parser': 'false',
'node_shared_libuv': 'false',
'node_shared_openssl': 'false',
'node_shared_zlib': 'false',
'node_tag': '',
'node_use_dtrace': 'false',
'node_use_etw': 'false',
'node_use_lttng': 'false',
'node_use_openssl': 'true',
'node_use_perfctr': 'false',
'openssl_fips': '',
'openssl_no_asm': 0,
'target_arch': 'mips',
'uv_parent_path': '/deps/uv/',
'uv_use_dtrace': 'false',
'v8_can_use_fpu_instructions': 'true',
'v8_enable_gdbjit': 0,
'v8_enable_i18n_support': 0,
'v8_inspector': 'true',
'v8_no_strict_aliasing': 1,
'v8_optimized_debug': 0,
'v8_random_seed': 0,
'v8_use_mips_abi_hardfloat': 'true',
'v8_use_snapshot': 'false',
'want_separate_host_toolset': 0}}

Is this a known issue or I am doing something wrong?
Thanks in advance!

Activity

  1. added
    buildIssues and PRs related to Node.js builds or CI infrastructure.
    on Jun 16, 2016
  2. mscdex commented on Jun 16, 2016

    @mscdex
    Contributor

    It looks like uclibc (or at least the version you are linking against) does not support nearbyintf(). Have you considered using something like musl instead?

  3. mscdex commented on Jun 16, 2016

    @mscdex
    Contributor

    FWIW it looks like there may be a patch to fix this in uclibc.

  4. kmandov commented on Jun 17, 2016

    @kmandov
    Author

    Thanks for the suggestions! I'll try patching uclibc.

  5. mitsos1os commented on Aug 26, 2016

    @mitsos1os
    Contributor

    Hi @mscdex ! Did you actually find a solution for this? Because I am in the exact same procedure! Thanks!

  6. mscdex commented on Aug 26, 2016

    @mscdex
    Contributor

    @mitsos1os I've never used uclibc, just musl. If you want to continue using uclibc, then you need to upgrade your copy or at least patch your copy of uclibc using the link I gave.

  7. mitsos1os commented on Aug 26, 2016

    @mitsos1os
    Contributor

    Ooops I actually wanted to mention @kmandov if he actually solved his problem! But @mscdex could give me a small hint on how to integrate musl to the OpenWRT toolchain? or if you propose an other toolchain to cross compile NodeJS on MIPS???

  8. mscdex commented on Aug 26, 2016

    @mscdex
    Contributor

    @mitsos1os The extent of my use of musl is building node fully statically (for the original Chromecast) so that I didn't have to worry about dependencies and needing other shared libraries -- it made things simpler. However the drawback with that approach is that you can't load node addons, but I didn't care about that.

    If you want to continue down the musl path, you can try following the steps here. I should note that I believe part 3 of step 3 (editing config.sh) is the only thing necessary in that particular step now, since the patches and other changes have been merged/fixed since I wrote that comment. Alternatively, you can download older pre-compiled musl cross-compilers (up to musl 1.1.12 as of this writing) here if you want to skip to step 5. Also, musl 1.1.15 is the current version as of this writing, so you could try building a cross-compiler from that version if you need a feature/fix/etc. from a newer musl version (this should just be a matter of setting MUSL_DEFAULT_VERSION=1.1.15 in defs.sh).

  9. mitsos1os commented on Aug 26, 2016

    @mitsos1os
    Contributor

    @mscdex Thank you for your support and guidance. I will give it a try when I can

  10. bnoordhuis commented on Jan 19, 2017

    @bnoordhuis
    Member

    Closing due to inactivity. For people who have the same issue, try switching to uclibc-ng or musl.

  11. elimisteve commented on Mar 7, 2017

    @elimisteve

    @mitsos1os Hi, I'm apparently in a very similar situation as you: trying to compile Node for a big endian 32-bit MIPS device with no hardware nor software FPU. Did you ever get this working?

    I've gathered that running a modern version of Node on a MIPS (or ARM) device with no FPU is very hard: http://stackoverflow.com/questions/34871072/how-to-compile-node-v4-2-4-with-armv7-without-fpu

    At that same link and a couple others, it sounds like using Node v0.10.x does work well on our target devices (SSL and all), and that perhaps the most promising way to go about building it is specified at http://wiki.linino.org/doku.php?id=wiki:nodepackage, which has you start with building Node for OpenWRT via the instructions at http://wiki.linino.org/doku.php?id=wiki:nodejsbuild.

    Have you found a more effective way to solve this problem? If the Linino instructions fail for me, I'll probably try compiling a custom kernel that does have soft FPU support, then try something like what you did above -- try using a modern version of Node.

    Thanks!

  12. mitsos1os commented on Mar 8, 2017

    @mitsos1os
    Contributor

    Hi @elimisteve, unfortunately I haven't successfully compiled latest node versions (>4) without fpu. These versions require at least a kernel with software FPU emulation.
    So what I did which I found the easiest, if you are able to use OPENWRT or LEDE on your device, use the very good packages found here: https://github.com/nxhack/openwrt-node-packages and it will be automatically compiled for your device. This is the latest version. LEDE (and probably Openwrt as well) include by default the 4 version, so you do not need the extra package setup if you are OK with 4 version of Node.
    Just remember to use FPU EMULATION in your kernel setup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildIssues and PRs related to Node.js builds or CI infrastructure.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions