OpenWrt Forum Archive

Topic: using glibc instead musl

The content of this topic has been archived on 6 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I am trying to use applications compiled for another arm device on my linksys wrt1200 (also arm) without using openwrt imagebuilder and tools, which works for some apps.
but now I am trying to use lantern proxy on my router but I don't know how to compile it static. so it needs" interpreter /lib/ld-linux-armhf.so.3" which is not available in openwrt installation because it uses musl.
now my question is: if I set the compiler in openwrt image builder to glibc instead musl and use that image to install openwrt, what is the penalty for that?
does it work? is the musl the default and so glibc may be buggy? it is an space issue? or RAM space issue?

update:
the image created via imgaebuilder buy using glibc instead of musl is 32MB!!
so I cant install this , am I right?

It's a size issue mostly. Images produced with glibc are much larger as you've discovered. They're really only suitable for systems with significant resources.

this "resources" is a bit ambiguous for me.
do you mean flash size (basically drive size) or RAM size?

BTW can I compile   on my linux machine(x64) for  openwrt ,an application  that has a makefile but it is a big beast in sources and config files (like lantern proxy as I mentioned).
the openwrt uses musl but when I want to compile lantern for arm the tools are only based on gcc (I think , I am not a programmer, I just tinker with config till the errors go away smile )
like arm-linux-gnueabihf-g++

and this is the part of makefile that is for the arm arch:

linux-arm: $(RESOURCES_DOT_GO) $(SOURCES)
    @source setenv.bash && \
    HEADLESS=1 && \
    $(call build-tags) && \
    CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 go build  -a -o lantern_linux_arm -tags="$$BUILD_TAGS" -ldflags="$(LDFLAGS) $$EXTRA_LDFLAGS -linkmode internal -extldflags \"-static\"" github.com/getlantern/flashlight/main

and gnueabihf was gnueabil I think, I changed it to mine on archlinux.

EDIT:
I think I solved it.
in arch there was a "arm-linux-gnueabihf-musl " already in AUR packages.
installed that and change the CC and CXX  from their value to arm-linux-gnueabihf-musl crossed my fingures recompiled and wow it worked.at least it gave a bianry that its interpreter is  /lib/ld-musl-armhf.so.1

file ./lantern_linux_arm 
./lantern_linux_arm: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-armhf.so.1, stripped

so I think it is gonna work on the musl version of openwrt(or is it LEDE now?).

BTW the size issue is ram or space?

(Last edited by rezad1393 on 3 Dec 2016, 20:22)

rezad1393 wrote:

BTW can I compile   on my linux machine(x64) for  openwrt ,an application  that has a makefile but it is a big beast in sources and config files (like lantern proxy as I mentioned).

Yes, you can compile on your x86_64 machine for OpenWrt on a different target architecture. This is known as cross-compilation. You use the OpenWrt buildroot environment (or the OpenWrt SDK). You'll need to do quite a lot of reading of the wiki and also view some sample package Makefiles to understand how to use it. This is a non-trivial exercise.

BTW the size issue is ram or space?

Both. See http://www.etalabs.net/compare_libcs.html

thanks for the answer.
I changed back to musl  (cause I got my lantern compiled , just by editing the makefile smile ) and deleted the bin and statge_dir and build_dir folders and remade the image for openwrt but the size of image is the exact size as the one produced by gcc !

is that not weird?
I have checked the diffconfig file and there gcc is remove correctly and I checked and the produced image is musl based but the size is the same as the glibc one.

The discussion might have continued from here.