hyperboria / bugs

Peer-to-peer IPv6 networking, secure and near-zero-conf.
153 stars 17 forks source link

#warning _FORTIFY_SOURCE requires compiling with optimization #164

Open cyisfor opened 7 years ago

cyisfor commented 7 years ago

Won't compile, because warnings are errors. The javascript build thingy checks for an explicit "-O0" but by default doesn't optimize, and doesn't remove _FORTIFY_SOURCE. In fact, if I specify CFLAGS=-O2 ./do then I get: gcc -E -std=c99 -Wall -Wextra -Werror -Wno-pointer-sign -pedantic -D linux=1 -D CJD_PACKAGE_VERSION="cjdns-v20-75-g9f5decca-dirty" -Wno-unused-parameter -D Log_DEBUG -g -D NumberCompress_TYPE=v3x5x8 -D Identity_CHECK=1 -D Allocator_USE_CANARIES=1 -D PARANOIA=1 -march=native -DHAS_ETH_INTERFACE=1 -fPIE -D_FORTIFY_SOURCE=2 -fno-stack-protector -fstack-protector-all -Wstack-protector -I . -I build_linux/dependencies/cnacl/jsbuild/include/ -I build_linux/dependencies/cnacl/jsbuild/include_internal/ -I build_linux/dependencies/libuv/include/ client/cjdroute2.c So it removes the "-O2" disabling optimization, but does not remove _FORTIFY_SOURCE.

Only by specifying CFLAGS=-O0 ./do will the code recompile. I have no idea if cjdns requires a certain optimization level.

Starting from a fresh clone, I can compile cjdns just fine without specifying "-O" anything just by running "./do". But any attempt to recompile does that mixup with _FORTIFY_SOURCE.

cyisfor commented 7 years ago

This might be just me though. Can't really verify it on more than just this machine.

cyisfor commented 7 years ago

And... now I can't even replicate it myself. Meh.

Kubuxu commented 7 years ago

It is semi random, depends on the order of execution. Problem is that sometimes the preprocessor can run before link optimization check is done, thus no -OX flag and the error.

cyisfor commented 6 years ago

I don't know about semi random, because now it's happening every time I try to compile cjdns. git clean -fdx, repeating the process, always spams a bunch of redefining _FORTIFY_SOURCE warnings, then dies saying that's an error. If it were at all random, I'd be able to compile it at least some of the time...

cyisfor commented 6 years ago

And um... doing this causes cjdns to compile perfectly, without any errors.

diff --git a/node_build/make.js b/node_build/make.js
index b3ae15db..43ff3a5f 100644
--- a/node_build/make.js
+++ b/node_build/make.js
@@ -163,9 +163,6 @@ Builder.configure({
         });
     }

-    if (!/^\-O0$/.test(builder.config.optimizeLevel)) {
-        builder.config.cflags.push('-D_FORTIFY_SOURCE=2');
-    }

     // We also need to pass various architecture/floating point flags to GCC when invoked as
     // a linker.