On Sun, Apr 27, 2025 at 02:50:11PM +0000, Yao Zi wrote: > Similar to AArch64's case, Clang may wrongly fold accesses to gd pointer > which is defined with register qualifier into constants, breaking > various components. > > This patch defines gd as a macro when building with Clang or LTO, which > expands to get_gd() that accesses gp pointer in assembly, making RISC-V > ports function properly and preparing for introduction of LTO in the > future. Board initialization code is also adapted for non-assignable gd. > > Reported-by: Nathaniel Hourt <i...@nathaniel.land> > Signed-off-by: Yao Zi <zi...@disroot.org> > --- > arch/riscv/cpu/cpu.c | 6 ++++++ > arch/riscv/include/asm/global_data.h | 19 +++++++++++++++++++ > common/board_r.c | 4 +++- > common/init/board_init.c | 7 +++++-- > 4 files changed, 33 insertions(+), 3 deletions(-)
Reviewed-by: Leo Yu-Chi Liang <ycli...@andestech.com>