Skip to content
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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
name: Build docker images
concurrency:
group: "${{github.workflow}}-${{github.ref}}"
cancel-in-progress: true
on: [push, pull_request]

jobs:
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile.mri.erb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ RUN git clone -q --depth=1 https://github.com/tpoechtrager/osxcross.git /opt/osx
tar -cJf MacOSX11.1.sdk.tar.xz MacOSX11.1.sdk && \
cd /opt/osxcross && \
UNATTENDED=1 SDK_VERSION=11.1 OSX_VERSION_MIN=10.13 USE_CLANG_AS=1 ./build.sh && \
ln -s /usr/bin/llvm-config-10 /usr/bin/llvm-config && \
ENABLE_COMPILER_RT_INSTALL=1 SDK_VERSION=11.1 ./build_compiler_rt.sh && \
rm -rf *~ build tarballs/*

RUN echo "export PATH=/opt/osxcross/target/bin:\$PATH" >> /etc/rubybashrc && \
Expand Down
19 changes: 19 additions & 0 deletions test/rcd_test/ext/mri/rcd_test_ext.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include "rcd_test_ext.h"

#ifndef __has_builtin
#define __has_builtin(x) 0
#endif

VALUE rb_mRcdTest;

static VALUE
Expand All @@ -8,9 +12,24 @@ rcdt_do_something(VALUE self)
return rb_str_new_cstr("something has been done");
}

static VALUE
rcdt_darwin_builtin_available_eh(VALUE self)
{
#if __has_builtin(__builtin_available)
// This version must be higher than MACOSX_DEPLOYMENT_TARGET to prevent clang from optimizing it away
if (__builtin_available(macOS 10.14, *)) {
return Qtrue;
}
return Qfalse;
#else
rb_raise(rb_eRuntimeError, "__builtin_available is not defined");
#endif
}

void
Init_rcd_test_ext(void)
{
rb_mRcdTest = rb_define_module("RcdTest");
rb_define_singleton_method(rb_mRcdTest, "do_something", rcdt_do_something, 0);
rb_define_singleton_method(rb_mRcdTest, "darwin_builtin_available?", rcdt_darwin_builtin_available_eh, 0);
}
10 changes: 10 additions & 0 deletions test/rcd_test/test/test_basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,14 @@ def test_do_something
assert_equal "something has been done", RcdTest.do_something
end

def test_check_darwin_compiler_rt_symbol_resolution
skip("jruby should not run libc-specific tests") if RUBY_ENGINE == "jruby"

if RUBY_PLATFORM.include?("darwin")
assert(RcdTest.darwin_builtin_available?)
else
e = assert_raises(RuntimeError) { RcdTest.darwin_builtin_available? }
assert_equal("__builtin_available is not defined", e.message)
end
end
end