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 /template | |
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 'template')
-rw-r--r-- | template/Makefile.in | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/template/Makefile.in b/template/Makefile.in index c4d05ef243..bae3980440 100644 --- a/template/Makefile.in +++ b/template/Makefile.in @@ -114,6 +114,7 @@ MJIT_TABS=@MJIT_TABS@ YJIT_SUPPORT=@YJIT_SUPPORT@ YJIT_LIBS=@YJIT_LIBS@ YJIT_OBJ=@YJIT_OBJ@ +YJIT_LIBOBJ = $(YJIT_LIBS:.a=.@OBJEXT@) CARGO_TARGET_DIR=@abs_top_builddir@/yjit/target CARGO_BUILD_ARGS=@CARGO_BUILD_ARGS@ LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@ @@ -130,7 +131,7 @@ XDLDFLAGS = @DLDFLAGS@ DLDFLAGS = @LIBRUBY_DLDFLAGS@ $(XLDFLAGS) $(ARCH_FLAG) SOLIBS = @SOLIBS@ ENABLE_DEBUG_ENV = @ENABLE_DEBUG_ENV@ -MAINLIBS = $(YJIT_LIBS) @MAINLIBS@ +MAINLIBS = @MAINLIBS@ ARCHMINIOBJS = @MINIOBJS@ DLNOBJ = @DLNOBJ@ ENCOBJS = @ENCOBJS@ @@ -319,16 +320,6 @@ $(LIBRUBY_A): @-[ -z "$(EXTSTATIC)" ] || $(PRE_LIBRUBY_UPDATE) $(ECHO) linking static-library $@ $(Q) $(AR) $(ARFLAGS) $@ $(LIBRUBY_A_OBJS) $(INITOBJS) - $(Q) if [ 'no' != '$(YJIT_SUPPORT)' ]; then \ - set -eu$(V0:1=x) && \ - $(ECHO0) 'merging $(YJIT_LIBS) into $@' && \ - $(RMALL) libyjit/ && \ - $(MAKEDIRS) libyjit/ && \ - trap "$(RMALL) libyjit/" 0 && \ - (cd libyjit/ && $(AR) -x ../$(YJIT_LIBS)) && \ - : "$(AR) $(ARFLAGS) $@ libyjit/*.$(OBJEXT)" && \ - find libyjit/ -name '*.$(OBJEXT)' -exec $(AR) $(ARFLAGS) $@ '{}' '+' ; \ - fi @-$(RANLIB) $@ 2> /dev/null || true verify-static-library: $(LIBRUBY_A) |