mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add mjit-bindgen workflow (#6327)
This commit is contained in:
parent
c2986f7d28
commit
06eb9af8c0
Notes:
git
2022-09-05 17:07:02 +09:00
Merged-By: k0kubun <takashikkbn@gmail.com>
4 changed files with 145 additions and 28 deletions
101
.github/workflows/mjit-bindgen.yml
vendored
Normal file
101
.github/workflows/mjit-bindgen.yml
vendored
Normal file
|
@ -0,0 +1,101 @@
|
|||
name: MJIT bindgen
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- 'doc/**'
|
||||
- '**.md'
|
||||
- '**.rdoc'
|
||||
- '**/.document'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- 'doc/**'
|
||||
- '**.md'
|
||||
- '**.rdoc'
|
||||
- '**/.document'
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
|
||||
cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
|
||||
|
||||
jobs:
|
||||
make:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- task: mjit-bindgen
|
||||
configure: '--enable-yjit=dev_nodebug'
|
||||
- task: mjit-bindgen
|
||||
arch: i686
|
||||
fail-fast: false
|
||||
env:
|
||||
SETARCH: ${{ matrix.arch && format('setarch {0}', matrix.arch) }}
|
||||
runs-on: ubuntu-20.04
|
||||
if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
|
||||
steps:
|
||||
- run: mkdir build
|
||||
working-directory:
|
||||
- name: Set ENV
|
||||
run: |
|
||||
echo "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV
|
||||
- name: Install libraries
|
||||
env:
|
||||
arch: ${{ matrix.arch }}
|
||||
run: |
|
||||
set -x
|
||||
arch=${arch:+:${arch/i[3-6]86/i386}}
|
||||
${arch:+sudo dpkg --add-architecture ${arch#:}}
|
||||
sudo apt-get update -q || :
|
||||
sudo apt-get install --no-install-recommends -q -y \
|
||||
${arch:+cross}build-essential${arch/:/-} \
|
||||
libssl-dev${arch} libyaml-dev${arch} libreadline6-dev${arch} \
|
||||
zlib1g-dev${arch} libncurses5-dev${arch} libffi-dev${arch} \
|
||||
libclang1-10${arch} \
|
||||
bison autoconf ruby
|
||||
sudo apt-get install -q -y pkg-config${arch} || :
|
||||
- name: git config
|
||||
run: |
|
||||
git config --global advice.detachedHead 0
|
||||
git config --global init.defaultBranch garbage
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
path: src
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
path: src/.downloaded-cache
|
||||
key: downloaded-cache
|
||||
- name: Fixed world writable dirs
|
||||
run: |
|
||||
chmod -v go-w $HOME $HOME/.config
|
||||
sudo chmod -R go-w /usr/share
|
||||
sudo bash -c 'IFS=:; for d in '"$PATH"'; do chmod -v go-w $d; done' || :
|
||||
- run: ./autogen.sh
|
||||
working-directory: src
|
||||
- name: Run configure
|
||||
env:
|
||||
arch: ${{ matrix.arch }}
|
||||
run: >-
|
||||
$SETARCH ../src/configure -C --disable-install-doc --prefix=$(pwd)/install ${{ matrix.configure }}
|
||||
${arch:+--target=$arch-$OSTYPE --host=$arch-$OSTYPE}
|
||||
- run: $SETARCH make incs
|
||||
- run: $SETARCH make
|
||||
- run: $SETARCH make install
|
||||
- run: $SETARCH make ${{ matrix.task }}
|
||||
- run: git diff --exit-code
|
||||
working-directory: src
|
||||
- uses: k0kubun/action-slack@v2.0.0
|
||||
with:
|
||||
payload: |
|
||||
{
|
||||
"ci": "GitHub Actions",
|
||||
"env": "${{ matrix.os }} / ${{ matrix.test_task }}${{ matrix.configure }}",
|
||||
"url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
|
||||
"commit": "${{ github.sha }}",
|
||||
"branch": "${{ github.ref }}".split('/').reverse()[0]
|
||||
}
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
|
||||
if: ${{ failure() && github.event_name == 'push' }}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: build
|
15
common.mk
15
common.mk
|
@ -229,6 +229,21 @@ yes-mjit-headers: mjit_config.h PHONY
|
|||
mjit.$(OBJEXT): mjit_config.h
|
||||
mjit_config.h: Makefile
|
||||
|
||||
.PHONY: mjit-bindgen
|
||||
mjit-bindgen:
|
||||
$(Q)$(XRUBY) -C $(srcdir) -Ilib \
|
||||
-e 'ENV["GEM_HOME"] = File.expand_path(".bundle")' \
|
||||
-e 'ENV["BUNDLE_APP_CONFIG"] = File.expand_path(".bundle")' \
|
||||
-e 'ENV["BUNDLE_PATH__SYSTEM"] = "true"' \
|
||||
-e 'ENV["BUNDLE_WITHOUT"] = "lint doc"' \
|
||||
-e 'load "spec/bundler/support/bundle.rb"' -- install --gemfile=tool/mjit/Gemfile
|
||||
$(Q)$(XRUBY) -C $(srcdir) -Ilib \
|
||||
-e 'ENV["GEM_HOME"] = File.expand_path(".bundle")' \
|
||||
-e 'ENV["BUNDLE_APP_CONFIG"] = File.expand_path(".bundle")' \
|
||||
-e 'ENV["BUNDLE_GEMFILE"] = "tool/mjit/Gemfile"' \
|
||||
-e 'ENV["BUNDLE_PATH__SYSTEM"] = "true"' \
|
||||
-e 'ENV["BUNDLE_WITHOUT"] = "lint doc"' \
|
||||
-e 'load "spec/bundler/support/bundle.rb"' -- exec tool/mjit/bindgen.rb $(CURDIR)
|
||||
|
||||
# These rules using MJIT_HEADER_SUFFIX must be in common.mk, not
|
||||
# Makefile.in, in order to override the macro in defs/universal.mk.
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
gem 'ffi-clang', git: 'https://github.com/ioquatix/ffi-clang'
|
||||
gem 'pry-byebug'
|
||||
gem 'ffi-clang', git: 'https://github.com/ioquatix/ffi-clang', ref: 'c08ca683c4f4cf73f4dc38539c3180288b360ea1'
|
||||
|
|
|
@ -4,7 +4,15 @@ require 'etc'
|
|||
require 'fiddle/import'
|
||||
require 'set'
|
||||
|
||||
arch_bits = Integer(ARGV.first || 64)
|
||||
unless build_dir = ARGV.first
|
||||
abort "Usage: #{$0} BUILD_DIR"
|
||||
end
|
||||
|
||||
if Fiddle::SIZEOF_VOIDP == 8
|
||||
arch_bits = 64
|
||||
else
|
||||
arch_bits = 32
|
||||
end
|
||||
|
||||
# Help ffi-clang find libclang
|
||||
if arch_bits == 64
|
||||
|
@ -235,7 +243,7 @@ class BindingGenerator
|
|||
in Node[kind: :field_decl, spelling:, bitwidth:, children: [_grandchild]] if bitwidth > 0
|
||||
buf << field_builder.call(spelling, "CType::BitField.new(#{bitwidth}, #{node.offsetof.fetch(spelling) % 8})")
|
||||
# In most cases, we'd like to let generate_type handle the type unless it's "(unnamed ...)".
|
||||
in Node[kind: :field_decl, spelling:, type:] if !type.empty? && !type.match?(/\(unnamed [^)]+\)\z/)
|
||||
in Node[kind: :field_decl, spelling:, type:] if !type.empty? && !type.match?(/\((unnamed|anonymous) [^)]+\)\z/)
|
||||
buf << field_builder.call(spelling, generate_type(type))
|
||||
# Lastly, "(unnamed ...)" struct and union are handled here, which are also struct-specific.
|
||||
in Node[kind: :field_decl, spelling:, children: [grandchild]]
|
||||
|
@ -312,33 +320,27 @@ class BindingGenerator
|
|||
end
|
||||
|
||||
src_dir = File.expand_path('../..', __dir__)
|
||||
if arch_bits == 64
|
||||
build_dir = File.join(src_dir, '.ruby')
|
||||
ruby_platform = RUBY_PLATFORM
|
||||
else
|
||||
build_dir = File.join(src_dir, '.ruby-m32')
|
||||
ruby_platform = 'i686-linux'
|
||||
end
|
||||
build_dir = File.expand_path(build_dir)
|
||||
cflags = [
|
||||
src_dir,
|
||||
build_dir,
|
||||
File.join(src_dir, 'include'),
|
||||
File.join(build_dir, ".ext/include/#{ruby_platform}"),
|
||||
File.join(build_dir, ".ext/include/#{RUBY_PLATFORM}"),
|
||||
].map { |dir| "-I#{dir}" }
|
||||
|
||||
nodes = HeaderParser.new(File.join(src_dir, 'mjit_compiler.h'), cflags: cflags).parse
|
||||
generator = BindingGenerator.new(
|
||||
macros: %w[
|
||||
NOT_COMPILED_STACK_SIZE
|
||||
USE_LAZY_LOAD
|
||||
USE_RVARGC
|
||||
VM_CALL_KW_SPLAT
|
||||
VM_CALL_TAILCALL
|
||||
NOT_COMPILED_STACK_SIZE
|
||||
],
|
||||
enums: {
|
||||
rb_method_type_t: %w[
|
||||
VM_METHOD_TYPE_ISEQ
|
||||
VM_METHOD_TYPE_CFUNC
|
||||
VM_METHOD_TYPE_ISEQ
|
||||
],
|
||||
vm_call_flag_bits: %w[
|
||||
VM_CALL_KW_SPLAT_bit
|
||||
|
@ -346,43 +348,43 @@ generator = BindingGenerator.new(
|
|||
],
|
||||
},
|
||||
types: %w[
|
||||
CALL_DATA
|
||||
IC
|
||||
IVC
|
||||
RB_BUILTIN
|
||||
VALUE
|
||||
compile_branch
|
||||
compile_status
|
||||
inlined_call_context
|
||||
iseq_inline_constant_cache
|
||||
iseq_inline_constant_cache_entry
|
||||
iseq_inline_iv_cache_entry
|
||||
iseq_inline_storage_entry
|
||||
mjit_options
|
||||
rb_builtin_function
|
||||
rb_call_data
|
||||
rb_callable_method_entry_struct
|
||||
rb_callcache
|
||||
rb_callinfo
|
||||
rb_cref_t
|
||||
rb_iseq_constant_body
|
||||
rb_iseq_location_t
|
||||
rb_iseq_struct
|
||||
rb_iseq_t
|
||||
rb_iv_index_tbl_entry
|
||||
rb_mjit_compile_info
|
||||
rb_serial_t
|
||||
rb_mjit_unit
|
||||
CALL_DATA
|
||||
rb_call_data
|
||||
rb_callcache
|
||||
rb_callable_method_entry_struct
|
||||
rb_method_definition_struct
|
||||
rb_method_iseq_t
|
||||
rb_callinfo
|
||||
rb_method_type_t
|
||||
mjit_options
|
||||
compile_branch
|
||||
inlined_call_context
|
||||
rb_iseq_location_t
|
||||
rb_mjit_compile_info
|
||||
rb_mjit_unit
|
||||
rb_serial_t
|
||||
],
|
||||
ruby_fields: {
|
||||
rb_iseq_location_struct: %w[
|
||||
pathobj
|
||||
base_label
|
||||
label
|
||||
first_lineno
|
||||
label
|
||||
pathobj
|
||||
]
|
||||
},
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue