[ruby/psych] Require libfyaml 0.9 and build it from source in CI

The libfyaml-dev package on Ubuntu is 0.8, which segfaults psych's
emitter, while 0.9.6 (used on macOS via Homebrew) passes the whole suite.
Build the same 0.9.6 release from source in the Linux CI job, and reject
libfyaml older than 0.9 in extconf so users get a clear error instead of
a runtime crash. Also drop an unused variable in set_canonical.

https://github.com/ruby/psych/commit/88ac4a0cc0

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hiroshi SHIBATA 2026-07-01 12:05:57 +09:00 committed by git
parent 82ab14ecb0
commit 5ef8b6ef81
2 changed files with 6 additions and 2 deletions

View File

@ -12,6 +12,12 @@ if enable_config("libfyaml", false)
unless pkg_config('libfyaml')
abort "libfyaml was requested with --enable-libfyaml but was not found via pkg-config"
end
# libfyaml 0.8 and earlier crash psych's emitter, so require a known-good
# version rather than building something that segfaults at runtime.
pkgconfig = ENV["PKG_CONFIG"] || "pkg-config"
unless system(pkgconfig, "--atleast-version=0.9", "libfyaml")
abort "The libfyaml backend requires libfyaml 0.9 or newer"
end
$defs << "-DPSYCH_USE_LIBFYAML"
create_makefile 'psych'

View File

@ -408,8 +408,6 @@ static VALUE alias(VALUE self, VALUE anchor)
static VALUE set_canonical(VALUE self, VALUE style)
{
psych_fy_emitter_t *e;
TypedData_Get_Struct(self, psych_fy_emitter_t, &psych_emitter_type, e);
/* libfyaml has no canonical emit mode, so reject enabling it rather than
* pretending to honor the request. */
if (RTEST(style)) {