Skip to content

Commit bd8127f

Browse files
committed
Merge branch 'LucasSte-solana-1.84.1' into solana-1.84.1
2 parents e71f9a9 + aa44b91 commit bd8127f

File tree

153 files changed

+4341
-445
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+4341
-445
lines changed

Diff for: .github/workflows/ci.yml

+11-40
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ on:
1515
- try
1616
- try-perf
1717
- automation/bors/try
18+
- master
19+
- solana-**
1820
pull_request:
1921
branches:
2022
- "**"
@@ -130,8 +132,8 @@ jobs:
130132
# which then uses log commands to actually set them.
131133
EXTRA_VARIABLES: ${{ toJson(matrix.env) }}
132134

133-
- name: ensure the channel matches the target branch
134-
run: src/ci/scripts/verify-channel.sh
135+
# - name: ensure the channel matches the target branch
136+
# run: src/ci/scripts/verify-channel.sh
135137

136138
- name: collect CPU statistics
137139
run: src/ci/scripts/collect-cpu-stats.sh
@@ -180,14 +182,14 @@ jobs:
180182
- name: disable git crlf conversion
181183
run: src/ci/scripts/disable-git-crlf-conversion.sh
182184

183-
- name: ensure line endings are correct
184-
run: src/ci/scripts/verify-line-endings.sh
185-
186-
- name: ensure backported commits are in upstream branches
187-
run: src/ci/scripts/verify-backported-commits.sh
185+
# - name: ensure line endings are correct
186+
# run: src/ci/scripts/verify-line-endings.sh
187+
#
188+
# - name: ensure backported commits are in upstream branches
189+
# run: src/ci/scripts/verify-backported-commits.sh
188190

189-
- name: ensure the stable version number is correct
190-
run: src/ci/scripts/verify-stable-version-number.sh
191+
# - name: ensure the stable version number is correct
192+
# run: src/ci/scripts/verify-stable-version-number.sh
191193

192194
- name: run the build
193195
# Redirect stderr to stdout to avoid reordering the two streams in the GHA logs.
@@ -204,37 +206,6 @@ jobs:
204206
echo "disk usage:"
205207
df -h
206208
207-
- name: upload artifacts to github
208-
uses: actions/upload-artifact@v4
209-
with:
210-
# name is set in previous step
211-
name: ${{ env.DOC_ARTIFACT_NAME }}
212-
path: obj/artifacts/doc
213-
if-no-files-found: ignore
214-
retention-days: 5
215-
216-
- name: upload artifacts to S3
217-
run: src/ci/scripts/upload-artifacts.sh
218-
env:
219-
AWS_ACCESS_KEY_ID: ${{ env.ARTIFACTS_AWS_ACCESS_KEY_ID }}
220-
AWS_SECRET_ACCESS_KEY: ${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}
221-
# Adding a condition on DEPLOY=1 or DEPLOY_ALT=1 is not needed as all deploy
222-
# builders *should* have the AWS credentials available. Still, explicitly
223-
# adding the condition is helpful as this way CI will not silently skip
224-
# deploying artifacts from a dist builder if the variables are misconfigured,
225-
# erroring about invalid credentials instead.
226-
if: github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1'
227-
228-
- name: upload job metrics to DataDog
229-
if: needs.calculate_matrix.outputs.run_type != 'pr'
230-
env:
231-
DATADOG_SITE: datadoghq.com
232-
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
233-
DD_GITHUB_JOB_NAME: ${{ matrix.name }}
234-
run: |
235-
npm install -g @datadog/datadog-ci@^2.x.x
236-
python3 src/ci/scripts/upload-build-metrics.py build/cpu-usage.csv
237-
238209
# This job isused to tell bors the final status of the build, as there is no practical way to detect
239210
# when a workflow is successful listening to webhooks only in our current bors implementation (homu).
240211
outcome:

Diff for: .gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ Session.vim
3434
!/tests/run-make/thumb-none-qemu/example/.cargo
3535

