Skip to content

Commit

Permalink
[SOL] Adjust SBF customization after upgrading to rust 1.72.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dmakarov authored and LucasSte committed Feb 2, 2024
1 parent 2bc12d8 commit c3afa9e
Show file tree
Hide file tree
Showing 25 changed files with 91 additions and 383 deletions.
51 changes: 26 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ jobs:
CI_JOB_NAME: "${{ matrix.name }}"
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
HEAD_SHA: "${{ github.event.pull_request.head.sha || github.sha }}"
SCCACHE_BUCKET: rust-lang-ci-sccache2
SCCACHE_BUCKET: cached-ci-artifacts
SCCACHE_REGION: us-east-2
SCCACHE_S3_NO_CREDENTIALS: 1
TOOLSTATE_REPO: "https://github.com/rust-lang-nursery/rust-toolstate"
CACHE_DOMAIN: cached-ci-artifacts.s3.us-east-2.amazonaws.com
if: "github.event_name == 'pull_request'"
Expand All @@ -64,7 +66,7 @@ jobs:
env: {}
- name: sbf-solana-solana
tidy: false
os: ubuntu-latest
os: ubuntu-20.04-16core-64gb
env: {}
- name: x86_64-gnu-tools
os: ubuntu-20.04-16core-64gb
Expand All @@ -91,9 +93,6 @@ jobs:
- name: decide whether to skip this job
run: src/ci/scripts/should-skip-this.sh
if: success() && !env.SKIP_JOB
- name: ensure the channel matches the target branch
run: src/ci/scripts/verify-channel.sh
if: success() && !env.SKIP_JOB
- name: collect CPU statistics
run: src/ci/scripts/collect-cpu-stats.sh
if: success() && !env.SKIP_JOB
Expand Down Expand Up @@ -179,6 +178,8 @@ jobs:
name: push
env:
CI_JOB_NAME: "${{ matrix.name }}"
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
HEAD_SHA: "${{ github.event.pull_request.head.sha || github.sha }}"
SCCACHE_BUCKET: cached-ci-artifacts
SCCACHE_REGION: us-east-2
DEPLOY_BUCKET: rust-lang-ci2
Expand All @@ -187,19 +188,20 @@ jobs:
TOOLSTATE_PUBLISH: 0
CACHES_AWS_ACCESS_KEY_ID: AKIASSXOBJJGY5HRQO4U
ARTIFACTS_AWS_ACCESS_KEY_ID: AKIA46X5W6CZN24CBO55
CACHE_DOMAIN: cached-ci-artifacts.s3.us-east-2.amazonaws.com
AWS_REGION: us-west-1
CACHE_DOMAIN: ci-caches.rust-lang.org
if: "github.event_name == 'push' && startsWith(github.ref, 'refs/heads/solana-') && github.repository == 'solana-labs/rust'"
strategy:
matrix:
include:
- name: mingw-check
os: ubuntu-latest
os: ubuntu-20.04-16core-64gb
env: {}
- name: x86_64-gnu-llvm-12
os: ubuntu-latest
os: ubuntu-20.04-16core-64gb
env: {}
- name: sbf-solana-solana
os: ubuntu-latest
os: ubuntu-20.04-16core-64gb
env: {}
timeout-minutes: 600
runs-on: "${{ matrix.os }}"
Expand All @@ -223,20 +225,12 @@ jobs:
- name: decide whether to skip this job
run: src/ci/scripts/should-skip-this.sh
if: success() && !env.SKIP_JOB
- name: configure GitHub Actions to kill the build when outdated
uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
with:
github_token: "${{ secrets.github_token }}"
if: "success() && !env.SKIP_JOB && github.ref != 'refs/heads/try' && github.ref != 'refs/heads/try-perf'"
- name: collect CPU statistics
run: src/ci/scripts/collect-cpu-stats.sh
if: success() && !env.SKIP_JOB
- name: show the current environment
run: src/ci/scripts/dump-environment.sh
if: success() && !env.SKIP_JOB
- name: install awscli
run: src/ci/scripts/install-awscli.sh
if: success() && !env.SKIP_JOB
- name: install sccache
run: src/ci/scripts/install-sccache.sh
if: success() && !env.SKIP_JOB
Expand Down Expand Up @@ -288,6 +282,17 @@ jobs:
AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }}"
TOOLSTATE_REPO_ACCESS_TOKEN: "${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}"
if: success() && !env.SKIP_JOB
- name: create github artifacts
run: src/ci/scripts/create-doc-artifacts.sh
if: success() && !env.SKIP_JOB
- name: upload artifacts to github
uses: actions/upload-artifact@v3
with:
name: "${{ env.DOC_ARTIFACT_NAME }}"
path: obj/artifacts/doc
if-no-files-found: ignore
retention-days: 5
if: success() && !env.SKIP_JOB
- name: upload artifacts to S3
run: src/ci/scripts/upload-artifacts.sh
env:
Expand All @@ -301,7 +306,8 @@ jobs:
CI_JOB_NAME: "${{ matrix.name }}"
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
HEAD_SHA: "${{ github.event.pull_request.head.sha || github.sha }}"
SCCACHE_BUCKET: rust-lang-ci-sccache2
SCCACHE_BUCKET: cached-ci-artifacts
SCCACHE_REGION: us-east-2
DEPLOY_BUCKET: rust-lang-ci2
TOOLSTATE_REPO: "https://github.com/rust-lang-nursery/rust-toolstate"
TOOLSTATE_ISSUES_API_URL: "https://api.github.com/repos/rust-lang/rust/issues"
Expand Down Expand Up @@ -607,9 +613,6 @@ jobs:
- name: decide whether to skip this job
run: src/ci/scripts/should-skip-this.sh
if: success() && !env.SKIP_JOB
- name: ensure the channel matches the target branch
run: src/ci/scripts/verify-channel.sh
if: success() && !env.SKIP_JOB
- name: collect CPU statistics
run: src/ci/scripts/collect-cpu-stats.sh
if: success() && !env.SKIP_JOB
Expand Down Expand Up @@ -698,7 +701,8 @@ jobs:
CI_JOB_NAME: "${{ matrix.name }}"
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
HEAD_SHA: "${{ github.event.pull_request.head.sha || github.sha }}"
SCCACHE_BUCKET: rust-lang-ci-sccache2
SCCACHE_BUCKET: cached-ci-artifacts
SCCACHE_REGION: us-east-2
DEPLOY_BUCKET: rust-lang-ci2
TOOLSTATE_REPO: "https://github.com/rust-lang-nursery/rust-toolstate"
TOOLSTATE_ISSUES_API_URL: "https://api.github.com/repos/rust-lang/rust/issues"
Expand Down Expand Up @@ -737,9 +741,6 @@ jobs:
- name: decide whether to skip this job
run: src/ci/scripts/should-skip-this.sh
if: success() && !env.SKIP_JOB
- name: ensure the channel matches the target branch
run: src/ci/scripts/verify-channel.sh
if: success() && !env.SKIP_JOB
- name: collect CPU statistics
run: src/ci/scripts/collect-cpu-stats.sh
if: success() && !env.SKIP_JOB
Expand Down
14 changes: 8 additions & 6 deletions compiler/rustc_codegen_llvm/src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,15 @@ pub(crate) unsafe fn codegen(
let llval = llvm::LLVMConstInt(i8, val as u64, False);
llvm::LLVMSetInitializer(ll_g, llval);

let name = NO_ALLOC_SHIM_IS_UNSTABLE;
let ll_g = llvm::LLVMRustGetOrInsertGlobal(llmod, name.as_ptr().cast(), name.len(), i8);
if tcx.sess.target.default_hidden_visibility {
llvm::LLVMRustSetVisibility(ll_g, llvm::Visibility::Hidden);
if tcx.sess.target.arch != "sbf" {
let name = NO_ALLOC_SHIM_IS_UNSTABLE;
let ll_g = llvm::LLVMRustGetOrInsertGlobal(llmod, name.as_ptr().cast(), name.len(), i8);
if tcx.sess.target.default_hidden_visibility {
llvm::LLVMRustSetVisibility(ll_g, llvm::Visibility::Hidden);
}
let llval = llvm::LLVMConstInt(i8, 0, False);
llvm::LLVMSetInitializer(ll_g, llval);
}
let llval = llvm::LLVMConstInt(i8, 0, False);
llvm::LLVMSetInitializer(ll_g, llval);

if tcx.sess.opts.debuginfo != DebugInfo::None {
let dbg_cx = debuginfo::CodegenUnitDebugContext::new(llmod);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1959,7 +1959,7 @@ fn patch_synthetic_object_file(sess: &Session, path: &PathBuf) {
sf.write(&EM_SBF).unwrap();
}
} else {
sess.fatal(&format!("failed to patch {}", path.display()));
sess.fatal(format!("failed to patch {}", path.display()));
}
}

Expand Down
7 changes: 0 additions & 7 deletions compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,20 +420,13 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
rust_main_def_id: DefId,
entry_type: EntryFnType,
) -> Bx::Function {
<<<<<<< HEAD
// The entry function is either `int main(void)` or `int main(int argc, char **argv)`, or
// `usize efi_main(void *handle, void *system_table)` depending on the target.
let is_bpf = cx.sess().target.arch == "bpf" && cx.sess().opts.test;
let llfty = if cx.sess().target.os.contains("uefi") {
cx.type_func(&[cx.type_ptr(), cx.type_ptr()], cx.type_isize())
} else if cx.sess().target.main_needs_argc_argv {
cx.type_func(&[cx.type_int(), cx.type_ptr()], cx.type_int())
=======
// The entry function is either `int main(void)` or `int main(int argc, char **argv)`,
// depending on whether the target needs `argc` and `argv` to be passed in.
let llfty = if cx.sess().target.main_needs_argc_argv {
cx.type_func(&[cx.type_int(), cx.type_ptr_to(cx.type_i8p())], cx.type_int())
>>>>>>> e5c32090239 ([SOL] rework test harness codegen a bit)
} else {
cx.type_func(&[], cx.type_int())
};
Expand Down
2 changes: 1 addition & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ experimental-targets = "BPF;SBF"
# each linker process.
# If absent or 0, linker invocations are treated like any other job and
# controlled by rustbuild's -j parameter.
#link-jobs = 0
link-jobs = 2

# When invoking `llvm-config` this configures whether the `--shared` argument is
# passed to prefer linking to shared libraries.
Expand Down
2 changes: 2 additions & 0 deletions library/alloc/src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ extern "Rust" {
#[rustc_nounwind]
fn __rust_alloc_zeroed(size: usize, align: usize) -> *mut u8;

#[cfg(not(target_family = "solana"))]
static __rust_no_alloc_shim_is_unstable: u8;
}

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

__rust_alloc(layout.size(), layout.align())
Expand Down
2 changes: 0 additions & 2 deletions library/core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
use crate::cell::{Cell, Ref, RefCell, RefMut, SyncUnsafeCell, UnsafeCell};
use crate::char::EscapeDebugExtArgs;
use crate::iter;
#[cfg(target_family = "solana")]
use crate::intrinsics::abort;
use crate::marker::PhantomData;
use crate::mem;
use crate::num::fmt as numfmt;
Expand Down
1 change: 1 addition & 0 deletions library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ crate-type = ["dylib", "rlib"]
[dependencies]
alloc = { path = "../alloc", public = true }
cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
panic_unwind = { path = "../panic_unwind", optional = true }
panic_abort = { path = "../panic_abort" }
core = { path = "../core", public = true }
libc = { version = "0.2.150", default-features = false, features = ['rustc-dep-of-std'], public = true }
Expand Down
5 changes: 4 additions & 1 deletion library/std/src/io/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::fs::File;
#[cfg(not(target_family = "solana"))]
use crate::io::{self, BorrowedCursor, BufReader, IoSlice, IoSliceMut, LineWriter, Lines};
#[cfg(target_family = "solana")]
use crate::io::{self, BufReader, IoSlice, IoSliceMut};
use crate::io::{self, BorrowedCursor, BufReader, IoSlice, IoSliceMut};
#[cfg(not(target_family = "solana"))]
use crate::sync::atomic::{AtomicBool, Ordering};
use crate::sync::{Arc, Mutex, MutexGuard};
Expand Down Expand Up @@ -475,6 +475,9 @@ impl Read for Stdin {
fn read(&mut self, _buf: &mut [u8]) -> io::Result<usize> {
Ok(0)
}
fn read_buf(&mut self, _buf: BorrowedCursor<'_>) -> io::Result<()> {
Ok(())
}
fn read_vectored(&mut self, _bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
Ok(0)
}
Expand Down
1 change: 1 addition & 0 deletions library/std/src/panicking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ pub mod panic_count {
})
}

#[cfg(not(target_family = "solana"))]
pub fn finished_panic_hook() {
LOCAL_PANIC_COUNT.with(|c| {
let (count, _) = c.get();
Expand Down
12 changes: 12 additions & 0 deletions library/std/src/sync/mpmc/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use super::select::Selected;
use super::waker::current_thread_id;

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

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

#[cfg(target_family = "solana")]
#[inline]
pub fn with<F, R>(f: F) -> R
where
F: FnOnce(&Context) -> R,
{
f(&Context::new())
}

/// Creates a new `Context`.
#[cold]
fn new() -> Context {
Expand All @@ -77,6 +88,7 @@ impl Context {
}

/// Resets `select` and `packet`.
#[cfg(not(target_family = "solana"))]
#[inline]
fn reset(&self) {
self.inner.select.store(Selected::Waiting.into(), Ordering::Release);
Expand Down
8 changes: 8 additions & 0 deletions library/std/src/sync/mpmc/waker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,18 @@ impl Drop for SyncWaker {
}

/// Returns a unique id for the current thread.
#[cfg(not(target_family = "solana"))]
#[inline]
pub fn current_thread_id() -> usize {
// `u8` is not drop so this variable will be available during thread destruction,
// whereas `thread::current()` would not be
thread_local! { static DUMMY: u8 = 0 }
DUMMY.with(|x| (x as *const u8).addr())
}

/// Returns a unique id for the current thread.
#[cfg(target_family = "solana")]
#[inline]
pub fn current_thread_id() -> usize {
0
}
3 changes: 2 additions & 1 deletion library/std/src/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ cfg_if::cfg_if! {
}

cfg_if::cfg_if! {
if #[cfg(target_family = "solana")] {
// Fuchsia components default to full backtrace.
if #[cfg(target_os = "fuchsia")] {
} else if #[cfg(target_os = "fuchsia")] {
pub const FULL_BACKTRACE_DEFAULT: bool = true;
} else {
pub const FULL_BACKTRACE_DEFAULT: bool = false;
Expand Down
4 changes: 0 additions & 4 deletions library/std/src/sys/sbf/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,6 @@ impl File {
pub fn set_times(&self, _times: FileTimes) -> io::Result<()> {
match self.0 {}
}

pub fn diverge(&self) -> ! {
match self.0 {}
}
}

impl DirBuilder {
Expand Down
11 changes: 8 additions & 3 deletions library/std/src/sys/sbf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,23 @@ pub mod memchr;
pub mod net;
pub mod os;
pub mod path;
#[path = "../unsupported/pipe.rs"]
pub mod pipe;
#[path = "../unsupported/process.rs"]
pub mod process;
pub mod stdio;
pub mod thread;
#[path = "../unsupported/thread_local_dtor.rs"]
pub mod thread_local_dtor;
#[path = "../unsupported/thread_local_key.rs"]
pub mod thread_local_key;
#[path = "../unsupported/thread_parking.rs"]
pub mod thread_parking;
pub mod time;

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

pub mod thread_local_dtor;
pub mod thread_local_key;

#[path = "../unix/locks"]
pub mod locks {
mod futex_condvar;
Expand Down
6 changes: 5 additions & 1 deletion library/std/src/sys/sbf/net.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::fmt;
use crate::io::{self, IoSlice, IoSliceMut};
use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut};
use crate::net::{SocketAddr, Shutdown, Ipv4Addr, Ipv6Addr};
use crate::time::Duration;
use crate::sys::{unsupported, Void};
Expand Down Expand Up @@ -45,6 +45,10 @@ impl TcpStream {
match self.0 {}
}

pub fn read_buf(&self, _: BorrowedCursor<'_>) -> io::Result<()> {
match self.0 {}
}

pub fn read_vectored(&self, _: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
match self.0 {}
}
Expand Down
Loading

0 comments on commit c3afa9e

Please sign in to comment.