building node-canvas under AIX
Posted: Tue Dec 08, 2020 2:06 am
After a long struggle compiling dependencies, I managed to compile node-canvas under AIX.
However I got a runtime error when I attempted to use it in a test:
node ~/didit.js
internal/modules/cjs/loader.js:1122
return process.dlopen(module, path.toNamespacedPath(filename));
Error: rtld: 0712-001 Symbol _ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_ was referenced
from module /home/AZIZHQS/node-canvas-2.6.1/build/Release/canvas.node(), but a runtime definition
of the symbol was not found.
rtld: 0712-002 fatal error: exiting.
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1122:18)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/home/AZIZHQS/node-canvas-2.6.1/lib/bindings.js:3:18)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
I tried to figure out where this symbol was coming from.
echo whereis _ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_
| dbx /home/AZIZHQS/node-canvas-2.6.1/build/Release/canvas.node
Type 'help' for help.
warning: cannot execute /home/AZIZHQS/node-canvas-2.6.1/build/Release/canvas.node
reading symbolic information ...program is not active
glink64._ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_
BMPParser.std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > std::operator+<char, std::char_traits<c
har>, std::allocator<char> >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*)
glink64._ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_
I'm not sure how to read this, but I see BMPParser.std which is an object in this package.
However, I noticed that the Node export file also had this symbol in it:
grep _ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_
/QOpenSys/pkgs/lib/nodejs14/include/node/node.exp
_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_
I see this being used here in the Makefile:
quiet_cmd_regen_makefile = ACTION Regenerating $@
cmd_regen_makefile = cd $(srcdir); /QOpenSys/pkgs/lib/nodejs14/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py -fmake
--ignore-environment "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/home/AZIZHQS/.cache/node-gyp/14.15.1" "-
Dnode_exp_file=/QOpenSys/pkgs/lib/nodejs14/include/node/node.exp" "-Dnode_gyp_dir=/QOpenSys/pkgs/lib/nodejs14/lib/node_modules/np
m/node_modules/node-gyp" "-Dnode_lib_file=/home/AZIZHQS/.cache/node-gyp/14.15.1/<(target_arch)/node.lib" "-Dmodule_root_dir=/home
/AZIZHQS/node-canvas-2.6.1" "-Dnode_engine=v8" "--depth=." "-Goutput_dir=." "--generator-output=build" -I/home/AZIZHQS/node-canva
s-2.6.1/build/config.gypi -I/QOpenSys/pkgs/lib/nodejs14/lib/node_modules/npm/node_modules/node-gyp/addon.gypi -I/home/AZIZHQS/.ca
che/node-gyp/14.15.1/include/node/common.gypi "--toplevel-dir=." binding.gyp
Makefile: $(srcdir)/../../../QOpenSys/pkgs/lib/nodejs14/lib/node_modules/npm/node_modules/node-gyp/addon.gypi $(srcdir)/../.cache
/node-gyp/14.15.1/include/node/common.gypi $(srcdir)/build/config.gypi $(srcdir)/binding.gyp
$(call do_cmd,regen_makefile)
I tried recompiling with -Xlinker -bexpfull (and -Xlinker -bexpfull -ffunction-sections).
This caused the linker error:
ld: 0711-302 ERROR: Object Release/obj.target/canvas/src/CanvasPattern.o, csect <_CanvasPattern.ro_>
The csect is part of the .text section, and relocation entries
from the csect have been written to the .loader section.
ld: 0711-302 ERROR: Object Release/obj.target/canvas/src/Image.o, csect <_Image.ro_>
The csect is part of the .text section, and relocation entries
from the csect have been written to the .loader section.
ld: 0711-302 ERROR: Object Release/obj.target/canvas/src/ImageData.o, csect <_ImageData.ro_>
The csect is part of the .text section, and relocation entries
from the csect have been written to the .loader section.
ld: 0711-302 ERROR: Object Release/obj.target/canvas/src/init.o, csect <_init.ro_>
The csect is part of the .text section, and relocation entries
from the csect have been written to the .loader section.
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: error: ld returned 8 exit status
make: *** [canvas.target.mk:188: Release/obj.target/canvas.node] Error 1
internal/modules/cjs/loader.js:1122
return process.dlopen(module, path.toNamespacedPath(filename));
I also tried to create an export module file but (a) I wasn't able to get this working either, still got the same error and (b) I'm not sure how to determine what symbols I would need.
Thanks in advance for any help whatsoever!
However I got a runtime error when I attempted to use it in a test:
node ~/didit.js
internal/modules/cjs/loader.js:1122
return process.dlopen(module, path.toNamespacedPath(filename));
Error: rtld: 0712-001 Symbol _ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_ was referenced
from module /home/AZIZHQS/node-canvas-2.6.1/build/Release/canvas.node(), but a runtime definition
of the symbol was not found.
rtld: 0712-002 fatal error: exiting.
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1122:18)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/home/AZIZHQS/node-canvas-2.6.1/lib/bindings.js:3:18)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
I tried to figure out where this symbol was coming from.
echo whereis _ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_
| dbx /home/AZIZHQS/node-canvas-2.6.1/build/Release/canvas.node
Type 'help' for help.
warning: cannot execute /home/AZIZHQS/node-canvas-2.6.1/build/Release/canvas.node
reading symbolic information ...program is not active
glink64._ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_
BMPParser.std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > std::operator+<char, std::char_traits<c
har>, std::allocator<char> >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*)
glink64._ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_
I'm not sure how to read this, but I see BMPParser.std which is an object in this package.
However, I noticed that the Node export file also had this symbol in it:
grep _ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_
/QOpenSys/pkgs/lib/nodejs14/include/node/node.exp
_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_
I see this being used here in the Makefile:
quiet_cmd_regen_makefile = ACTION Regenerating $@
cmd_regen_makefile = cd $(srcdir); /QOpenSys/pkgs/lib/nodejs14/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py -fmake
--ignore-environment "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/home/AZIZHQS/.cache/node-gyp/14.15.1" "-
Dnode_exp_file=/QOpenSys/pkgs/lib/nodejs14/include/node/node.exp" "-Dnode_gyp_dir=/QOpenSys/pkgs/lib/nodejs14/lib/node_modules/np
m/node_modules/node-gyp" "-Dnode_lib_file=/home/AZIZHQS/.cache/node-gyp/14.15.1/<(target_arch)/node.lib" "-Dmodule_root_dir=/home
/AZIZHQS/node-canvas-2.6.1" "-Dnode_engine=v8" "--depth=." "-Goutput_dir=." "--generator-output=build" -I/home/AZIZHQS/node-canva
s-2.6.1/build/config.gypi -I/QOpenSys/pkgs/lib/nodejs14/lib/node_modules/npm/node_modules/node-gyp/addon.gypi -I/home/AZIZHQS/.ca
che/node-gyp/14.15.1/include/node/common.gypi "--toplevel-dir=." binding.gyp
Makefile: $(srcdir)/../../../QOpenSys/pkgs/lib/nodejs14/lib/node_modules/npm/node_modules/node-gyp/addon.gypi $(srcdir)/../.cache
/node-gyp/14.15.1/include/node/common.gypi $(srcdir)/build/config.gypi $(srcdir)/binding.gyp
$(call do_cmd,regen_makefile)
I tried recompiling with -Xlinker -bexpfull (and -Xlinker -bexpfull -ffunction-sections).
This caused the linker error:
ld: 0711-302 ERROR: Object Release/obj.target/canvas/src/CanvasPattern.o, csect <_CanvasPattern.ro_>
The csect is part of the .text section, and relocation entries
from the csect have been written to the .loader section.
ld: 0711-302 ERROR: Object Release/obj.target/canvas/src/Image.o, csect <_Image.ro_>
The csect is part of the .text section, and relocation entries
from the csect have been written to the .loader section.
ld: 0711-302 ERROR: Object Release/obj.target/canvas/src/ImageData.o, csect <_ImageData.ro_>
The csect is part of the .text section, and relocation entries
from the csect have been written to the .loader section.
ld: 0711-302 ERROR: Object Release/obj.target/canvas/src/init.o, csect <_init.ro_>
The csect is part of the .text section, and relocation entries
from the csect have been written to the .loader section.
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: error: ld returned 8 exit status
make: *** [canvas.target.mk:188: Release/obj.target/canvas.node] Error 1
internal/modules/cjs/loader.js:1122
return process.dlopen(module, path.toNamespacedPath(filename));
I also tried to create an export module file but (a) I wasn't able to get this working either, still got the same error and (b) I'm not sure how to determine what symbols I would need.
Thanks in advance for any help whatsoever!