<commit_before># Define some compilation flags for Linux
#
# Debian defines hardening flags in https://wiki.debian.org/Hardening:
# * gcc -Wformat-security -Werror=format-security
# * gcc -O2 -D_FORTIFY_SOURCE=2
# * gcc -fstack-protector --param ssp-buffer-size=4
# * gcc -fPIE -pie
# * ld -z relro -z now
#
# Arch Linux defines compilation flags in /etc/makepkg.conf (from pacman)
# https://projects.archlinux.org/svntogit/packages.git/tree/trunk/makepkg.conf?h=packages/pacman
# * -D_FORTIFY_SOURCE=2
# * -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4
# * -Wl,-O1,--sort-common,--as-needed,-z,relro

include $(dir $(lastword $(MAKEFILE_LIST)))common.mk

# Centralize the choice of C compiler here (gcc, clang...)
CC ?= cc

# C preprocessor flags
# Gentoo Hardened already defines _FORTIFY_SOURCE in the compiler and warns
# about possible redefinition, so detect these warnings.
# Generate dependencies files targetting $@ in a .$@.d file
# ... while allowing using CPPFLAGS outside of a target (where $@ is empty)
CPPFLAGS = $(call ccpp-option,-D_FORTIFY_SOURCE=2) $(@:%=-Wp,-MT,$@ -Wp,-MD,$(dir $@).$(notdir $@).d)

# C compiler flags
# list of warnings from https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
CFLAGS = -O2 -ansi -pedantic -pipe \
	-Wall -Wextra \
	-Waggregate-return \
	-Wcast-align \
	-Wfloat-equal \
	-Wformat=2 \
	-Winit-self \
	-Winline \
	-Wmissing-declarations \
	-Wmissing-format-attribute \
	-Wmissing-include-dirs \
	-Wmissing-prototypes \
	-Wnested-externs \
	-Wold-style-definition \
	-Wpointer-arith \
	-Wredundant-decls \
	-Wshadow \
	-Wstrict-prototypes \
	-Wunknown-pragmas \
	-Wwrite-strings \
	-Wno-long-long \
	-Wno-unused-function \
	-fPIE  \
	-fno-exceptions \
	-fstack-protector --param=ssp-buffer-size=4 \
	-fvisibility=hidden

# Uncomment the next line to enable debug
#CFLAGS += -g -fvar-tracking-assignments -fno-omit-frame-pointer

# Add clang-specific options unknown to GCC
ifeq ($(call ccpp-has-option,-Weverything), y)
	CFLAGS += -Weverything \
		-Wno-padded \
		-Wno-shift-sign-overflow \
		-Wno-unused-macros
	# added after clang 3.0
	CFLAGS += $(call cc-disable-warning,disabled-macro-expansion)
	CFLAGS += $(call cc-disable-warning,documentation)
	# clang 3.6 added -Wreserved-id-macro, which is incompatible with _GNU_SOURCE definition
	CFLAGS += $(call cc-disable-warning,reserved-id-macro)
	# clang 3.7 added -Wdocumentation-unknown-command and -fcatch-undefined-behavior
	CFLAGS += $(call cc-disable-warning,documentation-unknown-command)
endif

# Add GCC-specific options unknown to clang
ifeq ($(call ccpp-has-option,-Wtrampolines), y)
	CFLAGS += \
		-Wjump-misses-init \
		-Wlogical-op \
		-Wtrampolines
	# gcc 4.6 added -Wsuggest-attribute=[const|pure|noreturn]
	CFLAGS += $(call ccpp-option,-Wsuggest-attribute=format)
	CFLAGS += $(call ccpp-option,-Wsuggest-attribute=noreturn)
endif

# Add strong stack protector if supported
CFLAGS += $(call ccpp-option,-fstack-protector-strong)

# Linker flags
LDFLAGS = -Wl,-O1,-as-needed,-no-undefined,-z,relro,-z,now \
	-fPIE -pie -fstack-protector

LIBS =

# Application build configuration
BIN_EXT := $(EXT_PREFIX)bin

