Skip to content

Cross-compilation bug when compiling for loongarch64 on a non-loongarch64 host with Linux #56280

Description

@wojiushixiaobai

Version

v22.12.0

Platform

Linux debian 6.1.0-27-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.115-1 (2024-11-01) x86_64 GNU/Linux

Subsystem

Cross-compiling for Linux loongarch64 on a Linux x86_64 machine.

What steps will reproduce the bug?

curl -L https://github.com/loongson/build-tools/releases/download/2023.08.08/CLFS-loongarch64-8.1-x86_64-cross-tools-gcc-glibc.tar.xz | tar xJf - -C /opt

export 'CC=ccache /opt/cross-tools/bin/loongarch64-unknown-linux-gnu-gcc'
export 'CXX=ccache /opt/cross-tools/bin/loongarch64-unknown-linux-gnu-g++'

make -j8 binary V= DESTCPU=loong64 ARCH=loong64 VARIATION= DISTTYPE=release CUSTOMTAG= DATESTRING= COMMIT= RELEASE_URLBASE=https://unofficial-builds.nodejs.org/download/release/ CONFIG_FLAGS=--openssl-no-asm

How often does it reproduce? Is there a required condition?

always

What is the expected behavior? Why is that the expected behavior?

Should compile.

What do you see instead?

