hv: riscv: specifiy -fpie / -fno-pie explicitly

Without -fpie or -fno-pie specified in the CFLAGS and ASFLAGS, different
versions of riscv64-linux-gnu-gcc have different behavior, for example,
Ubuntu 13.3.0-6ubuntu2~24.04 will compile as if -fpie, but 15.1.0 will
compile as if -fno-pie. To make the build consistent specify -fpie when
CONFIG_RELOC=y and -fno-pie otherwize explicitly.

Tracked-On: #8791
Signed-off-by: Jian Jun Chen <jian.jun.chen@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
This commit is contained in:
Jian Jun Chen
2025-09-11 14:08:42 +08:00
committed by acrnsi-robot
parent 17c9a4d7be
commit c103ef655d

View File

@@ -14,6 +14,15 @@ ASFLAGS +=
LDFLAGS += -Wl,--no-warn-rwx-segments
ifeq (y, $(CONFIG_RELOC))
# -fpie is already added into CFLAGS in common Makefile
#CFLAGS += -fpie
ASFLAGS += -fpie
else
CFLAGS += -fno-pie
ASFLAGS += -fno-pie
endif
# g expands to i, m, a, f, d, zicsr and zifencei.
# h for hypervisor extension
RV_ISA += gh