Skip to content

Build for another architecture #233

@elitistphoenix

Description

@elitistphoenix

node-expat doesn't seem to support building on arm64 for amd64

It builds fine on amd64 for amd64. Sort of builds fine on aarch64/arm64 but then adds the wrong aarch binaries to lambda deploy so it doesn't work for x86_64 (the lambda doesn't seem to work as aarch64).

Removed the package-lock.json file too.


sudo apt install build-essential crossbuild-essential-amd64 gcc-x86-64-linux-gnu python3-dev gcc libexpat1-dev libexpat1 expat -y
export npm_config_arch=x64
export npm_package_config_node_gyp_arch=x64
npm install --loglevel verbose --target_arch=x64
npm info run [email protected] install node_modules/node-expat node-gyp rebuild
npm info run [email protected] install { code: 1, signal: null }
npm verbose stack Error: command failed
npm verbose stack     at promiseSpawn (/home/runner/_work/_tool/node/22.19.0/arm64/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:22:22)
npm verbose stack     at spawnWithShell (/home/runner/_work/_tool/node/22.19.0/arm64/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:124:10)
npm verbose stack     at promiseSpawn (/home/runner/_work/_tool/node/22.19.0/arm64/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:12:12)
npm verbose stack     at runScriptPkg (/home/runner/_work/_tool/node/22.19.0/arm64/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/run-script-pkg.js:79:13)
npm verbose stack     at runScript (/home/runner/_work/_tool/node/22.19.0/arm64/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/run-script.js:9:12)
npm verbose stack     at /home/runner/_work/_tool/node/22.19.0/arm64/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/rebuild.js:329:17
npm verbose stack     at run (/home/runner/_work/_tool/node/22.19.0/arm64/lib/node_modules/npm/node_modules/promise-call-limit/dist/commonjs/index.js:67:22)
npm verbose stack     at /home/runner/_work/_tool/node/22.19.0/arm64/lib/node_modules/npm/node_modules/promise-call-limit/dist/commonjs/index.js:79:13
npm verbose pkgid [email protected]
npm error code 1
npm error path /home/runner/_work/project-name/project-name/node_modules/node-expat
npm error command failed
npm error command sh -c node-gyp rebuild
npm error make: Entering directory '/home/runner/_work/project-name/project-name/node_modules/node-expat/build'
npm error   cc -o Release/obj.target/expat/deps/libexpat/lib/xmlparse.o ../deps/libexpat/lib/xmlparse.c '-DNODE_GYP_MODULE_NAME=expat' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_FILE_OFFSET_BITS=64' '-D_LARGEFILE_SOURCE' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DPIC' '-DHAVE_EXPAT_CONFIG_H' '-DNDEBUG' -I/home/runner/.cache/node-gyp/22.19.0/include/node -I/home/runner/.cache/node-gyp/22.19.0/src -I/home/runner/.cache/node-gyp/22.19.0/deps/openssl/config -I/home/runner/.cache/node-gyp/22.19.0/deps/openssl/openssl/include -I/home/runner/.cache/node-gyp/22.19.0/deps/uv/include -I/home/runner/.cache/node-gyp/22.19.0/deps/zlib -I/home/runner/.cache/node-gyp/22.19.0/deps/v8/include -I../deps/libexpat -I../deps/libexpat/lib  -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -m64 -O3 -fno-omit-frame-pointer  -MMD -MF ./Release/.deps/Release/obj.target/expat/deps/libexpat/lib/xmlparse.o.d.raw   -c
npm error make: Leaving directory '/home/runner/_work/project-name/project-name/node_modules/node-expat/build'
npm error gyp info it worked if it ends with ok
npm error gyp verb cli [
npm error gyp verb cli '/home/runner/_work/_tool/node/22.19.0/arm64/bin/node',
npm error gyp verb cli '/home/runner/_work/_tool/node/22.19.0/arm64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js',
npm error gyp verb cli 'rebuild'
npm error gyp verb cli ]
npm error gyp info using [email protected]
npm error gyp info using [email protected] | linux | arm64
npm error gyp verb clean removing "build" directory
npm error gyp verb find Python Python is not set from command line or npm configuration
npm error gyp verb find Python Python is not set from environment variable PYTHON
npm error gyp verb find Python checking if "python3" can be used
npm error gyp verb find Python - executing "python3" to get executable path
npm error gyp verb find Python - executable path is "/usr/bin/python3"
npm error gyp verb find Python - executing "/usr/bin/python3" to get version
npm error gyp verb find Python - version is "3.10.12"
npm error gyp info find Python using Python version 3.10.12 found at "/usr/bin/python3"
npm error gyp verb get node dir no --target version specified, falling back to host node version: 22.19.0
npm error gyp verb install input version string "22.19.0"
npm error gyp verb install installing version: 22.19.0
npm error gyp verb install --ensure was passed, so won't reinstall if already installed
npm error gyp verb install version not already installed, continuing with install 22.19.0
npm error gyp verb ensuring devDir is created /home/runner/.cache/node-gyp/22.19.0
npm error gyp verb created devDir /home/runner/.cache