/usr/bin/ld: /home/node/node-v22.12.0/out/Release/obj.host/v8_base_without_compiler/deps/v8/src/execution/loong64/simulator-loong64.o: in function `v8::internal::Simulator::ProbeMemory(unsigned long, unsigned long)':
simulator-loong64.cc:(.text._ZN2v88internal9Simulator11ProbeMemoryEmm+0x1e): undefined reference to `v8_internal_simulator_ProbeMemory'
/usr/bin/ld: /home/node/node-v22.12.0/out/Release/obj.host/v8_base_without_compiler/deps/v8/src/execution/loong64/simulator-loong64.o: in function `v8::internal::Simulator::DecodeTypeOp8()':
simulator-loong64.cc:(.text._ZN2v88internal9Simulator13DecodeTypeOp8Ev+0x9f): undefined reference to `v8_internal_simulator_ProbeMemory'
/usr/bin/ld: simulator-loong64.cc:(.text._ZN2v88internal9Simulator13DecodeTypeOp8Ev+0x135): undefined reference to `v8_internal_simulator_ProbeMemory'
/usr/bin/ld: simulator-loong64.cc:(.text._ZN2v88internal9Simulator13DecodeTypeOp8Ev+0x19e): undefined reference to `v8_internal_simulator_ProbeMemory'
/usr/bin/ld: simulator-loong64.cc:(.text._ZN2v88internal9Simulator13DecodeTypeOp8Ev+0x2e9): undefined reference to `v8_internal_simulator_ProbeMemory'
/usr/bin/ld: /home/node/node-v22.12.0/out/Release/obj.host/v8_base_without_compiler/deps/v8/src/execution/loong64/simulator-loong64.o:simulator-loong64.cc:(.text._ZN2v88internal9Simulator13DecodeTypeOp8Ev+0x41a): more undefined references to `v8_internal_simulator_ProbeMemory' follow
/usr/bin/ld: /home/node/node-v22.12.0/out/Release/obj.host/v8_base_without_compiler/deps/v8/src/trap-handler/handler-inside-posix.o: in function `v8::internal::trap_handler::TryHandleSignal(int, siginfo_t*, void*)':
handler-inside-posix.cc:(.text._ZN2v88internal12trap_handler15TryHandleSignalEiP9siginfo_tPv+0x12a): undefined reference to `v8_simulator_probe_memory_continuation'
/usr/bin/ld: /home/node/node-v22.12.0/out/Release/obj.host/v8_base_without_compiler/deps/v8/src/trap-handler/handler-inside-posix.o: in function `v8::internal::trap_handler::HandleSignal(int, siginfo_t*, void*)':
handler-inside-posix.cc:(.text._ZN2v88internal12trap_handler12HandleSignalEiP9siginfo_tPv+0xf5): undefined reference to `v8_internal_simulator_ProbeMemory'
/usr/bin/ld: handler-inside-posix.cc:(.text._ZN2v88internal12trap_handler12HandleSignalEiP9siginfo_tPv+0x175): undefined reference to `v8_simulator_probe_memory_continuation'
collect2: error: ld returned 1 exit status
make[2]: *** [tools/v8_gypfiles/mksnapshot.host.mk:236: /home/node/node-v22.12.0/out/Release/mksnapshot] Error 1
make[2]: *** Waiting for unfinished jobs....
rm b4a0d10d3c29914b575ce9ad4666728a0d995d28.intermediate bb54289c543f1d9b876c0edabd6e91b29871ca2d.intermediate 29fc33456ce4ab84d02eefe81cbf9d94fdf35786.intermediate 4cee9ba7988dd93bec236edf2979db37428f6a95.intermediate 1382e7b097370c924d1bc8d2ba172e7ce6f4d202.intermediate
make[1]: *** [Makefile:135: node] Error 2
make: *** [Makefile:1279: node-v22.12.0-linux-loong64.tar] Error 2

Additional information

Activity

  1. jakecastelli commented on Dec 21, 2024

    @jakecastelli
    Member
  2. wojiushixiaobai commented on Dec 21, 2024

    @wojiushixiaobai
    ContributorAuthor

    @jakecastelli This is another question, not related to #56271.

      CXX(target) /home/node/node-v23.5.0/out/Release/obj.target/simdjson/deps/simdjson/simdjson.o
      CXX(target) /home/node/node-v23.5.0/out/Release/obj.target/simdutf/deps/simdutf/simdutf.o
    In file included from ../deps/simdutf/simdutf.cpp:3:
    ../deps/simdutf/simdutf.h: In function 'uint32_t simdutf::internal::detect_supported_architectures()':
    ../deps/simdutf/simdutf.h:1010:15: error: 'HWCAP_LOONGARCH_LSX' was not declared in this scope; did you mean 'NT_LOONGARCH_LSX'?
     1010 |   if (hwcap & HWCAP_LOONGARCH_LSX) {
          |               ^~~~~~~~~~~~~~~~~~~
          |               NT_LOONGARCH_LSX
    ../deps/simdutf/simdutf.h:1013:15: error: 'HWCAP_LOONGARCH_LASX' was not declared in this scope; did you mean 'NT_LOONGARCH_LASX'?
     1013 |   if (hwcap & HWCAP_LOONGARCH_LASX) {
          |               ^~~~~~~~~~~~~~~~~~~~
          |               NT_LOONGARCH_LASX
    make[2]: *** [deps/simdutf/simdutf.target.mk:86: /home/node/node-v23.5.0/out/Release/obj.target/simdutf/deps/simdutf/simdutf.o] Error 1
    make[2]: *** Waiting for unfinished jobs....
    rm b3e7be9c273d1b3e28c4c7a2c640f007e0b1a736.intermediate d5d23d9e558114923b72eb56873d6fc9b5ff4d1f.intermediate
    make[1]: *** [Makefile:135: node] Error 2
    make: *** [Makefile:1288: node-v23.5.0-linux-loong64.tar] Error 2
  3. jakecastelli commented on Dec 21, 2024

    @jakecastelli
    Member

    Sorry about that!

  4. Xiao-Tao commented on Jan 4, 2025

    @Xiao-Tao
    Contributor

    @wojiushixiaobai
    Fix undefined reference to 'v8_internal_simulator_ProbeMemory'
    #56466

    The loongarch64-clfs-7.3-cross-tools-gcc-glibc.tar.xz compilation toolchain used does not support LSX/LASX yet.
    We may need to upgrade the toolchain to Binutils (>=2.41) and GCC (>=14.1.0)
    nodejs/unofficial-builds#165

  5. wojiushixiaobai commented on Mar 10, 2025

    @wojiushixiaobai
    ContributorAuthor

    @Xiao-Tao Feedback a new question.

    Done, source tarball is at /home/runner/work/node/node/workdir/staging/src/v18.20.7/node-v18.20.7.tar.xz
    Building musl recipe...
    WARNING: The requested image's platform (linux/loong64) does not match the detected host platform (linux/amd64/v3) and no specific platform was requested
    + release_urlbase=https://unofficial-builds.nodejs.org/download/release/
    + disttype=release
    + customtag=
    + datestring=
    + commit=
    + fullversion=v18.20.7
    + source_url=https://nodejs.org/download/release/v18.20.7/node-v18.20.7.tar.xz
    + source_urlbase=https://nodejs.org/download/release/v18.20.7
    + config_flags=--openssl-no-asm
    + cd /home/node
    + tar -xf node.tar.xz
    + cd node-v18.20.7
    + export 'CC=ccache gcc'
    + CC='ccache gcc'
    + export 'CXX=ccache g++'
    + CXX='ccache g++'
    ++ getconf _NPROCESSORS_ONLN
    + make -j4 binary V= DESTCPU=loong64 ARCH=loong64 VARIATION=musl DISTTYPE=release CUSTOMTAG= DATESTRING= COMMIT= RELEASE_URLBASE=https://unofficial-builds.nodejs.org/download/release/ CONFIG_FLAGS=--openssl-no-asm
    /bin/sh: git: not found
    rm -f -r node-v18.20.7-linux-loong64-musl
    rm -f -r out/deps out/Release
    python3 ./configure \
    	--prefix=/ \
    	--dest-cpu=loong64 \
    	--tag= \
    	--release-urlbase=https://unofficial-builds.nodejs.org/download/release/ \
    	--openssl-no-asm --download=all --with-intl=full-icu
    Node.js configure: Found Python 3.12.9...
    WARNING: --openssl-no-asm will result in binaries that do not take advantage
             of modern CPU cryptographic instructions and will therefore be slower.
             Please refer to BUILDING.md
    WARNING: warnings were emitted in the configure phase
    INFO: configure completed successfully
    /usr/bin/make install DESTDIR=node-v18.20.7-linux-loong64-musl V= PORTABLE=1
    /usr/bin/make -C out BUILDTYPE=Release V=
      CXX(target) /home/node/node-v18.20.7/out/Release/obj.target/libnode/src/crypto/crypto_context.o
    In file included from ../deps/postject/postject-api.h:14,
                     from ../src/node_sea.cc:16:
    /usr/include/link.h:22:9: error: 'Elf64_Addr' does not name a type
       22 |         ElfW(Addr) dlpi_addr;
          |         ^~~~
    /usr/include/link.h:24:15: error: 'Elf64_Phdr' does not name a type
       24 |         const ElfW(Phdr) *dlpi_phdr;
          |               ^~~~
    /usr/include/link.h:25:9: error: 'Elf64_Half' does not name a type
       25 |         ElfW(Half) dlpi_phnum;
          |         ^~~~
    /usr/include/link.h:33:9: error: 'Elf64_Addr' does not name a type
       33 |         ElfW(Addr) l_addr;
          |         ^~~~
    /usr/include/link.h:35:9: error: 'Elf64_Dyn' does not name a type
       35 |         ElfW(Dyn) *l_ld;
          |         ^~~~
    /usr/include/link.h:42:9: error: 'Elf64_Addr' does not name a type
       42 |         ElfW(Addr) r_brk;
          |         ^~~~
    /usr/include/link.h:44:9: error: 'Elf64_Addr' does not name a type
       44 |         ElfW(Addr) r_ldbase;
          |         ^~~~
    ../deps/postject/postject-api.h: In function 'const void* postject_find_resource(const char*, size_t*, const postject_options*)':
    ../deps/postject/postject-api.h:129:46: error: 'struct dl_phdr_info' has no member named 'dlpi_phdr'; did you mean 'dlpi_adds'?
      129 |   uintptr_t p = (uintptr_t)main_program_info.dlpi_phdr;
          |                                              ^~~~~~~~~
          |                                              dlpi_adds
    ../deps/postject/postject-api.h:130:32: error: 'struct dl_phdr_info' has no member named 'dlpi_phnum'
      130 |   size_t n = main_program_info.dlpi_phnum;
          |                                ^~~~~~~~~~
    ../deps/postject/postject-api.h:131:43: error: 'struct dl_phdr_info' has no member named 'dlpi_addr'; did you mean 'dlpi_adds'?
      131 |   uintptr_t base_addr = main_program_info.dlpi_addr;
          |                                           ^~~~~~~~~
          |                                           dlpi_adds
    ../deps/postject/postject-api.h:134:34: error: 'Elf64_Phdr' was not declared in this scope; did you mean 'simdutf::internal::Elf64_Phdr'?
      134 |   for (; n > 0; n--, p += sizeof(ElfW(Phdr))) {
          |                                  ^~~~
    In file included from /usr/include/sys/auxv.h:8,
                     from ../deps/simdutf/simdutf.h:999,
                     from ../src/node_sea.cc:7:
    /usr/include/elf.h:597:3: note: 'simdutf::internal::Elf64_Phdr' declared here
      597 | } Elf64_Phdr;
          |   ^~~~~~~~~~
    ../deps/postject/postject-api.h:135:17: error: 'phdr' was not declared in this scope; did you mean 'tcphdr'?
      135 |     ElfW(Phdr)* phdr = (ElfW(Phdr)*)p;
          |                 ^~~~
          |                 tcphdr
    ../deps/postject/postject-api.h:135:36: error: expected primary-expression before ')' token
      135 |     ElfW(Phdr)* phdr = (ElfW(Phdr)*)p;
          |                                    ^
    ../deps/postject/postject-api.h:148:24: error: 'Elf64_Nhdr' was not declared in this scope; did you mean 'simdutf::internal::Elf64_Nhdr'?
      148 |       if (pos + sizeof(ElfW(Nhdr)) > end) {
          |                        ^~~~
    /usr/include/elf.h:1080:3: note: 'simdutf::internal::Elf64_Nhdr' declared here
     1080 | } Elf64_Nhdr;
          |   ^~~~~~~~~~
    ../deps/postject/postject-api.h:152:7: error: 'Elf64_Nhdr' was not declared in this scope; did you mean 'simdutf::internal::Elf64_Nhdr'?
      152 |       ElfW(Nhdr)* note = (ElfW(Nhdr)*)(uintptr_t)pos;
          |       ^~~~
    /usr/include/elf.h:1080:3: note: 'simdutf::internal::Elf64_Nhdr' declared here
     1080 | } Elf64_Nhdr;
          |   ^~~~~~~~~~
    ../deps/postject/postject-api.h:152:19: error: 'note' was not declared in this scope; did you mean 'node'?
      152 |       ElfW(Nhdr)* note = (ElfW(Nhdr)*)(uintptr_t)pos;
          |                   ^~~~
          |                   node
    ../deps/postject/postject-api.h:152:38: error: expected primary-expression before ')' token
      152 |       ElfW(Nhdr)* note = (ElfW(Nhdr)*)(uintptr_t)pos;
          |                                      ^
    ../deps/postject/postject-api.h:152:49: error: expected primary-expression before ')' token
      152 |       ElfW(Nhdr)* note = (ElfW(Nhdr)*)(uintptr_t)pos;
          |                                                 ^
    make[2]: *** [libnode.target.mk:435: /home/node/node-v18.20.7/out/Release/obj.target/libnode/src/node_sea.o] Error 1
    make[2]: *** Waiting for unfinished jobs....
    rm 2df1916b8b4150fc990af368fcf6e90c1992bbd1.intermediate 9c0e6b56e087088647d0eae76012a1ff1730b388.intermediate 38cf139ba6b3cd5b1e33129273a666243bb1704f.intermediate
    make[1]: *** [Makefile:135: node] Error 2
    make: *** [Makefile:1280: node-v18.20.7-linux-loong64-musl.tar] Error 2
  6. Xiao-Tao commented on Mar 11, 2025

    @Xiao-Tao
    Contributor

    @wojiushixiaobai Thanks for the report!!!
    This issue has been fixed at simdutf/simdutf#691

    CXX(target) /home/node/node-v18.20.7/out/Release/obj.target/libnode/src/crypto/crypto_context.o
    In file included from ../deps/postject/postject-api.h:14,
    from ../src/node_sea.cc:16:
    /usr/include/link.h:22:9: error: 'Elf64_Addr' does not name a type
    22 | ElfW(Addr) dlpi_addr;
    | ^~~~
    /usr/include/link.h:24:15: error: 'Elf64_Phdr' does not name a type
    24 | const ElfW(Phdr) *dlpi_phdr;
    | ^~~~

    Upgrading simdutf to 6.2.1 may solve the issue

  7. wojiushixiaobai commented on May 16, 2025

    @wojiushixiaobai
    ContributorAuthor

    @Xiao-Tao Upgrading simdutf to 6.2.1, build completed.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions