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>
53 lines
1.3 KiB
Makefile
53 lines
1.3 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
CC=gcc
|
|
CFLAGS += -std=gnu11 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow \
|
|
-I../lib/ -idirafter $(UAPI_PATH)
|
|
ifeq ("$(DEBUG)","1")
|
|
CFLAGS += -g -fsanitize=address -fsanitize=leak -static-libasan
|
|
endif
|
|
|
|
include ../Makefile.deps
|
|
|
|
YNL_GEN_ARG_ethtool:=--user-header linux/ethtool_netlink.h \
|
|
--exclude-op stats-get
|
|
|
|
TOOL:=../ynl-gen-c.py
|
|
|
|
GENS_PATHS=$(shell grep -nrI --files-without-match \
|
|
'protocol: netlink' \
|
|
../../../../Documentation/netlink/specs/)
|
|
GENS=$(patsubst ../../../../Documentation/netlink/specs/%.yaml,%,${GENS_PATHS})
|
|
SRCS=$(patsubst %,%-user.c,${GENS})
|
|
HDRS=$(patsubst %,%-user.h,${GENS})
|
|
OBJS=$(patsubst %,%-user.o,${GENS})
|
|
|
|
all: protos.a $(HDRS) $(SRCS) $(KHDRS) $(KSRCS) $(UAPI)
|
|
|
|
protos.a: $(OBJS)
|
|
@echo -e "\tAR $@"
|
|
@ar rcs $@ $(OBJS)
|
|
|
|
%-user.h: ../../../../Documentation/netlink/specs/%.yaml $(TOOL)
|
|
@echo -e "\tGEN $@"
|
|
@$(TOOL) --mode user --header --spec $< -o $@ $(YNL_GEN_ARG_$*)
|
|
|
|
%-user.c: ../../../../Documentation/netlink/specs/%.yaml $(TOOL)
|
|
@echo -e "\tGEN $@"
|
|
@$(TOOL) --mode user --source --spec $< -o $@ $(YNL_GEN_ARG_$*)
|
|
|
|
%-user.o: %-user.c %-user.h
|
|
@echo -e "\tCC $@"
|
|
@$(COMPILE.c) $(CFLAGS_$*) -o $@ $<
|
|
|
|
clean:
|
|
rm -f *.o
|
|
|
|
distclean: clean
|
|
rm -f *.c *.h *.a
|
|
|
|
regen:
|
|
@../ynl-regen.sh
|
|
|
|
.PHONY: all clean distclean regen
|
|
.DEFAULT_GOAL: all
|