From d4a31ee13abb4cce71e42a70a1eab4fd7da11ddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Varl=C4=B1?= Date: Wed, 23 Oct 2024 12:20:48 +0100 Subject: [PATCH] Bump to stable Rust (1.82) (#1075) * Use `stable` Rust channel Signed-off-by: Burak Varli * Pass `+whole-archive` linker flag for `aws-c-common` in debug build Signed-off-by: Burak Varli * Replace deprecated PanicInfo type alias Signed-off-by: Vlad Volodkin (cherry picked from commit bbaead293880eaa84cc12f0136b8c50de368afd4) * Always pass `+whole-archive` modifier for `aws-c-common` Signed-off-by: Burak Varli --------- Signed-off-by: Burak Varli Co-authored-by: Vlad Volodkin --- mountpoint-s3-crt-sys/build.rs | 31 +++++++++++++++++++++++++------ mountpoint-s3/src/logging.rs | 4 ++-- rust-toolchain.toml | 2 +- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/mountpoint-s3-crt-sys/build.rs b/mountpoint-s3-crt-sys/build.rs index adfd91046..ce7ce0908 100644 --- a/mountpoint-s3-crt-sys/build.rs +++ b/mountpoint-s3-crt-sys/build.rs @@ -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 @@ -301,6 +305,21 @@ fn compile_logging_shim(crt_include_dir: impl AsRef) { 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 @@ -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); } diff --git a/mountpoint-s3/src/logging.rs b/mountpoint-s3/src/logging.rs index 8e82aa6a6..6acc63531 100644 --- a/mountpoint-s3/src/logging.rs +++ b/mountpoint-s3/src/logging.rs @@ -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; @@ -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)) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index fc4efca1a..ac7d50260 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.81.0" +channel = "stable" components = ["rust-src"]