Project

General

Profile

Actions

Bug #19255

closed

YJIT: global symbol leakage

Added by nobu (Nobuyoshi Nakada) almost 2 years ago. Updated almost 2 years ago.

Status:
Closed
Assignee:
Target version:
-
[ruby-core:111402]

Description

When YJIT support is enabled, libyjit.a adds thousands leaking global symbols.

With this patch:

diff --git a/template/Makefile.in b/template/Makefile.in
index 145631386d8..6191bcbeb88 100644
--- a/template/Makefile.in
+++ b/template/Makefile.in
@@ -720,5 +720,5 @@ mjit_build_dir.$(SOEXT): $(MJIT_MIN_HEADER) $(srcdir)/ruby-runner.c ruby-runner.
 		$(OUTFLAG)$@ $(srcdir)/ruby-runner.c
 
 # yes-test-basic: leaked-globals
-leaked-globals: $(COMMONOBJS) prog $(tooldir)/leaked-globals PHONY
-	$(Q) $(XRUBY) $(tooldir)/leaked-globals NM=$(NM) SYMBOL_PREFIX=$(SYMBOL_PREFIX) PLATFORM=$(hdrdir)/ruby/$(PLATFORM_DIR).h $(srcdir)/configure.ac $(COMMONOBJS)
+leaked-globals: $(COMMONOBJS) $(YJIT_LIBS) prog $(tooldir)/leaked-globals PHONY
+	$(Q) $(XRUBY) $(tooldir)/leaked-globals NM=$(NM) SYMBOL_PREFIX=$(SYMBOL_PREFIX) PLATFORM=$(hdrdir)/ruby/$(PLATFORM_DIR).h $(srcdir)/configure.ac $(COMMONOBJS) $(YJIT_LIBS)

make leaked-globals reports 2915 un-prefixed symbols leaked.

Updated by hsbt (Hiroshi SHIBATA) almost 2 years ago

  • Status changed from Open to Assigned
  • Assignee set to yjit
Actions #3

Updated by alanwu (Alan Wu) almost 2 years ago

  • Status changed from Assigned to Closed

Applied in changeset git|7d4395cb690c4b6be41bc51b25a8a5cda6210a81.


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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0