Skip to content

make: error: "_FORTIFY_SOURCE" redefined #7

@toogle

Description

@toogle

I get an error while trying to build zmap:

% make
gcc -Wall -pedantic -Wextra -std=gnu99 -I../lib -I./ -Ioutput_modules -O2 -g -Wall  -g -O2  -D_FORTIFY_SOURCE=2 -fstack-protector-all -fwrapv -fPIC --param ssp-buffer-size=1 -Wall -fno-strict-aliasing -W -Wfloat-equal -Wundef -Wpointer-arith -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2 -Wwrite-strings -Wredundant-decls -Wno-unused-but-set-variable -Wnested-externs -Wbad-function-cast -Winit-self -Wmissing-field-initializers -Waddress -Wmissing-noreturn -Wnormalized=id -Woverride-init -Wstrict-overflow=1 -Wextra -Warray-bounds -Wstack-protector -Wformat -Wformat-security -Wpointer-sign -Wno-format-nonliteral -Wno-format-y2k -Werror   -c -o constraint.o ../lib/constraint.c
<command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
../lib/constraint.c:1:0: note: this is the location of the previous definition
cc1: all warnings being treated as errors
make: *** [constraint.o] Error 1

The following patch solves the problem:

diff --git a/src/Makefile b/src/Makefile
index 72eb0d5..e35c4ab 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -24,7 +24,7 @@ GCCWARNINGS = -Wall -fno-strict-aliasing -W -Wfloat-equal -Wundef      \
 -Waddress -Wmissing-noreturn -Wnormalized=id    \
 -Woverride-init -Wstrict-overflow=1 -Wextra -Warray-bounds             \
 -Wstack-protector -Wformat -Wformat-security -Wpointer-sign -Wno-format-nonliteral -Wno-format-y2k
-GCCHARDENING=-D_FORTIFY_SOURCE=2 -fstack-protector-all -fwrapv -fPIC --param ssp-buffer-size=1
+GCCHARDENING=-fstack-protector-all -fwrapv -fPIC --param ssp-buffer-size=1
 LDHARDENING=-z relro -z now

 EXTRACFLAGS=-g -O2 $(EXTRA_CFLAGS) $(GCCHARDENING) $(GCCWARNINGS) -Werror

I have gcc version 4.7.3 and x86_64 arch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions