On 11/25/20 7:14 AM, Jazzoo Watchman wrote:
> Rob,
> 
> Thank you for your time.  I have learned a great deal studying your work and
> following you on and off since your time at the "fool."

Ok, that _is_ a long time. :)

> My post was not meant in any way to criticize or second guess the code in
> config2help.c.

It's fine, I'm not offended. I just can't be sure I fixed your issue if I can't
reproduce your issue.

> I seek to understand if my analysis follows the intent of the
> author(s) or I missed the point entirely.  And on the off-chance that I can
> help-out, to do so.
> 
> Cloned Toybox into a new folder.
> 
> Toybox builds cleanly. 
> 
> I apologize for that distraction and thank you for the generous gift of your 
> time.

It's ok. Today's bug report to "test" was way more distracting, but it's stuff I
needed to do.

I _want_ this to work for everyone, I'm glad your issue was easily fixed, and I
admit this _is_ an area of the code that could use significant work. (It's just
that most of that work is removing old infrastructure that's no longer needed,
which means it's not currently blocking anything, and disturbing it _can_ break
stuff, and I'm in the middle of a half-dozen other things...)

> I'm trying to build a development environment for an arm926tj-s variant device
> for a device that the OED and OEM have NOT released their source nor their 
> build
> tools.

According to https://en.wikipedia.org/wiki/ARM9#ARM9E-S_and_ARM9EJ-S that's
armv5l. (Probably with VFP for the floating point API?)

> Aboriginal-1.4.5 seems like a good starting point to generate the tools I'd 
> need.>
> Aboriginal has not been "touched" in 5 years ... but one can hope to stand on
> the shoulders ...

That project got replaced by a 250 line bash script, which is merged into
toybox, but if you find the old one informative good luck with it?

The new one is https://landley.net/toybox/faq.html#mkroot and the toolchain
build is file:///home/landley/toybox/toybox/www/faq.html#cross2 although I
haven't yet connected everything up to have a native development environment
working under it yet. In THEORY you just mount an ext3 scratch space partition
and extract the native toolchain tarball into it and update the $PATH. In
practice there's no "make" in either yet (I plan to write one for toybox but
haven't yet) and the shell is only about 80% there so far. (Working on it...)
and I'm pretty sure the toolchain's going to have some path expections
(/usr/include and friends) that will need symlinks to fix up. (Probably
something like
https://github.com/landley/aboriginal/blob/master/sources/toys/hdainit.sh will
wind up still being needed...)

(And somebody's having problems with qemu 5.0 running the mkroot arm image I
uploaded last release, but I can't rebuild current qemu-git from source because
QEMU recently decided to no longer build with python 3.5 but requires python 3.6
which isn't in my distro repository for the version I'm running, and I'm not
ready to update my laptop from devuan 2.0 to devuan 3.0 yet because I have
deadlines and am on the other side of the planet from my _proper_ backups and
spare machines and really dowanna try to salvage the inevitable failed upgrade
using the lab machine at the soldering station running "Elementary Linux" on a
monitor we bought used for $25. I can see a lost week looming just to get back
to where I started on the far side of the upgrade, and now is not the time.)

If you just want to get something to _work_, there's almost certainly an armv5l
Linux From Scratch build? Or cross debootstrap. I've attached a cut and paste
from an old email I sent a co-worker about using the qemu-debootstrap wrapper to
create a tiny debian instance for another architecture. (By "old" I mean the
instructions are from 2015 so no idea if the tools have moved out from under it.
I very vaguely recall having to pull kernel images off of loopback monted boot
CD .iso images at one point, but hope that wasn't the final version. And yes,
the result is a debian image with glibc for the target. Oh well...)

> If you can/will point me in a more fruitful direction I'd be grateful.

Above are a couple options?

> The following are the pieces to reproduce should you deem fit to comment.
> Otherwise, please disregard; no harm, no foul.
> 
> Thanks again for your time,
> 
> 
> James
> 
> Build Environment
> * Linux 4.19.0-12-amd64 #1 SMP Debian 4.19.152-1 (2020-10-18) x86_64 GNU/Linux
> * gcc (Debian 8.3.0-6) 8.3.0
> * GNU ld (GNU Binutils for Debian) 2.31.1
> * ldd (Debian GLIBC 2.28-10) 2.28
> 
> Cloned aboriginal-1.4.5 into an empty folder
> 
> ran ./build.sh armv5l
> 
> ... snip out the clean parts ...
> === toybox (host host-tools)
> Snapshot 'toybox'...
> scripts/genconfig.sh
> cc -o kconfig/conf kconfig/conf.c kconfig/zconf.tab.c -DKBUILD_NO_NLS=1 \
> -DPROJECT_NAME=\"ToyBox\"
> kconfig/conf -D /dev/null Config.in > /dev/null
> scripts/make.sh
> Generate headers from toys/*/*.c...
> generated/newtoys.h Library probe.......
> Make generated/config.h from .config.
> generated/flags.h generated/globals.h generated/help.h
> scripts/make.sh: line 218: 17069 Segmentation fault      generated/config2help
> Config.in $KCONFIG_CONFIG > generated/help.h
> make: *** [Makefile:19: toybox] Error 1

Um. git annotate download.sh | grep toybox

a7e63549        (Rob Landley    2015-11-04 00:14:29 -0600
69)URL=http://landley.net/toybox/downloads/toybox-0.6.1.tar.gz \

That's... not a current version of toybox.

Last year I poked at an aboriginal linux version that builds toybox 0.8.3 to see
if I could poke at the old linux from scratch build with toybox commands, and it
needed musl updated to 1.1.24 and once I did THAT the old LFS build broke on
musl changes so I never really got to compare the toybox and busybox command
output. Patch attached if you're curious, but I didn't find it useful...

Rob
The chroot setup's not that hard. The armhf install instructions are
derived from https://wiki.debian.org/ArmHardFloatChroot and here's what
you do:

1) become root, install and run qemu-debootstrap (we could do fakeroot
instead, but let's not go there):

  sudo /bin/bash
  apt-get install debootstrap qemu-user-static
  qemu-debootstrap --no-check-gpg --arch=armhf sid ~/sid-armhf \
    ftp://ftp.debian.org/debian/

2) tweak a couple config files to tell the new chroot not to launch
daemons and where to ftp more packages from.

  echo exit 101 > ~/sid-armhf/usr/sbin/policy-rc.d
  echo deb http://ftp.debian.org/debian sid main > \
    ~/sid-armhf/etc/apt/sources.list
  echo deb-src http://ftp.debian.org/debian sid main >> \
    ~/sid-armhf/etc/apt/sources.list

3) Chroot into it and install more packages (native toolchain and
mercurial).

  chroot ~/sid-armhf
  apt-get update
  apt-get install build-essential mercurial

That's it, your chroot should now be a working native armhf build
environment, running under qemu's application emulation mode. You can
"exit" back to the host and chroot back in later, and qemu should run
itself automatically as necessary (installing the qemu-user-static
package set up the binfmt_misc thing).

The same technique can set up other targets, the full debian arch list
is at http://debian.org/ports if you're curious.

Rob
diff --git a/download.sh b/download.sh
index 982f808..e71dd4e 100755
--- a/download.sh
+++ b/download.sh
@@ -25,8 +25,8 @@ URL=http://uclibc.org/downloads/uClibc-0.9.33.2.tar.bz2 \
 SHA1=4d8d67d6754409bd10015d67d1ce7a04c0b001ba \
 maybe_fork "download || dienow"
 
-URL=http://www.musl-libc.org/releases/musl-1.1.12.tar.gz \
-SHA1=e098ce88e7dd4398c178240b4c380771c5b4fe6b \
+URL=http://www.musl-libc.org/releases/musl-1.1.24.tar.gz \
+SHA1=b0b5ddf6b65355ac02e2f11c3d262ac5dcf0bab5 \
 maybe_fork "download || dienow"
 
 URL=ftp://kernel.org/pub/linux/kernel/v4.x/linux-4.3.tar.gz \
@@ -66,8 +66,8 @@ maybe_fork "download || dienow"
 # BusyBox.  Adding a native toolchain requires binutils and gcc (above) plus
 # make and bash.
 
-URL=http://landley.net/toybox/downloads/toybox-0.6.1.tar.gz \
-SHA1=7bdf7253d5a5dbf7073e8f5ca0999a7928a63dae \
+URL=http://landley.net/toybox/downloads/toybox-0.8.2.tar.gz \
+SHA1=22f1dbfcfb1dc2046c551585b7b402b48878d9bd \
 maybe_fork "download || dienow"
 
 URL=http://www.busybox.net/downloads/busybox-1.24.1.tar.bz2 \
diff --git a/host-tools.sh b/host-tools.sh
index 8ea5a6a..95eb4e7 100755
--- a/host-tools.sh
+++ b/host-tools.sh
@@ -81,7 +81,7 @@ fi
 # thing.
 
 # Building packages with hush breaks stuff. Symlink host sh until toysh ready
-[ ! -f "$STAGE_DIR/busybox" ] && build_section busybox && rm -f "$STAGE_DIR/sh"
+[ ! -f "$STAGE_DIR/busybox" ] && build_section busybox && rm -f "$STAGE_DIR"/{sh,cp}
 [ ! -f "$STAGE_DIR/toybox" ] && build_section toybox
 
 # Create symlinks to the host toolchain.  We need a usable existing host
diff --git a/sources/baseconfig-busybox b/sources/baseconfig-busybox
index e2ca94b..f1b4368 100644
--- a/sources/baseconfig-busybox
+++ b/sources/baseconfig-busybox
@@ -7,22 +7,9 @@ CONFIG_LONG_OPTS=y
 
 # low hanging fruit:
 
-CONFIG_BUNZIP2=y
 CONFIG_BZIP2=y
-CONFIG_GUNZIP=y
 CONFIG_GZIP=y
-CONFIG_UNXZ=y
-
-CONFIG_TAR=y
-CONFIG_FEATURE_TAR_CREATE=y
-CONFIG_FEATURE_TAR_AUTODETECT=y
-CONFIG_FEATURE_TAR_GNU_EXTENSIONS=y
-CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY=y
-CONFIG_FEATURE_TAR_LONG_OPTIONS=y
-CONFIG_FEATURE_TAR_FROM=y
-CONFIG_FEATURE_SEAMLESS_BZ2=y
-CONFIG_FEATURE_SEAMLESS_GZ=y
-CONFIG_FEATURE_SEAMLESS_XZ=y
+CONFIG_GUNZIP=y
 
 CONFIG_DD=y
 CONFIG_FEATURE_DD_SIGNAL_HANDLING=y
@@ -35,9 +22,6 @@ CONFIG_TR=y
 CONFIG_DIFF=y
 CONFIG_FEATURE_DIFF_DIR=y
 
-CONFIG_TEST=y
-CONFIG_FEATURE_TEST_64=y
-
 CONFIG_ROUTE=y
 
 # shell
@@ -88,15 +72,10 @@ CONFIG_FTPPUT=y
 CONFIG_WGET=y
 CONFIG_FEATURE_WGET_STATUSBAR=y
 
-CONFIG_PING=y
-
 # Not net
 
 CONFIG_LESS=y
 
-CONFIG_PGREP=y
-CONFIG_PKILL=y
-
 CONFIG_SHA512SUM=y
 
 CONFIG_FDISK=y
@@ -250,3 +229,21 @@ CONFIG_SED=y
 CONFIG_PS=y
 CONFIG_FEATURE_PS_TIME=y
 CONFIG_FEATURE_PS_ADDITIONAL_COLUMNS=y
+
+CONFIG_BUNZIP2=y
+CONFIG_UNXZ=y
+CONFIG_TAR=y
+CONFIG_FEATURE_TAR_CREATE=y
+CONFIG_FEATURE_TAR_AUTODETECT=y
+CONFIG_FEATURE_TAR_GNU_EXTENSIONS=y
+CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY=y
+CONFIG_FEATURE_TAR_LONG_OPTIONS=y
+CONFIG_FEATURE_TAR_FROM=y
+CONFIG_FEATURE_SEAMLESS_BZ2=y
+CONFIG_FEATURE_SEAMLESS_GZ=y
+CONFIG_FEATURE_SEAMLESS_XZ=y
+CONFIG_TEST=y
+CONFIG_FEATURE_TEST_64=y
+CONFIG_PING=y
+CONFIG_PGREP=y
+CONFIG_PKILL=y
diff --git a/sources/patches/musl-mips.patch b/sources/patches/musl-mips.patch
deleted file mode 100644
index c39af2e..0000000
--- a/sources/patches/musl-mips.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-Workaround for binutils 2.17 linking things on mips in a way musl doesn't like.
-
-diff --git a/arch/mips/crt_arch.h b/arch/mips/crt_arch.h
-index 21e139b..f4ba02a 100644
---- a/arch/mips/crt_arch.h
-+++ b/arch/mips/crt_arch.h
-@@ -4,13 +4,16 @@ __asm__(
- ".text \n"
- ".global _" START "\n"
- ".global " START "\n"
-+".global " START "_data\n"
- ".type   _" START ", @function\n"
- ".type   " START ", @function\n"
-+".type   " START "_data, @function\n"
- "_" START ":\n"
- "" START ":\n"
- "	bal 1f \n"
- "	 move $fp, $0 \n"
--"2:	.gpword 2b \n"
-+"" START "_data: \n"
-+"	.gpword " START "_data \n"
- "	.gpword " START "_c \n"
- ".weak _DYNAMIC \n"
- ".hidden _DYNAMIC \n"
diff --git a/sources/patches/musl-regex.patch b/sources/patches/musl-regex.patch
deleted file mode 100644
index 1fb5804..0000000
--- a/sources/patches/musl-regex.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff --git a/src/regex/regcomp.c b/src/regex/regcomp.c
-index 978dd87..d7e7a9c 100644
---- a/src/regex/regcomp.c
-+++ b/src/regex/regcomp.c
-@@ -1008,13 +1008,18 @@ static reg_errcode_t tre_parse(tre_parse_ctx_t *ctx)
- 		nbranch = tre_ast_new_catenation(ctx->mem, nbranch, ctx->n);
- 		if ((ere && *s == '|') ||
- 		    (ere && *s == ')' && depth) ||
--		    (!ere && *s == '\\' && s[1] == ')') ||
-+		    (!ere && *s == '\\' && (s[1] == ')' || s[1] == '|')) ||
- 		    !*s) {
- 			/* extension: empty branch is unspecified (), (|a), (a|)
- 			   here they are not rejected but match on empty string */
- 			int c = *s;
- 			nunion = tre_ast_new_union(ctx->mem, nunion, nbranch);
- 			nbranch = 0;
-+
-+			if (c == '\\' && s[1] == '|') {
-+				s++;
-+				c = '|';
-+			}
- 			if (c != '|') {
- 				if (c == '\\') {
- 					if (!depth) return REG_EPAREN;
diff --git a/sources/patches/toybox-grep.patch b/sources/patches/toybox-grep.patch
index 9904185..a1585a6 100644
--- a/sources/patches/toybox-grep.patch
+++ b/sources/patches/toybox-grep.patch
@@ -3,31 +3,18 @@ happen in glibc, musl, or bionic, so it's not worth adding a workaround
 upstream.
 
 diff --git a/toys/posix/grep.c b/toys/posix/grep.c
-index d44a92d..b9c2def 100644
+index 30a9819..b187441 100644
 --- a/toys/posix/grep.c
 +++ b/toys/posix/grep.c
-@@ -63,7 +63,8 @@ GLOBALS(
- // Show matches in one file
- static void do_grep(int fd, char *name)
- {
--  FILE *file = fdopen(fd, "r");
-+  struct stat *st = (void *)(toybuf+sizeof(regex_t));
-+  FILE *file = 0;
-   long offset = 0;
-   int lcount = 0, mcount = 0;
-   char indelim = '\n' * !(toys.optflags&FLAG_z),
-@@ -71,8 +72,13 @@ static void do_grep(int fd, char *name)
+@@ -117,6 +117,11 @@ static void do_grep(int fd, char *name)
+   FILE *file;
+   int bin = 0;
  
-   if (!fd) name = "(standard input)";
- 
-+  if (!fstat(fd, st)) {
-+    // grep * hits directories, skip but don't treat them as errors.
-+    if (S_ISDIR(st->st_mode)) errno = 0;
-+    else file = fdopen(fd, "r");
++  {
++    struct stat st;
++    if (!fstat(fd, &st) && S_ISDIR(st.st_mode)) return;
 +  }
-   if (!file) {
--    perror_msg("%s", name);
-+    if (errno) perror_msg("%s", name);
-     return;
-   }
++
+   if (!FLAG(r)) TT.tried++;
+   if (!fd) name = "(standard input)";
  
diff --git a/sources/sections/busybox.build b/sources/sections/busybox.build
index 5844c22..de66744 100644
--- a/sources/sections/busybox.build
+++ b/sources/sections/busybox.build
@@ -9,6 +9,12 @@ then
   make defconfig V=${BUILD_VERBOSE:+1} &&
   # breaks on ubuntu 11.10
   sed -i -e 's/^\(CONFIG_UBI.*\)=y/# \1 is not set/' .config &&
+  sed -i -e 's/^\(CONFIG_LAST\)=y/# \1 is not set/' .config &&
+  sed -i -e 's/^\(CONFIG_INETD\)=y/# \1 is not set/' .config &&
+  sed -i -e 's/^\(CONFIG_TCPSVD\)=y/# \1 is not set/' .config &&
+  sed -i -e 's/^\(CONFIG_UDPSVD\)=y/# \1 is not set/' .config &&
+  sed -i -e 's/^\(CONFIG_RUNSV\)=y/# \1 is not set/' .config &&
+  sed -i -e 's/^\(CONFIG_FEATURE_SYNC_FANCY\)=y/# \1 is not set/' .config &&
   cp .config "$WORK"/config-busybox || dienow
 else
   getconfig busybox | sed '/toybox/,$d' > "$WORK/config-busybox" &&
diff --git a/sources/sections/toybox.build b/sources/sections/toybox.build
index 51fd11f..cb5a9e8 100755
--- a/sources/sections/toybox.build
+++ b/sources/sections/toybox.build
@@ -5,8 +5,19 @@
 # for details
 
 # Build toybox
+if [ ! -z "$BUSYBOX" ]
+then
+  for i in defconfig bin/cp bin/truncate sbin/oneit
+  do
+    X=$(basename $i)
+    Y=$(dirname $i)
+    PREFIX="$STAGE_DIR/${ARCH:+$Y/}" CFLAGS="$CFLAGS $STATIC_FLAGS" \
+      CC= STRIP= make $VERBOSITY $DO_CROSS $X || exit 1
+    unset X Y
+  done
+else
 
-for i in defconfig toybox \
+for i in distclean defconfig toybox \
   $( [ -z "$BUSYBOX" ] && echo install$([ -z "$ARCH" ] && echo _flat) )
 do
   PREFIX="$STAGE_DIR" CFLAGS="$CFLAGS $STATIC_FLAGS" CC= STRIP= \
@@ -25,3 +36,5 @@ if [ ! -z "$SKIP_STRIP" ]
 then
   cp --remove-destination toybox_unstripped "$INSTDIR/toybox" || dienow
 fi
+
+fi
diff --git a/sources/targets/i686 b/sources/targets/i686
index f17414b..d5c2b12 100644
--- a/sources/targets/i686
+++ b/sources/targets/i686
@@ -23,3 +23,10 @@ emulator_command()
   echo qemu-system-i386 -cpu pentium3 $(qemu_defaults "$@") \
     -net nic,model=e1000 -net user
 }
+
+UCLIBC_CONFIG="
+ARCH_HAS_MMU=y
+TARGET_i386=y
+CONFIG_PENTIUMIII=y
+UCLIBC_HAS_FPU=y
+"
--- /dev/null
+++ b/sources/patches/busybox-musl.patch
@@ -0,0 +1,23 @@
+Old busybox doesn't build against current musl, hack around lib/ parts.
+
+--- busybox/libbb/messages.c	2015-10-23 19:24:35.000000000 -0500
++++ busybox/libbb/messages.c	2019-11-13 10:54:44.743565599 -0600
+@@ -56,6 +56,6 @@
+ # elif defined WTMP_FILE
+ 	WTMP_FILE;
+ # else
++"/dev/null";
+-#  error unknown path to wtmp file
+ # endif
+ #endif
+ 
+--- busybox/libbb/utmp.c
++++ busybox/libbb/utmp.c
+@@ -10,6 +10,7 @@
+  */
+ #include "libbb.h"
+ 
++#define _PATH_UTMPX "/dev/null"
+ static void touch(const char *filename)
+ {
+ 	if (access(filename, R_OK | W_OK) == -1)
_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to