3636
## Configuration
37-
/config.toml
3837
/Makefile
3938
config.mk
4039
config.stamp

Diff for: .gitmodules

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
shallow = true
3333
[submodule "src/llvm-project"]
3434
path = src/llvm-project
35-
url = https://github.com/rust-lang/llvm-project.git
36-
branch = rustc/19.1-2024-12-03
35+
url = https://github.com/anza-xyz/llvm-project.git
36+
branch = solana-rustc/19.1-2024-12-03
3737
shallow = true
3838
[submodule "src/doc/embedded-book"]
3939
path = src/doc/embedded-book

Diff for: Cargo.lock

+2-3
Original file line numberDiff line numberDiff line change
@@ -3117,9 +3117,8 @@ dependencies = [
31173117

31183118
[[package]]
31193119
name = "rustc-build-sysroot"
3120-
version = "0.5.4"
3121-
source = "registry+https://github.com/rust-lang/crates.io-index"
3122-
checksum = "d6d984a9db43148467059309bd1e5ad577085162f695d9fe2cf3543aeb25cd38"
3120+
version = "0.5.3"
3121+
source = "git+https://github.com/anza-xyz/rustc-build-sysroot?tag=solana-tools-v1.47#0d6d7ae18aaecf45f0a6e87bcf83b2293263f5bd"
31233122
dependencies = [
31243123
"anyhow",
31253124
"rustc_version",

Diff for: README.md

+47
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,50 @@
1+
# Fork of the Rust Programming Language that supports Berkley Packet Filter (BPF) targets
2+
3+
This fork of Rust contains changes that enable rustc to build BPF
4+
modules. It depends on a customized
5+
[fork](https://github.com/anza-xyz/llvm-project) of Rust's LLVM
6+
fork.
7+
8+
Solana SDK does not depend directly on this repo. Instead [platform-tools]
9+
builds and releases binary packages that the Solana SDK pulls in.
10+
11+
[platform-tools]: https://github.com/anza-xyz/platform-tools
12+
13+
BPF modules are built using target triple `bpfel-unknown-unknown`
14+
which represents the little endian version of BPF. There is no
15+
support for big endian at this time.
16+
17+
Upgrading the compiler and standard library source tree
18+
-------------------------------------------------------
19+
20+
The source tree has two external dependencies
21+
1. [compiler-builtins]
22+
2. [llvm-project]
23+
24+
If any of the depencies is changed or this repository is updated to
25+
make a new release of the bpf-tools, tag the dependencies, and this
26+
repository with a new bpf-tools-v1.x tag, so that all components of
27+
the released bpf-tools have the same tag, e.g. bpf-tools-v1.6. Thus,
28+
release of every version of the bpf-tools is fully specified by the
29+
release version.
30+
31+
The [llvm-project] is a submodule of this repository, therefore its
32+
version is explicitly committed in this repository. However,
33+
[compiler-builtins] is pulled in as a cargo package. Therefore, it is
34+
necessary to update the `[patch.crates-io]` subsection of the
35+
top-level `Cargo.toml` file, and specify which tag must be used to
36+
pull the correct version of [compiler-builtins].
37+
38+
After this repository is tagged for a new release, update the
39+
`bpf-tools/build.sh` in [bpf-tools] repository to pull the correct
40+
version of the rust repository and make a new release tag in
41+
[bpf-tools] repository.
42+
43+
[compiler-builtins]: https://github.com/anza-xyz/compiler-builtins
44+
[llvm-project]: https://github.com/anza-xyz/llvm-project
45+
46+
---
47+
148
<div align="center">
249
<picture>
350
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/rust-lang/www.rust-lang.org/master/static/images/rust-social-wide-dark.svg">

Diff for: build.sh

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SPDX-FileCopyrightText: 2025 Anza Technology Inc. <https://www.anza.xyz>
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
#!/usr/bin/env bash
6+
7+
set -ex
8+
9+
if [ "$1" == "--help" ] || [ "$1" == "-h" ]; then
10+
echo "--llvm to rebuild llvm";
11+
exit;
12+
fi
13+
14+
unameOut="$(uname -s)-$(uname -m)"
15+
case "${unameOut}" in
16+
Linux-x86_64*) HOST_TRIPLE=x86_64-unknown-linux-gnu;;
17+
Linux-aarch64*) HOST_TRIPLE=aarch64-unknown-linux-gnu;;
18+
Darwin-x86_64*) HOST_TRIPLE=x86_64-apple-darwin;;
19+
Darwin-arm64*) HOST_TRIPLE=aarch64-apple-darwin;;
20+
MINGW*) HOST_TRIPLE=x86_64-pc-windows-msvc;;
21+
*) HOST_TRIPLE=x86_64-unknown-linux-gnu
22+
esac
23+
24+
if [ "$1" == "--llvm" ]; then
25+
rm -f build/${HOST_TRIPLE}/llvm/llvm-finished-building;
26+
fi
27+
./x.py build --stage 1 --target ${HOST_TRIPLE},sbf-solana-solana,sbpf-solana-solana,sbpfv1-solana-solana,sbpfv2-solana-solana,sbpfv3-solana-solana

