HOW-TO generate 32-bit code on a 64-bit machine
My laptop has a AMD Athlon 64 Processor 3700+, Architecture is x86_64. My problem is that I have to compile a code that will then be linked to pre-compile binaries produced on 32-bit machines. In short, everything must be compiled to generate 32-bit code for the sake of compatibility. I was suggested to prefix the command "linux32". I've tried and played around with the above command. Here are the results: mauede@linux:~> uname -m x86_64 mauede@linux:~> linux32 bash mauede@linux:~> uname -m i686 mauede@linux:~> source ~/bin/gcc-4.1 /* establishes gcc 4.1 as the default gcc in the shell where the script is sourced */ mauede@linux:~> uname -m i686 I have recently succeeded at installing the CERN library. The 1st step of the provided installation procedure un-gzips and un-tars all the source files, then creates the lib structure, generates all the necessary Makefiles, and finally execs the Makefiles at each structure level, therefore creating the library functions. The problem I'm facing is that if I run such a procedure "as is" on my 64-bit laptop, then by default the invoked compilers (gcc, g++, f77), no matter their version, will generate code for my system, that is for a 64-bit processor. But I do need to generate 32-bit code. I wonder if I run the CERLIB installation procedure AFTER launching the linux32 bash ... something like: mauede@linux:~> linux32 bash mauede@linux:~> ./start_cern /* CERNLIB installation procedure */ then all the compilers (gcc, f77, g++) invoked by "start_cern" will see the processor being emulated, that is i686 rather than the true processor x86_64, therefore they automatically will, hopefully, geneate 32-bit code WITHOUT setting any flag and/or option ... ???? .... I might be insane ..... If this is not the case then I will have to split the native CERNLIB installation procedure e manually force the proper options/flags in order to generate code for a 32-bit machine.... a pain ... Thank you very much for your help, Maura
On Sunday 16 April 2006 09:20, Maura Edeweiss Monville wrote: ...
will see the processor being emulated, that is i686 rather than the true processor x86_64, therefore they automatically will, hopefully, geneate 32-bit code WITHOUT setting any flag and/or option ... ???? .... I might be insane .....
Have you considered tinkering with the gcc 4.1 setup ? In the specs file (if it is using that) there is an entry: ---snip--- *multilib_defaults: m64 ---snip--- which may be worth trying to change to 'm32' Alternatively you should be able to rebuild GCC with --target=i586-suse-linux I haven't tried any of the above two suggestions. Regards, Ivan
On Sunday 16 April 2006 09:20, Maura Edeweiss Monville wrote:
then all the compilers (gcc, f77, g++) invoked by "start_cern" will see the processor being emulated, that is i686 rather than the true processor x86_64, therefore they automatically will, hopefully, geneate 32-bit code WITHOUT setting any flag and/or option ... ???? .... I might be insane .....
No, linux32 just changes uname output.
If this is not the case then I will have to split the native CERNLIB installation procedure e manually force the proper options/flags in order to generate code for a 32-bit machine.... a pain ...
You can download ftp://ftp.firstfloor.org/pub/ak/shell/gccwrap.tar.gz and unpack it in your home directory. Then compile the program with ~/gccwrap/32bit <build command> This will work as long as the build command looks in $PATH for gcc, not hardcodes /usr/bin/gcc or similar. Better strategy is to fix the broken build system though to support passing flags. Sooner or later someone has to do this anyways and you might as well start. -Andi
participants (3)
-
Andi Kleen
-
Ivan Skytte Jørgensen
-
Maura Edeweiss Monville