]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
x86: Append -z cet-report=error to LDFLAGS 2994/head
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 11 Jan 2022 18:36:44 +0000 (10:36 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 20 Jan 2022 16:32:01 +0000 (08:32 -0800)
Append -z cet-report=error to LDFLAGS if -fcf-protection is enabled by
default in compiler to catch the missing Intel CET marker:

compiling multi-threaded dynamic library 1.5.1
/usr/local/bin/ld: obj/conf_f408b4c825de923ffc88f7f21b6884b1/dynamic/huf_decompress_amd64.o: error: missing IBT and SHSTK properties
collect2: error: ld returned 1 exit status
...
LINK obj/conf_dbc0b41e36c44111bb0bb918e093d7c1/zstd
/usr/local/bin/ld: obj/conf_dbc0b41e36c44111bb0bb918e093d7c1/huf_decompress_amd64.o: error: missing IBT and SHSTK properties
collect2: error: ld returned 1 exit status

lib/libzstd.mk

index 6e9a643954ba0afeb944d58f1b1841e4b315a0a3..df298d789783a1ad3a4217fd1bdd36c7774c188b 100644 (file)
@@ -114,6 +114,10 @@ CFLAGS  += -Qunused-arguments -Wa,--noexecstack
 endif
 endif
 
+ifeq ($(shell echo "int main(int argc, char* argv[]) { (void)argc; (void)argv; return 0; }" | $(CC) $(FLAGS) -z cet-report=error -x c -Werror - -o $(VOID) 2>$(VOID) && echo 1 || echo 0),1)
+LDFLAGS += -z cet-report=error
+endif
+
 HAVE_COLORNEVER = $(shell echo a | grep --color=never a > /dev/null 2> /dev/null && echo 1 || echo 0)
 GREP_OPTIONS ?=
 ifeq ($HAVE_COLORNEVER, 1)