Further down after a lot of extracting files

npm error gyp verb build dir attempting to create "build" dir: /home/runner/_work/project-name/project-name/node_modules/node-expat/build
npm error gyp verb build dir "build" dir needed to be created? Yes
npm error gyp verb build/config.gypi creating config file
npm error gyp verb build/config.gypi writing out config file: /home/runner/_work/project-name/project-name/node_modules/node-expat/build/config.gypi
npm error gyp verb config.gypi checking for gypi file: /home/runner/_work/project-name/project-name/node_modules/node-expat/config.gypi
npm error gyp verb common.gypi checking for gypi file: /home/runner/_work/project-name/project-name/node_modules/node-expat/common.gypi
npm error gyp verb gyp gyp format was not specified; forcing "make"
npm error gyp info spawn /usr/bin/python3
npm error gyp info spawn args [
npm error gyp info spawn args '/home/runner/_work/_tool/node/22.19.0/arm64/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm error gyp info spawn args 'binding.gyp',
npm error gyp info spawn args '-f',
npm error gyp info spawn args 'make',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/home/runner/_work/project-name/project-name/node_modules/node-expat/build/config.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/home/runner/_work/_tool/node/22.19.0/arm64/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/home/runner/.cache/node-gyp/22.19.0/include/node/common.gypi',
npm error gyp info spawn args '-Dlibrary=shared_library',
npm error gyp info spawn args '-Dvisibility=default',
npm error gyp info spawn args '-Dnode_root_dir=/home/runner/.cache/node-gyp/22.19.0',
npm error gyp info spawn args '-Dnode_gyp_dir=/home/runner/_work/_tool/node/22.19.0/arm64/lib/node_modules/npm/node_modules/node-gyp',
npm error gyp info spawn args '-Dnode_lib_file=/home/runner/.cache/node-gyp/22.19.0/<(target_arch)/node.lib',
npm error gyp info spawn args '-Dmodule_root_dir=/home/runner/_work/project-name/project-name/node_modules/node-expat',
npm error gyp info spawn args '-Dnode_engine=v8',
npm error gyp info spawn args '--depth=.',
npm error gyp info spawn args '--no-parallel',
npm error gyp info spawn args '--generator-output',
npm error gyp info spawn args 'build',
npm error gyp info spawn args '-Goutput_dir=.'
npm error gyp info spawn args ]
npm error gyp verb build type Release
npm error gyp verb architecture x64
npm error gyp verb node dev dir /home/runner/.cache/node-gyp/22.19.0
npm error gyp verb python /usr/bin/python3
npm error gyp verb `which` succeeded for `make` /usr/bin/make
npm error gyp verb bin symlinks created symlink to "/usr/bin/python3" in "/home/runner/_work/project-name/project-name/node_modules/node-expat/build/node_gyp_bins" and added to PATH
npm error gyp info spawn make
npm error gyp info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ]
npm error cc: error: unrecognized command-line option '-m64'
npm error make: *** [deps/libexpat/expat.target.mk:119: Release/obj.target/expat/deps/libexpat/lib/xmlparse.o] Error 1
npm error gyp ERR! build error 
npm error gyp ERR! stack Error: `make` failed with exit code: 2
npm error gyp ERR! stack at ChildProcess.<anonymous> (/home/runner/_work/_tool/node/22.19.0/arm64/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:219:23)
npm error gyp ERR! System Linux 6.12.40
npm error gyp ERR! command "/home/runner/_work/_tool/node/22.19.0/arm64/bin/node" "/home/runner/_work/_tool/node/22.19.0/arm64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm error gyp ERR! cwd /home/runner/_work/project-name/project-name/node_modules/node-expat

Any help, ideas or pointing out where I've gone wrong would be greatly appreciated!

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