Skip to content

Commit

Permalink
Bump to stable Rust (1.82) (#1075)
Browse files Browse the repository at this point in the history
* Use `stable` Rust channel

Signed-off-by: Burak Varli <burakvar@amazon.co.uk>

* Pass `+whole-archive` linker flag for `aws-c-common` in debug build

Signed-off-by: Burak Varli <burakvar@amazon.co.uk>

* Replace deprecated PanicInfo type alias

Signed-off-by: Vlad Volodkin <vlaad@amazon.com>
(cherry picked from commit bbaead2)

* Always pass `+whole-archive` modifier for `aws-c-common`

Signed-off-by: Burak Varli <burakvar@amazon.co.uk>

---------

Signed-off-by: Burak Varli <burakvar@amazon.co.uk>
Co-authored-by: Vlad Volodkin <vlaad@amazon.com>
  • Loading branch information
unexge and Vlad Volodkin authored Oct 23, 2024
1 parent 286d348 commit d4a31ee
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
31 changes: 25 additions & 6 deletions mountpoint-s3-crt-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,11 @@ fn compile_crt(output_dir: &Path) -> PathBuf {

// Statically link all the compiled CRT libraries
for lib in libraries.iter() {
println!("cargo:rustc-link-lib=static={}", lib.library_name);
println!(
"cargo:rustc-link-lib={}={}",
static_link_modifiers_for_lib(&lib.library_name),
lib.library_name
);
}

target_dir
Expand All @@ -301,6 +305,21 @@ fn compile_logging_shim(crt_include_dir: impl AsRef<Path>) {
println!("cargo:rerun-if-changed=src/logging_shim.c");
}

/// Returns kind and modifiers to use while statically linking the given library.
/// Should be used in `cargo:rustc-link-lib`.
fn static_link_modifiers_for_lib(library_name: &str) -> &'static str {
// Up until v1.82, Rust was passing `+whole-archive` linker flag while building the tests.
// That's no longer the case with v1.82 and our tests started to fail with undefined references from `aws-c-common`.
// To preserve this behaviour, we're passing `+whole-archive` explicitly for `aws-c-common`,
// unfortunately we're passing this flag for all builds as there is no way to detect if we're
// building the tests currently, see https://github.com/rust-lang/cargo/issues/1581.
if library_name == "aws-c-common" {
"static:+whole-archive"
} else {
"static"
}
}

/// Build or link to the CRT.
///
/// By default, we build and statically link the CRT libraries embedded in this crate as Git
Expand All @@ -324,13 +343,13 @@ fn main() {
let include_dir = if let Some(path) = get_env("MOUNTPOINT_CRT_LIB_DIR") {
println!("cargo:rustc-link-search=native={path}");

let link_type = match get_env("MOUNTPOINT_CRT_LIB_LINK_STATIC") {
Some(_) => "static",
None => "dylib",
};

let libraries = get_required_libraries(&target_os());
for lib in libraries {
let link_type = match get_env("MOUNTPOINT_CRT_LIB_LINK_STATIC") {
Some(_) => static_link_modifiers_for_lib(&lib.library_name),
None => "dylib",
};

println!("cargo:rustc-link-lib={}={}", link_type, lib.library_name);
}

Expand Down
4 changes: 2 additions & 2 deletions mountpoint-s3/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::backtrace::Backtrace;
use std::fs::{DirBuilder, OpenOptions};
use std::os::unix::fs::DirBuilderExt;
use std::os::unix::prelude::OpenOptionsExt;
use std::panic::{self, PanicInfo};
use std::panic::{self, PanicHookInfo};
use std::path::{Path, PathBuf};
use std::thread;

Expand Down Expand Up @@ -70,7 +70,7 @@ pub fn prepare_log_file_name(log_directory: &Path) -> PathBuf {
log_directory.join(file_name)
}

fn tracing_panic_hook(panic_info: &PanicInfo) {
fn tracing_panic_hook(panic_info: &PanicHookInfo) {
let location = panic_info
.location()
.map(|l| format!("{}", l))
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.81.0"
channel = "stable"
components = ["rust-src"]

0 comments on commit d4a31ee

Please sign in to comment.