Diff for: compiler/rustc_codegen_gcc/build_system/build_sysroot/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ resolver = "2"
66

77
[dependencies]
88
core = { path = "./sysroot_src/library/core" }
9-
compiler_builtins = "0.1"
9+
compiler_builtins = { git = "https://github.com/anza-xyz/compiler-builtins", tag = "solana-tools-v1.47" }
1010
alloc = { path = "./sysroot_src/library/alloc" }
1111
std = { path = "./sysroot_src/library/std", features = ["panic_unwind", "backtrace"] }
1212
test = { path = "./sysroot_src/library/test" }

Diff for: compiler/rustc_codegen_gcc/src/type_.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
3333
}
3434
}
3535

36-
pub fn type_void(&self) -> Type<'gcc> {
37-
self.context.new_type::<()>()
38-
}
39-
4036
pub fn type_size_t(&self) -> Type<'gcc> {
4137
self.context.new_type::<usize>()
4238
}
@@ -180,6 +176,10 @@ impl<'gcc, 'tcx> BaseTypeCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
180176
bug!("unsupported float width 128")
181177
}
182178

179+
fn type_void(&self) -> Type<'gcc> {
180+
self.context.new_type::<()>()
181+
}
182+
183183
fn type_func(&self, params: &[Type<'gcc>], return_type: Type<'gcc>) -> Type<'gcc> {
184184
self.context.new_function_pointer_type(None, return_type, params, false)
185185
}

Diff for: compiler/rustc_codegen_llvm/src/allocator.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,13 @@ pub(crate) unsafe fn codegen(
8383
let llval = llvm::LLVMConstInt(i8, val as u64, False);
8484
llvm::LLVMSetInitializer(ll_g, llval);
8585

86-
let name = NO_ALLOC_SHIM_IS_UNSTABLE;
87-
let ll_g = llvm::LLVMRustGetOrInsertGlobal(llmod, name.as_c_char_ptr(), name.len(), i8);
88-
llvm::set_visibility(ll_g, llvm::Visibility::from_generic(tcx.sess.default_visibility()));
89-
let llval = llvm::LLVMConstInt(i8, 0, False);
90-
llvm::LLVMSetInitializer(ll_g, llval);
86+
if tcx.sess.target.arch != "sbf" {
87+
let name = NO_ALLOC_SHIM_IS_UNSTABLE;
88+
let ll_g = llvm::LLVMRustGetOrInsertGlobal(llmod, name.as_ptr().cast(), name.len(), i8);
89+
llvm::set_visibility(ll_g, llvm::Visibility::from_generic(tcx.sess.default_visibility()));
90+
let llval = llvm::LLVMConstInt(i8, 0, False);
91+
llvm::LLVMSetInitializer(ll_g, llval);
92+
}
9193
}
9294

