Skip to content

Commit

Permalink
[SOL] Adjust compiler after upgrade to 1.75.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasSte committed Feb 6, 2024
1 parent c9f2a41 commit 98fbbc6
Show file tree
Hide file tree
Showing 20 changed files with 71 additions and 53 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ jobs:
- name: disable git crlf conversion
run: git config --global core.autocrlf false
- name: checkout the source code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: configure the PR in which the error message will be posted
Expand All @@ -230,6 +230,9 @@ jobs:
- 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 All @@ -239,6 +242,9 @@ jobs:
- name: install clang
run: src/ci/scripts/install-clang.sh
if: success() && !env.SKIP_JOB
- name: install tidy
run: src/ci/scripts/install-tidy.sh
if: success() && !env.SKIP_JOB
- name: install WIX
run: src/ci/scripts/install-wix.sh
if: success() && !env.SKIP_JOB
Expand Down Expand Up @@ -431,7 +437,7 @@ jobs:
- name: x86_64-gnu-llvm-17
env:
RUST_BACKTRACE: 1
os: ubuntu-20.04-8core-32gb
os: ubuntu-latest
- name: x86_64-gnu-llvm-16
env:
RUST_BACKTRACE: 1
Expand Down
43 changes: 27 additions & 16 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -723,8 +723,7 @@ checksum = "55b672471b4e9f9e95499ea597ff64941a309b2cdbffcc46f2cc5e2d971fd335"
[[package]]
name = "compiler_builtins"
version = "0.1.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3b73c3443a5fd2438d7ba4853c64e4c8efc2404a9e28a9234cc2d5eebc6c242"
source = "git+https://github.com/LucasSte/compiler-builtins?tag=solana-tools-v1.40#81ef46f3fe1357095acdd089a700890fe4e13974"
dependencies = [
"cc",
"rustc-std-workspace-core",
Expand Down Expand Up @@ -781,8 +780,8 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
name = "core"
version = "0.0.0"
dependencies = [
"getrandom 0.1.14",
"rand 0.7.3",
"getrandom 0.1.16",
"rand",
"rand_xorshift",
]

Expand Down Expand Up @@ -1592,6 +1591,17 @@ dependencies = [
"unicode-width",
]

[[package]]
name = "getrandom"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
dependencies = [
"cfg-if",
"libc",
"wasi 0.9.0+wasi-snapshot-preview1",
]

[[package]]
name = "getrandom"
version = "0.2.10"
Expand All @@ -1600,7 +1610,7 @@ checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427"
dependencies = [
"cfg-if",
"libc",
"wasi",
"wasi 0.11.0+wasi-snapshot-preview1",
]

[[package]]
Expand Down Expand Up @@ -2524,7 +2534,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2"
dependencies = [
"libc",
"wasi",
"wasi 0.11.0+wasi-snapshot-preview1",
"windows-sys 0.48.0",
]

Expand All @@ -2545,7 +2555,7 @@ dependencies = [
"colored",
"ctrlc",
"env_logger 0.10.0",
"getrandom",
"getrandom 0.2.10",
"lazy_static",
"libc",
"libffi",
Expand Down Expand Up @@ -3176,7 +3186,7 @@ version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [
"getrandom",
"getrandom 0.2.10",
]

[[package]]
Expand Down Expand Up @@ -3241,7 +3251,7 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b"
dependencies = [
"getrandom",
"getrandom 0.2.10",
"redox_syscall 0.2.16",
"thiserror",
]
Expand Down Expand Up @@ -5138,7 +5148,7 @@ dependencies = [
"rustc-demangle",
"std_detect",
"unwind",
"wasi",
"wasi 0.11.0+wasi-snapshot-preview1",
]

[[package]]
Expand Down Expand Up @@ -5964,7 +5974,7 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d023da39d1fde5a8a3fe1f3e01ca9632ada0a63e9797de55a879d6e2236277be"
dependencies = [
"getrandom",
"getrandom 0.2.10",
]

[[package]]
Expand Down Expand Up @@ -6004,6 +6014,12 @@ dependencies = [
"try-lock",
]

[[package]]
name = "wasi"
version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"

[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
Expand Down Expand Up @@ -6439,8 +6455,3 @@ dependencies = [
"crossbeam-utils",
"flate2",
]

[[patch.unused]]
name = "compiler_builtins"
version = "0.1.76"
source = "git+https://github.com/solana-labs/compiler-builtins#2044d7e16a99d951853ce362e384027dec4c5b92"
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ miniz_oxide.debug = 0
object.debug = 0

[patch.crates-io]
compiler_builtins = { git = "https://github.com/solana-labs/compiler-builtins" }
compiler_builtins = { git = "https://github.com/LucasSte/compiler-builtins", tag = "solana-tools-v1.40" }
# See comments in `library/rustc-std-workspace-core/README.md` for what's going on
# here
rustc-std-workspace-core = { path = 'library/rustc-std-workspace-core' }
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_codegen_gcc/src/intrinsic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
use rustc_codegen_ssa::mir::place::PlaceRef;
use rustc_codegen_ssa::traits::{ArgAbiMethods, BuilderMethods, ConstMethods, IntrinsicCallMethods};
#[cfg(feature="master")]
use rustc_codegen_ssa::traits::{BaseTypeMethods, MiscMethods};
use rustc_codegen_ssa::traits::MiscMethods;
use rustc_codegen_ssa::traits::BaseTypeMethods;
use rustc_codegen_ssa::errors::InvalidMonomorphization;
use rustc_middle::bug;
use rustc_middle::ty::{self, Instance, Ty};
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,6 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
) -> Bx::Function {
// 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 {
Expand Down Expand Up @@ -487,7 +486,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
(rust_main, start_ty, vec![arg_argc, arg_argv])
};

let result = bx.call(start_ty, None, start_fn, &args, None);
let result = bx.call(start_ty, None, None, start_fn, &args, None);
if cx.sess().target.os.contains("uefi") {
bx.ret(result);
} else {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/base/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub(crate) mod netbsd;
pub(crate) mod nto_qnx;
pub(crate) mod openbsd;
pub(crate) mod redox;
pub(crate) mod sbf_base;
pub(crate) mod solaris;
pub(crate) mod solid;
pub(crate) mod teeos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::abi::Endian;
use super::{Cc, cvs, LinkerFlavor, Lld, PanicStrategy, TargetOptions};
use crate::spec::{Cc, cvs, LinkerFlavor, Lld, PanicStrategy, TargetOptions};

pub fn opts() -> TargetOptions {
let linker_script = r"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::spec::Target;
use crate::spec::sbf_base;
use crate::spec::base::sbf_base;

pub fn target() -> Target {
Target {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::spec::Target;
use crate::spec::sbf_base;
use crate::spec::base::sbf_base;

pub fn target() -> Target {
Target {
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ pub mod __alloc_error_handler {
pub unsafe fn __rdl_oom(size: usize, _align: usize) -> ! {
core::panicking::panic_nounwind_fmt(format_args!(
"memory allocation of {size} bytes failed"
))
), /* force_no_backtrace */ false)
}
}

Expand Down
5 changes: 4 additions & 1 deletion library/std/src/backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ use crate::env;
use crate::ffi::c_void;
use crate::fmt;
#[cfg(not(target_family = "solana"))]
use crate::panic::UnwindSafe;
#[cfg(not(target_family = "solana"))]
use crate::sync::atomic::{AtomicUsize, Ordering::Relaxed};
#[cfg(not(target_family = "solana"))]
use crate::sync::LazyLock;
Expand Down Expand Up @@ -485,9 +487,10 @@ impl fmt::Display for Backtrace {
}
}


#[cfg(not(target_family = "solana"))]
type LazyResolve = impl (FnOnce() -> Capture) + Send + Sync + UnwindSafe;

#[cfg(not(target_family = "solana"))]
fn lazy_resolve(mut capture: Capture) -> LazyResolve {
move || {
// Use the global backtrace lock to synchronize this as it's a
Expand Down
7 changes: 4 additions & 3 deletions library/std/src/panicking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#[cfg(not(target_family = "solana"))]
use crate::panic::BacktraceStyle;
#[cfg(not(target_os = "solana"))]
#[cfg(not(target_family = "solana"))]
use core::panic::{PanicPayload};
use core::panic::{Location, PanicInfo};

Expand Down Expand Up @@ -521,14 +521,12 @@ pub use realstd::rt::panic_count;

/// Invoke a closure, capturing the cause of an unwinding panic if one occurs.
#[cfg(feature = "panic_immediate_abort")]
#[cfg(not(target_arch = "bpf"))]
pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>> {
Ok(f())
}

/// Invoke a closure, capturing the cause of an unwinding panic if one occurs.
#[cfg(not(feature = "panic_immediate_abort"))]
#[cfg(not(target_arch = "bpf"))]
pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>> {
union Data<F, R> {
f: ManuallyDrop<F>,
Expand Down Expand Up @@ -915,6 +913,7 @@ fn rust_panic(_: &mut dyn PanicPayload) -> ! {
unsafe {
crate::intrinsics::abort();
}
}

// Note: The panicking functions have been stripped and rewritten
// in order to save space in SBF programs. Panic messages
Expand Down Expand Up @@ -956,6 +955,7 @@ pub fn begin_panic<M: Any + Send>(_msg: M) -> ! {
None,
Location::caller(),
false,
false,
);
crate::sys::panic(&info);
}
Expand All @@ -974,6 +974,7 @@ pub fn begin_panic_fmt(msg: &fmt::Arguments<'_>) -> ! {
Some(msg),
Location::caller(),
false,
false,
);
crate::sys::panic(&info);
}
4 changes: 4 additions & 0 deletions library/std/src/sys/sbf/cmath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ extern {
pub fn tanf(n: f32) -> f32;
pub fn tanh(n: f64) -> f64;
pub fn tanhf(n: f32) -> f32;
pub fn tgamma(n: f64) -> f64;
pub fn tgammaf(n: f32) -> f32;
pub fn lgamma_r(n: f64, s: &mut i32) -> f64;
pub fn lgammaf_r(n: f32, s: &mut i32) -> f32;
}
5 changes: 5 additions & 0 deletions library/std/src/sys/sbf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,8 @@ pub fn abort_internal() -> ! {
pub fn hashmap_random_keys() -> (u64, u64) {
(1, 2)
}

#[inline]
pub fn is_interrupted(_errno: i32) -> bool {
false
}
7 changes: 7 additions & 0 deletions library/std/src/sys/sbf/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
unsupported()
}

#[derive(Debug)]
pub struct Env(Void);

impl Iterator for Env {
Expand All @@ -70,6 +71,12 @@ impl Iterator for Env {
}
}

impl Env {
pub fn str_debug(&self) -> impl fmt::Debug + '_ {
[OsString::new(), OsString::new()]
}
}

pub fn env() -> Env {
panic!();
}
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test = false

[[bin]]
name = "rustdoc"
path = "bin/rustdoc.rs"
path = "src/bin/rustdoc.rs"
test = false

[[bin]]
Expand Down
11 changes: 0 additions & 11 deletions src/bootstrap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,17 +848,6 @@ impl Build {
}
}

/// Returns the path to llvm/bin
fn llvm_bin(&self, target: TargetSelection) -> PathBuf {
let target_config = self.config.target_config.get(&target);
if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) {
let llvm_bindir = output(Command::new(s).arg("--bindir"));
PathBuf::from(llvm_bindir.trim())
} else {
self.llvm_out(self.config.build).join("bin")
}
}

/// Returns the path to `FileCheck` binary for the specified target
fn llvm_filecheck(&self, target: TargetSelection) -> PathBuf {
let target_config = self.config.target_config.get(&target);
Expand Down
9 changes: 0 additions & 9 deletions src/bootstrap/src/utils/cc_detect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ pub fn find_target(build: &Build, target: TargetSelection) {
{
cfg.compiler(cxx);
true
} else if &*target.triple == "sbf-solana-solana" || &*target.triple == "bpfel-unknown-unknown" {
set_compiler(&mut cfg, Language::CPlusPlus, target, config, build);
true
} else {
// Use an auto-detected compiler (or one configured via `CXX_target_triple` env vars).
cfg.try_get_compiler().is_ok()
Expand Down Expand Up @@ -222,12 +219,6 @@ fn default_compiler(
None
}
}
"bpfel-unknown-unknown" => {
cfg.compiler(build.llvm_bin(target).join(compiler.clang()));
}
"sbf-solana-solana" => {
cfg.compiler(build.llvm_bin(target).join(compiler.clang()));
}

t if t.contains("musl") && compiler == Language::C => {
if let Some(root) = build.musl_root(target) {
Expand Down
2 changes: 1 addition & 1 deletion src/llvm-project
Loading

0 comments on commit 98fbbc6

Please sign in to comment.