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

Issue compiling rb-sys using latest version of clang-sys #383

Open
andrewtbiehl opened this issue May 30, 2024 · 3 comments
Open

Issue compiling rb-sys using latest version of clang-sys #383

andrewtbiehl opened this issue May 30, 2024 · 3 comments

Comments

@andrewtbiehl
Copy link

Hi, I maintain a project that uses rb-sys as an indirect dependency, and I noticed yesterday that rb-sys fails to compile after a patch bump to one of rb-sys' indirect dependencies, namely clang-sys, was released. The library clang-sys was bumped from version 1.8.1 to 1.8.2 yesterday, and the latter version appears to break rb-sys compilation, as demonstrated below.

Here is a GitHub actions workflow that provides a reproducible example of the issue:

name: Test rb-sys
on: workflow_dispatch
jobs:
  test:
    name: Test rb-sys using clang-sys version ${{matrix.clang-sys-version}}
    runs-on: macos-14
    strategy:
      matrix:
        clang-sys-version: ['1.8.1', '1.8.2']
    continue-on-error: true
    steps:
      - name: Install Ruby
        uses: ruby/[email protected]
        with:
          ruby-version: 3.3.1
      - name: Install Rust
        run: |
          rustup install 1.78.0
          rustup default 1.78.0
      # This succeeds with clang-sys v1.8.1 and fails with clang-sys v1.8.2
      - name: Run test
        run: |
          cargo new testpackage
          cd testpackage
          cargo add clang-sys@"= ${{matrix.clang-sys-version}}"
          cargo add rb-sys@"= 0.9.97"
          cargo build

In this example, when using clang-sys v1.8.2, running cargo build yields this error:

Click to view error
Downloading crates ...
  Downloaded aho-corasick v1.1.3
  Downloaded bindgen v0.69.4
  Downloaded cfg-if v1.0.0
  Downloaded cexpr v0.6.0
  Downloaded bitflags v2.5.0
  Downloaded lazy_static v1.4.0
  Downloaded itertools v0.12.1
  Downloaded lazycell v1.3.0
  Downloaded libloading v0.8.3
  Downloaded glob v0.3.1
  Downloaded regex v1.10.4
  Downloaded unicode-ident v1.0.12
  Downloaded syn v2.0.66
  Downloaded regex-automata v0.4.6
  Downloaded libc v0.2.155
  Downloaded regex-syntax v0.8.3
  Downloaded shlex v1.3.0
  Downloaded shell-words v1.1.0
  Downloaded rustc-hash v1.1.0
  Downloaded rb-sys-build v0.9.97
  Downloaded either v1.12.0
  Downloaded clang-sys v1.8.2
  Downloaded rb-sys v0.9.97
  Downloaded quote v1.0.36
  Downloaded proc-macro2 v1.0.84
  Downloaded nom v7.1.3
  Downloaded minimal-lexical v0.2.1
  Downloaded memchr v2.7.2
   Compiling glob v0.3.1
   Compiling memchr v2.7.2
   Compiling proc-macro2 v1.0.84
   Compiling libc v0.2.155
   Compiling clang-sys v1.8.2
   Compiling unicode-ident v1.0.12
   Compiling aho-corasick v1.1.3
   Compiling regex-syntax v0.8.3
   Compiling minimal-lexical v0.2.1
   Compiling cfg-if v1.0.0
   Compiling libloading v0.8.3
   Compiling nom v7.1.3
   Compiling quote v1.0.36
   Compiling regex-automata v0.4.6
   Compiling either v1.12.0
   Compiling bindgen v0.69.4
   Compiling itertools v0.12.1
   Compiling cexpr v0.6.0
   Compiling syn v2.0.66
   Compiling regex v1.10.4
   Compiling bitflags v2.5.0
   Compiling rustc-hash v1.1.0
   Compiling shlex v1.3.0
   Compiling lazy_static v1.4.0
   Compiling lazycell v1.3.0
   Compiling shell-words v1.1.0
   Compiling rb-sys-build v0.9.97
   Compiling rb-sys v0.9.97
