Skip to content

llvm.download-ci-llvm cannot be set to true #141782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
smallprogram opened this issue May 30, 2025 · 3 comments
Closed

llvm.download-ci-llvm cannot be set to true #141782

smallprogram opened this issue May 30, 2025 · 3 comments
Labels
C-discussion Category: Discussion or questions that doesn't represent real issues. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@smallprogram
Copy link

Summary

When I use the openwrt source code to build the system, the compilation will depend on rust, where the Makefile of rust is as follows:

# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2023 Luca Barbato and Donald Hoskins

include $(TOPDIR)/rules.mk

PKG_NAME:=rust
PKG_VERSION:=1.87.0
PKG_RELEASE:=1

PKG_SOURCE:=rustc-$(PKG_VERSION)-src.tar.gz
PKG_SOURCE_URL:=https://static.rust-lang.org/dist/
PKG_HASH:=149bb9fd29be592da4e87900fc68f0629a37bf6850b46339dd44434c04fd8e76
HOST_BUILD_DIR:=$(BUILD_DIR)/host/rustc-$(PKG_VERSION)-src

PKG_MAINTAINER:=Luca Barbato <lu_zero@luminem.org>
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
include ./rust-values.mk

define Package/rust
SECTION:=lang
CATEGORY:=Languages
SUBMENU:=Rust
TITLE:=Rust Programming Language Compiler
URL:=https://www.rust-lang.org/
DEPENDS:=$(RUST_ARCH_DEPENDS)
endef

define Package/rust/description
Rust is a multi-paradigm, general-purpose programming language designed for performance
and safety, especially safe concurrency. Rust is syntactically similar to C++, but can
guarantee memory safety by using a borrow checker to validate references.
endef

define Package/rust/config
source "$(SOURCE)/Config.in"
endef

# Rust-lang has an uninstall script
RUST_UNINSTALL:=$(STAGING_DIR)/host/lib/rustlib/uninstall.sh

# Target Flags
TARGET_CONFIGURE_ARGS = \
--set=target.$(RUSTC_TARGET_ARCH).ar=$(TARGET_AR) \
--set=target.$(RUSTC_TARGET_ARCH).cc=$(TARGET_CC_NOCACHE) \
--set=target.$(RUSTC_TARGET_ARCH).cxx=$(TARGET_CXX_NOCACHE) \
--set=target.$(RUSTC_TARGET_ARCH).linker=$(TARGET_CC_NOCACHE) \
--set=target.$(RUSTC_TARGET_ARCH).ranlib=$(TARGET_RANLIB) \
--set=target.$(RUSTC_TARGET_ARCH).crt-static=false \
$(if $(CONFIG_USE_MUSL),--set=target.$(RUSTC_TARGET_ARCH).musl-root=$(TOOLCHAIN_ROOT_DIR))

# CARGO_HOME is an environmental
HOST_CONFIGURE_VARS += CARGO_HOME="$(CARGO_HOME)"

# Rust Configuration Arguments
HOST_CONFIGURE_ARGS = \
--build=$(RUSTC_HOST_ARCH) \
--target=$(RUSTC_TARGET_ARCH),$(RUSTC_HOST_ARCH) \
--host=$(RUSTC_HOST_ARCH) \
--prefix=$(STAGING_DIR)/host \
--bindir=$(STAGING_DIR)/host/bin \
--libdir=$(STAGING_DIR)/host/lib \
--sysconfdir=$(STAGING_DIR)/host/etc \
--datadir=$(STAGING_DIR)/host/share \
--mandir=$(STAGING_DIR)/host/man \
--dist-compression-formats=gz \
--disable-sanitizers \
--release-channel=stable \
--enable-cargo-native-static \
--bootstrap-cache-path=$(DL_DIR)/rustc \
--set=llvm.download-ci-llvm=true \
$(TARGET_CONFIGURE_ARGS)

define Host/Uninstall
# Call the Uninstall script
[ -f $(RUST_UNINSTALL) ] && \
$(BASH) $(RUST_UNINSTALL) || echo No Uninstall
endef

define Host/Compile
$(RUST_SCCACHE_VARS) \
CARGO_HOME=$(CARGO_HOME) \
TARGET_CFLAGS="$(TARGET_CFLAGS)" \
$(PYTHON) $(HOST_BUILD_DIR)/x.py \
--build-dir $(HOST_BUILD_DIR)/build \
dist build-manifest rustc rust-std cargo llvm-tools rust-src
endef

