Issue #11201 has been updated by Hans Mackowiak.

Priority changed from Normal to Low

i try to modify your possible patch a bit,
now it can parse the libs from the libflags again.

makes it work with wx-config and freetype-config

~~~diff
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index 0f588a5..7e8b22d 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -1816,11 +1816,18 @@ SRC
         cflags = get['cflags']
       end
       libs = get['libs-only-l']
-      ldflags = (Shellwords.shellwords(ldflags) - Shellwords.shellwords(libs)).quote.join(" ")
-      $CFLAGS += " " << cflags
-      $CXXFLAGS += " " << cflags
-      $LDFLAGS = [orig_ldflags, ldflags].join(' ')
+      if cflags
+        $CFLAGS += " " << cflags
+        $CXXFLAGS += " " << cflags
+      end
+      if libs
+        ldflags = (Shellwords.shellwords(ldflags) - Shellwords.shellwords(libs)).quote.join(" ")
+      else
+        libs, ldflags = Shellwords.shellwords(ldflags).partition {|s| s =~ /-l([^ ]+)/ }.map {|l| l.quote.join(" ") }
+      end
       $libs += " " << libs
+
+      $LDFLAGS = [orig_ldflags, ldflags].join(' ')
       Logging::message "package configuration for %s\n", pkg
       Logging::message "cflags: %s\nldflags: %s\nlibs: %s\n\n",
                        cflags, ldflags, libs
~~~

sdl2-config and xml2-config makes problems with "cflags-only-I" and "libs-only-l" because they do not return error so $?.success? does think the data is ok

----------------------------------------
Bug #11201: pkg_config NoMethodError when finding other -config program
https://bugs.ruby-lang.org/issues/11201#change-52700

* Author: Hans Mackowiak
* Status: Feedback
* Priority: Low
* Assignee: 
* ruby -v: ruby 2.3.0dev (2015-05-28 trunk 50658) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------

where it does work (existing package)

~~~ruby
pkg_config("gtk+-x11-2.0") #  => ["-pthread", "", "-lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype"] 
pkg_config("gtk+-x11-2.0", "version") # => "0.28" 
~~~

where it does work (non-existing package)

~~~ruby
pkg_config("wx-bla", "version") # => nil 
pkg_config("wx-bla") #  => nil 
~~~

where it maybe not work (other (pkg)-config program)

~~~ruby
pkg_config("wx", "version") # => "3.1.0" 

pkg_config("wx") #either should try to return the same stuff as pkg_config("gtk+-x11-2.0") if possible, or if not return nil
~~~
~~~
NoMethodError: undefined method `scan' for nil:NilClass
	from /usr/local/rvm/rubies/ruby-head/lib/ruby/2.3.0/shellwords.rb:73:in `shellsplit'
	from /usr/local/rvm/rubies/ruby-head/lib/ruby/2.3.0/mkmf.rb:1819:in `pkg_config'
	from (irb):11
	from /usr/local/rvm/rubies/ruby-head/bin/irb:11:in `<main>'
~~~



-- 
https://bugs.ruby-lang.org/