Tiny Core Linux

Tiny Core Base => CorePlus => Topic started by: t18 on May 26, 2025, 07:25:27 AM

Title: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: t18 on May 26, 2025, 07:25:27 AM
Hello,

my question is coz I'm unable to run even a simple xterm on my P166.

I get:

Code: [Select]
Illegal instruction
or

Code: [Select]
CPU ISA level is lower than requested
And I can't even load the linux headers:

Code: [Select]
no space left on device
Here is some output:

Code: [Select]
tc@box:~$ free
              total        used        free      shared  buff/cache   available
Mem:          86172       52036        8568        3716       25568       25344
Swap:        252048       21456      230592

tc@box:~$ free -m
              total        used        free      shared  buff/cache   available
Mem:             84          51           8           4          25          25
Swap:           246          21         225

tc@box:~$ df -h
Filesystem                Size      Used Available Use% Mounted on
rootfs                   75.7M     23.1M     52.6M  31% /
tmpfs                    42.1M         0     42.1M   0% /dev/shm
/dev/sda2                 3.0G    991.6M      2.0G  33% /mnt/sda2
/dev/loop0                8.0K      8.0K         0 100% /tmp/tcloop/libxcvt
/dev/loop1              280.0K    280.0K         0 100% /tmp/tcloop/pixman
/dev/loop2                1.4M      1.4M         0 100% /tmp/tcloop/gcc_libs
/dev/loop3                2.7M      2.7M         0 100% /tmp/tcloop/openssl

So I'd try an older version of gcc, if that's feasible.

Many thanks
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: Juanito on May 26, 2025, 07:49:13 AM
Which x server are you trying to run, Xvesa, Xfbdev or Xorg-7.7?

Which version and architecture of tinycore?

How much ram does your machine have?

It's possible you've hit on a kernel bug for early i486 and perhaps others - you could try using http://tinycorelinux.net/16.x/x86/release/distribution_files/i486/bzImage to see if it helps.
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: t18 on May 26, 2025, 08:15:04 AM
Which x server are you trying to run, Xvesa, Xfbdev or Xorg-7.7?

Xvesa.

I'm not referring to the default rxvt but to the latest Xterm code that I've downloaded and compiled for 32 bit on my i5 10600.

Quote
Which version and architecture of tinycore?

15

Quote
How much ram does your machine have?

96 Mb

Quote
It's possible you've hit on a kernel bug for early i486 and perhaps others - you could try using http://tinycorelinux.net/16.x/x86/release/distribution_files/i486/bzImage to see if it helps.

That's shown as "Potential security risk" on Firefox since its http and not https.

Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: Juanito on May 26, 2025, 08:56:57 AM
I'm not referring to the default rxvt but to the latest Xterm code that I've downloaded and compiled for 32 bit on my i5 10600.

Did you use “-march=i486 -mtune=i686”? If not you will have compiled code that works on your i5, but not necessarily on your pentium.
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: Rich on May 26, 2025, 09:00:06 AM
Hi t18
A couple of thoughts, since code compiled for an i5 is probably
not 486 compatible.

Did you include the 486 compiler directive for CFLAGS:
Code: [Select]
-march=i486
If you did, was it ignored?
Some projects have make files that ignore compiler directives
that the user specifies in the environment.
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: t18 on May 26, 2025, 09:08:39 AM
Did you use “-march=i486 -mtune=i686”? If not you will have compiled code that works on your i5, but not necessarily on your pentium.

Yes, i did.

If you did, was it ignored?
Some projects have make files that ignore compiler directives
that the user specifies in the environment.

I don't know, I didn't be aware of it.

This is the "file" output:

Code: [Select]
bash-5.1$ file xterm
xterm: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, with debug_info, not stripped
bash-5.1$

And this is its Makefile:

Code: [Select]
# -----------------------------------------------------------------------------

SHELL = /bin/sh

#### Start of system configuration section. ####

srcdir = .


x =
o = .o

