Skip to content

Commit

Permalink
Enable CI for MMTk/Ruby
Browse files Browse the repository at this point in the history
This commit creates a github actions workflow that builds Ruby with the
latest commit of the mmtk-ruby binding and runs `make test-all` with
MMTk enabled.

Several changes were necessary to make this CI pipeline pass:

- C99 prohibits empty compile units, so some code had to be moved around
  in mmtk_support.c to introduce some superfluous #include directives.
  These should either be optimised out or remain unused so have little
  impact on the final binary.

- Correct the dependancy lists in common.mk, by building with the
  appropiate flags defined in `tool/update-deps` and subsequently
  running `make update-deps`

- Pre-fixing all externally visible MMTk related symbols and globals with `rb_`

- Skipping tests related to GC compaction or other functionality
  specific to Ruby's GC.

- Updating YJIT bindings
  • Loading branch information
eightbitraptor committed Jul 17, 2024
1 parent 1be8640 commit 5aa5789
Show file tree
Hide file tree
Showing 18 changed files with 316 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup/directories/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ runs:
echo distclean='make -C ${{ inputs.builddir }} distclean' >> $GITHUB_OUTPUT
echo remained-files='find ${{ inputs.builddir }} -ls' >> $GITHUB_OUTPUT
[ "${{ inputs.builddir }}" = "${{ inputs.srcdir }}" ] ||
echo final='rmdir ${{ inputs.builddir }}' >> $GITHUB_OUTPUT
echo final='rm -rf ${{ inputs.builddir }}' >> $GITHUB_OUTPUT
- name: clean
uses: gacts/run-and-post-run@4683764dd706df847f57b9bed39d08164bcd2690 # v1.4.1
Expand Down
122 changes: 122 additions & 0 deletions .github/workflows/mmtk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: MMTK
on:
push:
paths-ignore:
- 'doc/**'
- '**/man/*'
- '**.md'
- '**.rdoc'
- '**/.document'
- '.*.yml'
pull_request:
# Do not use paths-ignore for required status checks
# https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
merge_group:

concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}

permissions:
contents: read

jobs:
make:
strategy:
matrix:
include:
- test_task: btest
os: ubuntu-20.04
fail-fast: false

env:
GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
RUBY_DEBUG: ci

runs-on: ${{ matrix.os || 'ubuntu-22.04' }}

if: >-
${{!(false
|| contains(github.event.head_commit.message, '[DOC]')
|| contains(github.event.head_commit.message, 'Document')
|| contains(github.event.pull_request.title, '[DOC]')
|| contains(github.event.pull_request.title, 'Document')
|| contains(github.event.pull_request.labels.*.name, 'Document')
|| (github.event_name == 'push' && github.actor == 'dependabot[bot]')
)}}
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
sparse-checkout-cone-mode: false
sparse-checkout: /.github

- uses: ./.github/actions/setup/ubuntu
with:
arch: ${{ matrix.arch }}

- uses: ruby/setup-ruby@78c01b705fd9d5ad960d432d3a0cfa341d50e410 # v1.179.1
with:
ruby-version: '3.0'
bundler: none

- uses: ./.github/actions/setup/directories
with:
srcdir: src
builddir: build
makeup: true
clean: true
dummy-files: ${{ matrix.test_task == 'check' }}
# Set fetch-depth: 10 so that Launchable can receive commits information.
fetch-depth: 10

- uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Clone and build MMTK
run: >-
git clone https://github.com/mmtk/mmtk-ruby &&
cd mmtk-ruby/mmtk &&
cargo build --release
- name: Run configure
env:
arch: ${{ matrix.arch }}
configure: ${{ matrix.configure }}
run: >-
$SETARCH ../src/configure -C --disable-install-doc ${configure:-cppflags=-DRUBY_DEBUG}
${arch:+--target=$arch-$OSTYPE --host=$arch-$OSTYPE}
--with-mmtk-ruby=./mmtk-ruby
- run: $SETARCH make prepare-gems
if: ${{ matrix.test_task == 'test-bundled-gems' }}

- run: $SETARCH make

- name: make ${{ matrix.test_task }} --mmtk
run: >-
$SETARCH make -s ${{ matrix.test_task }}
${TESTS:+TESTS="$TESTS"}
${{ !contains(matrix.test_task, 'bundle') && 'RUBYOPT=-w' || '' }}
timeout-minutes: 40
env:
TESTS: $(cat $srcdir/mmtk_tests.txt | ruby -e 'puts ARGF.map(&:strip).reject { |line| line.start_with?("#") }.join(" ")')
RUBY_TESTOPTS: '-q --tty=no'
TEST_BUNDLED_GEMS_ALLOW_FAILURES: ''
PRECHECK_BUNDLED_GEMS: 'no'

