Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow missing AR/CC/etc tools for precompiled rubies #394

Merged
merged 3 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
fail-fast: false
matrix:
# Test against all versions supported by rubygems
ruby_version: ["2.5", "2.6", "2.7", "3.0", "3.1", "3.2", "3.3"]
ruby_version: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3"]
sys:
- os: ubuntu-latest
rust_toolchain: ${{ needs.fetch_ci_data.outputs.minimum-supported-rust-version }}
Expand All @@ -45,7 +45,7 @@
- os: windows-2022
rust_toolchain: stable
include:
- ruby_version: mswin

Check warning on line 48 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / 🧪 Test (mswin, windows-2022, stable-x86_64-pc-windows-msvc)

mswin builds use ruby-master, and which is unstable and may break your build at any time (see https://github.com/MSP-Greg/ruby-loco/issues/12)
sys:
os: windows-2022
rust_toolchain: stable-x86_64-pc-windows-msvc
Expand Down Expand Up @@ -92,7 +92,7 @@

- name: 🧪 Cargo test
shell: bash
if: matrix.ruby_version != 'mswin'

Check warning on line 95 in .github/workflows/ci.yml

View workflow job for this annotation

GitHub Actions / 🧪 Test (mswin, windows-2022, stable-x86_64-pc-windows-msvc)

mswin builds use ruby-master, and which is unstable and may break your build at any time (see https://github.com/MSP-Greg/ruby-loco/issues/12)
run: |
ulimit -c unlimited
bundle exec rake test:cargo
Expand Down
1 change: 1 addition & 0 deletions crates/rb-sys-build/src/bindings/stable_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ pub fn categorize_bindings(syntax: &mut syn::File) {
}

/// Unstable items for usage internally in rb_sys to avoid deprecated warnings.
#[allow(dead_code)]
pub (crate) mod internal {
use super::uncategorized::*;

Expand Down
13 changes: 11 additions & 2 deletions crates/rb-sys-build/src/cc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ impl Build {
let rb = rb_config();

let object_files = self.compile_each_file(compiler, &rb, &out_dir)?;
debug_log!("INFO: compiled object files: {:?}", object_files);
let (lib_path, lib_name) =
self.archive_object_files(archiver.copied(), name, &out_dir, object_files)?;
self.strip_archived_objects(archiver, &lib_path)?;
if let Err(e) = self.strip_archived_objects(archiver, &lib_path) {
debug_log!("WARN: failed to strip archived objects: {:?}", e);
}

println!("cargo:rustc-link-search=native={}", out_dir.display());
println!("cargo:rustc-link-lib=static={}", lib_name);
Expand Down Expand Up @@ -270,7 +273,13 @@ fn get_tool(env_var: &str, default: &str) -> Command {
let mut tool_args = shellsplit(tool_args).into_iter();
let tool = tool_args.next().unwrap_or_else(|| default.to_string());

let mut cmd = new_command(&tool);
let mut cmd = if Path::new(&tool).is_file() {
new_command(&tool)
} else {
debug_log!("[WARN] {tool} tool not found, falling back to {default}");
new_command(default)
};

cmd.args(tool_args.clone());

debug_log!("INFO: found {:?} tool ({:?})", env_var, &cmd);
Expand Down
2 changes: 1 addition & 1 deletion crates/rb-sys-build/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn shellsplit<S: AsRef<str>>(s: S) -> Vec<String> {
match shell_words::split(s) {
Ok(v) => v,
Err(e) => {
debug_log!("shellsplit failed: {}", e);
debug_log!("WARN: shellsplit failed: {}", e);
s.split_whitespace().map(Into::into).collect()
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/rb-sys-test-helpers/src/ruby_test_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ impl Drop for RubyTestExecutor {
}

pub fn global_executor() -> &'static RubyTestExecutor {
#[allow(static_mut_refs)]
unsafe { &GLOBAL_EXECUTOR }.get_or_init(RubyTestExecutor::start)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/rb-sys/build/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn main() {
export_cargo_cfg(&mut rbconfig, &mut cfg_capture_file);

#[cfg(feature = "stable-api")]
stable_api_config::setup(Version::current(&rbconfig)).unwrap();
stable_api_config::setup(Version::current(&rbconfig)).expect("could not setup stable API");

if is_link_ruby_enabled() {
link_libruby(&mut rbconfig);
Expand Down
2 changes: 2 additions & 0 deletions crates/rb-sys/build/stable_api_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,11 @@ fn maybe_warn_old_ruby_version(current_ruby_version: Version) {
}

fn compile() -> Result<(), Box<dyn Error>> {
eprintln!("INFO: Compiling the stable API compiled module");
let mut build = rb_sys_build::cc::Build::new();
let crate_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
let path = crate_dir.join("src").join("stable_api").join("compiled.c");
eprintln!("cargo:rerun-if-changed={}", path.display());

build.file(path);
build.try_compile("compiled")
Expand Down
1 change: 1 addition & 0 deletions crates/rb-sys/src/tracking_allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub struct TrackingAllocator;

impl TrackingAllocator {
/// Create a new [`TrackingAllocator`].
#[allow(clippy::new_without_default)]
pub const fn new() -> Self {
Self
}
Expand Down
4 changes: 2 additions & 2 deletions data/toolchains.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"policy": {
"minimum-supported-ruby-version": "2.5",
"minimum-supported-ruby-version": "2.6",
"minimum-supported-rust-version": "1.63"
},
"toolchains": [
Expand Down Expand Up @@ -115,4 +115,4 @@
"supported": true
}
]
}
}
3 changes: 2 additions & 1 deletion docker/Dockerfile.aarch64-linux
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.5.0-mri-aarch64-linux

ENV RUBY_TARGET="aarch64-linux" \
ENV RUBY_CC_VERSION="3.3.0:3.2.0:3.1.0:3.0.0:2.7.0:2.6.0" \
RUBY_TARGET="aarch64-linux" \
RUST_TARGET="aarch64-unknown-linux-gnu" \
RUSTUP_DEFAULT_TOOLCHAIN="stable" \
PKG_CONFIG_ALLOW_CROSS="1" \
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile.aarch64-linux-musl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.5.0-mri-aarch64-linux-musl

ENV RUBY_TARGET="aarch64-linux-musl" \
ENV RUBY_CC_VERSION="3.3.0:3.2.0:3.1.0:3.0.0:2.7.0:2.6.0" \
RUBY_TARGET="aarch64-linux-musl" \
RUST_TARGET="aarch64-unknown-linux-musl" \
RUSTUP_DEFAULT_TOOLCHAIN="stable" \
RUSTUP_HOME="/usr/local/rustup" \
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile.arm-linux
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.5.0-mri-arm-linux

ENV RUBY_TARGET="arm-linux" \
ENV RUBY_CC_VERSION="3.3.0:3.2.0:3.1.0:3.0.0:2.7.0:2.6.0" \
RUBY_TARGET="arm-linux" \
RUST_TARGET="arm-unknown-linux-gnueabihf" \
RUSTUP_DEFAULT_TOOLCHAIN="stable" \
PKG_CONFIG_ALLOW_CROSS="1" \
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile.arm64-darwin
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.5.0-mri-arm64-darwin

ENV RUBY_TARGET="arm64-darwin" \
ENV RUBY_CC_VERSION="3.3.0:3.2.0:3.1.0:3.0.0:2.7.0:2.6.0" \
RUBY_TARGET="arm64-darwin" \
RUST_TARGET="aarch64-apple-darwin" \
RUSTUP_DEFAULT_TOOLCHAIN="stable" \
PKG_CONFIG_ALLOW_CROSS="1" \
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile.x64-mingw-ucrt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.5.0-mri-x64-mingw-ucrt

ENV RUBY_TARGET="x64-mingw-ucrt" \
ENV RUBY_CC_VERSION="3.3.0:3.2.0:3.1.0:3.0.0:2.7.0:2.6.0" \
RUBY_TARGET="x64-mingw-ucrt" \
RUST_TARGET="x86_64-pc-windows-gnu" \
RUSTUP_DEFAULT_TOOLCHAIN="stable" \
PKG_CONFIG_ALLOW_CROSS="1" \
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile.x64-mingw32
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.5.0-mri-x64-mingw32

ENV RUBY_TARGET="x64-mingw32" \
ENV RUBY_CC_VERSION="3.3.0:3.2.0:3.1.0:3.0.0:2.7.0:2.6.0" \
RUBY_TARGET="x64-mingw32" \
RUST_TARGET="x86_64-pc-windows-gnu" \
RUSTUP_DEFAULT_TOOLCHAIN="stable" \
PKG_CONFIG_ALLOW_CROSS="1" \
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile.x86-linux
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.5.0-mri-x86-linux

ENV RUBY_TARGET="x86-linux" \
ENV RUBY_CC_VERSION="3.3.0:3.2.0:3.1.0:3.0.0:2.7.0:2.6.0" \
RUBY_TARGET="x86-linux" \
RUST_TARGET="i686-unknown-linux-gnu" \
RUSTUP_DEFAULT_TOOLCHAIN="stable" \
PKG_CONFIG_ALLOW_CROSS="1" \
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile.x86-mingw32
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ ARG LLVM_MINGW_VERSION=20231128 \
LLVM_MINGW_SHA256=2d532648bfd202bfe5edfa8b7f6c55970f65639779f34115a9a8bfa6f7d87f0b \
LLVM_MINGW_LIBCLANG_VERSION=14.0.0

ENV RUBY_TARGET="x86-mingw32" \
ENV RUBY_CC_VERSION="3.3.0:3.2.0:3.1.0:3.0.0:2.7.0:2.6.0" \
RUBY_TARGET="x86-mingw32" \
RUST_TARGET="i686-pc-windows-gnu" \
RUSTUP_DEFAULT_TOOLCHAIN="stable" \
PKG_CONFIG_ALLOW_CROSS="1" \
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile.x86_64-darwin
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.5.0-mri-x86_64-darwin

ENV RUBY_TARGET="x86_64-darwin" \
ENV RUBY_CC_VERSION="3.3.0:3.2.0:3.1.0:3.0.0:2.7.0:2.6.0" \
RUBY_TARGET="x86_64-darwin" \
RUST_TARGET="x86_64-apple-darwin" \
RUSTUP_DEFAULT_TOOLCHAIN="stable" \
PKG_CONFIG_ALLOW_CROSS="1" \
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile.x86_64-linux
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.5.0-mri-x86_64-linux

ENV RUBY_TARGET="x86_64-linux" \
ENV RUBY_CC_VERSION="3.3.0:3.2.0:3.1.0:3.0.0:2.7.0:2.6.0" \
RUBY_TARGET="x86_64-linux" \
RUST_TARGET="x86_64-unknown-linux-gnu" \
RUSTUP_DEFAULT_TOOLCHAIN="stable" \
PKG_CONFIG_ALLOW_CROSS="1" \
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile.x86_64-linux-musl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM ghcr.io/rake-compiler/rake-compiler-dock-image:1.5.0-mri-x86_64-linux-musl

ENV RUBY_TARGET="x86_64-linux-musl" \
ENV RUBY_CC_VERSION="3.3.0:3.2.0:3.1.0:3.0.0:2.7.0:2.6.0" \
RUBY_TARGET="x86_64-linux-musl" \
RUST_TARGET="x86_64-unknown-linux-musl" \
RUSTUP_DEFAULT_TOOLCHAIN="stable" \
RUSTUP_HOME="/usr/local/rustup" \
Expand Down
Loading