From c68ce6f7f5e6020409cfe689ba5946f284828d4b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 15 Jan 2024 10:20:16 +0900 Subject: [PATCH] Skip checking for symbol leaks in libruby.so linking extensions The libruby.so linking extension libraries contain symbols exported from extension libraries, and is not subject of test-leaked-globals. --- template/Makefile.in | 3 ++- tool/leaked-globals | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/template/Makefile.in b/template/Makefile.in index 61f420d966..ae1bbd8f24 100644 --- a/template/Makefile.in +++ b/template/Makefile.in @@ -643,7 +643,7 @@ un-runnable: $(ECHO) cannot make runnable, configure with --enable-load-relative. $(Q) exit 1 -LIBRUBY_FOR_LEAKED_GLOBALS = $(enable_shared:no=$(EXTSTATIC:static=)) +LIBRUBY_FOR_LEAKED_GLOBALS = $(enable_shared:no=) yes-test-basic: $(DOT_WAIT) test-leaked-globals leaked-globals: test-leaked-globals yes-test-leaked-globals-precheck: $(COMMONOBJS) prog $(tooldir)/leaked-globals @@ -653,6 +653,7 @@ yes-test-leaked-globals: yes-test-leaked-globals-precheck $(Q) $(XRUBY) $(tooldir)/leaked-globals \ SOEXT=$(SOEXT) NM="$(NM) -Pgp" SYMBOL_PREFIX=$(SYMBOL_PREFIX) \ SYMBOLS_IN_EMPTYLIB="@XSYMBOLS_IN_EMPTYLIB@" \ + EXTSTATIC="$(EXTSTATIC)" \ PLATFORM=$(hdrdir)/ruby/$(PLATFORM_DIR).h $(srcdir)/configure.ac \ $(COMMONOBJS) $(LIBRUBY_FOR_LEAKED_GLOBALS:yes=$(LIBRUBY_SO)) $(ACTIONS_ENDGROUP) diff --git a/tool/leaked-globals b/tool/leaked-globals index 87089ebd81..ee75f78d1d 100755 --- a/tool/leaked-globals +++ b/tool/leaked-globals @@ -13,12 +13,15 @@ until ARGV.empty? soext = $1 when /\A SYMBOLS_IN_EMPTYLIB=(.*)/x SYMBOLS_IN_EMPTYLIB = $1.split(" ") + when /\A EXTSTATIC=(.+)?/x + EXTSTATIC = true else break end ARGV.shift end SYMBOLS_IN_EMPTYLIB ||= nil +EXTSTATIC ||= false config = ARGV.shift count = 0 @@ -56,8 +59,14 @@ REPLACE.push("rust_eh_personality") if RUBY_PLATFORM.include?("darwin") print "Checking leaked global symbols..." STDOUT.flush -soext = /\.#{soext}(?:$|\.)/ if soext -so = soext =~ ARGV.first if ARGV.size == 1 +if soext + soext = /\.#{soext}(?:$|\.)/ + if EXTSTATIC + ARGV.delete_if {|n| soext =~ n} + elsif ARGV.size == 1 + so = soext =~ ARGV.first + end +end IO.foreach("|#{NM} #{ARGV.join(' ')}") do |line| line.chomp! next so = nil if line.empty?