BSP Reference Minimal Image v6.x.y with nodejs

We have built a custom BSP Reference Minimal Image with docker package, that is working on our custom board with no problems.

Now we need to build this image with the nodejs package, and we enabled it on or image, but now the image stops building when trying to compile nodejs with the errors below:

| collect2: fatal error: ld terminated with signal 9 [Killed]
| compilation terminated.
| make[1]: *** [node.target.mk:193: Release/node] Error 1
| make[1]: *** Waiting for unfinished jobs....
| collect2: fatal error: ld terminated with signal 9 [Killed]
| compilation terminated.
| make[1]: *** [cctest.target.mk:225: Release/cctest] Error 1
| collect2: fatal error: ld terminated with signal 9 [Killed]
| compilation terminated.
| make[1]: *** [node_mksnapshot.target.mk:187: Release/node_mksnapshot] Error 1
| rm ce4005a9f3c414c7f161db21cbc9e6a3c8a65c1a.intermediate 224b5fa8b9a109ae691741cd53ed53c989e88b51.intermediate 584df6a6f2e1bd2cd64dceac369f27b95d74ba5f.intermediate 6839c36cc9a463749da00256ab2e3026b0aec239.intermediate b5007b287cd1de8542dbd9ca38481999bbc5b79f.intermediate 80d5e920d842a9ba2a8ef14613cbf6d65e3ecddf.intermediate
| make: *** [Makefile:113: node] Error 2
| ERROR: oe_runmake failed
| WARNING: exit code 1 from a shell command.
ERROR: Task (/home/smar/toradex/oe-bsp/build/../layers/meta-openembedded/meta-oe/recipes-devtools/nodejs/nodejs_16.20.2.bb:do_compile) failed with exit code '1'

NOTE: We cannot use Torizon TCBuilder right now. This will be studied later.

Best regards,
Vilson Balestero

Software summary
------------------------------------------------------------
Bootloader:               U-Boot
Kernel version:           6.1.95-rt34-6.7.0+git.7d6bbd3e0ef0 #1 SMP Wed Jun 26 1                                                                                        5:24:17 UTC 2024
Kernel command line:      enable_wait_mode=off galcore.contiguousSize=50331648 r                                                                                        oot=PARTUUID=4e5d7f3a-02 ro rootwait fec_mac=00:14:2d:ac:5e:30 consoleblank=0 no                                                                                        _console_suspend=1 console=tty1 console=ttymxc0,115200n8 fbmem=8M
Distro name:              NAME="DCN I/O Gateway"
Distro version:           VERSION_ID=6.7.0-build.0
Distro variant:           -
Hostname:                 dcnio
------------------------------------------------------------

Hardware info
------------------------------------------------------------
HW model:                 Toradex Colibri iMX6DL/S on Colibri Evaluation Board V                                                                                        3
Toradex version:          0017 V1.1B
Serial number:            11296304
Processor arch:           armv7l
------------------------------------------------------------

Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello Vilson Balestero,

The error you’re encountering during the compilation of Node.js, indicated by collect2: fatal error: ld terminated with signal 9 [Killed], typically suggests that the linker (ld) was killed due to running out of memory. This is a common issue when building large projects like Node.js on systems with limited memory resources.

Here are a few strategies to resolve this issue:

  1. Increase Physical Memory: If possible, increase the physical RAM in the build machine. This is the most straightforward solution but may not be feasible in all environments.

  2. Enable Swap Space: If increasing physical memory is not an option, consider enabling or increasing the swap space on your build machine. Swap space can provide additional virtual memory to mitigate out-of-memory issues, albeit at the cost of reduced performance. You can create a swap file or increase the swap partition size depending on your system configuration.

  3. Use External Build Hosts: For Yocto builds, you can leverage more powerful external machines as build hosts. This involves setting up a build server with ample memory and configuring your local environment to use this server for the heavy lifting during the build process.

  4. Optimize Local Builds: If you must build locally and cannot increase memory or swap, consider optimizing your build environment:

    • Close unnecessary applications and services to free up memory.
    • Build Node.js separately and then include it in your image as a precompiled binary. This approach requires ensuring compatibility with your target architecture and system libraries.
    • Adjust the parallel make options (-j flag) for bitbake to reduce the number of parallel jobs. This can be done by setting BB_NUMBER_THREADS and PARALLEL_MAKE in your local.conf to lower values, though it will increase the build time.
  5. Cross-Compilation: Consider cross-compiling Node.js on a more powerful machine that matches your target architecture. This approach involves setting up a cross-compilation environment where you can compile Node.js for the ARM architecture of your Colibri iMX6DL/S module.

  6. Use Precompiled Packages: If available, use precompiled Node.js packages for your target architecture instead of compiling from source. This can significantly reduce the build complexity and resource requirements.

Remember, when making changes to swap space or system configurations, it’s essential to understand the implications and ensure that you have adequate backups or recovery plans in place.

Best regards,
Toradex AI Assistant

Please, also check if these links can help you solve your problem:

Working with Weston on Torizon OS | Toradex Developer Center.

Thanks, by increasing the swap size help me.