Skip to content

Commit

Permalink
Alas, nproc isn't portable (sched_getaffinity() syscall) and
Browse files Browse the repository at this point in the history
scripts/portability.sh already has two fallbacks (sysctl -n hw.nproc for
mac/bsd and if that doesn't work either it sets CPUS=1).

With this, I built on mac outside of homebrew, albeit cheating to get .config:
$ homebrew
$ make macos_defconfig
$ make clean
$ exit
$ scripts/prereq/build.sh #ignoring SO many warnings
$ mkdir prereq; mv toybox-prereq prereq/
$ for i in $(prereq/toybox-prereq); do ln -s toybox-prereq prereq/$i; done
$ PATH=$PWD/prereq:$PATH scripts/make.sh
$ ./toybox
  • Loading branch information
landley committed Apr 5, 2024
1 parent d21f10e commit 3bbc31c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 33 deletions.
14 changes: 7 additions & 7 deletions scripts/prereq/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
BUILD='cc -funsigned-char -I scripts/prereq -I . -Os -ffunction-sections -fdata-sections -fno-asynchronous-unwind-tables -fno-strict-aliasing -DTOYBOX_VERSION=""'
LINK=''
FILES="
main.c toys/lsb/gzip.c toys/other/readlink.c toys/other/taskset.c
toys/other/which.c toys/pending/tr.c toys/posix/basename.c toys/posix/cat.c
toys/posix/chmod.c toys/posix/cmp.c toys/posix/dirname.c toys/posix/echo.c
toys/posix/fold.c toys/posix/grep.c toys/posix/head.c toys/posix/ln.c
toys/posix/ls.c toys/posix/mkdir.c toys/posix/od.c toys/posix/rm.c
toys/posix/sed.c toys/posix/sort.c toys/posix/tail.c toys/posix/tee.c
toys/posix/uname.c toys/posix/wc.c toys/posix/xargs.c
main.c toys/lsb/gzip.c toys/other/readlink.c toys/other/which.c
toys/pending/tr.c toys/posix/basename.c toys/posix/cat.c toys/posix/chmod.c
toys/posix/cmp.c toys/posix/dirname.c toys/posix/echo.c toys/posix/fold.c
toys/posix/grep.c toys/posix/head.c toys/posix/ln.c toys/posix/ls.c
toys/posix/mkdir.c toys/posix/od.c toys/posix/rm.c toys/posix/sed.c
toys/posix/sort.c toys/posix/tail.c toys/posix/tee.c toys/posix/uname.c
toys/posix/wc.c toys/posix/xargs.c
"

$BUILD lib/*.c $FILES $LINK -o toybox-prereq
4 changes: 2 additions & 2 deletions scripts/prereq/generated/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,8 @@
#define USE_SYSCTL(...)
#define CFG_TAC 0
#define USE_TAC(...)
#define CFG_NPROC 1
#define USE_NPROC(...) __VA_ARGS__
#define CFG_NPROC 0
#define USE_NPROC(...)
#define CFG_TASKSET 0
#define USE_TASKSET(...)
#define CFG_TIMEOUT 0
Expand Down
21 changes: 0 additions & 21 deletions scripts/prereq/generated/flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,16 +348,6 @@
#undef FLAG_f
#endif

// taskset <1^pa
#undef OPTSTR_taskset
#define OPTSTR_taskset "<1^pa"
#ifdef CLEANUP_taskset
#undef CLEANUP_taskset
#undef FOR_taskset
#undef FLAG_a
#undef FLAG_p
#endif

// tee ia ia
#undef OPTSTR_tee
#define OPTSTR_tee "ia"
Expand Down Expand Up @@ -751,15 +741,6 @@
#define FLAG_f (1LL<<4)
#endif

#ifdef FOR_taskset
#define CLEANUP_taskset
#ifndef TT
#define TT this.taskset
#endif
#define FLAG_a (FORCED_FLAG<<0)
#define FLAG_p (FORCED_FLAG<<1)
#endif

#ifdef FOR_tee
#define CLEANUP_tee
#ifndef TT
Expand Down Expand Up @@ -840,8 +821,6 @@
#define OPTSTR_gitremote "<1"
#undef OPTSTR_makedevs
#define OPTSTR_makedevs "<1>1d:"
#undef OPTSTR_nproc
#define OPTSTR_nproc "(all)"
#undef OPTSTR_toybox
#define OPTSTR_toybox 0
#undef OPTSTR_which
Expand Down
1 change: 0 additions & 1 deletion scripts/prereq/generated/help.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#define HELP_ls ""
#define HELP_make ""
#define HELP_mkdir ""
#define HELP_nproc ""
#define HELP_od ""
#define HELP_readlink ""
#define HELP_rm ""
Expand Down
1 change: 0 additions & 1 deletion scripts/prereq/generated/newtoys.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ USE_NBD_CLIENT(OLDTOY(nbd-client, nbd_client, TOYFLAG_USR|TOYFLAG_BIN))
USE_NBD_SERVER(OLDTOY(nbd-server, nbd_server, TOYFLAG_USR|TOYFLAG_BIN))
USE_NETCAT(OLDTOY(nc, netcat, TOYFLAG_USR|TOYFLAG_BIN))
USE_NETCAT(NEWTOY(netcat, "^tElLw#<1W#<1p#<1>65535q#<1s:f:46uUnvz[!tlL][!Lw][!Lu][!46U]", TOYFLAG_BIN))
USE_NPROC(NEWTOY(nproc, "(all)", TOYFLAG_USR|TOYFLAG_BIN))
USE_OD(NEWTOY(od, "j#vw#<1=16N#xsodcbA:t*", TOYFLAG_USR|TOYFLAG_BIN))
USE_PASSWD(NEWTOY(passwd, ">1a:dlu", TOYFLAG_STAYROOT|TOYFLAG_USR|TOYFLAG_BIN))
USE_PASTE(NEWTOY(paste, "d:s", TOYFLAG_USR|TOYFLAG_BIN))
Expand Down
2 changes: 1 addition & 1 deletion scripts/recreate-prereq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

mkroot/record-commands make clean defconfig toybox
sed -i 's/default y/default n/' generated/Config.probed
CMDLIST="$(echo toybox; ./toybox cut -DF 1 log.txt | sort -u)"
CMDLIST="$(echo toybox; ./toybox cut -DF 1 log.txt | sort -u | grep -v nproc)"
{
for i in $(tr '[:lower:]' '[:upper:]' <<<"$CMDLIST")
do
Expand Down

0 comments on commit 3bbc31c

Please sign in to comment.