Skip to content

Commit 04522f4

Browse files
committed
ext: work around MakeMakefile.pkg_config issue in Ruby 3.1
see https://bugs.ruby-lang.org/issues/18490
1 parent abdbfd5 commit 04522f4

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

ext/sqlite3/extconf.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,15 @@
3333
end
3434
recipe.activate
3535

36-
pkg_config(File.join(recipe.path, "lib", "pkgconfig", "sqlite3.pc"))
37-
have_library("dl") # sqlite3.pc has this in Libs.private, but see https://bugs.ruby-lang.org/issues/18490
38-
have_library("pthread") # sqlite3.pc has this in Libs.private, but see https://bugs.ruby-lang.org/issues/18490
36+
ENV["PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"] = "t" # on macos, pkg-config will not return --cflags without this
37+
pcfile = File.join(recipe.path, "lib", "pkgconfig", "sqlite3.pc")
38+
if pkg_config(pcfile)
39+
# see https://bugs.ruby-lang.org/issues/18490
40+
libs = xpopen(["pkg-config", "--libs", "--static", pcfile], err: [:child, :out], &:read)
41+
libs.split.each { |lib| append_ldflags(lib) } if $?.success?
42+
else
43+
message("Please install either the `pkg-config` utility or the `pkg-config` rubygem.\n")
44+
end
3945
end
4046

4147
# ldflags = cppflags = nil

0 commit comments

Comments
 (0)