Skip to content

Commit

Permalink
Prepare for NDK 28 and Rust 1.82.0
Browse files Browse the repository at this point in the history
  • Loading branch information
topjohnwu committed Oct 14, 2024
1 parent d251d57 commit 5e162cb
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 88 deletions.
15 changes: 7 additions & 8 deletions common.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# Copyright 2022-2024 Google LLC.
# SPDX-License-Identifier: Apache-2.0

RUST_VERSION='1.81.0'
# Switch to 1.82.0 once released
RUST_VERSION='stable'

NDK_VERSION='r27b'
NDK_VERSION='r28-beta1'
NDK_DIR_VERSION=$NDK_VERSION

# These revisions are obtained from the NDK's LLVM manifest.xml
# Update in sync with the NDK package
LLVM_VERSION='d8003a456d14a3deb8054cdaa529ffbf02d9b262'
LLVM_SVN='522817'
LLVM_ANDROID_VERSION='2a4ee244d6dd0dcb8365590b898f7a40ec3cb87a'
LLVM_VERSION='97a699bf4812a18fb657c2779f5296a4ab2694d2'
LLVM_SVN='530567'
LLVM_ANDROID_VERSION='ab3ade05b26c45b59ac47b3779b7a6c999e6d634'
TOOLCHAIN_UTILS_VERSION='dd1ee45a84cb07337f9d5d0a6769d9b865c6e620'

OUTPUT_VERSION='r27.5'
OUTPUT_VERSION='r28.0'

PYTHON_CMD='python3'

Expand Down Expand Up @@ -135,8 +136,6 @@ run_cmd() {
rm -rf out
# Set common LLVM configs
set_llvm_cfg LLVM_VERSION_SUFFIX
set_llvm_cfg LLVM_ENABLE_ZSTD FORCE_ON
set_llvm_cfg LLVM_USE_STATIC_ZSTD TRUE
build
;;
ndk)
Expand Down
3 changes: 2 additions & 1 deletion config.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
change-id = 127866
change-id = 129295

[llvm]
targets = "AArch64;ARM;X86;RISCV"
Expand All @@ -7,6 +7,7 @@ clang = true
download-ci-llvm = false
version-suffix = ""
ldflags = "-s"
libzstd = true

[build]
docs = false
Expand Down
77 changes: 0 additions & 77 deletions patches/fix_bootstrap_windows.patch

This file was deleted.

4 changes: 2 additions & 2 deletions patches/fix_lib_llvm_path.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs
index 701bd585..115bcda4 100644
index e1eea31b..aa3465a3 100644
--- a/src/bootstrap/src/core/build_steps/llvm.rs
+++ b/src/bootstrap/src/core/build_steps/llvm.rs
@@ -519,7 +519,7 @@ fn run(self, builder: &Builder<'_>) -> LlvmResult {
@@ -535,7 +535,7 @@ fn run(self, builder: &Builder<'_>) -> LlvmResult {
// link to make llvm-config happy.
if builder.llvm_link_shared() && target.contains("apple-darwin") {
let lib_name = find_llvm_lib_name("dylib");
Expand Down
57 changes: 57 additions & 0 deletions patches/support_ndk_llvm.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs
index dea574a5..498a2c7e 100644
--- a/compiler/rustc_codegen_llvm/src/abi.rs
+++ b/compiler/rustc_codegen_llvm/src/abi.rs
@@ -433,7 +433,7 @@ fn apply_attrs_llfn(

let apply_range_attr = |idx: AttributePlace, scalar: rustc_target::abi::Scalar| {
if cx.sess().opts.optimize != config::OptLevel::No
- && llvm_util::get_version() >= (19, 0, 0)
+ && (llvm_util::get_version() >= (19, 0, 0) && false)
&& matches!(scalar.primitive(), Int(..))
// If the value is a boolean, the range is 0..2 and that ultimately
// become 0..0 when the type becomes i1, which would be rejected
@@ -570,7 +570,7 @@ fn apply_attrs_callsite(&self, bx: &mut Builder<'_, 'll, 'tcx>, callsite: &'ll V
_ => {}
}
if bx.cx.sess().opts.optimize != config::OptLevel::No
- && llvm_util::get_version() < (19, 0, 0)
+ && (llvm_util::get_version() < (19, 0, 0) || true)
&& let abi::Abi::Scalar(scalar) = self.ret.layout.abi
&& matches!(scalar.primitive(), Int(..))
// If the value is a boolean, the range is 0..2 and that ultimately
diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs
index 01aae24a..cc2fc532 100644
--- a/compiler/rustc_codegen_llvm/src/context.rs
+++ b/compiler/rustc_codegen_llvm/src/context.rs
@@ -131,7 +131,7 @@ pub(crate) unsafe fn create_module<'ll>(
}
}

- if llvm_version < (19, 0, 0) {
+ if llvm_version < (19, 0, 0) || true {
if sess.target.arch == "aarch64" || sess.target.arch.starts_with("arm64") {
// LLVM 19 sets -Fn32 in its data layout string for 64-bit ARM
// Earlier LLVMs leave this default, so remove it.
diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
index ed12318c..870a1d0b 100644
--- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
@@ -401,7 +401,7 @@ extern "C" LLVMAttributeRef
LLVMRustCreateRangeAttribute(LLVMContextRef C, unsigned NumBits,
const uint64_t LowerWords[],
const uint64_t UpperWords[]) {
-#if LLVM_VERSION_GE(19, 0)
+#if LLVM_VERSION_GE(19, 0) && 0
return LLVMCreateConstantRangeAttribute(C, Attribute::Range, NumBits,
LowerWords, UpperWords);
#else
@@ -2051,7 +2051,7 @@ extern "C" void LLVMRustContextConfigureDiagnosticHandler(
}
}
if (DiagnosticHandlerCallback) {
-#if LLVM_VERSION_GE(19, 0)
+#if LLVM_VERSION_GE(19, 0) && 0
DiagnosticHandlerCallback(&DI, DiagnosticHandlerContext);
#else
DiagnosticHandlerCallback(DI, DiagnosticHandlerContext);

0 comments on commit 5e162cb

Please sign in to comment.