9395
if tcx.sess.opts.debuginfo != DebugInfo::None {

Diff for: compiler/rustc_codegen_llvm/src/type_.rs

+4
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ impl<'ll, 'tcx> BaseTypeCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
182182
unsafe { llvm::LLVMFP128TypeInContext(self.llcx) }
183183
}
184184

185+
fn type_void(&self) -> &'ll Type {
186+
unsafe { llvm::LLVMVoidTypeInContext(self.llcx) }
187+
}
188+
185189
fn type_func(&self, args: &[&'ll Type], ret: &'ll Type) -> &'ll Type {
186190
unsafe { llvm::LLVMFunctionType(ret, args.as_ptr(), args.len() as c_uint, False) }
187191
}

Diff for: compiler/rustc_codegen_ssa/src/back/link.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1970,17 +1970,23 @@ fn add_pre_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor)
19701970
cmd.verbatim_args(&sess.opts.unstable_opts.pre_link_args);
19711971
}
19721972

1973-
/// Add a link script embedded in the target, if applicable.
1973+
/// Add a link script embedded in the target, if applicable and not found in the command line.
19741974
fn add_link_script(cmd: &mut dyn Linker, sess: &Session, tmpdir: &Path, crate_type: CrateType) {
19751975
match (crate_type, &sess.target.link_script) {
19761976
(CrateType::Cdylib | CrateType::Executable, Some(script)) => {
19771977
if !sess.target.linker_flavor.is_gnu() {
19781978
sess.dcx().emit_fatal(errors::LinkScriptUnavailable);
19791979
}
19801980

1981+
if sess.opts.cg.link_args.contains(&String::from("--script"))
1982+
|| sess.opts.cg.link_args.contains(&String::from("-T")) {
1983+
return;
1984+
}
1985+
19811986
let file_name = ["rustc", &sess.target.llvm_target, "linkfile.ld"].join("-");
19821987

19831988
let path = tmpdir.join(file_name);
1989+
19841990
if let Err(error) = fs::write(&path, script.as_ref()) {
19851991
sess.dcx().emit_fatal(errors::LinkScriptWriteFailure { path, error });
19861992
}

Diff for: compiler/rustc_codegen_ssa/src/back/linker.rs

+15
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,21 @@ impl<'a> GccLinker<'a> {
444444
self.link_arg(soname);
445445
}
446446
}
447+
448+
if self.sess.target.arch == "bpf" || self.sess.target.arch == "sbf" {
449+
if self.sess.opts.test {
450+
self.link_arg("--entry=main");
451+
} else {
452+
self.link_arg("--entry=entrypoint");
453+
}
454+
if self.sess.opts.cg.target_cpu.as_ref()
455+
.unwrap_or(&self.sess.target.cpu.as_ref().to_string()) == "v3" {
456+
self.link_arg("-Bsymbolic");
457+
if self.sess.opts.debuginfo == DebugInfo::None {
458+
self.link_arg("--strip-all");
459+
}
460+
}
461+
}
447462
}
448463
}
449464

Diff for: compiler/rustc_codegen_ssa/src/back/metadata.rs

+1
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ pub(crate) fn create_object_file(sess: &Session) -> Option<write::Object<'static
249249
"loongarch64" => (Architecture::LoongArch64, None),
250250
"csky" => (Architecture::Csky, None),
251251
"arm64ec" => (Architecture::Aarch64, Some(SubArchitecture::Arm64EC)),
252+
"sbf" => (Architecture::Sbf, None),
252253
// Unsupported architecture.
253254
_ => return None,
254255
};

Diff for: compiler/rustc_codegen_ssa/src/base.rs

+1
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
519519
};
520520

