LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Cross Compiling from i686 to i586 -- Necessary? (https://www.linuxquestions.org/questions/programming-9/cross-compiling-from-i686-to-i586-necessary-582102/)

dwhitney67 09-04-2007 09:20 AM

Cross Compiling from i686 to i586 -- Necessary?
 
Hi,

I've been developing software for many years but I have never had to put much thought into cross-compiling from one architecture to another because the tools I needed were either provided by an outside vendor.

Therefore I would be grateful if somebody could help me answer these questions:

1) I assume that since I am developing on an i686 system running FC7 (or whatever) and my target is a 586MMX (i586), that I require a cross compiler. Is this correct?


2) If I use Kegel's (http://www.kegel.com/crosstool) cross-compiler builder suite, what do I do with the cross-compiler once it is built?

That may sound silly question but what I need to know is at what point am I ready to start building the binaries that I want to include with my deliverable? Do I need to dwell on making a suite of tools (similar to what is done in Cross-Compiled Linux From Scratch) that include binutils, gcc, etc. first and then, using those newly created tools, build my deliverables? Or can I just start building my deliverables?


3) Has anybody used 'ttylinux' (http://www.minimalinux.org/ttylinux)? Can I use it to cross compile from one arch to another?


4) Besides ttylinux, is there any other "minimal" Linux distro available? I do not require a development system for my deliverable -- just a basic system with a kernel, ncurses, busybox, glibc, gcc shared libraries, and a handful of other utilitarian tools.

The current distro I am attempting to build will include:
PHP Code:

busybox
dvdrtools
eject
expat
e2fsprogs
gcc
glibc
grub
hwclock
kernel
lockdev
ncurses
openssl
openssh
portmap
Qt
setserial
tinyxml
X11
xpm
xvkbd
zlib 

Thank you.

gnashley 09-05-2007 05:44 AM

Yes, you need to build a cross compiler to start with. This will let you create the libraries and binaries for i586 from your running i686 system. If you were meaning to produce a new system which includes the ability to compile new programs for the new system, then the first thing you'd need to do with you cross-compiler is produce a native compiler for that system plus the necessary binaries for a development-capable system, including the shell, util-linux, coreutils, sed, awk etc.
Since your goal is a mini system this may not be what you want.
ttylinux will nowhere near meet your needs for compiling new software -all the binaries used in ttylinux are produced from another running system which is more complete.

But your posting is not clear on this -if you don't intend the deliverable system to be a development platform then why is gcc in the list. Also why do you need QT? If you start checking the dependencies of what you have listed you'll find that you need to add around 50-100 packages to your list already(many of these are covered minimally by busybox, but not all of them).

dwhitney67 09-05-2007 09:23 AM

gnashley -

Thank you for your response. Could you please help me understand this comment you made?

Quote:

This will let you create the libraries and binaries for i586 from your running i686 system. If you were meaning to produce a new system which includes the ability to compile new programs for the new system, then the first thing you'd need to do with you cross-compiler is produce a native compiler...
I have built a cross-compiler using the instructions given in the CLFS guide. As my target system is not going to be a development system, are you saying that all I need to do is use the cross-compiler to build the source packages that will run on the target system?

I am a little confused because the CLFS guide provides instructions for building GCC as a cross-compiler, then again for a "temporary system", and then a third time (native compiler??) for the final system. Do I need to build GCC as prescribed for a "temporary system" before I can begin building the packages to be included with my distro?

Btw, I am not fully aware of what dependencies are needed, and hence I am only following a working setup that is currently in use at my company. The gcc and Qt are included because they contain shared libraries that certain applications require during runtime. I guess the X11, tinyxml, and others are included for the same reason.

gnashley 09-06-2007 07:43 AM

If all you need are the gcc libs you wouldn't have to have the compiler itself as part of the deliverable. I suspect you'll be needing the libstdc++ libs as well as gcc.so since you are running Qt-based stuff. Anything written in C++ will need these.
You can produce all the programs from a 'foreign' platform if you want. The LFS intermediate or temporary stage is a very minimal, but bootable system used to produce the rest of the shared libs and binaries for a full system including the final compiler.
The reason for the several passes at compiling is that in the end everything on the new system should be compiled by/with/for/against the programs and libs of the new system. There are 'circular dependencies' between some libs and programs so mulitple passes are needed to resolve them.

In addition to the LFS docs, you might have a look at DIY linux. The process is much the same, but the documents being worder differently may help you to come to terms with it all. Don't feel bad if it causes you headaches while studying and doing thsi -that's perfectly normal. The fact that you are sticking to ix86 arches helpy a great deal and reduces the complexity of what you have to do.

dwhitney67 09-06-2007 08:34 AM

Thank you again for your help and suggestions. I feel I understand a little more now concerning removing unwanted dependencies from my build. I've completed the minimal work environment as described per the CLFS guide, and now I am at the point where I will need to perform a chroot to start building the individual source packages necessary for my distro.

Upon examining the host.def file used by X11R6.9.0, I can see that there are many system dependencies that were originally taken for granted by the previous engineer assigned to the task I have been given. These will have to be built prior to any attempts to build X11. Undoubtedly similar issues are prevalent with the other source packages I must build as well.

This exercise is complicated in the sense that I must be able to easily reproduce all steps involved in creating the system using either build scripts or Makefiles, or a combination of both. Also not only do I have to account for the build environment, I also have to produce a Linux distro that will run on a bootable CD, and include the necessary applications to replicate the Linux distro onto a HDD should the operator choose to "install". This is a lot of work for just one person! I hope my company does not lose patience with my efforts.

gnashley 09-08-2007 02:44 AM

I've been where you are before and wanted to do much thesame thing. So I hope you'll believe me when I tell you that you just described about 2 years of work -if your learning process progresses regularly. But don't think I mean you won't or can't get there or that I mean to discourage you.

Do write scripts for each phase of what you are doing(as much as possible -stuff you do in a chroot environment or that include reboots are hard to script). Write 3 times as many lines of comments (to yourself) as lines of code, so that you don't forget what you were doing last night or last week.

You probably begin to understand why most home-grown distros are simply off-shoots of existing distros. Even a very minimal self-contained distro capable of compiling itself consists already of up to 200 packages. For a bootable CD you'll have to create still another very tiny system for the initrd which is smart enough to find the main installation or create it.
Uisng busybox for your temporary/intermediate phases saves configuring and compiling many separate packages, but it's probably not a good idea to use these utilities in your end-product.


All times are GMT -5. The time now is 04:23 AM.