- name: Clean build directory
run: rm -rf $builddir/mmtk-ruby

result:
if: ${{ always() }}
name: ${{ github.workflow }} result
runs-on: ubuntu-latest
needs: [make]
steps:
- run: exit 1
working-directory:
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}

defaults:
run:
working-directory: build
14 changes: 14 additions & 0 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2026,6 +2026,7 @@ array.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
array.$(OBJEXT): $(top_srcdir)/internal/gc.h
array.$(OBJEXT): $(top_srcdir)/internal/hash.h
array.$(OBJEXT): $(top_srcdir)/internal/imemo.h
array.$(OBJEXT): $(top_srcdir)/internal/mmtk_macros.h
array.$(OBJEXT): $(top_srcdir)/internal/numeric.h
array.$(OBJEXT): $(top_srcdir)/internal/object.h
array.$(OBJEXT): $(top_srcdir)/internal/proc.h
Expand Down Expand Up @@ -7242,6 +7243,7 @@ gc.$(OBJEXT): $(top_srcdir)/internal/gc.h
gc.$(OBJEXT): $(top_srcdir)/internal/hash.h
gc.$(OBJEXT): $(top_srcdir)/internal/imemo.h
gc.$(OBJEXT): $(top_srcdir)/internal/io.h
gc.$(OBJEXT): $(top_srcdir)/internal/mmtk_macros.h
gc.$(OBJEXT): $(top_srcdir)/internal/numeric.h
gc.$(OBJEXT): $(top_srcdir)/internal/object.h
gc.$(OBJEXT): $(top_srcdir)/internal/proc.h
Expand Down Expand Up @@ -7743,6 +7745,7 @@ hash.$(OBJEXT): $(top_srcdir)/internal/error.h
hash.$(OBJEXT): $(top_srcdir)/internal/gc.h
hash.$(OBJEXT): $(top_srcdir)/internal/hash.h
hash.$(OBJEXT): $(top_srcdir)/internal/imemo.h
hash.$(OBJEXT): $(top_srcdir)/internal/mmtk_macros.h
hash.$(OBJEXT): $(top_srcdir)/internal/object.h
hash.$(OBJEXT): $(top_srcdir)/internal/proc.h
hash.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
Expand Down Expand Up @@ -10624,6 +10627,17 @@ miniinit.$(OBJEXT): {$(VPATH)}vm_core.h
miniinit.$(OBJEXT): {$(VPATH)}vm_opts.h
miniinit.$(OBJEXT): {$(VPATH)}warning.rb
miniinit.$(OBJEXT): {$(VPATH)}yjit.rb
mmtk_support.$(OBJEXT): {$(VPATH)}config.h
mmtk_support.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
mmtk_support.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
mmtk_support.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
mmtk_support.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
mmtk_support.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
mmtk_support.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
mmtk_support.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
mmtk_support.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
mmtk_support.$(OBJEXT): {$(VPATH)}internal/config.h
mmtk_support.$(OBJEXT): {$(VPATH)}mmtk_support.c
node.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
node.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
node.$(OBJEXT): $(CCAN_DIR)/list/list.h
Expand Down
10 changes: 10 additions & 0 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -14590,7 +14590,11 @@ Init_GC(void)
rb_define_singleton_method(rb_mGC, "malloc_allocations", gc_malloc_allocations, 0);
#endif

#if USE_MMTK
if (GC_COMPACTION_SUPPORTED && !rb_mmtk_enabled_p()) {
#else
if (GC_COMPACTION_SUPPORTED) {
#endif
rb_define_singleton_method(rb_mGC, "compact", gc_compact, 0);
rb_define_singleton_method(rb_mGC, "auto_compact", gc_get_auto_compact, 0);
rb_define_singleton_method(rb_mGC, "auto_compact=", gc_set_auto_compact, 1);
Expand Down Expand Up @@ -14631,7 +14635,13 @@ Init_GC(void)
OPT(MALLOC_ALLOCATED_SIZE);
OPT(MALLOC_ALLOCATED_SIZE_CHECK);
OPT(GC_PROFILE_DETAIL_MEMORY);
#if USE_MMTK
if (!rb_mmtk_enabled_p()) {
#endif
OPT(GC_COMPACTION_SUPPORTED);
#if USE_MMTK
}
#endif
#undef OPT
OBJ_FREEZE(opts);
}
Expand Down
Loading

0 comments on commit 5aa5789

Please sign in to comment.