mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

Package build environments like Fedora rpmbuild introduced hardening options (e.g. -pie -Wl,-z,now) by passing a -spec option to CFLAGS and LDFLAGS. ynl Makefiles currently override CFLAGS but not LDFLAGS, which leads to a mismatch and build failure: CC sample devlink /usr/bin/ld: devlink.o: relocation R_X86_64_32 against symbol `ynl_devlink_family' can not be used when making a PIE object; recompile with -fPIE /usr/bin/ld: failed to set dynamic section sizes: bad value collect2: error: ld returned 1 exit status Extend CFLAGS to support hardening options set by build environment. Signed-off-by: Jan Stancek <jstancek@redhat.com> Acked-by: Jakub Kicinski <kuba@kernel.org> Reviewed-by: Donald Hunter <donald.hunter@gmail.com> Link: https://patch.msgid.link/265b2d5d3a6d4721a161219f081058ed47dc846a.1731399562.git.jstancek@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
31 lines
521 B
Makefile
31 lines
521 B
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
CC=gcc
|
|
CFLAGS += -std=gnu11 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow
|
|
ifeq ("$(DEBUG)","1")
|
|
CFLAGS += -g -fsanitize=address -fsanitize=leak -static-libasan
|
|
endif
|
|
|
|
SRCS=$(wildcard *.c)
|
|
OBJS=$(patsubst %.c,%.o,${SRCS})
|
|
|
|
include $(wildcard *.d)
|
|
|
|
all: ynl.a
|
|
|
|
ynl.a: $(OBJS)
|
|
@echo -e "\tAR $@"
|
|
@ar rcs $@ $(OBJS)
|
|
|
|
clean:
|
|
rm -f *.o *.d *~
|
|
rm -rf __pycache__
|
|
|
|
distclean: clean
|
|
rm -f *.a
|
|
|
|
%.o: %.c
|
|
$(COMPILE.c) -MMD -c -o $@ $<
|
|
|
|
.PHONY: all clean distclean
|
|
.DEFAULT_GOAL=all
|