054493350 ("Do not add -lresolv on non-Linux systems") adds a condition
to link with libresolv only on linux systems.
The check requires that CONFIG_UNAME_OSNAME equals Linux. This works only
if the uname applet is enabled. Otherwise, CONFIG_UNAME_OSNAME is empty,
regardless of the platform.
By default, CONFIG_UNAME_OSNAME is the output of uname -o. For most
linux systems, uname -o returns "GNU/Linux" and the check fails. In this
case, linking a static busybox fails because of missing symbols from
libresolv.
networking/lib.a(nslookup.o): In function `add_query':
nslookup.c:789: undefined reference to `__res_mkquery'
networking/lib.a(nslookup.o): In function `parse_reply':
nslookup.c:355: undefined reference to `ns_initparse'
nslookup.c:361: undefined reference to `ns_parserr'
nslookup.c:404: undefined reference to `ns_name_uncompress'
nslookup.c:418: undefined reference to `ns_get16'
nslookup.c:419: undefined reference to `ns_name_uncompress'
..
nslookup.c:456: undefined reference to `ns_get16'
...
nslookup.c:469: undefined reference to `ns_name_uncompress'
...
nslookup.c:489: undefined reference to `ns_get32'
...
collect2: error: ld returned 1 exit status
This patch uses the output of $CC -dumpmachine to detect the target platform
for which we compile. Both gcc and clang support -dumpmachine. Like the
original patch, we link against libresolv only if our target platform is
linux-based.
Fixes: 054493350 ("Do not add -lresolv on non-Linux systems")
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
On FreeBSD getaddrinfo and friends are part of libc.
Other OS-es will also have own dependencies
Signed-off-by: Alex Samorukov <samm@os2.kiev.ua>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
When using GNU Make >=4.3, the KBUILD_STR() definition interferes badly
with dependency checks during build, and forces a complete rebuild every
time Make runs.
In if_changed_rule, Kconfig checks if the command used to build a file
has changed since last execution. The previous command is stored in the
generated .<file>.o.cmd file. For example applets/.applets.o.cmd defines
a "cmd_applets/applets.o" variable:
cmd_applets/applets.o := gcc ... -D"KBUILD_STR(s)=#s" ...
Here the '#' should be escaped with a backslash, otherwise GNU Make
interprets it as starting a comment, and ignore the rest of the
variable. As a result of this truncation, the previous command doesn't
equal the new command and Make rebuilds each target.
The problem started to appear when GNU Make 4.3 (released January 2020),
introduced a backward-incompatible fix to macros containing a '#'. While
the above use of '#', a simple Make variable, still needs to be escaped,
a '#' within a function invocation doesn't need to be escaped anymore.
As Martin Dorey explained on the GNU Make discussion [1], the above
declaration is generated from make-cmd, defined as:
make-cmd = $(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1))))
Since GNU Make 4.3, the first argument of subst should not have a
backslash. make-cmd now looks for literally \# and doesn't find it, and
as a result doesn't add the backslash when generating .o.cmd files.
[1] http://savannah.gnu.org/bugs/?20513
We could fix it by changing make-cmd to "$(subst #,\#,...)", but to
avoid compatibility headaches, simply get rid of the KBUILD_STR
definition, as done in Linux by b42841b7bb62 ("kbuild: Get rid of
KBUILD_STR"). Quote the string arguments directly rather than asking the
preprocessor to quote them.
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Before this change, BB_EXTRA_VERSION of "" resulted in:
"BusyBox v1.28.0.git () multi-call binary"
message, after the fix it is:
"BusyBox v1.28.0.git multi-call binary"
While at it, eliminate BB_BT and BANNER single-use macros.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Building & running with ASAN is super helpful, so add a dedicated config
knob for it. This way people don't have to guess at the right compiler
settings in order to get a good build. We can just tell people to enable
this one option.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Static build with CONFIG_PAM fails on Debian Jessie due to undefined
references to libdl and libaudit.
Static build without pam, but with libcrypt required fails as well due
to undefined references to libpthread.
Fix these two cases by adding the missing libraries to LDLIBS when
appropriate.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Newer versions of libselinux has started linking against more libs.
Rather than continuing hardcoding things, switch to using pkg-config
to query for its dependencies.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
From Rich Felker:
By default, modern GCC generates DWARF2 debug/unwind tables in the
.eh_frame section of the object files/binaries. This adds significant
bloat (as much as 15%) to the size of the busybox binary, including
the portion mapped/loaded into memory at runtime (possibly a big issue
for NOMMU targets), and the section is not strippable with the strip
command due to being part of the loaded program text.
I've since done some further checking - both testing and asking the
GCC developers about it - and it seems the solution is to add to the
CFLAGS -fno-unwind-tables and -fno-asynchronous-unwind-tables. If
debugging is disabled, this will prevent GCC from outputting DWARF2
tables entirely. But since busybox builds with -g by default, the
interesting case is what happens then. I originally thought these
options would break debugging, but they don't; instead, they tell GCC
to output the DWARF2 tables in the .debug_frame section instead of
the newish .eh_frame section (used for exception handling). With these
options added, busybox_unstripped is still fully debuggable, and the
final busybox binary loses the 15% bloat factor from the DWARF2
tables.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
We pass strings to printf directly a lot. Some distros enable some flags
in their gcc by default like -Wformat-security. With these two things, we
end up with a lot of build warnings like so:
loginutils/chpasswd.c:42:3: warning: format not a string literal and
no format arguments [-Wformat-security]
But we don't care. Our focus is first and foremost on size, so adding a
lot of dummy calls like:
- printf(some_constant_string);
+ printf("%s", some_constant_string);
is pointless bloat.
Disable this warning flag if the compiler supports it.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Recent versions of GCC for PowerPC systems suffer from some compiler
bugs which prevent the use of "--enable-target-optspace" in their
configuration, which makes the compiler option "-Os" unavailable;
for reference see
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43810http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48278http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45053
In the result, BusyBox will be compiled without any optimization
options, which causes a huge binary (1.8 MiB for default configuration
on PPC, built with gcc 54.51 from the Yocto / Poky / OpenEmbedded tool
chains). This commit changes behaviour so "-O2" gets used as fallback
when "-Os" is not available. This reduces the image size in above
test to 1.3 MiB. This is still 10...15% more then what we get with
"-Os", but much better than using no optimization at all.
Signed-off-by: Wolfgang Denk <wd@denx.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This is the result after converting mtd-utils' flash_eraseall to BB.
The functionality given by this patch almost the same except that this
one does not support long options.
I needed this tool a system which does not have a lot of flash for RFS
and merging this into BB as the only way out.
[bigeasy@]$ ./scripts/bloat-o-meter bb_wo_fl bb_w_fl
function old new delta
flash_eraseall_main - 1072 +1072
show_progress - 62 +62
packed_usage 25156 25176 +20
applet_names 1958 1973 +15
applet_main 2352 2360 +8
target_endian - 4 +4
applet_nameofs 588 590 +2
applet_install_loc 147 148 +1
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 5/0 up/down: 1184/0) Total: 1184 bytes
[bigeasy@]$ size miscutils/flash_eraseall.o
text data bss dec hex filename
1586 4 0 1590 636 miscutils/flash_eraseall.o
Signed-off-by: Benedigt Spranger <b.spranger@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
This helps with remembering additional flags like e.g. cpu settings for
people who did not configured their compiler to produce code for their cpu
per default.
specified libs, and if it succeeds, we try to remove them
one-by-one. If link succeeds, then library is thrown out.
Should solve the problem with SELinux linking in libsepol
even when not needed.