Skip to content

Commit 6f6d004

Browse files
committed
Decrease size of Ruby in libretro builds
This decreases the size of the libretro core by around 10% without having a discernable effect on game compatibility.
1 parent c2aa007 commit 6f6d004

File tree

2 files changed

+8
-36
lines changed

2 files changed

+8
-36
lines changed

binding-sandbox/wasm-rt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#define WASM_PAGE_SIZE ((uint64_t)65536U)
2929

30-
#define WASM_MIN_PAGES ((uint32_t)1536U)
30+
#define WASM_MIN_PAGES ((uint32_t)1280U)
3131

3232
extern "C" bool wasm_rt_is_initialized(void) {
3333
return true;

libretro/Makefile

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
RUBY_VERSION ?= v3_3_7
44
LIBYAML_VERSION ?= 0.2.5
55
ZLIB_VERSION ?= 1.3.1
6-
OPENSSL_VERSION ?= 3.2.0
76
TARGET ?= wasm32-wasip1
87
WASI_SDK ?= /opt/wasi-sdk
98
WASM_OPT ?= wasm-opt
@@ -85,7 +84,10 @@ $(OUTDIR)/mkxp-retro-dist.zip: $(LIBDIR)/mkxp-retro-dist/bin/ruby $(RUBY)
8584
rm $(LIBDIR)/_mkxp-retro-dist/lib/libruby-static.a
8685
rm -r $(LIBDIR)/_mkxp-retro-dist/include
8786
rm -r $(LIBDIR)/_mkxp-retro-dist/share
88-
rm -r $(LIBDIR)/_mkxp-retro-dist/lib/ruby/gems/$(shell $(RUBY) -e 'puts RUBY_VERSION.split(".")[..1].join(".")').0/cache/*
87+
rm -r $(LIBDIR)/_mkxp-retro-dist/lib/ruby/gems
88+
rm -r $(LIBDIR)/_mkxp-retro-dist/lib/ruby/$(shell $(RUBY) -e 'puts RUBY_VERSION.split(".")[..1].join(".")').0/bundler
89+
rm -r $(LIBDIR)/_mkxp-retro-dist/lib/ruby/$(shell $(RUBY) -e 'puts RUBY_VERSION.split(".")[..1].join(".")').0/rdoc
90+
rm -r $(LIBDIR)/_mkxp-retro-dist/lib/ruby/$(shell $(RUBY) -e 'puts RUBY_VERSION.split(".")[..1].join(".")').0/rubygems
8991
echo '# This is a Ruby script that does nothing. We make Ruby load this file on startup just because Ruby needs to load a script on startup for some reason.' > $(LIBDIR)/_mkxp-retro-dist/bin/mkxp-z
9092
rm -f $(OUTDIR)/mkxp-retro-dist.zip
9193
cd $(LIBDIR)/_mkxp-retro-dist && $(ZIP) -r $(OUTDIR)/mkxp-retro-dist.zip *
@@ -107,16 +109,15 @@ $(LIBDIR)/tags.c: $(DOWNLOADS)/crossruby/.ext/include/$(TARGET)/ruby/config.h
107109
mkdir -p $(LIBDIR)
108110
echo '#include <ruby.h>' | $(WASI_CC) -E -I$(DOWNLOADS)/crossruby/include -I$(DOWNLOADS)/crossruby/.ext/include/$(TARGET) -o $(LIBDIR)/tags.c -
109111

110-
$(DOWNLOADS)/crossruby/Makefile $(DOWNLOADS)/crossruby/.ext/include/$(TARGET)/ruby/config.h &: $(DOWNLOADS)/crossruby/configure $(RUBY) $(LIBDIR)/usr/local/lib/libyaml.a $(LIBDIR)/usr/local/lib/libz.a $(LIBDIR)/usr/local/lib/libssl.a
112+
$(DOWNLOADS)/crossruby/Makefile $(DOWNLOADS)/crossruby/.ext/include/$(TARGET)/ruby/config.h &: $(DOWNLOADS)/crossruby/configure $(RUBY) $(LIBDIR)/usr/local/lib/libyaml.a $(LIBDIR)/usr/local/lib/libz.a
111113
cd $(DOWNLOADS)/crossruby && ./configure \
112114
--prefix=/mkxp-retro-dist \
113115
--host $(TARGET) \
114116
--build $(shell $(RUBY) -e 'puts(RbConfig::CONFIG["host"])') \
115117
--with-static-linked-ext \
116-
--with-ext=bigdecimal,cgi/escape,continuation,coverage,date,dbm,digest/bubblebabble,digest,digest/md5,digest/rmd160,digest/sha1,digest/sha2,etc,fcntl,fiber,gdbm,json,json/generator,json/parser,nkf,objspace,pathname,psych,racc/cparse,rbconfig/sizeof,ripper,stringio,strscan,monitor,zlib,openssl \
118+
--with-ext=bigdecimal,cgi/escape,continuation,coverage,date,digest/bubblebabble,digest,digest/md5,digest/rmd160,digest/sha1,digest/sha2,etc,fcntl,fiber,json,json/generator,json/parser,nkf,objspace,pathname,psych,racc/cparse,rbconfig/sizeof,ripper,stringio,strscan,monitor,zlib \
117119
--with-libyaml-dir=$(LIBDIR)/usr/local \
118120
--with-zlib-dir=$(LIBDIR)/usr/local \
119-
--with-openssl-dir=$(LIBDIR)/usr/local \
120121
--with-baseruby=$(RUBY) \
121122
WASMOPT=$(WASM_OPT) \
122123
WASI_SDK_PATH=$(WASI_SDK) \
@@ -127,6 +128,7 @@ $(DOWNLOADS)/crossruby/Makefile $(DOWNLOADS)/crossruby/.ext/include/$(TARGET)/ru
127128
optflags='$(WASI_CFLAGS) -fno-fast-math' \
128129
wasmoptflags='$(WASM_OPT_FLAGS) --pass-arg=asyncify-ignore-imports' \
129130
$(shell $(RUBY) -e 'puts "ac_cv_func_dlopen=no" if RUBY_VERSION.split(".")[..1].join(".").to_f < 3.3') \
131+
--disable-rubygems \
130132
--disable-install-doc
131133

132134
$(DOWNLOADS)/crossruby/configure: $(DOWNLOADS)/crossruby/configure.ac $(RUBY)
@@ -181,33 +183,3 @@ $(DOWNLOADS)/zlib/Makefile: $(DOWNLOADS)/zlib/configure
181183
$(DOWNLOADS)/zlib/configure:
182184
mkdir -p $(DOWNLOADS)
183185
$(CLONE) $(GITHUB)/madler/zlib $(DOWNLOADS)/zlib -b v$(ZLIB_VERSION)
184-
185-
# OpenSSL
186-
187-
$(LIBDIR)/usr/local/lib/libssl.a: $(DOWNLOADS)/openssl/Makefile
188-
cd $(DOWNLOADS)/openssl && $(MAKE) install_dev DESTDIR=$(LIBDIR)
189-
190-
$(DOWNLOADS)/openssl/Makefile: $(DOWNLOADS)/openssl/Configure
191-
cd $(DOWNLOADS)/openssl && CFLAGS='$(WASI_CFLAGS)' CXXFLAGS='$(WASI_CXXFLAGS)' LDFLAGS='$(WASI_LDFLAGS)' ./Configure \
192-
gcc \
193-
-static \
194-
-no-asm \
195-
-no-threads \
196-
-no-afalgeng \
197-
-no-ui-console \
198-
-no-tests \
199-
-no-sock \
200-
-no-dgram \
201-
--libdir=lib \
202-
-Wl,--allow-undefined \
203-
-D_WASI_EMULATED_SIGNAL \
204-
-D_WASI_EMULATED_PROCESS_CLOCKS \
205-
-D_WASI_EMULATED_MMAN \
206-
-D_WASI_EMULATED_GETPID \
207-
-DNO_CHMOD \
208-
-DHAVE_FORK=0 \
209-
$(WASI_TOOLCHAIN)
210-
211-
$(DOWNLOADS)/openssl/Configure:
212-
mkdir -p $(DOWNLOADS)
213-
$(CLONE) $(GITHUB)/openssl/openssl $(DOWNLOADS)/openssl -b openssl-$(OPENSSL_VERSION)

0 commit comments

Comments
 (0)