How to tell buildroot not run strip.sh on a shared library file?

I am creating packages of several Lisp interpreters and compilers, and one of them is Chicken Scheme (http://call-cc.org), which is already available from downloads.openwrt.org via opkg. Chicken comes with an interpreter (csi) and a compiler (csc).

However, I have only packaged the Chicken interpreter, but not the compiler. This is because the compiler, csc, generates C code, which then is then compiled using gcc, and linked against a shared library, libchicken.so. But this library is stripped during the package build process, and has no section headers. When csc calls ld through gcc to link it, the symbols are not found.

# csc a.scm
(...) // several other undefined references here
a.c:(.text.f_130+0x74): undefined reference to `C_trace'
a.c:(.text.f_130+0xa0): undefined reference to `C_unbound_variable'
a.o: In function `main':
a.c:(.text.startup.main+0xc): undefined reference to `CHICKEN_main'
collect2: error: ld returned 1 exit status

Error: shell command terminated with non-zero exit status 256: 'mips-openwrt-linux-musl-gcc' 'a.o' -o 'a' -L/usr/lib -Wl,-R/usr/lib -lchicken -lm

# file /usr/lib/libchicken.so
/usr/lib/libchicken.so: ELF 32-bit MSB shared object, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked, no section header

Now, if I copy libchicken.so from ~/openwrt-19.07/build_dir/target-mips_24kc_musl/chicken-5.2.0rc2/libchicken.so (the non-stripped version) into the router, and put it in /usr/lib, then csc works perfectly.

# file /usr/lib/libchicken.so
/usr/lib/libchicken.so: ELF 32-bit MSB shared object, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked, with debug_info, not stripped
# csc a.scm
# ./a
x

(The program a.scm only prints an "x" and exits -- it all worked fine)

Since the compiler (csc) already depends on gcc, I'm not that worried about size, so I thought it would be OK to not strip the shared library when building the package. But I could not find a way to do that.

Is there a way to tell the buildroot to not run strip.sh on a specific file? (Or to override that file after strip has run?)

I know I can set CONFIG_NO_STRIP:=1 before including rules.mk, but then no files at all are stripped.

Try add this to your makefile
RSTRIP:=:

@Andy2244 thank you! have split the package in two; after the install section of the first package, I set RSTRIP:=: and the files in the second package are not stripped. That works!

A slightly different approach here: https://git.openwrt.org/?p=openwrt/openwrt.git;a=commitdiff;h=b070101c506ca5541d6f232c2da3e0f7b1383106;hp=44304c1d671696ed9598735e71a1635276102511

The idea is to turn the $(STRIP) command path into a no-op globally, then selectively run it for specific paths in the install phase.

1 Like