CC = gcc -march=i486 -mtune=i686 -Os -pipe -fomit-frame-pointer
CPP = gcc -march=i486 -mtune=i686 -Os -pipe -fomit-frame-pointer -E
AWK = gawk
LINK = $(CC) $(CFLAGS)

CTAGS = ctags
ETAGS = etags

LN_S = ln -s
RM              = rm -f
LINT =

INSTALL = /usr/bin/ginstall -c
INSTALL_PROGRAM = ${INSTALL}
INSTALL_SCRIPT = ${INSTALL}
INSTALL_DATA = ${INSTALL} -m 644
transform = s,x,x,

EXTRA_CFLAGS =
EXTRA_CPPFLAGS =  -DPROJECTROOT='"/usr"' -D__vendorversion__='"Version 7.7.0 X.Org"'
EXTRA_LOADFLAGS =

CPPFLAGS = -I. -I$(srcdir) -DHAVE_CONFIG_H  -D_GNU_SOURCE  -I. -I/usr/include/freetype2 -I/usr/include/freetype2/config -Dlinux -D__amd64__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DFUNCPROTO=15 -DNARROWPROTO     -DXFREE86_FT2 -DUTMP  -DOSMAJORVERSION=5 -DOSMINORVERSION=15 -I/usr/include  -I/usr/include/libxml2 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  -I/usr/include/libxml2 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 $(EXTRA_CPPFLAGS)
CFLAGS = -g -O2 $(EXTRA_CFLAGS)
LDFLAGS
LIBS =  -lfontconfig -lfreetype -lXft -lXmu -lXt -lX11 -lXaw7 -lXt -lX11 -lXpm -lSM -lICE -lXt -lX11 -ltermcap

prefix = /opt/_prog32/_instal32/x-term
exec_prefix = ${prefix}
datarootdir = ${prefix}/share
datadir = ${datarootdir}

manext = 1
bindir = ${exec_prefix}/bin
libdir = ${exec_prefix}/lib
mandir = ${datarootdir}/man/man$(manext)
appsdir = ${exec_prefix}/lib/X11/app-defaults
icondir = no
pixmapdir = ${datadir}/pixmaps

#### End of system configuration section. ####
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: Rich on May 26, 2025, 09:18:09 AM
Hi t18
I would add:
Code: [Select]
-march=i486 -mtune=i686 -Os -pipe -fomit-frame-pointerto  EXTRA_CFLAGS  and  EXTRA_CPPFLAGS
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: Juanito on May 26, 2025, 09:46:35 AM
..and if that doesn't work, you can try (in addition to the flags):
Code: [Select]
LD_PRELOAD=uname_hack.so ./configure --blah-blah
LD_PRELOAD=uname_hack.so make
LD_PRELOAD=uname_hack.so sudo make install

Using http://tinycorelinux.net/16.x/x86/release/src/toolchain/uname_hack.so
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: t18 on May 26, 2025, 10:44:39 AM
Hi t18
I would add:
Code: [Select]
-march=i486 -mtune=i686 -Os -pipe -fomit-frame-pointerto  EXTRA_CFLAGS  and  EXTRA_CPPFLAGS

They seems to get ignored: no change in the Makefile.

I did make distclean.
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: patrikg on May 26, 2025, 01:27:26 PM
There lots of include in there, maybe there some libs that doesn't was compiled with all flags to support old asm instructions code.
And do you compile static the linker maybe takes some libs.a (pre build static lib) into your compiled code.
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: Rich on May 26, 2025, 08:09:11 PM
Hi t18
... They seems to get ignored: no change in the Makefile. ...
What you posted ended with:
Code: [Select]
#### End of system configuration section. ####which suggests there was more to the Makefile. Without seeing
the actual commands, we don't know which variables are being
used or how they are being used.
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: CNK on May 26, 2025, 08:30:18 PM
It looks like you're not compiling Xterm in Tiny Core since the paths to libs in that Makefile aren't in /usr/local.

