From 53bf2d0f910f90ac9aefe9d9f6da84d2880a1426 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Thu, 19 Jan 2017 10:21:20 -0700 Subject: [PATCH] build: enable -fno-common This flag prevents the compiler from merging multiple tenative global variable declarations (e.g. 'int i;' without an assignment) into a single copy later. In the default (-fcommon) mode, this allows multiple definitions of an uninitialized global variable to be linked into a single program without any warnings. Change-Id: I0339012a7164dccd311ab1f62d11111d24529fbd Signed-off-by: Daniel Verkamp --- mk/spdk.common.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mk/spdk.common.mk b/mk/spdk.common.mk index c43c41554..cb3810341 100644 --- a/mk/spdk.common.mk +++ b/mk/spdk.common.mk @@ -64,6 +64,9 @@ COMMON_CFLAGS += -fPIC # Enable stack buffer overflow checking COMMON_CFLAGS += -fstack-protector +# Prevent accidental multiple definitions of global variables +COMMON_CFLAGS += -fno-common + # Enable full RELRO - no lazy relocation (resolve everything at load time). # This allows the GOT to be made read-only early in the loading process. LDFLAGS += -Wl,-z,relro,-z,now