Commit Graph

511 Commits

Author SHA1 Message Date
Denys Vlasenko
ed2af2e82d build system: detect if build host has no bzip2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2022-01-04 14:32:41 +01:00
Denys Vlasenko
0fcc7f5f73 scripts/echo.c: fix NUL handling in "abc\0 def"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-12-28 21:05:59 +01:00
Denys Vlasenko
540aa11661 scripts/randomtest.loop: let user know about SKIP_MOUNT_MAND_TESTS
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-16 20:03:07 +02:00
Denys Vlasenko
d32ef3174b *: remove remains of FEATURE_TOUCH_NODEREF
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-08-15 20:50:13 +02:00
Paul Spooren
947a22b332 build system: use SOURCE_DATE_EPOCH for timestamp if available
The SOURCE_DATE_EPOCH is an effort of the Reproducible Builds
organization to make timestamps/build dates in compiled tools
deterministic over several repetitive builds.

Busybox shows by default the build date timestamp which changes whenever
compiled. To have a reasonable accurate build date while staying
reproducible, it's possible to use the *date of last source
modification* rather than the current time and date.

Further information on SOURCE_DATE_EPOCH are available online [1].

This patch modifies `confdata.c` so that the content of the
SOURCE_DATE_EPOCH env variable is used as timestamp.

To be independent of different timezones between builds, whenever
SOURCE_DATE_EPOCH is defined the GMT time is used.

[1]: https://reproducible-builds.org/docs/source-date-epoch/

Signed-off-by: Paul Spooren <mail@aparcar.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-05 18:13:00 +02:00
Khem Raj
c0f8113f86 gen_build_files: Use C locale when calling sed on globbed files
When include/applets.h is re-generated

it generates code macros in include/applets.h e.g.

IF_XZCAT(APPLET_ODDNAME(xzcat, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xzcat))
...
IF_CHVT(APPLET_NOEXEC(chvt, chvt, BB_DIR_USR_BIN, BB_SUID_DROP, chvt))
...

sed is used to process source files like below to feed into this header
generation