Even though you're using dynamic linking GCC will still use object files like crtbeginS.o which are compiled with GCC using the build settings of your distro (probably for later CPUs than P166). If you boot your i5 PC to x86 Tiny Core and compile there, it should work. Or if you're really adventurous you could try copying the Tiny Core GCC extension's begin/end object files (crtbegin.o, crtbeginS.o, crtend.o, crtendS.o) over to your other distro and make the compiler link to them there, but that's likely to anger the gods.

To confirm, change to the GCC lib directory in the distro where you're building Xterm (eg. /usr/lib/gcc or /usr/lib/gcc-lib) and run this command to show the build settings for the crtbeginS.o file for installed GCC versions:
Code: [Select]
find -name crtbeginS.o -exec file '{}' \;

I'm guessing it will be for a later architecture than i586 (Pentium 1).
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: t18 on May 26, 2025, 10:40:50 PM
Hi t18
... They seems to get ignored: no change in the Makefile. ...
What you posted ended with:
Code: [Select]
#### End of system configuration section. ####which suggests there was more to the Makefile. Without seeing
the actual commands, we don't know which variables are being
used or how they are being used.

Yes it's quite long. Please find it attached.
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: t18 on May 26, 2025, 11:05:01 PM
It looks like you're not compiling Xterm in Tiny Core since the paths to libs in that Makefile aren't in /usr/local.

Yes, indeed I've compiled it on Slackware 15 (it hosts Virtualbox with TC on it).

Sometimes compiling succeeds on Slackware (gcc 11.2.0) and not on TC 15, or viceversa.

Libptytty-2.0 is an example. Although I've found the Juanito's direction: https://forum.tinycorelinux.net/index.php/topic,26669.msg172032.html#msg172032 it hasn't worked for me on TC.

Elsewhere, on Slackware I had problems with the -march option some time ago, while it worked great on TC.

Quote
Even though you're using dynamic linking GCC will still use object files like crtbeginS.o which are compiled with GCC using the build settings of your distro (probably for later CPUs than P166). If you boot your i5 PC to x86 Tiny Core and compile there, it should work. Or if you're really adventurous you could try copying the Tiny Core GCC extension's begin/end object files (crtbegin.o, crtbeginS.o, crtend.o, crtendS.o) over to your other distro and make the compiler link to them there, but that's likely to anger the gods.

That's way beyond my capabilities (and my available time).

Quote
To confirm, change to the GCC lib directory in the distro where you're building Xterm (eg. /usr/lib/gcc or /usr/lib/gcc-lib) and run this command to show the build settings for the crtbeginS.o file for installed GCC versions:
Code: [Select]
find -name crtbeginS.o -exec file '{}' \;

I'm guessing it will be for a later architecture than i586 (Pentium 1).

Here you are:

Code: [Select]
bash-5.1$ find -name crtbeginS.o -exec file '{}' \;
./crtbeginS.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
./32/crtbeginS.o: ELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV), not stripped

Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: t18 on May 26, 2025, 11:44:14 PM
If you boot your i5 PC to x86 Tiny Core and compile there, it should work.

Anyway:

Xterm compiled on Slackware (just for my convenience) for 32 bit and put on Virtualbox-TC works great. I just had to link libtinfo to libncursesw.

