From 79d7252bc4cd760a139016e88f066aaf50dd99ab Mon Sep 17 00:00:00 2001 From: Menche Date: Sat, 14 May 2016 19:13:33 -0700 Subject: [PATCH 1/2] clean up the flags and remove unneeded stuff --- CMakeLists.txt | 1 + src/CMakeLists.txt | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9dfc295..99291d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,7 @@ endif() set(REBUILD_ICNS 0 CACHE BOOL "Rebuild icns from voxelands.svg .") set(CPU_OPTS 0 CACHE BOOL "Enable CPU optimizations") +set(CPUTYPE native CACHE STRING "CPU to optimize for") set(ENABLE_SSP 1 CACHE BOOL "Enable stack smashing protection") set(ENABLE_SAFESTACK 1 CACHE BOOL "Enable SafeStack if supported (LLVM only)") set(ENABLE_PIE 0 CACHE BOOL "Produce a Position Independent Executable") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 500de21..d6bd9af 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -373,10 +373,10 @@ else() set(ARCH x86_64) endif() - set(SAFETY_FLAGS "-fno-strict-aliasing -fwrapv -fvisibility=hidden") - set(SAFETY_LDFLAGS "") + set(SAFETY_FLAGS "-fwrapv") + set(SAFETY_LDFLAGS "-Wl,-z,relro,-z,now") set(OPT_FLAGS "-O2 -fomit-frame-pointer") - set(OPT_LDFLAGS "-Wl,-O1,--as-needed,--discard-all,--no-undefined,-s,--sort-common,-z,relro,-z,now") + set(OPT_LDFLAGS "-Wl,-O1,--sort-common,-s") if(ENABLE_SSP) CHECK_CXX_COMPILER_FLAG("-fstack-protector-strong" HAS_FSTACK_STRONG) @@ -390,15 +390,15 @@ else() CHECK_CXX_COMPILER_FLAG("-fsanitize=safe-stack" HAS_SAFESTACK) if(HAS_SAFESTACK) set(SAFETY_FLAGS "${SAFETY_FLAGS} -fsanitize=safe-stack") - set(SAFETY_LDFLAGS "-fsanitize=safe-stack -lrt") + set(SAFETY_LDFLAGS "${SAFETY_LDFLAGS} -fsanitize=safe-stack -lrt") endif() endif() if(ENABLE_PIE) set(SAFETY_FLAGS "${SAFETY_FLAGS} -fPIC -fPIE") - set(SAFETY_LDFLAGS "${LINKER_FLAGS} -Wl,-pie") + set(SAFETY_LDFLAGS "${SAFETY_LDFLAGS} -Wl,-pie") endif() if(CPU_OPTS) - set(OPT_FLAGS "${OPT_FLAGS} -march=native -mtune=native") + set(OPT_FLAGS "${OPT_FLAGS} -march=${CPUTYPE}") endif() From 4e00dc2fe2411286182bd6664cda240aeb78f80c Mon Sep 17 00:00:00 2001 From: Menche Date: Sat, 21 May 2016 18:34:56 -0700 Subject: [PATCH 2/2] make FreeBSD's select() happy --- src/socket.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/socket.cpp b/src/socket.cpp index f4758f4..94a156c 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -312,8 +312,8 @@ bool UDPSocket::WaitData(int timeout_ms) // Initialize time out struct struct timeval tv; - tv.tv_sec = 0; - tv.tv_usec = timeout_ms * 1000; + tv.tv_sec = floor(timeout_ms / 1000) ; + tv.tv_usec = 1000 * (timeout_ms % 1000); // select() result = select(m_handle+1, &readset, NULL, NULL, &tv); @@ -574,8 +574,8 @@ bool TCPSocket::WaitData(int timeout_ms) // Initialize time out struct struct timeval tv; - tv.tv_sec = 0; - tv.tv_usec = timeout_ms * 1000; + tv.tv_sec = floor(timeout_ms / 1000); + tv.tv_usec = 1000 * (timeout_ms % 1000); if (m_bstart != m_bend) return true;