521521
let result = bx.call(start_ty, None, None, start_fn, &args, None, instance);
522+
522523
if cx.sess().target.os.contains("uefi") {
523524
bx.ret(result);
524525
} else {

Diff for: compiler/rustc_codegen_ssa/src/traits/type_.rs

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ pub trait BaseTypeCodegenMethods<'tcx>: BackendTypes {
2323
fn type_f128(&self) -> Self::Type;
2424

2525
fn type_array(&self, ty: Self::Type, len: u64) -> Self::Type;
26+
fn type_void(&self) -> Self::Type;
27+
2628
fn type_func(&self, args: &[Self::Type], ret: Self::Type) -> Self::Type;
2729
fn type_kind(&self, ty: Self::Type) -> TypeKind;
2830
fn type_ptr(&self) -> Self::Type;

Diff for: compiler/rustc_feature/src/unstable.rs

+1
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ declare_features! (
338338
(unstable, riscv_target_feature, "1.45.0", Some(44839)),
339339
(unstable, rtm_target_feature, "1.35.0", Some(44839)),
340340
(unstable, s390x_target_feature, "1.82.0", Some(44839)),
341+
(unstable, sbf_target_feature, "1.54.0", Some(44839)),
341342
(unstable, sparc_target_feature, "1.84.0", Some(132783)),
342343
(unstable, sse4a_target_feature, "1.27.0", Some(44839)),
343344
(unstable, tbm_target_feature, "1.27.0", Some(44839)),

Diff for: compiler/rustc_llvm/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const OPTIONAL_COMPONENTS: &[&str] = &[
2525
"riscv",
2626
"xtensa",
2727
"bpf",
28+
"sbf",
2829
];
2930

3031
const REQUIRED_COMPONENTS: &[&str] =

Diff for: compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ extern "C" void LLVMRustTimeTraceProfilerFinish(const char *FileName) {
168168
#define SUBTARGET_LOONGARCH
169169
#endif
170170

171+
#ifdef LLVM_COMPONENT_BPF
172+
#define SUBTARGET_BPF SUBTARGET(BPF)
173+
#else
174+
#define SUBTARGET_BPF
175+
#endif
176+
177+
#ifdef LLVM_COMPONENT_SBF
178+
#define SUBTARGET_SBF SUBTARGET(SBF)
179+
#else
180+
#define SUBTARGET_SBF
181+
#endif
182+
171183
#define GEN_SUBTARGETS \
172184
SUBTARGET_X86 \
173185
SUBTARGET_ARM \
@@ -183,7 +195,9 @@ extern "C" void LLVMRustTimeTraceProfilerFinish(const char *FileName) {
183195
SUBTARGET_HEXAGON \
184196
SUBTARGET_XTENSA \
185197
SUBTARGET_RISCV \
186-
SUBTARGET_LOONGARCH
198+
SUBTARGET_LOONGARCH \
199+
SUBTARGET_BPF \
200+
SUBTARGET_SBF
187201

188202
#define SUBTARGET(x) \
189203
namespace llvm { \

Diff for: compiler/rustc_llvm/src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -248,4 +248,12 @@ pub fn initialize_available_targets() {
248248
LLVMInitializeBPFAsmPrinter,
249249
LLVMInitializeBPFAsmParser
250250
);
251+
init_target!(
252+
llvm_component = "sbf",
253+
LLVMInitializeSBFTargetInfo,
254+
LLVMInitializeSBFTarget,
255+
LLVMInitializeSBFTargetMC,
256+
LLVMInitializeSBFAsmPrinter,
257+
LLVMInitializeSBFAsmParser
258+
);
251259
}

Diff for: compiler/rustc_passes/src/entry.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ struct EntryContext<'tcx> {
3030
}
3131

3232
fn entry_fn(tcx: TyCtxt<'_>, (): ()) -> Option<(DefId, EntryFnType)> {
33+
let exe_only = (tcx.sess.target.arch != "bpf" && tcx.sess.target.arch != "sbf") || !tcx.sess.opts.test;
3334
let any_exe = tcx.crate_types().iter().any(|ty| *ty == CrateType::Executable);
34-
if !any_exe {
35+
if !any_exe && exe_only {
3536
// No need to find a main function.
3637
return None;
3738
}

0 commit comments

Comments
 (0)