The same binary put on P166 shows the above errors.
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: CNK on May 27, 2025, 03:58:02 AM
That looks right and the build script for GCC in Slackware 15 (http://ftp://ftp.osuosl.org/pub/slackware/slackware-15.0/source/d/gcc/gcc.SlackBuild) shows that it is built for i586 (as are other programs/libraries), so that shouldn't be a problem after all. Still I'd try compiling Xterm in x86 Tiny Core Linux in Virtualbox, since it could be that something went wrong with the architecture setting in Slackware when GCC was compiled, and anyway it avoids potential problems with different library versions between Slackware and Tiny Core (although that shouldn't cause "illegal instruction" errors).
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: t18 on May 29, 2025, 02:14:16 PM
So, Xterm looks for ncurses and I've got it installed on a separate dir.

It looks for curses.h in /usr/include (not /usr/local/include) so I've linked it from the ncurses dir.

Tried to set LIBS but unsuccessfully (not sure what I did): either the default dir /usr/local/include and the ncurses/include dir seems not to work.

I get the following error:

Code: [Select]
/usr/local/bin/ld: xtermcap.o: in function `loadTermcapStrings':
/mnt/sda1/_aappz/__SRC/xterm-master/./xtermcap.c:238:(.text+0x92): undefined reference to `tgetstr'
/usr/local/bin/ld: xtermcap.o: in function `get_termcap':
/mnt/sda1/_aappz/__SRC/xterm-master/./xtermcap.c:493:(.text+0x4f6): undefined reference to `tgetent'
/usr/local/bin/ld: xtermcap.o: in function `get_tcap_erase':
/mnt/sda1/_aappz/__SRC/xterm-master/./xtermcap.c:540:(.text+0x583): undefined reference to `tgetstr'
/usr/local/bin/ld: xtermcap.o: in function `set_termcap':
/mnt/sda1/_aappz/__SRC/xterm-master/./xtermcap.c:598:(.text+0x6f5): undefined reference to `tgetent'
collect2: error: ld returned 1 exit status
make: *** [Makefile:174: xterm] Error 1

Please help, many thanks.
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: Rich on May 29, 2025, 04:07:36 PM
Hi t18
Did the source package you downloaded include a file called configure?
If it did, run:
Code: [Select]
./configure --helpThat should provide information on how to set the default include path.

I also see this in your Makefile:
Code: [Select]
CPPFLAGS = -I. -I$(srcdir) -DHAVE_CONFIG_H  ........ Your source package seems to have a configuration header file.

It might be the xtermcfg.h file:
Code: [Select]
$(OBJS1) : xterm.h ptyx.h xtermcfg.h
I also see no reference to curses in the Makefile you posted.
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: t18 on May 29, 2025, 11:41:54 PM
Hi Rich,

if I don't symlink curses.h I get the following error:

Code: [Select]
In file included from ./input.c:90:
./termcap.h:63:10: fatal error: curses.h: No such file or directory
  63 | #include <curses.h>
       |
compilation terminated.
make: *** [Makefile:127: input.o] Error 1

In termcap.h there is the following code block:

Code: [Select]
#ifdef HAVE_NCURSES_CURSES_H
#include <ncurses/curses.h>
#else
#include <curses.h>
#endif


In xtermcfg.h there is the following:

Code: [Select]
#define HAVE_NCURSES_CURSES_H 1 /* AC_CHECK_HEADERS(ncurses/curses.h) */

configure -h mentions CPPFLAGS that I've already (maybe not properly) set.


Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: CNK on May 30, 2025, 12:58:58 AM
So, Xterm looks for ncurses and I've got it installed on a separate dir.

It looks for curses.h in /usr/include (not /usr/local/include) so I've linked it from the ncurses dir.

There are no ncurses extensions for TC15 (if I assume that's where you're compiling Xterm now), so I assume you mean you linked to "/usr/local/include/ncursesw" from ncursesw-dev.tcz. That's only half the solution, you also need to link against ncursesw instead of ncurses by changing "-lncurses" to "-lncursesw" on the compiler command line in the Makefile.

Or if you actually copied ncurses header files from somewhere else, you're on the wrong track altogether, you need it to use the ncursesw headers.

Here's what I had to do to compile Cscope, which had the same problem of expecting ncurses not ncursesw:

Code: [Select]
./configure --prefix=/usr/local --with-ncurses=/usr/local/include/ncursesw
sed -i -e 's%-I/usr/local/include/ncursesw/include%-I/usr/local/include/ncursesw%g' -e 's%-lncurses%-lncursesw%g' Makefile src/Makefile

The configure script allowed supplying a custom path to ncurses, but it added a false "/include" directory on the end, and kept linking against ncurses instead of ncursesw. So I used Sed to adjust those parts of the two Makefiles which the configure script had generated. You might have to use symlinks to the ncursesw headers since the path looks to be hardcoded in the Xterm source files themselves (or edit those source files), but you still need to edit the Makefile/s to use "-lncursesw".
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: t18 on May 30, 2025, 04:25:30 AM
So, Xterm looks for ncurses and I've got it installed on a separate dir.

It looks for curses.h in /usr/include (not /usr/local/include) so I've linked it from the ncurses dir.

There are no ncurses extensions for TC15 (if I assume that's where you're compiling Xterm now), so I assume you mean you linked to "/usr/local/include/ncursesw" from ncursesw-dev.tcz.


Not really, I just downloaded and compiled the latest ncurses-6.5 source and installed the binary in a separate dir.

That's because there are a lot of programs that requires it.

It has a include/ncursesw subdir though, containing curses.h.

I linked it to /usr/include to avoid the above error, but the compilation process seems to ignore the CPPFLAGS=-I/<path-to-ncurses_6.5/include/ncursesw>.


I had also changed the termcap.h code to <ncursesw/curses.h> but no way.
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: Juanito on May 30, 2025, 04:48:52 AM
I’ll have a look, which source code tarball are you using?
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: t18 on May 30, 2025, 06:34:56 AM
I’ll have a look, which source code tarball are you using?

https://ftp.gnu.org/gnu/ncurses/ncurses-6.5.tar.gz

Thank you so much  :)
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: Juanito on May 30, 2025, 10:30:46 AM
Not ncurses, xterm
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: t18 on May 30, 2025, 03:47:06 PM
Sorry, my insomnia hit me again :)

