Commit 33991713 authored by Nick Connolly's avatar Nick Connolly Committed by Tomasz Zawadzki
Browse files

mk: workaround for mingw stack-protector bug



Add -mstack-protector-guard=global to work around GCC bug 86832,
where -fstack-protector will attempt to use native TLS, but mingw only
supports emulated TLS. This causes a segmentation violation at the start
of any function protected by stack-protector. The issue exists in GCC
versions prior to 8.3.

Enable -mstack-protector-guard=global which uses a global variable for
the guard value. This is the behaviour with the fix, so there is no
downside to enabling it for all versions of GCC on Windows.

Signed-off-by: default avatarNick Connolly <nick.connolly@mayadata.io>
Change-Id: I85bc831043585071b0d8b0a3dd637b8d9ff26dab
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6575


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
parent af17c1d4
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -129,6 +129,11 @@ COMMON_CFLAGS += -fPIC
# Enable stack buffer overflow checking
COMMON_CFLAGS += -fstack-protector

ifeq ($(OS).$(CC_TYPE),Windows.gcc)
# Workaround for gcc bug 86832 - invalid TLS usage
COMMON_CFLAGS += -mstack-protector-guard=global
endif

# Prevent accidental multiple definitions of global variables
COMMON_CFLAGS += -fno-common