Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Compiling i386 binaries in a amd64 world?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on AMD64
View previous topic :: View next topic  
Author Message
blietaer
Tux's lil' helper
Tux's lil' helper


Joined: 27 Apr 2006
Posts: 103

PostPosted: Tue Dec 10, 2013 12:42 pm    Post subject: Compiling i386 binaries in a amd64 world? Reply with quote

Hello,

My Gentoo Box is ~amd64/Xfce4 and I love it.
But my current job would be developing i386 binaries for embedded platforms.

As specifying '-m32' in gcc and having the correct /usr/lib32/*.so in the Makefile seems to be enough and do the trick so far, I would like to avoid going for a 32-chroot and/or a i386 crossdev environment (avoidable? pain?) and/or a virtual i386 machine (already have, but would be so cool to develop natively in my gentoo env,)...

The thing is, I am not sur how/(if?) I want/should/could emerge specific *32* version of libraries.
I *guess* having a /usr/lib32 is the whole point of the game, but is it what I would like to achieve ?
(Copying manually my *.so from the original i386 Debian dev VBox seems so lame/dangerous to me...)
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Tue Dec 10, 2013 2:21 pm    Post subject: Reply with quote

To avoid any mess or troubles, why not add a 32bits dev env itself, it's not like your cpu wasn't able to handle it. Or build a virtual env if you prefer.

Per example newer kernels have drop i386 support, so even in a 32bits env, calls to kernel won't warrant you made i386 valid programs, only valid 32bits one.
So your env need a specific kernel...
And if you are doing tools for i386 only, then it would be bad to see your i386 program is in fact not working.

I'm not sure how you use the term: are you really aiming at i386 code or state "i386" wrongly use it for "32bits" (i686 is also 32bits, and it was that even before 64bits appears).
Back to top
View user's profile Send private message
blietaer
Tux's lil' helper
Tux's lil' helper


Joined: 27 Apr 2006
Posts: 103

PostPosted: Tue Dec 10, 2013 3:22 pm    Post subject: Reply with quote

This is very valuable inputs.

1./ I am indeed wrongly messing around i386/i686/32bits.

2./ Today development is performed in a virtual Debian i386 (I insist) that is indeed 32 bits, but my goal is to be able to get closest to these i386 (and thus, old) libraries, so the generated binaries could actually 'run' in this debian environement (similar to the board env)

3./ what do you mean 'why not add a 32bits dev env itself'?
--> this is more probably what I want to achieve...but it is not clear for me: any 'howto's' available?

4./ In a way, I guess I am not sure what I am doing and what I need to do, but my guess is that many people went down that road more than twice...
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Tue Dec 10, 2013 3:58 pm    Post subject: Reply with quote

I mean build a gentoo with i386, and try to use gcc/glibc/kernel used by the debian.
That's if you really wish gentoo, as it's seem easier to install the debian you have in the embed system.
In both cases you've end with a special env that is the same as the embed system. But that will be run by your amd64 cpu (lol not really the same as a real i386 or an embed cpu).

Have a look at :
- http://www.gentoo.org/proj/en/base/embedded/handbook/
Where you can see others possibilities discuss, cross compiling, virtual env... So may fit your case

Or i would go with :
http://mirrors.mit.edu/gentoo-distfiles/releases/x86/autobuilds/current-stage3-i486/
i486 is close enough arch to your target arch (so this should make sure it comes with a toolchain that should works with i386).
Then read up : https://wiki.gentoo.org/wiki/Changing_the_CHOST_variable

Once done, just not forget to package.mask toolchain to keep it under a version that will be compatible with your embed system (yes, this mean it could also prevent you from using certain programs version that need feature you cannot provide : ie forget a udev version that might need a kernel option not provide by the kernel version you must use, and then restrict xfce version if it depends on udev version...).
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3437

PostPosted: Tue Dec 10, 2013 3:58 pm    Post subject: Reply with quote

I tend to use 32 bit userspace tools inside a chroot jail on my amd64 when I have to do something 32-bit and it works fine. Neither 64 bit kernel nor 32 bit tools complain.
Back to top
View user's profile Send private message
blietaer
Tux's lil' helper
Tux's lil' helper


Joined: 27 Apr 2006
Posts: 103

PostPosted: Wed Dec 11, 2013 10:34 am    Post subject: Reply with quote

@krinn> so you _really_ mean like a dual boot gentoo i386?
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Wed Dec 11, 2013 5:17 pm    Post subject: Reply with quote

Yes, your cpu can run in 32bits and run i386 code. So why not use it to run the same env, it will be just faster. I would take different options if the cpu wasn't able to do that.
Virtualization or really creating a dual boot will remove the pain at handling difference the running env and the dev env may have : libraries, headers... If the dev env == the running env, things get easier.
Back to top
View user's profile Send private message
blietaer
Tux's lil' helper
Tux's lil' helper


Joined: 27 Apr 2006
Posts: 103

PostPosted: Tue Dec 17, 2013 12:30 pm    Post subject: Reply with quote

OK, but that is too close to having the whole exact Debian in a VM and/or dual boot... I wish I could really benefit from my super-customized ~amd64 install, with all my settings and so AND having a terminal in wich I could compile my x86 stuffs, with the right libs...
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10315
Location: Córdoba (Spain)

PostPosted: Tue Dec 17, 2013 1:04 pm    Post subject: Reply with quote

blietaer wrote:
OK, but that is too close to having the whole exact Debian in a VM and/or dual boot... I wish I could really benefit from my super-customized ~amd64 install, with all my settings and so AND having a terminal in wich I could compile my x86 stuffs, with the right libs...


But that's cross-compilation, isn't it?

All depends on your tastes and the specific setup, but in my opinion, developing from x86_64 for x86 is easily done with a gcc-based cross-toolchain. Because it's easy to get a working cross-toolchain for x86, and because you won't be needing to hunt for versions and everything will -mostly- juts work.

On the other side, developing for Windows from Linux that way is often not worth all the trouble (my call, anyway, to each his or her own...). Just picking the right versions of each toolchain component can take some weeks if you can't devote 24/7 to that. So, on those cases, I just use virtualbox and then put perl, mingw, qtcreator or whatever I need into it.

Never bothered with the chroot way, but it should be straight enough as well in the x86_64 to x86 case, I think.

But, as said, it's just my view/experience. Others' experiences might be different.
Back to top
View user's profile Send private message
blietaer
Tux's lil' helper
Tux's lil' helper


Joined: 27 Apr 2006
Posts: 103

PostPosted: Tue Dec 17, 2013 1:24 pm    Post subject: Reply with quote

i92guboj wrote:

But that's cross-compilation, isn't it?

Well...yes.
Actually, you're right, I guess I want to go for cross-compilation.
:wink:
Apologies: I guess sometimes it takes a post to write in order to understand what you want to achieve actually... :-/
Sorry about that.

i92guboj wrote:

developing from x86_64 for x86 is easily done with a gcc-based cross-toolchain. Because it's easy to get a working cross-toolchain for x86, and because you won't be needing to hunt for versions and everything will -mostly- juts work.

You have to understand you precisely picked up my curiosity right here and leaving me alone with this taste in my mouth would be mean !
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10315
Location: Córdoba (Spain)

PostPosted: Wed Dec 18, 2013 10:52 pm    Post subject: Reply with quote

Well. The procedure to get cross-toolchains is well documented.

What I mean is that, while in some other more exotic arches like arm you have to go combining the toolchain components versions so that the components will compile and produce working binaries, in x86 and amd64 (being these two the more actively maintained architectures in Gentoo) you just have to stick to whatever is stable in either of the two, and you can then safely produce a toolchain for the other without much hassle.

There can be small issues here and there, but nothing to hold your breathe about.

Just pick the Gentoo guides and start experimenting :)

The actual reference guide for crossdev in Gentoo is this:

http://www.gentoo.org/proj/en/base/embedded/handbook/
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on AMD64 All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum