mwarning / zerotier-openwrt

A OpenWrt package for ZeroTier One - Pull requests are welcome!
697 stars 146 forks source link

Compile failure on PPC arch #11

Closed riptidewave93 closed 7 years ago

riptidewave93 commented 7 years ago

Hello,

First off, thanks for creating this package! I am working on getting this compiled for a LEDE device using the APM821xx target (PPC464 variant), and am hitting a small compile snag. The issue returned is:

node/Network.o: In function `ZeroTier::Network::applyConfiguration(ZeroTier::NetworkConfig const&)':
Network.cpp:(.text+0x9ac): undefined reference to `__stack_chk_fail_local'
node/Network.o: In function `ZeroTier::Network::setConfiguration(ZeroTier::NetworkConfig const&, bool)':
Network.cpp:(.text+0xc14): undefined reference to `__stack_chk_fail_local'
node/Network.o: In function `ZeroTier::Network::~Network()':
Network.cpp:(.text+0xd24): undefined reference to `__stack_chk_fail_local'
node/Network.o: In function `ZeroTier::Network::Network(ZeroTier::RuntimeEnvironment const*, unsigned long long, void*)':
Network.cpp:(.text+0x1248): undefined reference to `__stack_chk_fail_local'
node/Network.o: In function `ZeroTier::Network::requestConfiguration()':
Network.cpp:(.text+0x1610): undefined reference to `__stack_chk_fail_local'
node/Network.o:Network.cpp:(.text+0x1e50): more undefined references to `__stack_chk_fail_local' follow
/home/riptide_wave/Repos/source/staging_dir/toolchain-powerpc_464fp_gcc-5.4.0_musl-1.1.15/lib/gcc/powerpc-openwrt-linux-musl/5.4.0/../../../../powerpc-openwrt-linux-musl/bin/ld: zerotier-one: hidden symbol `__stack_chk_fail_local' isn't defined
/home/riptide_wave/Repos/source/staging_dir/toolchain-powerpc_464fp_gcc-5.4.0_musl-1.1.15/lib/gcc/powerpc-openwrt-linux-musl/5.4.0/../../../../powerpc-openwrt-linux-musl/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
make-linux.mk:127: recipe for target 'one' failed
make[4]: *** [one] Error 1

I also tried setting -fno-stack-protector but had no success.

mwarning commented 7 years ago

-fno-stack-protector would have been my guess as well (from searching on the Internet). ZT uses -fstack-protector in its own Makefile. I assume that it is not properly overwritten. and you need to patch it out of the Makefile or you can first try to edit the Makefile in the ZT build directory somewhere in openwrt/build_dir/ (oder lede/build_dir/)

riptidewave93 commented 7 years ago

@mwarning gave it a try, but no success. The command that is failing seems to be the following:

powerpc-openwrt-linux-musl-g++ -Os -pipe -mcpu=464fp -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -iremap /home/riptide_wave/source/build_dir/target-powerpc_464fp_musl-1.1.15/zerotier-1.1.14:zerotier-1.1.14 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro  -I/home/riptide_wave/source/staging_dir/target-powerpc_464fp_musl-1.1.15/usr/include -I/home/riptide_wave/source/staging_dir/target-powerpc_464fp_musl-1.1.15/include -I/home/riptide_wave/source/staging_dir/toolchain-powerpc_464fp_gcc-5.4.0_musl-1.1.15/usr/include -I/home/riptide_wave/source/staging_dir/toolchain-powerpc_464fp_gcc-5.4.0_musl-1.1.15/include/fortify -I/home/riptide_wave/source/staging_dir/toolchain-powerpc_464fp_gcc-5.4.0_musl-1.1.15/include  -fno-builtin -nostdinc++ -I/home/riptide_wave/source/staging_dir/target-powerpc_464fp_musl-1.1.15/usr/include/uClibc++ -DGCC_HASCLASSVISIBILITY -Wall -fPIE -fvisibility=hidden  -Wall -Wno-unused-result -Wreorder -fPIE -fno-rtti -pthread  -DNDEBUG -D_FORTIFY_SOURCE=2 -L/home/riptide_wave/source/staging_dir/target-powerpc_464fp_musl-1.1.15/usr/lib -L/home/riptide_wave/source/staging_dir/target-powerpc_464fp_musl-1.1.15/lib -L/home/riptide_wave/source/staging_dir/toolchain-powerpc_464fp_gcc-5.4.0_musl-1.1.15/usr/lib -L/home/riptide_wave/source/staging_dir/toolchain-powerpc_464fp_gcc-5.4.0_musl-1.1.15/lib -znow -zrelro  -L/home/riptide_wave/source/staging_dir/target-powerpc_464fp_musl-1.1.15/usr/lib/uClibc++ -pthread  -o zerotier-one node/C25519.o node/CertificateOfMembership.o node/Cluster.o node/DeferredPackets.o node/Identity.o node/IncomingPacket.o node/InetAddress.o node/Multicaster.o node/Network.o node/NetworkConfig.o node/Node.o node/OutboundMulticast.o node/Packet.o node/Path.o node/Peer.o node/Poly1305.o node/Salsa20.o node/SelfAwareness.o node/SHA512.o node/Switch.o node/Topology.o node/Utils.o osdep/BackgroundResolver.o osdep/ManagedRoute.o osdep/Http.o osdep/OSUtils.o service/ClusterGeoIpService.o service/ControlPlane.o ext/lz4/lz4.o ext/http-parser/http_parser.o ext/json-parser/json.o service/OneService.o one.o osdep/LinuxEthernetTap.o -fno-builtin -nodefaultlibs -Wl,-Bstatic -luClibc++ -Wl,-Bdynamic  -lpthread -lm -lc -lsupc++ -lc -lgcc -lgcc_eh -lgcc_s  -lpthread -lm -fno-stack-protector

I even tried with PKG_CC_STACKPROTECTOR_NONE=y being set in my LEDE config (which removes the occurrence of -fstack-protector in the above cmd), but that had no affect as well.

It also seems the only reverence to stack-protector are at https://github.com/zerotier/ZeroTierOne/blob/830250759cd4c14ca2ae5ddf24f0a0427f258622/make-linux.mk#L109, and 2 lines below as well. Even with these removed or replaced with -fno-stack-protector the issue continues.

mwarning commented 7 years ago

That line contains both -fstack-protector and -fno-stack-protector. Not sure what happens.

riptidewave93 commented 7 years ago

Yeah, as mentioned I was able to remove that with PKG_CC_STACKPROTECTOR_NONE=y being set in my LEDE config, but even then the same issue occurs. :/

riptidewave93 commented 7 years ago

The above PR was submitted to resolve the issue.

mwarning commented 7 years ago

Great to see that you were able to fix it.