diff options
author | Alan Wu <XrXr@users.noreply.github.com> | 2023-01-18 15:58:35 -0500 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2023-01-27 12:28:09 -0500 |
commit | 7d4395cb690c4b6be41bc51b25a8a5cda6210a81 (patch) | |
tree | b09030cd55b1534f68ae09470c59ab6bbd273839 /tool/leaked-globals | |
parent | e7e48e8a667614c8264993c746ad84b92de997fd (diff) |
YJIT: Fix shared/static library symbol leaks
Rust 1.58.0 unfortunately doesn't provide facilities to control symbol
visibility/presence, but we care about controlling the list of
symbols exported from libruby-static.a and libruby.so.
This commit uses `ld -r` to make a single object out of rustc's
staticlib output, libyjit.a. This moves libyjit.a out of MAINLIBS and adds
libyjit.o into COMMONOBJS, which obviates the code for merging libyjit.a
into libruby-static.a. The odd appearance of libyjit.a in SOLIBS is also
gone.
To filter out symbols we do not want to export on ELF platforms, we use
objcopy after the partial link. On darwin, we supply a symbol list to
the linker which takes care of hiding unprefixed symbols.
[Bug #19255]
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7115
Diffstat (limited to 'tool/leaked-globals')
-rwxr-xr-x | tool/leaked-globals | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tool/leaked-globals b/tool/leaked-globals index 083f658fb1..88b8ae9e72 100755 --- a/tool/leaked-globals +++ b/tool/leaked-globals @@ -43,9 +43,16 @@ ARGV.reject! do |n| true end end +# darwin's ld64 seems to require exception handling personality functions to be +# extern, so we allow the Rust one. +REPLACE.push("rust_eh_personality") if RUBY_PLATFORM.include?("darwin") +# nm errors with Rust's LLVM bitcode when Rust uses a newer LLVM version than nm. +# In case we're working with llvm-nm, tell it to not worry about the bitcode. +no_llvm = "--no-llvm-bc" if `#{NM} --version` =~ /llvm/i + print "Checking leaked global symbols..." STDOUT.flush -IO.foreach("|#{NM} #{ARGV.join(' ')}") do |line| +IO.foreach("|#{NM} #{no_llvm} #{ARGV.join(' ')}") do |line| n, t, = line.split next unless /[A-TV-Z]/ =~ t next unless n.sub!(/^#{SYMBOL_PREFIX}/o, "") |