rust: Fix compile error for mipsel_24kc+24kf
authorJeffery To <jeffery.to@gmail.com>
Thu, 26 Oct 2023 08:11:06 +0000 (16:11 +0800)
committerRosen Penev <rosenp@gmail.com>
Mon, 30 Oct 2023 20:29:33 +0000 (13:29 -0700)
Currently, rust fails to build for mipsel_24kc+24kf with "opcode not
supported on this processor: mips1 (mips1)" errors when building
libunwind.

Because mipsel_24kc+24kf is hard-float, a certain section of
src/llvm-project/libunwind/src/UnwindRegistersRestore.S is selected to
be compiled; the instructions in this section require MIPS II.

mipsel_24kc+24kf is compiled for MIPS32 Release 2 (MIPS32 is based on
MIPS II), but the C flags used to select this architecture were not
passed to the rust bootstrap (to be passed back to gcc).

This passes the C flags to rust bootstrap to fix this compile error.

This also adds PKG_BUILD_FLAGS:=no-mips16 as attempting to generate
MIPS16 code leads to a different compile error.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
lang/rust/Makefile

index f3189b5bf764a4dc5573c7d37acc918c7be2dfe2..78d95d3d9ca5244a55803094d7f211655ceebeae 100644 (file)
@@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=rust
 PKG_VERSION:=1.73.0
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=rustc-$(PKG_VERSION)-src.tar.gz
 PKG_SOURCE_URL:=https://static.rust-lang.org/dist/
@@ -18,6 +18,7 @@ PKG_LICENSE:=Apache-2.0 MIT
 PKG_LICENSE_FILES:=LICENSE-APACHE LICENSE-MIT
 
 PKG_HOST_ONLY:=1
+PKG_BUILD_FLAGS:=no-mips16
 
 include $(INCLUDE_DIR)/host-build.mk
 include $(INCLUDE_DIR)/package.mk
@@ -86,6 +87,7 @@ endef
 define Host/Compile
        $(RUST_SCCACHE_VARS) \
        CARGO_HOME=$(CARGO_HOME) \
+       TARGET_CFLAGS="$(TARGET_CFLAGS)" \
        OPENWRT_RUSTC_BOOTSTRAP_CACHE=$(DL_DIR)/rustc \
        $(PYTHON) $(HOST_BUILD_DIR)/x.py \
                --build-dir $(HOST_BUILD_DIR)/build \