View Full Version : Query regarding 32 bit and 64 bit assemblies
NaturalThoughts
16th November 2009, 12:38
Hi,
I am learning x264.
I saw the "configure" detect the system and other configuration like pthead and assemblers and all.
i checked that in x264 we have assemblies both for 64 bits (x86_64)and 32 bits (i386). And with the help of "configure" file, the "make" file automatically takes the 64 bit assemblies in my x86_64 system.
But if i want to use only 32 bit assemblies even in x86_64 system (Linux) what changes I should do ?
As 32 bit assemblies should also run in x86_64 system, with the concept of backwards compatibility.
Thanks in advance.
JohannesL
16th November 2009, 12:47
Why do you want that?
NaturalThoughts
16th November 2009, 13:01
It's for learning purpose..........
nm
16th November 2009, 13:02
But if i want to use only 32 bit assemblies even in x86_64 system (Linux) what changes I should do ?
It's not only the assembly code, but the complete build environment that needs to be adjusted. I didn't look around much, but I doubt that this would be easy on 64-bit Linux distributions. You probably need a 32-bit chroot with all the necessary tools and 32-bit libraries installed there. Personally, I'd rather install a 32-bit distribution to a virtual machine.
As 32 bit assemblies should also run in x86_64 system, with the concept of backwards compatibility.
64-bit x264 is about 10% faster than a 32-bit build. Compiling is easy on Linux, so how about building both if you need a 32-bit version for some computers.
akupenguin
16th November 2009, 13:26
You probably need a 32-bit chroot with all the necessary tools and 32-bit libraries installed there.
Sure, that's one way. The other way is called "multilib" and involves installing both versions of the relevant libs in the same root. Gentoo makes this easy, dunno about other distros. And it's libs only; one copy of gcc/ld/yasm/etc can compile both ways.
NaturalThoughts
16th November 2009, 13:39
I am using Ubuntu.
I checked my system, I have 3 folders in /usr directory. i.e there are /usr/lib, /usr/lib32 and /usr/lib64 folders are already present.
So I guess in my system the "multilib" is already present.
1)How can I force x264 to use 32 bit assemblies (I guess I have to change something in "make" file)?
2) Do i even need to install yasm for 32 bit mode ? as I am suspecting even my yasm must have checked the x86_64 architecture and installed for x86_64 system.
akupenguin
16th November 2009, 14:34
CC='gcc -m32' configure --host=i686--linux
As I said, you don't need a separate version of yasm.
kemuri-_9
16th November 2009, 16:09
you will also need to add -m32 to the ldflags to have it link with the x86 libraries instead of the x86_64 ones, here's what i do on my ubuntu distro with multilib installed:
./configure --extra-cflags=-m32 --extra-ldflags=-m32 --host=i686-pc-linux
nm
16th November 2009, 16:22
Sure, that's one way. The other way is called "multilib" and involves installing both versions of the relevant libs in the same root. Gentoo makes this easy, dunno about other distros. And it's libs only; one copy of gcc/ld/yasm/etc can compile both ways.
Ok, this is much easier than I expected. Only had to install gcc-multilib on Ubuntu and Debian and run the configure script as you instructed.
I didn't need to add -m32 to ldflags, only for gcc. (checked what x264 was linked against afterwards with ldd)
kemuri-_9
16th November 2009, 16:30
I didn't need to add -m32 to ldflags, only for gcc. (checked what x264 was linked against afterwards with ldd)
what pengvado gave actually adds -m32 to both the cflags and ldflags since x264 links via 'gcc' and not 'ld', this is why it seems that you don't need to add -m32 to the ldflags.
but this is just a simple matter of different methods to accomplish a single thing...
NaturalThoughts
17th November 2009, 07:04
thanks i checked both the ways from akupenguin and kemuri-_9 and as expected both are working properly.
Actually I had tried with -m32 flag already , but didn't use this --host=i686-pc-linux.
why it is required and and what is does basically....
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.