murat-dogan / node-datachannel

WebRTC For Node.js and Electron. libdatachannel node bindings.
Mozilla Public License 2.0
280 stars 52 forks source link

OpenSSL static linking for Linux arm64 #230

Closed murat-dogan closed 3 months ago

murat-dogan commented 4 months ago

Currently, we are linking OpenSSL dynamically and want to change that.

https://github.com/murat-dogan/node-datachannel/blob/a07715d4a13c89e1a79b0bad54b2490beb999ce5/CMakeLists.txt#L27-L30

murat-dogan commented 4 months ago

We are using cross compilation tool https://github.com/murat-dogan/node-datachannel/blob/a07715d4a13c89e1a79b0bad54b2490beb999ce5/.github/workflows/build-linux.yml#L47-L54

But got this error;

/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: /home/runner/work/node-datachannel/node-datachannel/sysroot/usr/lib/aarch64-linux-gnu/libcrypto.a(sha1-armv8.o): relocation R_AARCH64_PREL64 against symbol `OPENSSL_armcap_P' which may bind externally can not be used when making a shared object; recompile with -fPIC
/home/runner/work/node-datachannel/node-datachannel/sysroot/usr/lib/aarch64-linux-gnu/libcrypto.a(sha1-armv8.o): in function `sha1_block_armv8':
(.text+0x1240): dangerous relocation: unsupported relocation
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: /home/runner/work/node-datachannel/node-datachannel/sysroot/usr/lib/aarch64-linux-gnu/libcrypto.a(chacha-armv8.o): relocation R_AARCH64_PREL64 against symbol `OPENSSL_armcap_P' which may bind externally can not be used when making a shared object; recompile with -fPIC
/home/runner/work/node-datachannel/node-datachannel/sysroot/usr/lib/aarch64-linux-gnu/libcrypto.a(chacha-armv8.o):(.text+0x20): dangerous relocation: unsupported relocation
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: /home/runner/work/node-datachannel/node-datachannel/sysroot/usr/lib/aarch64-linux-gnu/libcrypto.a(poly1305-armv8.o): relocation R_AARCH64_ADR_PREL_LO21 against symbol `poly1305_blocks' which may bind externally can not be used when making a shared object; recompile with -fPIC
/home/runner/work/node-datachannel/node-datachannel/sysroot/usr/lib/aarch64-linux-gnu/libcrypto.a(poly1305-armv8.o): in function `poly1305_init':
(.text+0x40): dangerous relocation: unsupported relocation
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: /home/runner/work/node-datachannel/node-datachannel/sysroot/usr/lib/aarch64-linux-gnu/libcrypto.a(poly1305-armv8.o): relocation R_AARCH64_ADR_PREL_LO21 against symbol `poly1305_emit' which may bind externally can not be used when making a shared object; recompile with -fPIC
(.text+0x48): dangerous relocation: unsupported relocation
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: /home/runner/work/node-datachannel/node-datachannel/sysroot/usr/lib/aarch64-linux-gnu/libcrypto.a(poly1305-armv8.o): relocation R_AARCH64_PREL64 against symbol `OPENSSL_armcap_P' which may bind externally can not be used when making a shared object; recompile with -fPIC
/home/runner/work/node-datachannel/node-datachannel/sysroot/usr/lib/aarch64-linux-gnu/libcrypto.a(poly1305-armv8.o): in function `poly1305_emit_neon':
(.text+0x9a0): dangerous relocation: unsupported relocation
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: /home/runner/work/node-datachannel/node-datachannel/sysroot/usr/lib/aarch64-linux-gnu/libcrypto.a(sha256-armv8.o): relocation R_AARCH64_PREL64 against symbol `OPENSSL_armcap_P' which may bind externally can not be used when making a shared object; recompile with -fPIC
/home/runner/work/node-datachannel/node-datachannel/sysroot/usr/lib/aarch64-linux-gnu/libcrypto.a(sha256-armv8.o): in function `sha256_block_data_order':
(.text+0xf88): dangerous relocation: unsupported relocation
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: /home/runner/work/node-datachannel/node-datachannel/sysroot/usr/lib/aarch64-linux-gnu/libcrypto.a(sha512-armv8.o): relocation R_AARCH64_PREL64 against symbol `OPENSSL_armcap_P' which may bind externally can not be used when making a shared object; recompile with -fPIC
/home/runner/work/node-datachannel/node-datachannel/sysroot/usr/lib/aarch64-linux-gnu/libcrypto.a(sha512-armv8.o): in function `sha512_block_data_order':
(.text+0x10c8): dangerous relocation: unsupported relocation
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/node_datachannel.dir/build.make:247: Release/node_datachannel.node] Error 1
make[1]: *** [CMakeFiles/Makefile2:316: CMakeFiles/node_datachannel.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
murat-dogan commented 4 months ago

I changed the sysroot and now can compile Linux arm64 successfully

https://github.com/murat-dogan/node-datachannel/releases/download/v0.5.6-dev/node-datachannel-v0.5.6-dev-napi-v8-linux-arm64.tar.gz