Skip to content

package/nodejs: rework cross-building

Alexandru Ardelean buildroot 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest13 patches 11 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/13package/libuv: add host-buildpackage/libuv/libuv.mk+3 -00 replies
2/13package/nghttp2: add host-buildpackage/nghttp2/nghttp2.mk+1 -00 replies
3/13nodejs: remove v8-qemu-wrapper stuffpackage/nodejs/0001-add-qemu-wrapper-support.patch package/nodejs/Config.in.host package/nodejs/nodejs.mk +1 more+0 -1312 replies
4/13nodejs: fix 'Duplicate v8 target errors when cross-compiling' errorpackage/nodejs/0002-include-obj-name-in-shared-intermediate.patch+24 -00 replies
5/13package/nodejs: add host-{c-ares, libuv, nghttp2} to depspackage/nodejs/Config.in package/nodejs/Config.in.host package/nodejs/nodejs.mk+12 -00 replies
6/13package/nodejs: provide {CC, CXX, CFLAGS, CXXFLAGS, LDFLAGS}_host env vars to target-buildpackage/nodejs/nodejs.mk+11 -00 replies
7/13package/nodejs: don't install nodejs host-toolspackage/nodejs/nodejs.mk+0 -110 replies
8/13package/nodejs: rename LDFLAGS.host -> LDFLAGS optpackage/nodejs/nodejs.mk+1 -10 replies
9/13package/nodejs: impose dep on ia32 libs/compiler if target arch not 64 bitspackage/nodejs/Config.in+2 -00 replies
10/13package/nodejs: add host-zlib depedency to target packagepackage/nodejs/nodejs.mk+1 -00 replies
11/13package/nodejs: fix ARM build with VFP3 instructionpackage/nodejs/nodejs.mk+1 -10 replies
12/13package/nodejs: add a hack to cross-compile 32-bit targets on x64 hostspackage/nodejs/0003-fix-host-x64-cross-compile-for-32-bit-target.patch+71 -00 replies
13/13package/nodejs: build host-nodejs only if we're installing modules with NPMpackage/nodejs/Config.in package/nodejs/nodejs.mk+2 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [Buildroot] [PATCH 00/13] package/nodejs: rework cross-building

A bit of introduction here.

I tried to build nodejs from Buildroot master, but I couldn't. It could be that I did not setup something properly with regards to the 'v8-qemu-wrapper' stuff. I kept getting execution errors, when trying to run the nodejs build-tools scripts (see details in the patches). Either the host-qemu stuff isn't working correctly, or it needs some extra setup.

That eventually sent me down the rabbit-hole of trying to get nodejs to build for ARM64 (where I wanted it). It seems that nodejs cross-building can be done via their own infra-structure, which isn't perfect, but it seems usable; and it also looks like a good idea.

Using their cross-building stuff, has some issues/considerations:
* it's easiest when building a 32/64-bit target on a (same bit-width) 32/64-bit host; the host-{c-ares,icu,libuv,zlib} tools can be used for nodejs' host tools (in their cross-build infrastructure/tools)
* when building a 32-bit target on a 64-bit host, the nodejs cross-building logic will add the -m32 CFLAG, which will mean that the host-{c-ares,icu,libuv,zlib} tools will be unusable (they got compiled for 64-bit and are un-linkable to 32-bit binaries)
This requires that the user install on their system the host-{c-ares,icu,libuv,zlib} 32 bit versions. I suspect that the BR2_HOSTARCH_NEEDS_IA32_{LIBS,COMPILER} symbols are intented for this
* I haven't tried to build 64-bit targets on 32-bit hosts, though I'd guess this is a rare corner case.

I eventually got nodejs to build & run on an RPi4 32 & 64 bit.

I'm not sure if this patchset is fully correct.

But some things can be useful from it:
* the host-libuv and host-nghttp2 packages (for other potential users)
* the 'fix ARM build with VFP3 instruction' patch (maybe)
* the 'build host-nodejs only if we're installing modules with NPM' patch looks to me that even without this rework, if we don't install any node modules on the target, we don't really need the host-nodejs build

Alexandru Ardelean (13):
package/libuv: add host-build
package/nghttp2: add host-build
nodejs: remove v8-qemu-wrapper stuff
nodejs: fix 'Duplicate v8 target errors when cross-compiling' error package/nodejs: add host-{c-ares,libuv,nghttp2} to deps package/nodejs: provide {CC,CXX,CFLAGS,CXXFLAGS,LDFLAGS}_host env vars
to target-build
package/nodejs: don't install nodejs host-tools package/nodejs: rename LDFLAGS.host -> LDFLAGS opt package/nodejs: impose dep on ia32 libs/compiler if target arch not 64
bits
package/nodejs: add host-zlib depedency to target package package/nodejs: fix ARM build with VFP3 instruction package/nodejs: add a hack to cross-compile 32-bit targets on x64
hosts
package/nodejs: build host-nodejs only if we're installing modules
with NPM

 package/libuv/libuv.mk                        |  3 +
 package/nghttp2/nghttp2.mk                    |  1 +
 .../0001-add-qemu-wrapper-support.patch       | 88 -------------------
 ...lude-obj-name-in-shared-intermediate.patch | 24 +++++
 ...-x64-cross-compile-for-32-bit-target.patch | 71 +++++++++++++++
 package/nodejs/Config.in                      |  7 +-
 package/nodejs/Config.in.host                 |  5 +-
 package/nodejs/nodejs.mk                      | 67 +++++---------
 package/nodejs/v8-qemu-wrapper.in             |  9 --
 9 files changed, 129 insertions(+), 146 deletions(-)
 delete mode 100644 package/nodejs/0001-add-qemu-wrapper-support.patch
 create mode 100644 package/nodejs/0002-include-obj-name-in-shared-intermediate.patch
 create mode 100644 package/nodejs/0003-fix-host-x64-cross-compile-for-32-bit-target.patch
 delete mode 100644 package/nodejs/v8-qemu-wrapper.in
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot