mirror of
https://github.com/ruby/ruby.git
synced 2026-01-28 21:14:28 +00:00
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>
19 lines
619 B
Makefile
19 lines
619 B
Makefile
# This file is included into the Makefile when
|
|
# we're *not* using GNU make. Stick to basic features.
|
|
|
|
# Rebuild every time since we don't want to list Rust source
|
|
# file dependencies.
|
|
.PHONY: yjit-static-lib
|
|
$(YJIT_LIBS): yjit-static-lib
|
|
$(empty)
|
|
|
|
yjit-static-lib:
|
|
$(ECHO) 'building Rust YJIT (release mode)'
|
|
$(Q) $(RUSTC) $(YJIT_RUSTC_ARGS)
|
|
|
|
# Assume GNU flavor LD and OBJCOPY. Works on FreeBSD 13, at least.
|
|
$(YJIT_LIBOBJ): $(YJIT_LIBS)
|
|
$(ECHO) 'partial linking $(YJIT_LIBS) into $@'
|
|
$(Q) $(LD) -r -o $@ --whole-archive $(YJIT_LIBS)
|
|
-$(Q) $(OBJCOPY) --wildcard --keep-global-symbol='$(SYMBOL_PREFIX)rb_*' $(@)
|