Compiling 32bit binaries on AMD64
gcc -march=i586 -c -o workman_stubs.o workman_stubs.c workman_stubs.c:1: error: CPU you selected does not support x86-64 instruction set Flags come from RPM_OPTS_FLAGS, via --target=i586 or --target=i586-suse-linux. Googling indicates there is some 32bit gcc backend needed, but these are installed: cpp-4.0.2_20050901-3 gcc-32bit-4.0.2_20050901-3 gcc-4.0.2_20050901-3 glibc-32bit-2.3.5-40 glibc-devel-32bit-2.3.5-40 libgcc-4.0.2_20050901-3 Linux xx 2.6.13-15.7-default #1 Tue Nov 29 14:32:29 UTC 2005 x86_64 x86_64 x86_64 GNU/Linux The trick appears to be to use a -m32 as well. Has no-one noticed this before, or am I doing something wrong? Essentially, rpmbuild --target=i586 doesn't work without this patch: --- /usr/lib/rpm/rpmrc.orig 2005-09-10 04:39:38.000000000 +1200 +++ /usr/lib/rpm/rpmrc 2006-01-03 17:02:30.000000000 +1300 @@ -13,8 +13,8 @@ optflags: i386 -O2 -g -march=i486 -fmessage-length=0 -D_FORTIFY_SOURCE=2 optflags: i486 -O2 -g -march=i486 -optflags: i586 -O2 -g -march=i586 -mtune=i686 -fmessage-length=0 -D_FORTIFY_SOURCE=2 -optflags: i686 -O2 -g -march=i686 -mtune=i686 -fmessage-length=0 -D_FORTIFY_SOURCE=2 +optflags: i586 -O2 -g -m32 -march=i586 -mtune=i686 -fmessage-length=0 -D_FORTIFY_SOURCE=2 +optflags: i686 -O2 -g -m32 -march=i686 -mtune=i686 -fmessage-length=0 -D_FORTIFY_SOURCE=2 optflags: athlon -O2 -g -march=athlon optflags: ia64 -O2 -g -fmessage-length=0 -D_FORTIFY_SOURCE=2 optflags: x86_64 -O2 -g -fmessage-length=0 -D_FORTIFY_SOURCE=2 Or should I be doing something else? #141206 Thanks, Volker -- Volker Kuhlmann is possibly list0570 with the domain in header http://volker.dnsalias.net/ Please do not CC list postings to me.
On Tue, Jan 03, 2006 at 05:38:32PM +1300, Volker Kuhlmann wrote:
gcc -march=i586 -c -o workman_stubs.o workman_stubs.c workman_stubs.c:1: error: CPU you selected does not support x86-64 instruction set
The trick appears to be to use a -m32 as well. Has no-one noticed this before, or am I doing something wrong? Essentially, rpmbuild --target=i586 doesn't work without this patch:
--- /usr/lib/rpm/rpmrc.orig 2005-09-10 04:39:38.000000000 +1200 +++ /usr/lib/rpm/rpmrc 2006-01-03 17:02:30.000000000 +1300 @@ -13,8 +13,8 @@
optflags: i386 -O2 -g -march=i486 -fmessage-length=0 -D_FORTIFY_SOURCE=2 optflags: i486 -O2 -g -march=i486 -optflags: i586 -O2 -g -march=i586 -mtune=i686 -fmessage-length=0 -D_FORTIFY_SOURCE=2 -optflags: i686 -O2 -g -march=i686 -mtune=i686 -fmessage-length=0 -D_FORTIFY_SOURCE=2 +optflags: i586 -O2 -g -m32 -march=i586 -mtune=i686 -fmessage-length=0 -D_FORTIFY_SOURCE=2 +optflags: i686 -O2 -g -m32 -march=i686 -mtune=i686 -fmessage-length=0 -D_FORTIFY_SOURCE=2 optflags: athlon -O2 -g -march=athlon optflags: ia64 -O2 -g -fmessage-length=0 -D_FORTIFY_SOURCE=2 optflags: x86_64 -O2 -g -fmessage-length=0 -D_FORTIFY_SOURCE=2
Or should I be doing something else?
I think that requiring -m32 was on purpose.. but can't speak for the gcc maintainers. I build 32bit stuff all the time in support of our engineers, and I've found that it's sometimes easier to do the configure script using linux32 like: CC='gcc =m32' CXX='g++ -m32' linux32 ./configure -- Mike Marion-Unix SysAdmin/Staff Engineer-http://www.qualcomm.com The needs of the many outweigh the needs of the few, or the one. That's from Trek. Pretty cool, huh? -- Dennis Miller
I've seen a few threads like this with people asking how to compile 32-bit binaries on SUSE AMD64. They don't seem to get clear answers. I'm trying to do such a compilation now and have the same trouble. I've looked in the admin and user guides, the Suse Help centre and on the suse portal without success. I've browsed www.amd.com and www.x86-64.org as suggested in the admin manual but didn't find anything useful. I hope I'm just being dumb and have missed something. Is there a guide to building 32-bit applications on a 64-bit SUSE system? Thanks, Dave
On Thursday 05 January 2006 05:30, Dave Howorth wrote:
I don't know about the other compilers, but "gcc" in SuSE 9.3 and later (these
are the only two I've tested on my x86_64 laptop) recognize the "-m32" flag
for compiling 32 bit applications. Simply, add the "-m32" flag to whenever
you invoke gcc to compile or "link" an application. I believe, although I
can't verify it at this time, there is a "GCCFLAGS" environment variable that
could be set too. Perhaps, google'n this might help...
Anyhow, by passing the "-m32" flag to gcc, gcc will generate 32 bit object
files, and will invoke the linker with the necessary options/libraries to
build a 32 bit application.
When you are done building your application, simple do a "file
I've seen a few threads like this with people asking how to compile 32-bit binaries on SUSE AMD64. They don't seem to get clear answers.
I'm trying to do such a compilation now and have the same trouble. I've looked in the admin and user guides, the Suse Help centre and on the suse portal without success. I've browsed www.amd.com and www.x86-64.org as suggested in the admin manual but didn't find anything useful.
I hope I'm just being dumb and have missed something. Is there a guide to building 32-bit applications on a 64-bit SUSE system?
Thanks, Dave
On Thursday 05 January 2006 05:30, Dave Howorth wrote:
I've seen a few threads like this with people asking how to compile 32-bit binaries on SUSE AMD64. They don't seem to get clear answers.
I'm trying to do such a compilation now and have the same trouble. I've looked in the admin and user guides, the Suse Help centre and on the suse portal without success. I've browsed www.amd.com and www.x86-64.org as suggested in the admin manual but didn't find anything useful.
I hope I'm just being dumb and have missed something. Is there a guide to building 32-bit applications on a 64-bit SUSE system?
Tom Corr replied: <snip main content>
sorry, i didnt have more time to spend looking up the specifics.
Thanks for your reply Tom. I think your last sentence makes my point. All the responses I've seen in threads like this have been individuals doing their best. Inevitably the answers are incomplete. That's why my question is not 'how do I do it?' but 'is there an [official] guide that explains it?'. Thanks and regards, Dave
On Thursday 05 January 2006 11:30, Dave Howorth wrote:
I've seen a few threads like this with people asking how to compile 32-bit binaries on SUSE AMD64. They don't seem to get clear answers.
The answers on this list all seemed clear to me. It's really a FAQ if you look at the archives there are probably hundreds of mails about it, all with the same information. It's also in the gcc documentation. You seem to expect some complicated procedure but there really isn't any. I guess people don't take a feature seriously if it's too easy to use :|
I'm trying to do such a compilation now and have the same trouble. I've looked in the admin and user guides, the Suse Help centre and on the suse portal without success. I've browsed www.amd.com and www.x86-64.org as suggested in the admin manual but didn't find anything useful.
I hope I'm just being dumb and have missed something. Is there a guide to building 32-bit applications on a 64-bit SUSE system?
Compile with -m32. If the Makefile checks uname output you can also run it under linux32 to fake "i686" -Andi
On Thu, 2006-01-05 at 17:23 +0100, Andi Kleen wrote:
On Thursday 05 January 2006 11:30, Dave Howorth wrote:
I've seen a few threads like this with people asking how to compile 32-bit binaries on SUSE AMD64. They don't seem to get clear answers.
The answers on this list all seemed clear to me. It's really a FAQ if you look at the archives there are probably hundreds of mails about it, all with the same information.
It's also in the gcc documentation.
You seem to expect some complicated procedure but there really isn't any. I guess people don't take a feature seriously if it's too easy to use :|
I was hoping that there was some self-contained summary. The admin manual specifically suggests to look at two external sites that don't seem to provide any relevant information, which is a worry because it implies that the information given there is not complete. I have a third-party 32-bit package (an Epson driver) and was hoping there was some easy standard way to create an environment that will build it without having to modify the package. Adding flags involves understanding how its build system works and it also seems a bit perverse to have to give a 32-bit only package knowledge that it is being compiled in a 64-bit environment. It seems to me that this would be a very common situation and so might have a FAQ answer. I also have some questions about libraries that I was hoping such a document would resolve. I'll submit those separately if I don't manage to resolve them with a search.
I'm trying to do such a compilation now and have the same trouble. I've looked in the admin and user guides, the Suse Help centre and on the suse portal without success. I've browsed www.amd.com and www.x86-64.org as suggested in the admin manual but didn't find anything useful.
I hope I'm just being dumb and have missed something. Is there a guide to building 32-bit applications on a 64-bit SUSE system?
Compile with -m32.
If the Makefile checks uname output you can also run it under linux32 to fake "i686"
Thanks, Dave
On Thu, Jan 05, 2006 at 05:23:09PM +0100, Andi Kleen wrote:
You seem to expect some complicated procedure but there really isn't any. I guess people don't take a feature seriously if it's too easy to use :|
The only thing I didn't find clear that took a couple tries to figure out, was that as uses -32 instead of -m32 if called directly. I ran into this when building systemc for some engineers, as there's one call directly to as in the Makefile. -- Mike Marion-Unix SysAdmin/Staff Engineer-http://www.qualcomm.com "Do you know what this is? No, I can see you don't. You have that vacant look in your eyes that says, 'Place my head to your ear.. you will hear the sea!'" --Londo, Babylon 5.
The answers on this list all seemed clear to me. It's really a FAQ if you look at the archives there are probably hundreds of mails about it, all with the same information.
I must have used the wrong words with google then.
You seem to expect some complicated procedure but there really isn't any. I guess people don't take a feature seriously if it's too easy to use :|
Even better if it's not complicated, not good if there's insufficently accessible documentation about it. For a long time -march= has switched to compiling code for that architecture - unless I'm completely mistaken. gcc -v --help is quite clear: -march= Generate code for given CPU So I can expect -march=i586 to compile 32bit code, but nope. The gcc people no doubt have a reason that -m32 is needed too. rpmbuild --rebuild --target i586 is expected to recompile a package for i586. Not so, as SUSE fails to supply the absolutely essential -m32 with RPM_OPT_FLAGS. (#141206) linux32 rpmbuild --rebuild target i586 is doing something, but whatever it is, it's not making 32bit code. 3 different packages are compiled from the same .src.rpm just for x86 and x85_64 (i586.rpm, x64_64.rpm, -libs32-...x85_64.rpm). As it's all from the same .src.rpm there obviously have to be different command invocations to achieve this result. WTF are they? The continued confusion about this shows that there is a need for better information. The admin guide mentions -m32 in sections 26.2 and 26.3, but it doesn't mention anything about recompiling packages. The whole affair is not a simple "... people don't take a feature seriously if it's too easy to use". Volker -- Volker Kuhlmann is possibly list0570 with the domain in header http://volker.dnsalias.net/ Please do not CC list postings to me.
On Fri, Jan 06, 2006 at 12:40:31PM +1300, Volker Kuhlmann wrote:
rpmbuild --rebuild --target i586 is expected to recompile a package for i586. Not so, as SUSE fails to supply the absolutely essential -m32 with RPM_OPT_FLAGS. (#141206)
This would be a bug in rpm/rpmbuild then.
linux32 rpmbuild --rebuild target i586 is doing something, but whatever it is, it's not making 32bit code.
You still have to add the -m32 flag. The same flag requirements were true on solaris when it went 64bit as well, so this isn't some kind of change to how gcc works. You can even give sparc specific flags for the newer UltraSPARC chips, and not get 32bit code with a 64bit gcc unless you specify -m32.
3 different packages are compiled from the same .src.rpm just for x86 and x85_64 (i586.rpm, x64_64.rpm, -libs32-...x85_64.rpm). As it's all from the same .src.rpm there obviously have to be different command invocations to achieve this result. WTF are they?
I built a 32bit pkg myself from a src.rpm. IIRC I basically ran: CC='gcc -m32' CXX='g++ -m32' linux32 rpmbuild -bb <specfile> One other thing I did was to comment out the spec bits where it specified things like docs and such that already existed from the 64bit version. -- Mike Marion-Unix SysAdmin/Staff Engineer-http://www.qualcomm.com Mayor: "Their little festival should pump some money into the local economy." Cartman: "They're hippies!! They don't have any money!!" ==> South Park.
participants (6)
-
Andi Kleen
-
Dave Howorth
-
Mike Marion
-
Tom Corr
-
Volker Kuhlmann
-
Volker Kuhlmann