Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Could a static-option be added to the menu interface? #491

Open
rubyFeedback opened this issue Apr 9, 2024 · 5 comments

Comments

@rubyFeedback
Copy link

Toybox offers some curses based menu. This is similar to busybox.

However had, in busybox there is an option called "compile as
static binary", or something like that. Could toybox also add
such a Setting or Configure option?

I understand we can probably work around this using LDFLAGS
or what not, but I'd prefer a configuration option via the menu
interface.

Static binaries can be nice because if things break on the host system,
a static binary may still work and thus can be used to fix things.

@oliverkwebb
Copy link

oliverkwebb commented Apr 10, 2024

Toybox offers some curses based menu. This is similar to busybox.

An old version of 2.6 menuconfig taken from busybox (who took it from the linux kernel).
That is (from my knowledge, in the early stages of) being replaced because of licensing
(0BSD is not compatible with GPLv2)

However had, in busybox there is an option called "compile as static binary", or something like that. Could toybox also add such a Setting or Configure option?

From my knowledge of the infrastructure We have no such method of doing so.
Compiler flags are generally a compile time thing, not a configuration time thing.

I understand we can probably work around this using LDFLAGS or what not, but I'd prefer a configuration option via the menu interface.

My suggestion, if you really want it; is to add this block to the Config.in:

config STATIC
    bool "Staticly Build toybox"
    default n

Then have a script grep -q for "#define CFG_STATIC 1" (in generated/config.h) and add LDFLAGS=--static (and maybe CC=musl-gcc since
glibc doesn't staticly link well) on build time.

Static binaries can be nice because if things break on the host system, a static binary may still work and thus can be used to fix things.

You can build a staticly linked binary of toybox with make LDFLAGS=--static (glibc will whine tho, I'd recommend
musl for this)

@landley
Copy link
Owner

landley commented Apr 10, 2024

I build with "LDFLAGS=--static" all the time. (So does mkroot/mkroot.sh when it builds toybox for the target.) I don't generally add config options for compiler flags you can easily add on the command line.

Also, static linking on glibc is terrible and intentionally broken. I ranted about it a bit in the FAQ at https://landley.net/toybox/faq.html#targets and it comes up here ala #418 where people blame me for glibc and I try to explain glibc to them. (The android NDK has a few screws missing from its static support too, but nowhere near to glibc's levels. Works fine on musl.)

@terefang
Copy link

could you make an exception for all those musl users (on Alpine, etc )out there or static musl on glibc systems ?

#496

@landley
Copy link
Owner

landley commented Apr 28, 2024

What do you mean by "exception"?

Also, you closed the other issue before I was done with it, see commit mentioned there.

@terefang
Copy link

maybe is was too brash about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants