Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] package/nodejs/nodejs-src: remove .node files with different architecture
@ 2023-10-31 12:07 Giulio Benetti
  2023-11-01 15:21 ` Yann E. MORIN
  0 siblings, 1 reply; 9+ messages in thread
From: Giulio Benetti @ 2023-10-31 12:07 UTC (permalink / raw)
  To: buildroot; +Cc: Giulio Benetti, Daniel Price, Thomas Petazzoni, Martin Bark

Actually nodejs-src fails to build when additional modules with prebuilt
.node files are added. This is due to Buildroot's check-bin-arch that
checks for executable files and libraries that have different architecture
from the one we're building for. So let's go through all .node files in
$(TARGET_DIR)/usr/lib/node_modules and check if the architecture is
different or not found and in case delete the .node file.

Fixes:
https://bugs.busybox.net/show_bug.cgi?id=15823

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
 package/nodejs/nodejs-src/nodejs-src.mk | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/package/nodejs/nodejs-src/nodejs-src.mk b/package/nodejs/nodejs-src/nodejs-src.mk
index 3452c93728..bdbf0709c6 100644
--- a/package/nodejs/nodejs-src/nodejs-src.mk
+++ b/package/nodejs/nodejs-src/nodejs-src.mk
@@ -247,6 +247,18 @@ define NODEJS_SRC_INSTALL_MODULES
 	# npm install call below and setting npm_config_rollback=false can both
 	# help in diagnosing the problem.
 	$(NPM) install -g $(NODEJS_SRC_MODULES_LIST)
+
+	# Remove prebuilt files which are not compatible with the architecture
+	# and OS(Linux) we're building for. NOTE: .node files that don't have a
+	# readelf output have different ABI(i.e. Windows, Darwin etc.)
+	for f in $$(find $(TARGET_DIR)/usr/lib/node_modules -type f -name "*.node"); do \
+		echo $$f; \
+		arch=`$(TARGET_READELF) -h "$$f" 2>&1 | \
+			sed -r -e '/^  Machine: +(.+)/!d; s//\1/;' | head -1`; \
+		if [ "$$arch" != "$(BR2_READELF_ARCH_NAME)" ]; then \
+			rm -f $$f; \
+		fi \
+	done
 endef
 endif
 
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-11-07 20:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-31 12:07 [Buildroot] [PATCH] package/nodejs/nodejs-src: remove .node files with different architecture Giulio Benetti
2023-11-01 15:21 ` Yann E. MORIN
2023-11-02 23:16   ` Giulio Benetti
2023-11-02 23:43     ` Giulio Benetti
2023-11-03 21:21     ` Yann E. MORIN
2023-11-05 14:27       ` Giulio Benetti
2023-11-07 16:15         ` Yann E. MORIN
2023-11-07 20:08           ` Arnout Vandecappelle via buildroot
2023-11-07 20:40             ` Yann E. MORIN

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox