LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-09-2007, 05:18 PM   #1
linuxcrazyguy
LQ Newbie
 
Registered: Mar 2007
Posts: 28

Rep: Reputation: 15
run i686 programs as i386


Hi guys

Here is my problem.

And correct me if I'm wrong.

I have made my own custom kernel and init based on the bash binary on Centos 4.4 (the i686 version).
My kernel + init works fine on all newer systems even like AMD K6 900 Mhz but it won't work on a AMD 600 mhz.

I'm told the problem is likely that the 600mhz can't execute the i686 bash init and that is why my init appears to not execute at all.

Is there some kind of program that can modify i686 binaries to be i386 compatibile?
I really would prefer not to have to compile a ton of binaries especially some that have a ton of dependencies.

Thanks for anyone who can help
 
Old 03-09-2007, 07:24 PM   #2
ille.pugil42
Member
 
Registered: Dec 2005
Distribution: Slackware
Posts: 151

Rep: Reputation: 30
As far as I understand it, no matter what a program was compiled for (unless you're talking x86 to x86_64 and seeking compatibility) i686 vs i386 should be just fine, just a little slower if on a slower system. Some Distros are compiled to take advantage of newer processors (hence i686) and some are compiled with none of those advantages since they are primarily on low impact systems. In your case, it ought to go just maybe a little slower if the system doesn't have tools your kernel was trying to take advantage of.

That out of the way, what are the symptoms. The system won't boot at all? No errors with grub/lilo?
 
Old 03-09-2007, 07:36 PM   #3
lazlow
Senior Member
 
Registered: Jan 2006
Posts: 4,363

Rep: Reputation: 172Reputation: 172
I do not THINK that is right. A 686 can run all 386 codes and extension but I do not think a 386 can run 686 codes and extensions. It (386) just does not know what to do when it runs into stuff that it does not know.

If you would compile it as a 386 then it would run on both 386 and 686. The 386 version will probably not run as fast as the 686 version but it will run on older cpus.

Good luck
Lazlow
 
Old 03-09-2007, 08:10 PM   #4
linuxcrazyguy
LQ Newbie
 
Registered: Mar 2007
Posts: 28

Original Poster
Rep: Reputation: 15
Hi guys

I would like to think that i686 codes can run on older machines but I don't think it is always the case. I really need a simple way to recompile for i386 on an i686 machine or some kind of program to patch or run programs in i386 mode.

The symptoms, are that the kernel boots just fine but when it should load init nothing happens at all, no error, no panic, the keyboard works but that is it.

What makes me think it is an inability to run i686 is what is being described in the thread below:

http://www.linuxquestions.org/questi....php?p=1099989

"I got message "Illegal instruction". Digging deeper I found that this message
appeared when system was trying to execute /bin/bash. That means that bash (and
some other parts of system, init for example) was compiled with instructions not
supported by my K6, only on Duron.

I hope this will help you, guys. Good luck "
 
Old 03-09-2007, 08:46 PM   #5
lazlow
Senior Member
 
Registered: Jan 2006
Posts: 4,363

Rep: Reputation: 172Reputation: 172
I do not really know how to apply it. But under man gcc the -mtune=cpu-type is probably a large part of what you need.
 
Old 03-09-2007, 09:17 PM   #6
Electro
LQ Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
A program that is compiled for an 80686 or i686 can not be run on any model lower than 80686. If a program is compiled for an 80386 or i386, any model higher than this can run it.

You can use pentiumpro as the arch or tune option for the compiler. Also you may want to use -Os to work on processors with small registers and L1 cache.

I suggest compiling code using the following line for CFLAG.

-march=i686 -mtune=pentium2 -Os -pipe

There are no 600 MHz and 900 MHz for the K6 processor. Not even K6-2 or K6-3 has such processors in these speeds. The K7 or Athlon has these speeds. Duron is a K7. You can also try the following CFLAGs.

A:
-march=i686 -mtune=athlon -mno-sse -Os -pipe

B:
-march=i686 -mtune=athlon -mno-sse -O2 -pipe

C:
-march=i686 -mtune=athlon -mno-sse -O3 -pipe

I suggest using version A because it should make the program use less memory and should execute more efficiently.

If you are trying to recompile bash and other programs, I suggest doing a stage 1 of Gentoo.

Read the kernel documentation on a topic using custom CFLAGs.
 
Old 03-10-2007, 04:00 AM   #7
linuxcrazyguy
LQ Newbie
 
Registered: Mar 2007
Posts: 28

Original Poster
Rep: Reputation: 15
Thanks Electro
I was aware of those flags but I was not aware of how to add them to the CFLAGS variable in a makefile.

Is it possible there is some front-end program that can execute i686 instructions as if they were i386? It would be a real pain to recompile everything for i386 and modify all the makefiles or even if there binaries.

Thanks again everyone for your help and input
 
Old 03-10-2007, 12:50 PM   #8
Electro
LQ Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
Creating a 80686 emulator and running the emulator on a 80386 will be very, very slow. The fastest 80386 is 40 MHz.

I recommend using Gentoo to make compiling programs easier. Gentoo provides tools to automate the compiling process.
 
Old 03-12-2007, 02:49 PM   #9
linuxcrazyguy
LQ Newbie
 
Registered: Mar 2007
Posts: 28

Original Poster
Rep: Reputation: 15
Thanks again guys.

Is there at least a program to see what architecture a binary was compiled for?
Does this also mean any .so files I used will not work on non i686 machines?

Can anyone confirm for sure that an i686 binary cannot execute on a AMD K6 380mhz?

Thanks!
 
Old 03-12-2007, 03:17 PM   #10
linuxcrazyguy
LQ Newbie
 
Registered: Mar 2007
Posts: 28

Original Poster
Rep: Reputation: 15
One more thing again.

If I were to download i386 Debian Packages would they run fine on an AMD K6-2 380mHz?
 
Old 03-12-2007, 04:41 PM   #11
lazlow
Senior Member
 
Registered: Jan 2006
Posts: 4,363

Rep: Reputation: 172Reputation: 172
If you run Debian on that machine, then sure. Debs are for Debian based destros and rpms are for Redhat (or similar) based destros. Most rpms (not all) are distribution specific. An rpm made for FC5 MAY not run on FC6 or FC4. There is quite an art to making rpms that are non distribution specific (within rpm destros).

Lazlow
 
Old 03-12-2007, 04:52 PM   #12
linuxcrazyguy
LQ Newbie
 
Registered: Mar 2007
Posts: 28

Original Poster
Rep: Reputation: 15
Thanks lazlow

I was thinking of using Debian on my non-distro kernel. It's just a custom 2.6 kernel that uses bash as an init and then runs some userspace utilities.

Do you know if there is an easy way to statically compile binaries? Meaning that any dependencies would be included with the binaries?

I'm trying to find the easiest way to make my custom distro 100% i386 compatible
 
Old 03-12-2007, 04:57 PM   #13
Electro
LQ Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
Go to http://www.sandpile.org/ for a list of processors.

Sorry, I mistaken K6 as 80686. They are 80586.

Are you sure that you a dealing with K6 processors.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
i386 i686 what does they mean??? muzzamil.luqman Linux - Newbie 12 12-22-2005 03:19 PM
i686 vs. i386 andzerger Linux - Distributions 1 02-22-2004 08:26 PM
is celeron 500 an i686 ? if so how to move from i386 to i686 raft Linux - Hardware 1 12-22-2003 06:58 AM
i386/i686 Surfmonkey Linux - Newbie 13 11-26-2003 10:50 AM
i686 vs i386 NewtonIX Linux - Newbie 4 11-08-2003 04:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration