Skip to content

Commit e55ed43

Browse files
dmakarovLucasSte
authored andcommitted
[SOL] Adjust SBF customization after upgrading to rust 1.72.0
1 parent 36111bb commit e55ed43

File tree

25 files changed

+91
-383
lines changed

25 files changed

+91
-383
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ jobs:
4343
CI_JOB_NAME: "${{ matrix.name }}"
4444
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
4545
HEAD_SHA: "${{ github.event.pull_request.head.sha || github.sha }}"
46-
SCCACHE_BUCKET: rust-lang-ci-sccache2
46+
SCCACHE_BUCKET: cached-ci-artifacts
47+
SCCACHE_REGION: us-east-2
48+
SCCACHE_S3_NO_CREDENTIALS: 1
4749
TOOLSTATE_REPO: "https://github.com/rust-lang-nursery/rust-toolstate"
4850
CACHE_DOMAIN: cached-ci-artifacts.s3.us-east-2.amazonaws.com
4951
if: "github.event_name == 'pull_request'"
@@ -64,7 +66,7 @@ jobs:
6466
env: {}
6567
- name: sbf-solana-solana
6668
tidy: false
67-
os: ubuntu-latest
69+
os: ubuntu-20.04-16core-64gb
6870
env: {}
6971
- name: x86_64-gnu-tools
7072
os: ubuntu-20.04-16core-64gb
@@ -91,9 +93,6 @@ jobs:
9193
- name: decide whether to skip this job
9294
run: src/ci/scripts/should-skip-this.sh
9395
if: success() && !env.SKIP_JOB
94-
- name: ensure the channel matches the target branch
95-
run: src/ci/scripts/verify-channel.sh
96-
if: success() && !env.SKIP_JOB
9796
- name: collect CPU statistics
9897
run: src/ci/scripts/collect-cpu-stats.sh
9998
if: success() && !env.SKIP_JOB
@@ -179,6 +178,8 @@ jobs:
179178
name: push
180179
env:
181180
CI_JOB_NAME: "${{ matrix.name }}"
181+
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
182+
HEAD_SHA: "${{ github.event.pull_request.head.sha || github.sha }}"
182183
SCCACHE_BUCKET: cached-ci-artifacts
183184
SCCACHE_REGION: us-east-2
184185
DEPLOY_BUCKET: rust-lang-ci2
@@ -187,19 +188,20 @@ jobs:
187188
TOOLSTATE_PUBLISH: 0
188189
CACHES_AWS_ACCESS_KEY_ID: AKIASSXOBJJGY5HRQO4U
189190
ARTIFACTS_AWS_ACCESS_KEY_ID: AKIA46X5W6CZN24CBO55
190-
CACHE_DOMAIN: cached-ci-artifacts.s3.us-east-2.amazonaws.com
191+
AWS_REGION: us-west-1
192+
CACHE_DOMAIN: ci-caches.rust-lang.org
191193
if: "github.event_name == 'push' && startsWith(github.ref, 'refs/heads/solana-') && github.repository == 'solana-labs/rust'"
192194
strategy:
193195
matrix:
194196
include:
195197
- name: mingw-check
196-
os: ubuntu-latest
198+
os: ubuntu-20.04-16core-64gb
197199
env: {}
198200
- name: x86_64-gnu-llvm-12
199-
os: ubuntu-latest
201+
os: ubuntu-20.04-16core-64gb
200202
env: {}
201203
- name: sbf-solana-solana
202-
os: ubuntu-latest
204+
os: ubuntu-20.04-16core-64gb
203205
env: {}
204206
timeout-minutes: 600
205207
runs-on: "${{ matrix.os }}"
@@ -223,20 +225,12 @@ jobs:
223225
- name: decide whether to skip this job
224226
run: src/ci/scripts/should-skip-this.sh
225227
if: success() && !env.SKIP_JOB
226-
- name: configure GitHub Actions to kill the build when outdated
227-
uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
228-
with:
229-
github_token: "${{ secrets.github_token }}"
230-
if: "success() && !env.SKIP_JOB && github.ref != 'refs/heads/try' && github.ref != 'refs/heads/try-perf'"
231228
- name: collect CPU statistics
232229
run: src/ci/scripts/collect-cpu-stats.sh
233230
if: success() && !env.SKIP_JOB
234231
- name: show the current environment
235232
run: src/ci/scripts/dump-environment.sh
236233
if: success() && !env.SKIP_JOB
237-
- name: install awscli
238-
run: src/ci/scripts/install-awscli.sh
239-
if: success() && !env.SKIP_JOB
240234
- name: install sccache
241235
run: src/ci/scripts/install-sccache.sh
242236
if: success() && !env.SKIP_JOB
@@ -288,6 +282,17 @@ jobs:
288282
AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }}"
289283
TOOLSTATE_REPO_ACCESS_TOKEN: "${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}"
290284
if: success() && !env.SKIP_JOB
285+
- name: create github artifacts
286+
run: src/ci/scripts/create-doc-artifacts.sh
287+
if: success() && !env.SKIP_JOB
288+
- name: upload artifacts to github
289+
uses: actions/upload-artifact@v3
290+
with:
291+
name: "${{ env.DOC_ARTIFACT_NAME }}"
292+
path: obj/artifacts/doc
293+
if-no-files-found: ignore
294+
retention-days: 5
295+
if: success() && !env.SKIP_JOB
291296
- name: upload artifacts to S3
292297
run: src/ci/scripts/upload-artifacts.sh
293298
env:
@@ -301,7 +306,8 @@ jobs:
301306
CI_JOB_NAME: "${{ matrix.name }}"
302307
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
303308
HEAD_SHA: "${{ github.event.pull_request.head.sha || github.sha }}"
304-
SCCACHE_BUCKET: rust-lang-ci-sccache2
309+
SCCACHE_BUCKET: cached-ci-artifacts
310+
SCCACHE_REGION: us-east-2
305311
DEPLOY_BUCKET: rust-lang-ci2
306312
TOOLSTATE_REPO: "https://github.com/rust-lang-nursery/rust-toolstate"
307313
TOOLSTATE_ISSUES_API_URL: "https://api.github.com/repos/rust-lang/rust/issues"
@@ -607,9 +613,6 @@ jobs:
607613
- name: decide whether to skip this job
608614
run: src/ci/scripts/should-skip-this.sh
609615
if: success() && !env.SKIP_JOB
610-
- name: ensure the channel matches the target branch
611-
run: src/ci/scripts/verify-channel.sh
612-
if: success() && !env.SKIP_JOB
613616
- name: collect CPU statistics
614617
run: src/ci/scripts/collect-cpu-stats.sh
615618
if: success() && !env.SKIP_JOB
@@ -698,7 +701,8 @@ jobs:
698701
CI_JOB_NAME: "${{ matrix.name }}"
699702
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
700703
HEAD_SHA: "${{ github.event.pull_request.head.sha || github.sha }}"
701-
SCCACHE_BUCKET: rust-lang-ci-sccache2
704+
SCCACHE_BUCKET: cached-ci-artifacts
705+
SCCACHE_REGION: us-east-2
702706
DEPLOY_BUCKET: rust-lang-ci2
703707
TOOLSTATE_REPO: "https://github.com/rust-lang-nursery/rust-toolstate"
704708
TOOLSTATE_ISSUES_API_URL: "https://api.github.com/repos/rust-lang/rust/issues"
@@ -737,9 +741,6 @@ jobs:
737741
- name: decide whether to skip this job
738742
run: src/ci/scripts/should-skip-this.sh
739743
if: success() && !env.SKIP_JOB
740-
- name: ensure the channel matches the target branch
741-
run: src/ci/scripts/verify-channel.sh
742-
if: success() && !env.SKIP_JOB
743744
- name: collect CPU statistics
744745
run: src/ci/scripts/collect-cpu-stats.sh
745746
if: success() && !env.SKIP_JOB