error: failed to run custom build command for `rb-sys v0.9.97`

Caused by:
  process didn't exit successfully: `/Users/runner/work/temp_test/temp_test/testpackage/target/debug/build/rb-sys-8b5c413da9536e09/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/version.rs
  cargo:rerun-if-changed=build/stable_api_config.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_aarch[64](https://github.com/andrewtbiehl/temp_test/actions/runs/9305648393/job/25613078615#step:4:65)-apple-darwin
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_aarch64-apple-darwin
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_aarch64_apple_darwin
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_aarch64_apple_darwin
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS

  --- stderr
  INFO: using bindgen with clang args: ["-I/Users/runner/hostedtoolcache/Ruby/3.3.1/arm64/include/ruby-3.3.0", "-I/Users/runner/hostedtoolcache/Ruby/3.3.1/arm64/include/ruby-3.3.0/arm64-darwin22", "-fms-extensions", "-fdeclspec", "-O3", "-fno-fast-math", "-ggdb3", "-Wall", "-Wextra", "-Wextra-tokens", "-Wdeprecated-declarations", "-Wdivision-by-zero", "-Wdiv-by-zero", "-Wimplicit-function-declaration", "-Wimplicit-int", "-Wpointer-arith", "-Wshorten-64-to-32", "-Wwrite-strings", "-Wold-style-definition", "-Wmissing-noreturn", "-Wno-cast-function-type", "-Wno-constant-logical-operand", "-Wno-long-long", "-Wno-missing-field-initializers", "-Wno-overlength-strings", "-Wno-parentheses-equality", "-Wno-self-assign", "-Wno-tautological-compare", "-Wno-unused-parameter", "-Wno-unused-value", "-Wunused-variable", "-Wmisleading-indentation", "-Wundef", "-DENABLE_PATH_CHECK=0", "-D_XOPEN_SOURCE", "-D_DARWIN_C_SOURCE", "-D_DARWIN_UNLIMITED_SELECT", "-D_REENTRANT"]
  #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; };
  struct rb_sys__Opaque__rb_matchext_struct { struct rb_matchext_struct dummy; };
  struct rb_sys__Opaque__rb_internal_thread_event_data { struct rb_internal_thread_event_data dummy; };
  struct rb_sys__Opaque__rb_io_internal_buffer { struct rb_io_internal_buffer dummy; };
  /Users/runner/hostedtoolcache/Ruby/3.3.1/arm64/include/ruby-3.3.0/ruby/defines.h:16:10: fatal error: 'stdio.h' file not found
  thread 'main' panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rb-sys-0.9.[97](https://github.com/andrewtbiehl/temp_test/actions/runs/9305648393/job/25613078615#step:4:98)/build/main.rs:55:6:
  generate bindings: ClangDiagnostic("/Users/runner/hostedtoolcache/Ruby/3.3.1/arm64/include/ruby-3.3.0/ruby/defines.h:16:10: fatal error: 'stdio.h' file not found\n")

I tested the issue on MacOS Sonoma because that is the OS on which I encountered the issue personally. I haven't checked whether this issue is specific to MacOS or not.

This issue doesn't impact me much as I am able to pin clang-sys to version 1.8.1 in my own project and everything works fine. I just thought I would raise this issue in case it is at all helpful to you or anyone else. :)

@ianks
Copy link
Collaborator

ianks commented May 30, 2024

Hey thanks for the report, we have a hot-patch in for GHA to fix https://github.com/oxidize-rb/actions/releases/tag/v1.2.7

Will have to investigate why 1.8.2 broke things though... seems like maybe unintentional breaking change?

@ianks
Copy link
Collaborator

ianks commented May 30, 2024

cc: KyleMayes/clang-sys#181

@andrewtbiehl
Copy link
Author

Shall I close this now that clang-sys version 1.8.2 has been yanked?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants