diff --git a/Makefile b/Makefile index 134fb8dfdf..747dc29fb3 100644 --- a/Makefile +++ b/Makefile @@ -201,6 +201,7 @@ $(BUILD)/debug/libc.a: $(BUILD)/debug/librelibc.a $(BUILD)/openlibm/libopenlibm. $(BUILD)/debug/librelibc.a: $(SRC) $(CARGO) rustc $(CARGOFLAGS) -- --emit link=$@ -g -C debug-assertions=no $(RUSTCFLAGS) ./renamesyms.sh "$@" "$(BUILD)/debug/deps/" + ./stripcore.sh "$@" touch $@ $(BUILD)/debug/crt0.o: $(SRC) @@ -238,6 +239,7 @@ $(BUILD)/release/librelibc.a: $(SRC) # TODO: Better to only allow a certain whitelisted set of symbols? Perhaps # use some cbindgen hook, specify them manually, or grep for #[unsafe(no_mangle)]. ./renamesyms.sh "$@" "$(BUILD)/release/deps/" + ./stripcore.sh "$@" touch $@ $(BUILD)/release/crt0.o: $(SRC) diff --git a/stripcore.sh b/stripcore.sh new file mode 100755 index 0000000000..3808722529 --- /dev/null +++ b/stripcore.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# This script exists as a workaround for https://github.com/rust-lang/rust/issues/142119 + +set -e + +target=$1 + +if [ -z "$target" ]; then + echo "Usage:\n\t./stripcore.sh TARGET" + exit 1 +fi + +for sym in cbrtf ceilf copysignf fabsf fdimf floorf fmaxf fminf fmofd rintf roundf sqrtf truncf \ + cbrt ceil copysign fabs fdim floor fmax fmin fmod rint round sqrt trunc; do \ + objcopy --globalize-symbol=$sym --strip-symbol=$sym "$target"; \ +done