mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-08-16 14:24:10 +00:00

rv, unlike rtla and perf, drops LDFLAGS supplied by the user and honors
only EXTRA_LDFLAGS. This is inconsistent with both perf and rtla and
can lead to all kinds of unexpected behavior.
For example, on Fedora and RHEL, it causes rv to be build without
PIE, unlike the aforementioned perf and rtla:
$ file /usr/bin/{rv,rtla,perf}
/usr/bin/rv: ELF 64-bit LSB executable, ...
/usr/bin/rtla: ELF 64-bit LSB pie executable, ...
/usr/bin/perf: ELF 64-bit LSB pie executable, ...
Keep both LDFLAGS and EXTRA_LDFLAGS for the build.
Cc: John Kacur <jkacur@redhat.com>
Cc: Luis Goncalves <lgoncalv@redhat.com>
Cc: Gabriele Monaco <gmonaco@redhat.com>
Link: https://lore.kernel.org/20250304142228.767658-1-tglozar@redhat.com
Fixes: 012e4e77df
("tools/verification: Use tools/build makefiles on rv")
Signed-off-by: Tomas Glozar <tglozar@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
52 lines
1.5 KiB
Makefile
52 lines
1.5 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
define allow-override
|
|
$(if $(or $(findstring environment,$(origin $(1))),\
|
|
$(findstring command line,$(origin $(1)))),,\
|
|
$(eval $(1) = $(2)))
|
|
endef
|
|
|
|
# Allow setting CC and AR, or setting CROSS_COMPILE as a prefix.
|
|
$(call allow-override,CC,$(CROSS_COMPILE)gcc)
|
|
$(call allow-override,AR,$(CROSS_COMPILE)ar)
|
|
$(call allow-override,STRIP,$(CROSS_COMPILE)strip)
|
|
$(call allow-override,PKG_CONFIG,pkg-config)
|
|
$(call allow-override,LD_SO_CONF_PATH,/etc/ld.so.conf.d/)
|
|
$(call allow-override,LDCONFIG,ldconfig)
|
|
export CC AR STRIP PKG_CONFIG LD_SO_CONF_PATH LDCONFIG
|
|
|
|
FOPTS :=-flto=auto -ffat-lto-objects -fexceptions -fstack-protector-strong \
|
|
-fasynchronous-unwind-tables -fstack-clash-protection
|
|
WOPTS := -O -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 \
|
|
-Wp,-D_GLIBCXX_ASSERTIONS -Wno-maybe-uninitialized
|
|
|
|
ifeq ($(CC),clang)
|
|
FOPTS := $(filter-out -flto=auto -ffat-lto-objects, $(FOPTS))
|
|
WOPTS := $(filter-out -Wno-maybe-uninitialized, $(WOPTS))
|
|
endif
|
|
|
|
INCLUDE := -Iinclude/
|
|
CFLAGS := -g -DVERSION=\"$(VERSION)\" $(FOPTS) $(WOPTS) $(EXTRA_CFLAGS) $(INCLUDE)
|
|
LDFLAGS := -ggdb $(LDFLAGS) $(EXTRA_LDFLAGS)
|
|
|
|
INSTALL := install
|
|
MKDIR := mkdir
|
|
STRIP := strip
|
|
BINDIR := /usr/bin
|
|
|
|
.PHONY: install
|
|
install: doc_install
|
|
$(Q)$(MKDIR) -p $(DESTDIR)$(BINDIR)
|
|
$(call QUIET_INSTALL,rv)$(INSTALL) $(OUTPUT)rv -m 755 $(DESTDIR)$(BINDIR)
|
|
$(Q)@$(STRIP) $(DESTDIR)$(BINDIR)/rv
|
|
|
|
.PHONY: doc doc_clean doc_install
|
|
doc:
|
|
$(MAKE) -C $(DOCSRC)
|
|
|
|
doc_clean:
|
|
$(MAKE) -C $(DOCSRC) clean
|
|
|
|
doc_install:
|
|
$(MAKE) -C $(DOCSRC) install
|