nxhack / openwrt-node-packages

OpenWrt Project Node.js packages. v18.x TLS and v20.x LTS
GNU General Public License v2.0
257 stars 99 forks source link

Compilation failure of node-ffi-napi for musl/arm platform #1520

Open kesslerm opened 1 year ago

kesslerm commented 1 year ago

Due to a hardcoded gnu suffix, the node-ffi-napi package fails to compile for other targets than libc. This could be resolved by using the $(TARGET_SUFFIX) variable, which resolves to gnu on platforms that use glibc and are not arm or armeb, but to e.g. muslgnueabi on a target platform using the musl libc library on arm or armeb.

diff --git a/node-ffi-napi/Makefile b/node-ffi-napi/Makefile
index cad3be7b..b3610937 100644
--- a/node-ffi-napi/Makefile
+++ b/node-ffi-napi/Makefile
@@ -44,7 +44,7 @@ NODEJS_CPU:=$(subst powerpc,ppc,$(subst aarch64,arm64,$(subst x86_64,x64,$(subst
 TMPNPM:=$(shell mktemp -u XXXXXXXXXX)
 NPM_CACHE_DIR:=$(if $(call qstrip,$(CONFIG_NODEJS_NPM_CACHE_DIR)),$(call qstrip,$(CONFIG_NODEJS_NPM_CACHE_DIR)),$(TMP_DIR))

-TARGET_CFLAGS+=$(FPIC) -I$(BUILD_DIR)/libffi-$(PKG_LIBFFI_VERSION)/$(GNU_TARGET_NAME)-gnu
+TARGET_CFLAGS+=$(FPIC) -I$(BUILD_DIR)/libffi-$(PKG_LIBFFI_VERSION)/$(GNU_TARGET_NAME)-$(TARGET_SUFFIX)
 TARGET_CPPFLAGS+=$(FPIC)

 define Build/Compile
nxhack commented 1 year ago

@kesslerm Thank you!

Merge after the test is run.

nxhack commented 1 year ago

@kesslerm I am testing with the combination you mentioned in openwrt, and abs_builddir in libffi seems to be ok with -gnu fixed. If you don't mind, could you give me the detailed conditions?

kesslerm commented 1 year ago

The issue first occured for me when building TurrisOS (hbd branch) for the turris omnia. Presumably any build for the mvebu target in OpenWRT master would also require this fix.

nxhack commented 1 year ago

I have merged the turris-omnia config into my existing test environment and tested it but could not reproduce it.

I will try to prepare the turris-omnia environment and do a full build. That will take some time.

nxhack commented 1 year ago

I was able to reproduce it. The solution is simple, but I will investigate the cause of the suffix change.

nxhack commented 1 year ago

A quick look,

> $(top_srcdir)/m4/ax_compiler_vendor.m4 \

but I haven't been able to find out why the results of automake are different.

nxhack commented 1 year ago

The reason for the difference of suffix was due to this patch.

https://gitlab.nic.cz/turris/os/build/-/blob/hbl/patches/openwrt/to-upstream/0100-mpc85xx-hardware-SPE-float-support.patch#L239-253

Workarounds have been merged.