define Host/Install
( \
cd $(HOST_BUILD_DIR)/build/dist ; \
for targz in *.tar.gz; do \
$(STAGING_DIR_HOST)/bin/libdeflate-gzip -dc "$$$$targz" | tar -xf - ; \
done ; \
find . -mindepth 2 -maxdepth 2 -type f -name install.sh \
-execdir bash '{}' --prefix=$(STAGING_DIR)/host --disable-ldconfig \; ; \
)
endef

$(eval $(call HostBuild))
$(eval $(call BuildPackage,rust))

Among them, llvm.download-ci-llvm=true, when the compilation is executed locally, there is no problem, no error, and it can be compiled perfectly. However, when using the Ubuntu-latest system environment (Ubuntu-24.04) in Github Action, an error will appear:

thread 'main' panicked at src/bootstrap/src/core/config/config.rs:3166:21:
llvm.download-ci-llvm cannot be set to true on CI. Use if-unchanged instead.
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
Build completed unsuccessfully in 0:00:00
make[3]: *** [Makefile:108: /home/runner/work/auto-build-openwrt/auto-build-openwrt/openwrt/build_dir/target-x86_64_musl/host/rustc-1.87.0-src/.built] Error 1
make[3]: Leaving directory '/home/runner/work/auto-build-openwrt/auto-build-openwrt/openwrt/feeds/packages/lang/rust'
time: package/feeds/packages/rust/host-compile#0.47#0.28#0.74
ERROR: package/feeds/packages/rust [host] failed to build.

I checked your source code and found that

match download_ci_llvm {
StringOrBool::Bool(b) => {
if !b && self.download_rustc_commit.is_some() {
panic!(
"`llvm.download-ci-llvm` cannot be set to `false` if `rust.download-rustc` is set to `true` or `if-unchanged`."
);
}
if b && self.is_running_on_ci {
// On CI, we must always rebuild LLVM if there were any modifications to it
panic!(
"`llvm.download-ci-llvm` cannot be set to `true` on CI. Use `if-unchanged` instead."
);
}
// If download-ci-llvm=true we also want to check that CI llvm is available
b && llvm::is_ci_llvm_available_for_target(self, asserts)
}
StringOrBool::String(s) if s == "if-unchanged" => if_unchanged(),
StringOrBool::String(other) => {
panic!("unrecognized option for download-ci-llvm: {other:?}")
}
}
}

It shows why this error occurs. I know nothing about rust and I don't understand why it needs to detect whether the environment is CI.

I hope this can help solve this problem, thank you.

Operating system

Ubuntu 24.04 Github Action

Link issue

@smallprogram smallprogram added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) C-bug Category: This is a bug. labels May 30, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 30, 2025
@smallprogram smallprogram changed the title llvm.download-ci-llvm cannot be set to true` llvm.download-ci-llvm cannot be set to true May 30, 2025
@onur-ozkan
Copy link
Member

I don't understand the reason of this report, it clearly says what you can do to avoid it. Or do you want to know "what's it about that build system doesn't allow llvm.download-ci-llvm on CI" ? If that so, you can come and ask in the Zulip channels instead.

@onur-ozkan onur-ozkan removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. C-bug Category: This is a bug. labels May 30, 2025
@smallprogram
Copy link
Author

Maybe I didn't express it clearly. When I used the prompts and modified it according to the prompts, setting llvm.download-ci-llvm to if-unchanged, it still had another error:

ERROR: 'if-unchanged' is only compatible with Git managed sources.
Build completed unsuccessfully in 0:01:04
make[2]: *** [Makefile:108: /workdir/openwrt/build_dir/target-x86_64_musl/host/rustc-1.87.0-src/.built] Error 1
make[2]: Leaving directory '/workdir/openwrt/feeds/packages/lang/rust'
time: package/feeds/packages/rust/host-compile#106.84#36.15#109.22
ERROR: package/feeds/packages/rust [host] failed to build.

@onur-ozkan
Copy link
Member

That error is also very clear. It looks like you will need a patch on bootstrap to use our CI-LLVM without using Git source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-discussion Category: Discussion or questions that doesn't represent real issues. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

4 participants