# Shared Object build configuration
LIB_EXT := $(EXT_PREFIX)so
LIB_CFLAGS = -fPIC -fvisibility=hidden
LIB_LDFLAGS = -fPIC -shared -Wl,-soname,$@<commit_msg>linux-flags: make ld warnings fatal<commit_after># Define some compilation flags for Linux
#
# Debian defines hardening flags in https://wiki.debian.org/Hardening:
# * gcc -Wformat-security -Werror=format-security
# * gcc -O2 -D_FORTIFY_SOURCE=2
# * gcc -fstack-protector --param ssp-buffer-size=4
# * gcc -fPIE -pie
# * ld -z relro -z now
#
# Arch Linux defines compilation flags in /etc/makepkg.conf (from pacman)
# https://projects.archlinux.org/svntogit/packages.git/tree/trunk/makepkg.conf?h=packages/pacman
# * -D_FORTIFY_SOURCE=2
# * -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4
# * -Wl,-O1,--sort-common,--as-needed,-z,relro

include $(dir $(lastword $(MAKEFILE_LIST)))common.mk

# Centralize the choice of C compiler here (gcc, clang...)
CC ?= cc

# C preprocessor flags
# Gentoo Hardened already defines _FORTIFY_SOURCE in the compiler and warns
# about possible redefinition, so detect these warnings.
# Generate dependencies files targetting $@ in a .$@.d file
# ... while allowing using CPPFLAGS outside of a target (where $@ is empty)
CPPFLAGS = $(call ccpp-option,-D_FORTIFY_SOURCE=2) $(@:%=-Wp,-MT,$@ -Wp,-MD,$(dir $@).$(notdir $@).d)

# C compiler flags
# list of warnings from https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
CFLAGS = -O2 -ansi -pedantic -pipe \
	-Wall -Wextra \
	-Waggregate-return \
	-Wcast-align \
	-Wfloat-equal \
	-Wformat=2 \
	-Winit-self \
	-Winline \
	-Wmissing-declarations \
	-Wmissing-format-attribute \
	-Wmissing-include-dirs \
	-Wmissing-prototypes \
	-Wnested-externs \
	-Wold-style-definition \
	-Wpointer-arith \
	-Wredundant-decls \
	-Wshadow \
	-Wstrict-prototypes \
	-Wunknown-pragmas \
	-Wwrite-strings \
	-Wno-long-long \
	-Wno-unused-function \
	-fPIE  \
	-fno-exceptions \
	-fstack-protector --param=ssp-buffer-size=4 \
	-fvisibility=hidden

# Uncomment the next line to enable debug
#CFLAGS += -g -fvar-tracking-assignments -fno-omit-frame-pointer

# Add strong stack protector if supported
CFLAGS += $(call ccpp-option,-fstack-protector-strong)

# Linker flags
LDFLAGS = -Wl,-O1,-as-needed,-no-undefined,-z,relro,-z,now,--fatal-warnings \
	-fPIE -pie -fstack-protector

LIBS =

# Add clang-specific options unknown to GCC
ifeq ($(call ccpp-has-option,-Weverything), y)
	CFLAGS += -Weverything \
		-Wno-padded \
		-Wno-shift-sign-overflow \
		-Wno-unused-macros
	# added after clang 3.0
	CFLAGS += $(call cc-disable-warning,disabled-macro-expansion)
	CFLAGS += $(call cc-disable-warning,documentation)
	# clang 3.6 added -Wreserved-id-macro, which is incompatible with _GNU_SOURCE definition
	CFLAGS += $(call cc-disable-warning,reserved-id-macro)
	# clang 3.7 added -Wdocumentation-unknown-command and -fcatch-undefined-behavior
	CFLAGS += $(call cc-disable-warning,documentation-unknown-command)
endif

# Add GCC-specific options unknown to clang
ifeq ($(call ccpp-has-option,-Wtrampolines), y)
	CFLAGS += \
		-Wjump-misses-init \
		-Wlogical-op \
		-Wtrampolines
	# gcc 4.6 added -Wsuggest-attribute=[const|pure|noreturn]
	CFLAGS += $(call ccpp-option,-Wsuggest-attribute=format)
	CFLAGS += $(call ccpp-option,-Wsuggest-attribute=noreturn)
endif

# Application build configuration
BIN_EXT := $(EXT_PREFIX)bin

# Shared Object build configuration
LIB_EXT := $(EXT_PREFIX)so
LIB_CFLAGS = -fPIC -fvisibility=hidden
LIB_LDFLAGS = -fPIC -shared -Wl,-soname,$@
{'fraction_non_alphanumeric': 0.14480587618048268, 'fraction_numerical': 0.00599610253335332, 'mean_word_length': 3.831281679942071, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '453804', 'n_tokens_mistral': 2530, 'n_tokens_neox': 2408, 'n_words': 539}