WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: My last (I promise) tantrum: is it possible to run gcc on a Pentium 166?  (Read 816 times)

Offline t18

  • Full Member
  • ***
  • Posts: 123
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

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 15174
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.
« Last Edit: May 26, 2025, 07:59:45 AM by Juanito »

Offline t18

  • Full Member
  • ***
  • Posts: 123
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.


Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 15174
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.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 12126
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.

Offline t18

  • Full Member
  • ***
  • Posts: 123
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. ####

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 12126
Hi t18
I would add:
Code: [Select]
-march=i486 -mtune=i686 -Os -pipe -fomit-frame-pointerto  EXTRA_CFLAGS  and  EXTRA_CPPFLAGS

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 15174
..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

Offline t18

  • Full Member
  • ***
  • Posts: 123
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.
« Last Edit: May 26, 2025, 10:46:17 AM by t18 »

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 755
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.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 12126
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.

Offline CNK

  • Wiki Author
  • Sr. Member
  • *****
  • Posts: 358
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).
« Last Edit: May 26, 2025, 08:39:13 PM by CNK »

Offline t18

  • Full Member
  • ***
  • Posts: 123
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.

Offline t18

  • Full Member
  • ***
  • Posts: 123
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

« Last Edit: May 26, 2025, 11:08:13 PM by t18 »

Offline t18

  • Full Member
  • ***
  • Posts: 123
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.