sed -n 's@^//applet:@@p' "$srctree"/*/*.c "$srctree"/*/*/*.c

this means we let shell decide the order of .c files being fed into sed
tool, applets.h has code snippets thats generated out of code fragments
from these .c files and the order of the generated code depends on the
order of .c files being fed to sed and then piped to generate tool, even
though the generated code is logically same, it does result in re-odered
code in applets.h based on which shell was used during build on exact busybox
sources since sort order is different based on chosen locale and also default shell
being bash or dash

This sets the environment variable LC_ALL to the value C, which will
enforce bytewise sorting, irrespective of the shell

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-06-05 17:36:19 +02:00
Chris Renshaw
6c6470b384 gcc-version.sh: fix for "invalid number" message during Android NDK builds
A CR in the gcc output would cause the following to show throughout build:

: invalid numberbox-1.32.1/scripts/gcc-version.sh: line 12: printf: 9

Signed-off-by: Chris Renshaw <osm0sis@outlook.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-22 09:21:39 +02:00
Denys Vlasenko
d9136efd7a gcc-version.sh: Cygwin fix
On Cygwin, "echo __GNUC__ __GNUC_MINOR__ | gcc -E -xc -" can print
extra empty trailing line.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-18 13:22:26 +02:00
Denys Vlasenko
1a45b2ccea fix "warning array subscript has type 'char'"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-14 19:12:43 +02:00
Ron Yorston
27c1bc8dfb build system: avoid build failure during bisection
Commit 4bdc914ff (build system: fix compiler warnings) added a
test on the return value of fgets() in split-include.c.

During bisection it's possible to go back to a state where a
configuration value didn't exist.  This results in an empty
include file corresponding to the missing feature.  If a
subsequent bisection returns to a state where the feature exists
split-include treats the empty file as an error and the build
fails.

Add a call to ferror() to distinguish between fgets() failing
due to an error and due to there being no data to read.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-13 18:26:46 +02:00
Ron Yorston
0b25e810ed bloat-o-meter: avoid double counting
Disable 'echo' in the default config, run 'make baseline', then
re-enable 'echo' and run 'make bloatcheck':

function                                             old     new   delta
.rodata                                           182521  182622    +101
packed_usage                                       33714   33792     +78
applet_main                                         3168    3176      +8
applet_names                                        2730    2735      +5
applet_suid                                           99     100      +1
applet_install_loc                                   198     199      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/0 up/down: 194/0)             Total: 194 bytes
   text	   data	    bss	    dec	    hex	filename
 955052	   4195	   1808	 961055	  eaa1f	busybox_old
 955153	   4195	   1808	 961156	  eaa84	busybox_unstripped

The Total bytes value doesn't equal the change in the size of the
binary.  The packed_usage and applet_* items are in .rodata and
are counted twice.  With this modified bloat-o-meter the size of
named items is deducted from .rodata:

function                                             old     new   delta
packed_usage                                       33714   33792     +78
applet_main                                         3168    3176      +8
.rodata                                           105105  105113      +8
applet_names                                        2730    2735      +5
applet_suid                                           99     100      +1
applet_install_loc                                   198     199      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/0 up/down: 101/0)             Total: 101 bytes
   text	   data	    bss	    dec	    hex	filename
 955052	   4195	   1808	 961055	  eaa1f	busybox_old
 955153	   4195	   1808	 961156	  eaa84	busybox_unstripped

v2: Sections numbered less than 10 were always being omitted from
    consideration because splitting "[ 1] .interp" leaves "1]" in
    x[1] where the section name is expected.  This wasn't a problem
    for .rodata (numbered 15 in my testing) but let's fix it anyway.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-03-09 17:25:07 +01:00
Denys Vlasenko
1f9ed02caf trylink: do not drop libs from CONFIG_EXTRA_LDLIBS
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-02-23 23:09:49 +01:00
Denys Vlasenko
9daa877d6b tar: add TODO about a bug with non-writable directories on extract
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-01-01 13:34:25 +01:00
Denys Vlasenko
7c443d110d randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-24 00:27:37 +02:00
Denys Vlasenko
5fa5c4bde8 randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2020-06-23 21:28:19 +02:00
Jean-Philippe Brucker
ed8af51b60 build system: remove KBUILD_STR()
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>
2020-04-29 14:52:19 +02:00
Nicolas Hüppelshäuser
b096ce0fdd scripts/echo.c: resolve implicit declaration of function 'dup2'
Signed-off-by: Nicolas Hüppelshäuser <nicolas.hueppelshaeuser@emlix.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-03-05 16:57:04 +01:00
Bernhard Reutner-Fischer
774879c4e1 checkstack.pl: tweak bfin re
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2019-01-18 09:56:19 +01:00
Bernhard Reutner-Fischer
f59739a663 checkstack: pull from upstream
merge upstream changes

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2019-01-17 22:59:45 +01:00
Bernhard Reutner-Fischer
fe7ae562e5 checkstack.pl: fix arch autodetection
chomp trailing newlines

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2019-01-17 22:59:45 +01:00
Denys Vlasenko
4bdc914ff9 build system: fix compiler warnings
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2019-01-06 20:12:16 +01:00
Ron Yorston
71df2d3589 hush: allow hush to run embedded scripts
Embedded scripts require a shell to be present in the BusyBox
binary.  Allow either ash or hush to be used for this purpose.
If both are enabled ash takes precedence.

The size of the binary is unchanged in the default configuration:
both ash and hush are present but support for embedded scripts
isn't compiled into hush.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-27 16:13:07 +01:00
Ron Yorston
7b42f8fc76 Tweaks to build process for embedded scripts
- Force a rebuild if a script in applets_sh is changed.

- Move the dummy usage messages for custom applets to usage.h and
  change the name from 'dummy' to 'scripted'.

- Hide an error from gen_build_files.sh if an embed directory exists
  but is empty.

- Tidy up embedded_scripts script.

v2: Remove a couple of unnecessary tests in embedded_scripts, as
    pointed out by Xabier Oneca.
    Drop the stripping of comments.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-27 10:38:10 +01:00
Denys Vlasenko
32511da87d scripts/trylink: be more clever when deciding that "lib elimination" has finished:
Before:
Trying libraries: crypt m resolv
 Library crypt is not needed, excluding it
 Library m is needed, can't exclude it (yet)
 Library resolv is needed, can't exclude it (yet)
 Library m is needed, can't exclude it (yet)
 Library resolv is needed, can't exclude it (yet)
Final link with: m resolv

After:
Trying libraries: crypt m resolv
 Library crypt is not needed, excluding it
 Library m is needed, can't exclude it (yet)
 Library resolv is needed, can't exclude it (yet)
Final link with: m resolv

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-19 20:36:16 +01:00
Ron Yorston
af694a4b29 Ensure build works when KBUILD_OUTPUT is set, closes 11511
The build process for embedded scripts didn't have consistent
support for saving output to a different directory.

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-18 19:34:39 +01:00
Ron Yorston
3778898f97 Treat custom and applet scripts as applets
BusyBox has support for embedded shell scripts.  Two types can be
distinguished:  custom scripts and scripts implementing applets.

Custom scripts should be placed in the 'embed' directory at build
time.  They are given a default applet configuration and appear
as applets to the user but no further configuration is possible.

Applet scripts are integrated with the BusyBox build system and
are intended to be used to ship standard applets that just happen
to be implemented as scripts.  They can be configured at build time
and appear just like native applets.

Such scripts should be placed in the 'applets_sh' directory.  A stub
C program should be written to provide the usual applet configuration
details and placed in a suitable subsystem directory.  It may be
helpful to have a configuration option to enable any dependencies the
script requires:  see the 'nologin' applet for an example.

function                                             old     new   delta
scripted_main                                          -      41     +41
applet_names                                        2773    2781      +8
applet_main                                         1600    1604      +4
i2cdetect_main                                       672     674      +2
applet_suid                                          100     101      +1
applet_install_loc                                   200     201      +1
applet_flags                                         100     101      +1
packed_usage                                       33180   33179      -1
tryexec                                              159     152      -7
evalcommand                                         1661    1653      -8
script_names                                           9       -      -9
packed_scripts                                       123     114      -9
complete_cmd_dir_file                                826     811     -15
shellexec                                            271     254     -17
find_command                                        1007     990     -17
busybox_main                                         642     624     -18
run_applet_and_exit                                  100      78     -22
find_script_by_name                                   51       -     -51
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 6/9 up/down: 58/-174)          Total: -116 bytes
   text	   data	    bss	    dec	    hex	filename
 950034	    477	   7296	 957807	  e9d6f	busybox_old
 949918	    477	   7296	 957691	  e9cfb	busybox_unstripped

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-17 21:16:33 +01:00
Denys Vlasenko
43794ff45d scripts/embedded_scripts: do not add superfluous NUL to script_names[]
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-02 14:18:36 +01:00
Denys Vlasenko
4f2ef4a836 ash: allow shell scripts to be embedded in the binary
To assist in the deployment of shell scripts it may be convenient
to embed them in the BusyBox binary.

'Embed scripts in the binary' takes any files in the directory
'embed', concatenates them with null separators, compresses them
and embeds them in the binary.

When scripts are embedded in the binary, scripts can be run as
'busybox SCRIPT [ARGS]' or by usual (sym)link mechanism.

embed/nologin is provided as an example.

function                                             old     new   delta
packed_scripts                                         -     123    +123
unpack_scripts                                         -      87     +87
ash_main                                            1103    1171     +68
run_applet_and_exit                                   78     128     +50
get_script_content                                     -      32     +32
script_names                                           -      10     +10
expmeta                                              663     659      -4
------------------------------------------------------------------------------
(add/remove: 4/0 grow/shrink: 2/1 up/down: 370/-4)            Total: 366 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-11-01 10:15:13 +01:00
Denys Vlasenko
762440b20e scripts/randomtest: disable CONFIG_NSLOOKUP for uclibc
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-06-26 17:22:35 +02:00
Denys Vlasenko
185326613d scripts/randomtest: disable CONFIG_FEATURE_INETD_RPC for glibc
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-06-26 16:08:22 +02:00
Denys Vlasenko
5f5119be97 scripts/randomtest: disable CONFIG_FEATURE_MOUNT_NFS for glibc
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-06-26 16:03:24 +02:00
Eli Schwartz
6fb8bd795c Update release script to generate detached signatures and checksum files
This is more usable for programmatically checking the validity of a
release.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-06-09 21:19:35 +02:00
Denys Vlasenko
6b6a3d9339 scripts/kconfig/mconf.c: survive is SIGWINCH is not defined
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-06 19:05:53 +02:00
Denys Vlasenko
d878ccca9c placate gcc 8.0.1 sprintf overflow warnings in config tools
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-04-05 15:21:34 +02:00
Denys Vlasenko
9c9a742e80 scripts/randomtest: do not try building static libbysubox
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-12-31 20:31:05 +01:00
Denys Vlasenko
82d1c1f84a randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-12-31 17:30:02 +01:00
Denys Vlasenko
d134aa9341 build system: fix a compiler warning
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-09-07 14:50:00 +02:00
Denys Vlasenko
0b1c629342 build system: fix "allnoconfig" to clear all options. Closes 10296
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-09-07 14:40:28 +02:00
Denys Vlasenko
ab77e81a85 klibc-utils: new applets: resume, nuke, minips
minips is a pure alias to ps, just in case someone needs 100% klibc-utils compat.
nuke is a primitive version of "rm -rf" without options and error checks. ~30 bytes.

resume is a tool for initramfs which resumes from a given block device.

function                                             old     new   delta
resume_main                                            -     582    +582
packed_usage                                       31640   31712     +72
nuke_main                                              -      28     +28
xstrtoull                                              -      24     +24
applet_names                                        2646    2665     +19
applet_main                                         1532    1544     +12
applet_suid                                           96      97      +1
applet_install_loc                                   192     193      +1
applet_flags                                          96      97      +1
------------------------------------------------------------------------------
(add/remove: 5/0 grow/shrink: 6/0 up/down: 740/0)             Total: 740 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-18 19:15:29 +02:00
Denys Vlasenko
95f7953f2c do not use `a' quoting style in comments
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-02 14:26:33 +02:00
Denys Vlasenko
bbf17bbf32 crond: do not assume setenv() does not leak
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-22 02:25:47 +02:00
Denys Vlasenko
367a55c7d7 build system: FEATURE_LIBBUSYBOX_STATIC - try to pull libc/libm into libbusybox
It variously fails with different toolchains I tried...

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-15 14:52:26 +02:00
Denys Vlasenko
d4e4fdb5ce fixes for bugs found by make_single_applets.sh
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-03 21:31:16 +02:00
Denys Vlasenko
7fdb764e2e scripts/randomtest: update things which can't be tested on uclibc
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-03 02:33:08 +02:00
Denys Vlasenko
bca4ea8b68 remove "local" bashism from a few scripts
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-24 20:52:42 +01:00
Denys Vlasenko
de912f0153 randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-12-12 11:08:51 +01:00
Denys Vlasenko
2ae86ad1c6 trylink: use "mktemp tmp.XXXXXXXXXX" to placate OS X
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-07-12 13:54:35 +02:00
Denys Vlasenko
5b8c89d1f2 build system: make CONFIG_FEATURE_USE_BSS_TAIL less funky
CONFIG_FEATURE_USE_BSS_TAIL code was aliasing bb_common_bufsiz1 to _end.
This is unreliable: _end may be not sufficiently aligned.

Change code to simply enlarge COMMON_BUFSIZE when we detect that _end
has significant amount of space to the end of page.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-06-29 15:00:52 +02:00
Denys Vlasenko
ea9ebc011b scripts/trylink: libbusybox fix
gcc 6.1.1 can emit empty line with spaces

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-06-20 12:23:35 +02:00
Denys Vlasenko
bb0bf287d8 randomconfig fixes 2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-06-19 21:54:04 +02:00