Skip to content

Commit

Permalink
ext: link libxml2 with -lpthread when necessary
Browse files Browse the repository at this point in the history
libxml 2.12 has a hard dependency on pthread symbols on older systems
with glibc version < 2.34.
  • Loading branch information
flavorjones committed Nov 17, 2023
1 parent f12e955 commit 6e005d2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ext/nokogiri/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,7 @@ def configure

cppflags = concat_flags(ENV["CPPFLAGS"])
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-U_FORTIFY_SOURCE", "-g")
libs = ""

if cross_build_p
cppflags = concat_flags(cppflags, "-DNOKOGIRI_PRECOMPILED_LIBRARIES")
Expand Down Expand Up @@ -913,6 +914,12 @@ def configure
"--disable-dependency-tracking"
end

# glibc 2.34 and later merged libpthread into libc, but we still need to know if it exists so we
# can link libxml2 against it.
if local_have_library("pthread", "pthread_key_delete")
libs = concat_flags(libs, "-lpthread")
end

recipe.configure_options += [
"--without-python",
"--without-readline",
Expand All @@ -921,6 +928,7 @@ def configure
"--with-threads",
"CPPFLAGS=#{cppflags}",
"CFLAGS=#{cflags}",
"LIBS=#{libs}",
]
end

Expand Down

0 comments on commit 6e005d2

Please sign in to comment.