Closed artemshein closed 6 months ago
Not sure if I do it right, I'm trying to build a shared object in an rb-sys docker container started with
bundle exec rb-sys-dock --platform x64-mingw32
and got an error running
cargo build --release --target=x86_64-pc-windows-gnu
error: failed to run custom build command for `rb-sys v0.9.86` Caused by: process didn't exit successfully: `/home/mygem/ext/myextension/target/release/build/rb-sys-19d1cc3fd7c38365/build-script-main` (exit status: 101) --- stdout cargo:rerun-if-env-changed=RUBY cargo:rerun-if-env-changed=RBCONFIG_CROSS_COMPILING cargo:rerun-if-env-changed=RBCONFIG_RUBY_PROGRAM_VERSION cargo:rerun-if-env-changed=RBCONFIG_platform cargo:rerun-if-env-changed=RUBY_ROOT cargo:rerun-if-env-changed=RUBY_VERSION cargo:rerun-if-env-changed=RUBY cargo:rerun-if-changed=build/features.rs cargo:rerun-if-changed=build/stable_api_config.rs cargo:rerun-if-changed=build/version.rs cargo:rerun-if-changed=build/main.rs cargo:rerun-if-env-changed=RUBY_STATIC cargo:rerun-if-env-changed=RBCONFIG_ENABLE_SHARED cargo:rerun-if-env-changed=RBCONFIG_rubyhdrdir cargo:rerun-if-env-changed=RBCONFIG_rubyarchhdrdir cargo:rerun-if-env-changed=RBCONFIG_CPPFLAGS cargo:rerun-if-env-changed=RBCONFIG_rubyhdrdir cargo:rerun-if-env-changed=RBCONFIG_MAJOR cargo:rerun-if-env-changed=RBCONFIG_MINOR cargo:rerun-if-env-changed=TARGET cargo:rerun-if-env-changed=TARGET cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64-pc-windows-gnu cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64-pc-windows-gnu cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64_pc_windows_gnu cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64_pc_windows_gnu --- stderr INFO: using bindgen with clang args: ["-I/usr/local/rvm/rubies/ruby-3.1.3/include/ruby-3.1.0", "-I/usr/local/rvm/rubies/ruby-3.1.3/include/ruby-3.1.0/x86_64-linux", "-fms-extensions", "-O3", "-fno-fast-math", "-ggdb3", "-Wall", "-Wextra", "-Wdeprecated-declarations", "-Wduplicated-cond", "-Wimplicit-function-declaration", "-Wimplicit-int", "-Wmisleading-indentation", "-Wpointer-arith", "-Wwrite-strings", "-Wimplicit-fallthrough=0", "-Wmissing-noreturn", "-Wno-cast-function-type", "-Wno-constant-logical-operand", "-Wno-long-long", "-Wno-missing-field-initializers", "-Wno-overlength-strings", "-Wno-packed-bitfield-compat", "-Wno-parentheses-equality", "-Wno-self-assign", "-Wno-tautological-compare", "-Wno-unused-parameter", "-Wno-unused-value", "-Wsuggest-attribute=format", "-Wsuggest-attribute=noreturn", "-Wunused-variable", "-Wundef"] #include "ruby.h" #ifdef HAVE_RUBY_DEBUG_H #include "ruby/debug.h" #endif #ifdef HAVE_RUBY_DEFINES_H #include "ruby/defines.h" #endif #ifdef HAVE_RUBY_ENCODING_H #include "ruby/encoding.h" #endif #ifdef HAVE_RUBY_FIBER_SCHEDULER_H #include "ruby/fiber/scheduler.h" #endif #ifdef HAVE_RUBY_INTERN_H #include "ruby/intern.h" #endif #ifdef HAVE_RUBY_IO_H #include "ruby/io.h" #endif #ifdef HAVE_RUBY_MEMORY_VIEW_H #include "ruby/memory_view.h" #endif #ifdef HAVE_RUBY_MISSING_H #include "ruby/missing.h" #endif #ifdef HAVE_RUBY_ONIGMO_H #include "ruby/onigmo.h" #endif #ifdef HAVE_RUBY_ONIGURUMA_H #include "ruby/oniguruma.h" #endif #ifdef HAVE_RUBY_RACTOR_H #include "ruby/ractor.h" #endif #ifdef HAVE_RUBY_RANDOM_H #include "ruby/random.h" #endif #ifdef HAVE_RUBY_RE_H #include "ruby/re.h" #endif #ifdef HAVE_RUBY_REGEX_H #include "ruby/regex.h" #endif #ifdef HAVE_RUBY_RUBY_H #include "ruby/ruby.h" #endif #ifdef HAVE_RUBY_ST_H #include "ruby/st.h" #endif #ifdef HAVE_RUBY_THREAD_H #include "ruby/thread.h" #endif #ifdef HAVE_RUBY_THREAD_NATIVE_H #include "ruby/thread_native.h" #endif #ifdef HAVE_RUBY_UTIL_H #include "ruby/util.h" #endif #ifdef HAVE_RUBY_VERSION_H #include "ruby/version.h" #endif #ifdef HAVE_RUBY_VM_H #include "ruby/vm.h" #endif #ifdef HAVE_RUBY_WIN32_H #include "ruby/win32.h" #endif #ifdef HAVE_RUBY_IO_BUFFER_H #include "ruby/io/buffer.h" #endif #ifdef HAVE_RUBY_ATOMIC_H #include "ruby/atomic.h" #endif struct rb_sys__Opaque__RString { struct RString dummy; }; struct rb_sys__Opaque__RArray { struct RArray dummy; }; warning: unknown warning option '-Wduplicated-cond' [-Wunknown-warning-option] warning: unknown warning option '-Wimplicit-fallthrough=0'; did you mean '-Wimplicit-fallthrough'? [-Wunknown-warning-option] warning: unknown warning option '-Wno-cast-function-type'; did you mean '-Wno-bad-function-cast'? [-Wunknown-warning-option] warning: unknown warning option '-Wno-packed-bitfield-compat'; did you mean '-Wno-keyword-compat'? [-Wunknown-warning-option] warning: unknown warning option '-Wsuggest-attribute=format'; did you mean '-Wproperty-attribute-mismatch'? [-Wunknown-warning-option] warning: unknown warning option '-Wsuggest-attribute=noreturn' [-Wunknown-warning-option] /usr/local/rvm/rubies/ruby-3.1.3/include/ruby-3.1.0/ruby/defines.h:63:11: fatal error: 'sys/select.h' file not found clang diag: warning: unknown warning option '-Wduplicated-cond' [-Wunknown-warning-option] clang diag: warning: unknown warning option '-Wimplicit-fallthrough=0'; did you mean '-Wimplicit-fallthrough'? [-Wunknown-warning-option] clang diag: warning: unknown warning option '-Wno-cast-function-type'; did you mean '-Wno-bad-function-cast'? [-Wunknown-warning-option] clang diag: warning: unknown warning option '-Wno-packed-bitfield-compat'; did you mean '-Wno-keyword-compat'? [-Wunknown-warning-option] clang diag: warning: unknown warning option '-Wsuggest-attribute=format'; did you mean '-Wproperty-attribute-mismatch'? [-Wunknown-warning-option] clang diag: warning: unknown warning option '-Wsuggest-attribute=noreturn' [-Wunknown-warning-option] thread 'main' panicked at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/rb-sys-0.9.86/build/main.rs:55:6: generate bindings: ClangDiagnostic("/usr/local/rvm/rubies/ruby-3.1.3/include/ruby-3.1.0/ruby/defines.h:63:11: fatal error: 'sys/select.h' file not found\n") note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
In order for cargo build
to work directly like that, you'll need to use rb-sys-env
to configure the correct env variables that cargo needs. Have you tried that?
Also, unless you have specific needs, it's probably best to use bundle exec rb-sys-dock --platform x64-mingw32 --build
to invoke rake-compiler for you rather than invoking cargo build
yourself. That will deal with creating binaries for multiple versions of Ruby and handle other plumbing.
Thanks for the info, unfortunately it doesn't help either:
clang diag: warning: unknown warning option '-Wsuggest-attribute=noreturn' [-Wunknown-warning-option]
thread 'main' panicked at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/rb-sys-0.9.86/build/main.rs:55:6:
generate bindings: ClangDiagnostic("/usr/local/rvm/rubies/ruby-3.1.3/include/ruby-3.1.0/ruby/defines.h:63:11: fatal error: 'sys/select.h' file not found\n")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
x64-mingw32 ➜ a_rb_rs (a111f17 ✗) $ cat build.rs
fn main() {
let _rb_env = rb_sys_env::activate();
}
x64-mingw32 ➜ a_rb_rs (a111f17 ✗) $ cat Cargo.toml
[package]
name = "a_rb_rs"
version = "0.1.0"
edition = "2021"
[lib]
crate-type = ["cdylib"]
[dependencies]
rb-sys = { version = "0.9", default-features = false, features = ["bindgen-rbimpls", "bindgen-deprecated-types", "stable-api"] }
[build-dependencies]
rb-sys-env = "0.1"
I also tried to use bundle exec rb-sys-dock --platform x64-mingw32 --build
, but there is some configuration issue, it fails with an error message:
RbSys::CargoMetadataError: Could not infer Rust crate information using `cargo metadata`. Original error was: RuntimeError: exited with non-zero status (pid 175 exit 101) Things to check: - Check that your ext/*/Cargo.toml at is valid - If you are using a workspace, make sure you are the root Cargo.toml exists - Make sure `cargo` is installed and in your PATHStderr from `cargo metadata` was:
error: could not find `Cargo.toml` in `/home/user/p/myrubygem-lib` or any parent directory
It searches for a Cargo.toml in the gem root folder, when Cargo.toml is actually in ext/myextension/.
ahh, yes. currently it assumes a root Cargo.toml (workspace root). would accept a patch to fix that, but for now it might be easiest add a workspace root one (like this)
Adding Cargo.toml with workspace and also extconf.rb helped in my case to build the binary.
Not sure if I do it right, I'm trying to build a shared object in an rb-sys docker container started with
and got an error running