Skip to content

Commit

Permalink
wip: also try removing -bundle_loader
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Dec 24, 2022
1 parent 841f5a5 commit 6ed0579
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions ext/nokogiri/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,38 @@ def concat_flags(*args)
args.compact.join(" ")
end

def remove_flags(flags, match, name)
def remove_bundle_loader
extdldflags = RbConfig::MAKEFILE_CONFIG["EXTDLDFLAGS"]

extdldflags = remove_flags(extdldflags, "-Wl,-flat_namespace", "EXTDLDFLAGS")
extdldflags = remove_flags(extdldflags, "-bundle_loader", "EXTDLDFLAGS", and_arg: true)

RbConfig::MAKEFILE_CONFIG["EXTDLDFLAGS"] = extdldflags
end

def remove_flags(flags, match, name, and_arg: false)
return flags if flags.nil?

old_flags = flags.split
new_flags = flags.split.reject { |flag| flag == match }

skip_arg = false
new_flags = flags.split.reject do |flag|
if skip_arg
skip_arg = false
true
elsif flag == match
skip_arg = and_arg
true
else
false
end
end

if old_flags != new_flags
diff = old_flags - new_flags
puts "Removed #{diff} from #{name}"
end

new_flags.join(" ")
end

Expand Down Expand Up @@ -712,11 +735,7 @@ def do_clean
puts "MIKE: EXTDLDFLAGS are #{RbConfig::MAKEFILE_CONFIG["EXTDLDFLAGS"]}"

# here we try to unwind that change upstream
RbConfig::MAKEFILE_CONFIG["EXTDLDFLAGS"] = remove_flags(
RbConfig::MAKEFILE_CONFIG["EXTDLDFLAGS"],
"-Wl,-flat_namespace",
"EXTDLDFLAGS",
)
remove_bundle_loader

puts "MIKE: EXTDLDFLAGS are now #{RbConfig::MAKEFILE_CONFIG["EXTDLDFLAGS"]}"

Expand Down

0 comments on commit 6ed0579

Please sign in to comment.