From 3bbc31c78b41c92eeb0aa394a002638fa48128e7 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 5 Apr 2024 07:06:05 -0500 Subject: [PATCH] Alas, nproc isn't portable (sched_getaffinity() syscall) and 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 --- scripts/prereq/build.sh | 14 +++++++------- scripts/prereq/generated/config.h | 4 ++-- scripts/prereq/generated/flags.h | 21 --------------------- scripts/prereq/generated/help.h | 1 - scripts/prereq/generated/newtoys.h | 1 - scripts/recreate-prereq.sh | 2 +- 6 files changed, 10 insertions(+), 33 deletions(-) diff --git a/scripts/prereq/build.sh b/scripts/prereq/build.sh index 0a5f8621..ac1fa11b 100755 --- a/scripts/prereq/build.sh +++ b/scripts/prereq/build.sh @@ -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 diff --git a/scripts/prereq/generated/config.h b/scripts/prereq/generated/config.h index 43eb0b6b..f46eed9b 100644 --- a/scripts/prereq/generated/config.h +++ b/scripts/prereq/generated/config.h @@ -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 diff --git a/scripts/prereq/generated/flags.h b/scripts/prereq/generated/flags.h index 2565862c..811899dd 100644 --- a/scripts/prereq/generated/flags.h +++ b/scripts/prereq/generated/flags.h @@ -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" @@ -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 @@ -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 diff --git a/scripts/prereq/generated/help.h b/scripts/prereq/generated/help.h index 9b17e37b..4457710d 100644 --- a/scripts/prereq/generated/help.h +++ b/scripts/prereq/generated/help.h @@ -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 "" diff --git a/scripts/prereq/generated/newtoys.h b/scripts/prereq/generated/newtoys.h index 289a3c5e..a9ed915d 100644 --- a/scripts/prereq/generated/newtoys.h +++ b/scripts/prereq/generated/newtoys.h @@ -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)) diff --git a/scripts/recreate-prereq.sh b/scripts/recreate-prereq.sh index 4e0db113..ec90f5ac 100755 --- a/scripts/recreate-prereq.sh +++ b/scripts/recreate-prereq.sh @@ -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 -- 2.39.2