summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2018-02-01 15:52:41 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2018-02-01 15:52:41 -0800
commit26aaf253acf115e67ab969f95e002ce1074df13e (patch)
tree6158943185d81ef0c68d4bf9f159983a08f97371
parent51715376bf6cb5c8251ea77e799dcf194bf8efcd (diff)
downloadinfinitytier-26aaf253acf115e67ab969f95e002ce1074df13e.tar.gz
infinitytier-26aaf253acf115e67ab969f95e002ce1074df13e.zip
Allow us to build a semi-dynamic official binary that works back to CentOS 6, at least on x64, and is very fast since we can build it with newer clang or icc.
-rw-r--r--ext/misc/linux-old-glibc-compat.c18
-rw-r--r--make-linux.mk11
-rw-r--r--selftest.cpp2
3 files changed, 28 insertions, 3 deletions
diff --git a/ext/misc/linux-old-glibc-compat.c b/ext/misc/linux-old-glibc-compat.c
new file mode 100644
index 00000000..6d793a2d
--- /dev/null
+++ b/ext/misc/linux-old-glibc-compat.c
@@ -0,0 +1,18 @@
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+__asm__(".symver memcpy,memcpy@GLIBC_2.2.5");
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern void *__wrap_memcpy(void *dest,const void *src,size_t n)
+{
+ return memcpy(dest,src,n);
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/make-linux.mk b/make-linux.mk
index 253a4cb7..a68935da 100644
--- a/make-linux.mk
+++ b/make-linux.mk
@@ -71,7 +71,6 @@ ifeq ($(ZT_DEBUG),1)
# C25519 in particular is almost UNUSABLE in -O0 even on a 3ghz box!
node/Salsa20.o node/SHA512.o node/C25519.o node/Poly1305.o: CXXFLAGS=-Wall -O2 -g -pthread $(INCLUDES) $(DEFS)
else
- override DEFS+=-D_FORTIFY_SOURCE=2
CFLAGS?=-O3 -fstack-protector
override CFLAGS+=-Wall -Wno-deprecated -fPIE -pthread $(INCLUDES) -DNDEBUG $(DEFS)
CXXFLAGS?=-O3 -fstack-protector
@@ -210,6 +209,12 @@ ifeq ($(ZT_STATIC),1)
override LDFLAGS+=-static
endif
+# For building an official semi-static binary on CentOS 7
+ifeq ($(ZT_OFFICIAL),1)
+ CORE_OBJS+=ext/misc/linux-old-glibc-compat.o
+ override LDFLAGS+=-Wl,--wrap=memcpy -static-libstdc++
+endif
+
# ARM32 hell -- use conservative CFLAGS
ifeq ($(ZT_ARCHITECTURE),3)
ifeq ($(shell if [ -e /usr/bin/dpkg ]; then dpkg --print-architecture; fi),armel)
@@ -254,7 +259,7 @@ libzerotiercore.a: FORCE
core: libzerotiercore.a
selftest: $(CORE_OBJS) $(ONE_OBJS) selftest.o
- $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-selftest selftest.o $(CORE_OBJS) $(ONE_OBJS $(LDLIBS)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-selftest selftest.o $(CORE_OBJS) $(ONE_OBJS) $(LDLIBS)
$(STRIP) zerotier-selftest
zerotier-selftest: selftest
@@ -265,7 +270,7 @@ manpages: FORCE
doc: manpages
clean: FORCE
- rm -rf *.a *.so *.o node/*.o controller/*.o osdep/*.o service/*.o ext/http-parser/*.o ext/miniupnpc/*.o ext/libnatpmp/*.o $(CORE_OBJS) $(ONE_OBJS) zerotier-one zerotier-idtool zerotier-cli zerotier-selftest build-* ZeroTierOneInstaller-* *.deb *.rpm .depend debian/files debian/zerotier-one*.debhelper debian/zerotier-one.substvars debian/*.log debian/zerotier-one doc/node_modules
+ rm -rf *.a *.so *.o node/*.o controller/*.o osdep/*.o service/*.o ext/http-parser/*.o ext/miniupnpc/*.o ext/libnatpmp/*.o $(CORE_OBJS) $(ONE_OBJS) zerotier-one zerotier-idtool zerotier-cli zerotier-selftest build-* ZeroTierOneInstaller-* *.deb *.rpm .depend debian/files debian/zerotier-one*.debhelper debian/zerotier-one.substvars debian/*.log debian/zerotier-one doc/node_modules ext/misc/*.o
distclean: clean
diff --git a/selftest.cpp b/selftest.cpp
index cf3bbdeb..03f587b0 100644
--- a/selftest.cpp
+++ b/selftest.cpp
@@ -660,6 +660,7 @@ static int testOther()
std::cout << " " << InetAddress("").toString(buf);
std::cout << std::endl;
+#if 0
std::cout << "[other] Benchmarking memcpy... "; std::cout.flush();
{
unsigned char *bb = (unsigned char *)::malloc(1234567);
@@ -681,6 +682,7 @@ static int testOther()
::free((void *)bb);
::free((void *)cc);
}
+#endif
std::cout << "[other] Benchmarking ZT_FAST_MEMCPY... "; std::cout.flush();
{