compiler/rustc_codegen_llvm/src/allocator.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,15 @@ 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_ptr().cast(), name.len(), i8);
88-
if tcx.sess.target.default_hidden_visibility {
89-
llvm::LLVMRustSetVisibility(ll_g, llvm::Visibility::Hidden);
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+
if tcx.sess.target.default_hidden_visibility {
90+
llvm::LLVMRustSetVisibility(ll_g, llvm::Visibility::Hidden);
91+
}
92+
let llval = llvm::LLVMConstInt(i8, 0, False);
93+
llvm::LLVMSetInitializer(ll_g, llval);
9094
}
91-
let llval = llvm::LLVMConstInt(i8, 0, False);
92-
llvm::LLVMSetInitializer(ll_g, llval);
9395

9496
if tcx.sess.opts.debuginfo != DebugInfo::None {
9597
let dbg_cx = debuginfo::CodegenUnitDebugContext::new(llmod);

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1959,7 +1959,7 @@ fn patch_synthetic_object_file(sess: &Session, path: &PathBuf) {
19591959
sf.write(&EM_SBF).unwrap();
19601960
}
19611961
} else {
1962-
sess.fatal(&format!("failed to patch {}", path.display()));
1962+
sess.fatal(format!("failed to patch {}", path.display()));
19631963
}
19641964
}
19651965

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -420,20 +420,13 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
420420
rust_main_def_id: DefId,
421421
entry_type: EntryFnType,
422422
) -> Bx::Function {
423-
<<<<<<< HEAD
424423
// The entry function is either `int main(void)` or `int main(int argc, char **argv)`, or
425424
// `usize efi_main(void *handle, void *system_table)` depending on the target.
426425
let is_bpf = cx.sess().target.arch == "bpf" && cx.sess().opts.test;
427426
let llfty = if cx.sess().target.os.contains("uefi") {
428427
cx.type_func(&[cx.type_ptr(), cx.type_ptr()], cx.type_isize())
429428
} else if cx.sess().target.main_needs_argc_argv {
430429
cx.type_func(&[cx.type_int(), cx.type_ptr()], cx.type_int())
431-
=======
432-
// The entry function is either `int main(void)` or `int main(int argc, char **argv)`,
433-
// depending on whether the target needs `argc` and `argv` to be passed in.
434-
let llfty = if cx.sess().target.main_needs_argc_argv {
435-
cx.type_func(&[cx.type_int(), cx.type_ptr_to(cx.type_i8p())], cx.type_int())
436-
>>>>>>> e5c32090239 ([SOL] rework test harness codegen a bit)
437430
} else {
438431
cx.type_func(&[], cx.type_int())
439432
};

config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ experimental-targets = "BPF;SBF"
7474
# each linker process.
7575
# If absent or 0, linker invocations are treated like any other job and
7676
# controlled by rustbuild's -j parameter.
77-
#link-jobs = 0
77+
link-jobs = 2
7878

7979
# When invoking `llvm-config` this configures whether the `--shared` argument is
8080
# passed to prefer linking to shared libraries.

library/alloc/src/alloc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ extern "Rust" {
3636
#[rustc_nounwind]
3737
fn __rust_alloc_zeroed(size: usize, align: usize) -> *mut u8;
3838

39+
#[cfg(not(target_family = "solana"))]
3940
static __rust_no_alloc_shim_is_unstable: u8;
4041
}
4142

@@ -93,6 +94,7 @@ pub unsafe fn alloc(layout: Layout) -> *mut u8 {
9394
unsafe {
9495
// Make sure we don't accidentally allow omitting the allocator shim in
9596
// stable code until it is actually stabilized.
97+
#[cfg(not(target_family = "solana"))]
9698
core::ptr::read_volatile(&__rust_no_alloc_shim_is_unstable);
9799

98100
__rust_alloc(layout.size(), layout.align())

library/core/src/fmt/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
use crate::cell::{Cell, Ref, RefCell, RefMut, SyncUnsafeCell, UnsafeCell};
66
use crate::char::EscapeDebugExtArgs;
77
use crate::iter;
8-
#[cfg(target_family = "solana")]
9-
use crate::intrinsics::abort;
108
use crate::marker::PhantomData;
119
use crate::mem;
1210
use crate::num::fmt as numfmt;

library/std/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ crate-type = ["dylib", "rlib"]
1414
[dependencies]
1515
alloc = { path = "../alloc", public = true }
1616
cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
17+
panic_unwind = { path = "../panic_unwind", optional = true }
1718
panic_abort = { path = "../panic_abort" }
1819
core = { path = "../core", public = true }
1920
libc = { version = "0.2.150", default-features = false, features = ['rustc-dep-of-std'], public = true }

library/std/src/io/stdio.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::fs::File;
1313
#[cfg(not(target_family = "solana"))]
1414
use crate::io::{self, BorrowedCursor, BufReader, IoSlice, IoSliceMut, LineWriter, Lines};
1515
#[cfg(target_family = "solana")]
16-
use crate::io::{self, BufReader, IoSlice, IoSliceMut};
16+
use crate::io::{self, BorrowedCursor, BufReader, IoSlice, IoSliceMut};
1717
#[cfg(not(target_family = "solana"))]
1818
use crate::sync::atomic::{AtomicBool, Ordering};
1919
use crate::sync::{Arc, Mutex, MutexGuard};
@@ -475,6 +475,9 @@ impl Read for Stdin {
475475
fn read(&mut self, _buf: &mut [u8]) -> io::Result<usize> {
476476
Ok(0)
477477
}
478+
fn read_buf(&mut self, _buf: BorrowedCursor<'_>) -> io::Result<()> {
479+
Ok(())
480+
}
478481
fn read_vectored(&mut self, _bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
479482
Ok(0)
480483
}

library/std/src/panicking.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ pub mod panic_count {
457457
})
458458
}
459459

460+
#[cfg(not(target_family = "solana"))]
460461
pub fn finished_panic_hook() {
461462
LOCAL_PANIC_COUNT.with(|c| {
462463
let (count, _) = c.get();

library/std/src/sync/mpmc/context.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use super::select::Selected;
44
use super::waker::current_thread_id;
55

6+
#[cfg(not(target_family = "solana"))]
67
use crate::cell::Cell;
78
use crate::ptr;
89
use crate::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
@@ -34,6 +35,7 @@ struct Inner {
3435

3536
impl Context {
3637
/// Creates a new context for the duration of the closure.
38+
#[cfg(not(target_family = "solana"))]
3739
#[inline]
3840
pub fn with<F, R>(f: F) -> R
3941
where
@@ -63,6 +65,15 @@ impl Context {
6365
.unwrap_or_else(|_| f(&Context::new()))
6466
}
6567

68+
#[cfg(target_family = "solana")]
69+
#[inline]
70+
pub fn with<F, R>(f: F) -> R
71+
where
72+
F: FnOnce(&Context) -> R,
73+
{
74+
f(&Context::new())
75+
}
76+
6677
/// Creates a new `Context`.
6778
#[cold]
6879
fn new() -> Context {
@@ -77,6 +88,7 @@ impl Context {
7788
}
7889

7990
/// Resets `select` and `packet`.
91+
#[cfg(not(target_family = "solana"))]
8092
#[inline]
8193
fn reset(&self) {
8294
self.inner.select.store(Selected::Waiting.into(), Ordering::Release);

library/std/src/sync/mpmc/waker.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,18 @@ impl Drop for SyncWaker {
201201
}
202202

203203
/// Returns a unique id for the current thread.
204+
#[cfg(not(target_family = "solana"))]
204205
#[inline]
205206
pub fn current_thread_id() -> usize {
206207
// `u8` is not drop so this variable will be available during thread destruction,
207208
// whereas `thread::current()` would not be
208209
thread_local! { static DUMMY: u8 = 0 }
209210
DUMMY.with(|x| (x as *const u8).addr())
210211
}
212+
213+
/// Returns a unique id for the current thread.
214+
#[cfg(target_family = "solana")]
215+
#[inline]
216+
pub fn current_thread_id() -> usize {
217+
0
218+
}

library/std/src/sys/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ cfg_if::cfg_if! {
6363
}
6464

6565
cfg_if::cfg_if! {
66+
if #[cfg(target_family = "solana")] {
6667
// Fuchsia components default to full backtrace.
67-
if #[cfg(target_os = "fuchsia")] {
68+
} else if #[cfg(target_os = "fuchsia")] {
6869
pub const FULL_BACKTRACE_DEFAULT: bool = true;
6970
} else {
7071
pub const FULL_BACKTRACE_DEFAULT: bool = false;

library/std/src/sys/sbf/fs.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,6 @@ impl File {
253253
pub fn set_times(&self, _times: FileTimes) -> io::Result<()> {
254254
match self.0 {}
255255
}
256-
257-
pub fn diverge(&self) -> ! {
258-
match self.0 {}
259-
}
260256
}
261257

262258
impl DirBuilder {

library/std/src/sys/sbf/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,23 @@ pub mod memchr;
2626
pub mod net;
2727
pub mod os;
2828
pub mod path;
29+
#[path = "../unsupported/pipe.rs"]
2930
pub mod pipe;
31+
#[path = "../unsupported/process.rs"]
3032
pub mod process;
3133
pub mod stdio;
3234
pub mod thread;
35+
#[path = "../unsupported/thread_local_dtor.rs"]
36+
pub mod thread_local_dtor;
37+
#[path = "../unsupported/thread_local_key.rs"]
38+
pub mod thread_local_key;
39+
#[path = "../unsupported/thread_parking.rs"]
40+
pub mod thread_parking;
3341
pub mod time;
3442

3543
#[path = "../unix/os_str.rs"]
3644
pub mod os_str;
3745

38-
pub mod thread_local_dtor;
39-
pub mod thread_local_key;
40-
4146
#[path = "../unix/locks"]
4247
pub mod locks {
4348
mod futex_condvar;

library/std/src/sys/sbf/net.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::fmt;
2-
use crate::io::{self, IoSlice, IoSliceMut};
2+
use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut};
33
use crate::net::{SocketAddr, Shutdown, Ipv4Addr, Ipv6Addr};
44
use crate::time::Duration;
55
use crate::sys::{unsupported, Void};
@@ -45,6 +45,10 @@ impl TcpStream {
4545
match self.0 {}
4646
}
4747

48+
pub fn read_buf(&self, _: BorrowedCursor<'_>) -> io::Result<()> {
49+
match self.0 {}
50+
}
51+
4852
pub fn read_vectored(&self, _: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
4953
match self.0 {}
5054
}

0 commit comments

Comments
 (0)