]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Adjust build rule for gen-riscv-ext-opt and gen-riscv-ext-texi
authorKito Cheng <kito.cheng@sifive.com>
Wed, 28 May 2025 09:59:11 +0000 (17:59 +0800)
committerKito Cheng <kito.cheng@sifive.com>
Mon, 2 Jun 2025 06:47:30 +0000 (14:47 +0800)
Separate the build rules to compile and link stage to make sure
BUILD_LINKERFLAGS and BUILD_LDFLAGS are applied correctly.

We hit this issue when we try to build GCC with non-system-default g++,
and it use newer libstdc++, and then got error from using older libstdc++ from
system, that should not happened if we link with -static-libgcc and
-static-libstdc++.

gcc/ChangeLog:

* config/riscv/t-riscv: Adjust build rule for gen-riscv-ext-opt
and gen-riscv-ext-texi.

gcc/config/riscv/t-riscv

index 854daa96e73c322994d54977da911215b0f9ea51..32092d856878a2ec0283421706092235310ddac4 100644 (file)
@@ -198,19 +198,24 @@ RISCV_EXT_DEFS = \
 
 $(srcdir)/config/riscv/riscv-ext.opt: $(RISCV_EXT_DEFS)
 
-build/gen-riscv-ext-opt$(build_exeext): $(srcdir)/config/riscv/gen-riscv-ext-opt.cc \
+build/gen-riscv-ext-opt.o: $(srcdir)/config/riscv/gen-riscv-ext-opt.cc \
        $(RISCV_EXT_DEFS)
-       $(CXX_FOR_BUILD) $(CXXFLAGS_FOR_BUILD) $< -o $@
+       $(CXX_FOR_BUILD) $(CXXFLAGS_FOR_BUILD) -c $< -o $@
+
+build/gen-riscv-ext-opt$(build_exeext): build/gen-riscv-ext-opt.o
+       $(LINKER_FOR_BUILD) $(BUILD_LINKERFLAGS) $(BUILD_LDFLAGS) -o $@ $<
 
 s-riscv-ext.opt: build/gen-riscv-ext-opt$(build_exeext)
        $(RUN_GEN) build/gen-riscv-ext-opt$(build_exeext) > tmp-riscv-ext.opt
        $(SHELL) $(srcdir)/../move-if-change tmp-riscv-ext.opt $(srcdir)/config/riscv/riscv-ext.opt
        $(STAMP) s-riscv-ext.opt
 
-build/gen-riscv-ext-texi$(build_exeext): $(srcdir)/config/riscv/gen-riscv-ext-texi.cc \
+build/gen-riscv-ext-texi.o: $(srcdir)/config/riscv/gen-riscv-ext-texi.cc \
        $(RISCV_EXT_DEFS)
-       $(CXX_FOR_BUILD) $(CXXFLAGS_FOR_BUILD) $< -o $@
+       $(CXX_FOR_BUILD) $(CXXFLAGS_FOR_BUILD) -c $< -o $@
 
+build/gen-riscv-ext-texi$(build_exeext): build/gen-riscv-ext-texi.o
+       $(LINKER_FOR_BUILD) $(BUILD_LINKERFLAGS) $(BUILD_LDFLAGS) -o $@ $<
 
 $(srcdir)/doc/riscv-ext.texi: $(RISCV_EXT_DEFS)
 $(srcdir)/doc/riscv-ext.texi: s-riscv-ext.texi ; @true