From: "matz (Yukihiro Matsumoto)" <noreply@...> Date: 2022-01-29T03:01:11+00:00 Subject: [ruby-core:107335] [Ruby master Feature#18490] MakeMakefile.pkg_config should accept multiple options Issue #18490 has been updated by matz (Yukihiro Matsumoto). Assignee set to nobu (Nobuyoshi Nakada) Accepted. Matz. ---------------------------------------- Feature #18490: MakeMakefile.pkg_config should accept multiple options https://bugs.ruby-lang.org/issues/18490#change-96233 * Author: mdalessio (Mike Dalessio) * Status: Open * Priority: Normal * Assignee: nobu (Nobuyoshi Nakada) ---------------------------------------- ## Summary When building static libraries it is sometimes necessary to pass multiple flags to `pkg-config`. Currently, `MakeMakefile.pkg_config` does not allow this. A PR has been submitted at https://github.com/ruby/ruby/pull/5436 ## Real-world example One example of this is the `libmagic` library which is wrapped by the `ruby-magic` gem. The `ruby-magic` gem's `extconf.rb` needs to pass two options to pkg-config, so that the command executed should be: ``` pkg-config --libs --static libmagic ``` (Note that passing only `--libs` then only `--static` and merging the results is not sufficient; both must be passed on the same invocation.) `MakeMakefile.pkg_config` only supports passing **one** option to `pkg-config` today. ## Historical context Prior to Ruby 3.1.0, it was possible to work around this limitation by crafting an options string like so: ``` pkg_config('libmagic', 'libs --static') ``` The `option` parameter would be interpolated into the command template as variable `opt`: ``` "#{$PKGCONFIG} --#{opt} #{pkg} ``` resulting in the desired command string of `pkg-config --libs --static libmagic`. However, with commit https://github.com/ruby/ruby/commit/dff8d12 this hack stopped working because the underlying ruby code is now: ``` xpopen([*envs, $PKGCONFIG, "--#{opt}", pkg], err:[:child, :out], &:read) ``` which results in `pkg-config` returning an error: ``` "Unknown option --libs --static\n" ``` -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>