https://github.com/joejulian/xterm.git

Many thanks :)
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: Juanito on May 31, 2025, 06:13:00 AM
This works:
Code: [Select]
tce-load -i compiletc ncursesw-dev ncursesw-utils libXaw-dev libXinerama-dev libXft-dev

wget https://invisible-mirror.net/archives/xterm/xterm-399.tgz

tar xf xterm-399.tgz

cd xterm-399

sed -i '/v0/{n;s/new:/new:kb=^?:/}' termcap
printf '\tkbs=\\177,\n' >> terminfo

CPPFLAGS="-I /usr/local/include/ncursesw" TERMINFO="/usr/local/share/terminfo" CC="gcc -flto -march=i486 -mtune=i686 -Os -pipe" CXX="g++ -flto -march=i486 -mtune=i686 -Os -pipe -fno-exceptions -fno-rtti"  ./configure --prefix=/usr/local --localstatedir=/var --sysconfdir=/etc --with-app-defaults=/etc/X11/app-defaults --with-tty-group=staff

find . -name Makefile -type f -exec sed -i 's/-g -O2//g' {} \;

make [ 0m 50.14s]
sudo make install
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: t18 on May 31, 2025, 09:17:16 AM
¡Muchas gracias, señor!  :)

It seem that what I found is not the "latest xterm" as they stated (it was definitely so at that time).

Well, indeed your work is superb and your settings work.

But I'd like to put it on my P166 and can't do "make install" on it since it's not possible, it seems, to install gcc on it.

Then, my best attempt was to install on a separate dir of my Virtualbox-TC, zip it and unpack it on my P166.

I successfully did that way for other programs yet, but changing the xterm --prefix it seems to me I split the installation somehow.

Not sure on how to set the remaining options:

Code: [Select]
--localstatedir=/var --sysconfdir=/etc --with-app-defaults=/etc/X11/app-defaults
Putting $PREFIX on them causes the old error.

Sorry, my IT knowledge is limited.

Many thanks







Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: Juanito on May 31, 2025, 01:33:03 PM
xterm posted to x86 16.x repo
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: t18 on June 01, 2025, 03:44:35 AM
xterm posted to x86 16.x repo

I'm so grateful.

I had used these option to enable unicode:

Code: [Select]
--enable-16bit-chars --enable-256-color
Are there any alternative methods to enable unicode?

Many thanks

Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: Juanito on June 01, 2025, 04:25:57 AM
You could try uxterm included with xterm or right-click on the xterm window and see if that brings up options?
Title: Re: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?
Post by: t18 on June 01, 2025, 07:54:03 AM
You could try uxterm included with xterm or right-click on the xterm window and see if that brings up options?

Uxterm doesn't run at all (please see the attached image) as well as right-clicking the xterm window.