Skip to content

Commit

Permalink
perf: Always compile libxml2 and libxslt with '-O2 -g'
Browse files Browse the repository at this point in the history
This is the default for those libraries, but we were overriding CFLAGS
in some cases.

Additionally, we need to compile with -U_FORTIFY_SOURCE to avoid
Ubuntu's convention of setting -D_FORTIFY_SOURCE=2 when -O2 is
set. This leads to problems when running precompiled libraries on
musl (see #2100 for details).

Closes #2022.
  • Loading branch information
flavorjones committed Oct 26, 2020
1 parent 4f5c4d6 commit 0b49210
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ext/nokogiri/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def configure
sha256: dependencies["libiconv"]["sha256"]
}]

cflags = [ENV["CFLAGS"], "-O2", "-g"].join(" ")
cflags = concat_flags(ENV["CFLAGS"], "-O2", "-U_FORTIFY_SOURCE", "-g")

recipe.configure_options += [
"CPPFLAGS=-Wall",
Expand Down Expand Up @@ -548,7 +548,7 @@ def configure
sha256: dependencies["libxml2"]["sha256"]
}]

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

if zlib_recipe
recipe.configure_options << "--with-zlib=#{zlib_recipe.path}"
Expand Down Expand Up @@ -581,6 +581,8 @@ def configure
sha256: dependencies["libxslt"]["sha256"]
}]

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

if darwin?
recipe.configure_options += ["RANLIB=/usr/bin/ranlib", "AR=/usr/bin/ar"]
end
Expand All @@ -590,6 +592,7 @@ def configure
"--without-crypto",
"--with-debug",
"--with-libxml-prefix=#{sh_export_path(libxml2_recipe.path)}",
"CFLAGS=#{cflags}",
]
end

Expand Down

0 comments on commit 0b49210

Please sign in to comment.