Compiling for 32 bit with 32 bit OS on 64 bit machine

For discussions about programming, and for programming questions and advice


Moderator: Forum moderators

Post Reply
User avatar
Dingo
Posts: 244
Joined: Sat Aug 01, 2020 3:03 pm
Has thanked: 10 times
Been thanked: 17 times

Compiling for 32 bit with 32 bit OS on 64 bit machine

Post by Dingo »

Woof Woof!

Sorry for silly question. I'll buy next days my first 64 bit machine. If I run a 32 bit OS on 64 bit machine, can I compile for 32 bit? Maybe as I stated my question is very silly, so, please, excuse me.
User avatar
taersh
Posts: 951
Joined: Tue Jul 07, 2020 11:13 pm
Location: Germany
Has thanked: 53 times
Been thanked: 119 times

Re: Compiling for 32 bit with 32 bit OS on 64 bit machine

Post by taersh »

Yes!

But if you are using a 64bit kernel on the 32bit OS the program will be compiled for 64bit.

There's possibility to compile 32bit programs in 64bit OS and/or 64bit kernel, but this needs a lot of 32bit stuff installed in addition plus some detailed knowledge of options from the compiling environment.

I have already compiled a few programs using a 32bit OS on a 64bit machine. No problems so far.

My Music:
https://soundcloud.com/user-633698367
Using my own build of Bionic64
The far-left is as fascist as the far-right is!

User avatar
mikewalsh
Moderator
Posts: 6150
Joined: Tue Dec 03, 2019 1:40 pm
Location: King's Lynn, UK
Has thanked: 788 times
Been thanked: 1976 times

Re: Compiling for 32 bit with 32 bit OS on 64 bit machine

Post by mikewalsh »

Hi, Dingo.
If I run a 32 bit OS on 64 bit machine, can I compile for 32 bit?
Not a silly question at all, but, yes.....you can. I won't go into all the technical explanations here, but what not everybody understands is that both 32-bit AND 64-bit are "x86" architecture. The addition that makes "x86" become "x86_64" is something known as "long mode", which switches in additional registers and other stuff inside the CPU's circuitry to handle the difference between 2³² bytes of data and 2⁶⁴ bytes of data.

https://en.wikipedia.org/wiki/Long_mode

  • If you install a 64-bit OS, the system will tell the CPU to run in "long mode", and to use all those extra registers.

  • If you install a 32-bit OS, the CPU doesn't receive that instruction from the system, and it will run in conventional "x86" mode, also known as "compatibility mode".....and behave, and act, in every way like a 32-bit CPU. So compiling for 32-bit on a 64-bit capable CPU will act as expected, providing your compile environment is running within a 32-bit OS.

(taersh's observation above about using a 64-bit kernel in a 32-bit OS is getting a bit above most people's 'pay-grade', it's true.....but these permutations are real, and are certainly possible, if you're prepared to put in the extra work to make them happen. I believe the current 'rolling' release of SliTaZ works this way.)

Does that help at all? :)


Mike. ;)
User avatar
01101001b
Posts: 164
Joined: Wed Jul 15, 2020 10:57 pm
Location: Buenos Aires, Argentina
Has thanked: 643 times
Been thanked: 21 times

Re: Compiling for 32 bit with 32 bit OS on 64 bit machine

Post by 01101001b »

Dingo wrote: Mon Sep 28, 2020 7:53 pm If I run a 32 bit OS on 64 bit machine, can I compile for 32 bit?
Yep, no problem. I'm doing exactly that in my machine right now (I'm compiling Palemoon 32bit in Dpupbuster32 in an AMD 64bit) :thumbup2:

''Most people make the mistake of thinking design is what it looks like [...] It's not [...]. Design is how it works.'' -- Steve Jobs

version2013
Posts: 153
Joined: Mon Jul 13, 2020 11:30 pm
Has thanked: 4 times
Been thanked: 24 times
Contact:

Re: Compiling for 32 bit with 32 bit OS on 64 bit machine

Post by version2013 »

Dingo wrote: Mon Sep 28, 2020 7:53 pm If I run a 32 bit OS on 64 bit machine, can I compile for 32 bit?
Yes. I compile wine 32-bit on a 64-bit machine in a Tahr 32-bit OS.
User avatar
Jafadmin
Posts: 385
Joined: Tue Aug 04, 2020 4:51 pm
Has thanked: 68 times
Been thanked: 85 times

Re: Compiling for 32 bit with 32 bit OS on 64 bit machine

Post by Jafadmin »

The compiler compiles for the OS and kernel that is running at compile time. It doesn't care about the hardware. Just the kernel.
User avatar
Dingo
Posts: 244
Joined: Sat Aug 01, 2020 3:03 pm
Has thanked: 10 times
Been thanked: 17 times

Re: Compiling for 32 bit with 32 bit OS on 64 bit machine

Post by Dingo »

Thanks for solving my silly dubts. I don't if this can be off topic, but if you have some recomendations about a cheap notebook for compiling I'll be grateful. I seen a good deal about a Dell e6400 but after read of its throttling issues even at not so warm temperatures I changed mind and no more bought and I'm oriented toward an hp probook 645 g1 AMD A6 powered only I'm not sure that compiling on this AMD cpu can end with building binaries fully performant on Intel cpu
User avatar
mikewalsh
Moderator
Posts: 6150
Joined: Tue Dec 03, 2019 1:40 pm
Location: King's Lynn, UK
Has thanked: 788 times
Been thanked: 1976 times

Re: Compiling for 32 bit with 32 bit OS on 64 bit machine

Post by mikewalsh »

Dingo wrote: Wed Oct 07, 2020 4:20 pm Thanks for solving my silly dubts. I don't if this can be off topic, but if you have some recomendations about a cheap notebook for compiling I'll be grateful. I seen a good deal about a Dell e6400 but after read of its throttling issues even at not so warm temperatures I changed mind and no more bought and I'm oriented toward an hp probook 645 g1 AMD A6 powered only I'm not sure that compiling on this AMD cpu can end with building binaries fully performant on Intel cpu
@Dingo :-

Umm....y'know, that's another common misconception.

I can see where your 'doubts' may be coming from! Most 64-bit binaries/packages/what-have-you tend to be labelled these days as "amd64". You know what the reason behind this is, don't you? It's the industry's own tribute to the very company that produced the first popular, commercially-viable 64-bit CPU for the desktop market.....the immortal AMD Athlon 64, back in 2003. That was pretty much the only time for years that AMD were 'one-up' over Intel, and the latter took it badly. Yet it was probably the impetus Intel needed, the 'kick up the backside', if you like, that led to them beginning development of what eventually became the all-conquering "Core" architecture. "Core" and subsequent generations would hold AMD at bay for nearly the next 15 years.....

...until 2017, when 'Ryzen' surfaced. And the competition began to hot up.....and battle commenced. Once again, we've got a competitive CPU market, and competition motivates.....and engenders innovation.

No, it doesn't matter whether you label it "amd64", or if you call it "x86_64". They're both the same thing, 'cos basic operation of all "x86" architecture CPUs is the same. The one thing 64-bit operation brings to the table is what's known as 'long mode'.....the ability to switch-in additional registers to cope with the difference between 2³² bytes of data and 2⁶⁴ bytes of data, as I mentioned earlier.

AMD call it one thing, Intel call it another. But they both work identically, and the end result is always the same; anything compiled with an AMD processor will run as expected on an Intel one.....and vice-versa.

At the end of the day, so long as the compiler functions, the code itself neither knows, nor cares what CPU it was actually compiled ON.


Mike. ;)
Last edited by mikewalsh on Thu Oct 08, 2020 9:36 am, edited 1 time in total.
User avatar
Dingo
Posts: 244
Joined: Sat Aug 01, 2020 3:03 pm
Has thanked: 10 times
Been thanked: 17 times

Re: Compiling for 32 bit with 32 bit OS on 64 bit machine

Post by Dingo »

@mikewalsh
Thanks again, then HP ProBook 645 g1 is good for me. only, since it has WiFi card with damned BCM43228 I have to looking for an optional USB adapter (in order to avoid to compile every time the broadcom driver for various puppy version I want to run) but this Iis a matter for another thread
User avatar
mikewalsh
Moderator
Posts: 6150
Joined: Tue Dec 03, 2019 1:40 pm
Location: King's Lynn, UK
Has thanked: 788 times
Been thanked: 1976 times

Re: Compiling for 32 bit with 32 bit OS on 64 bit machine

Post by mikewalsh »

Dingo wrote: Thu Oct 08, 2020 9:24 am @mikewalsh
Thanks again, then HP ProBook 645 g1 is good for me. only, since it has WiFi card with damned BCM43228 I have to looking for an optional USB adapter (in order to avoid to compile every time the broadcom driver for various puppy version I want to run) but this Iis a matter for another thread
@Dingo :-

Well, if you start a thread for that one I'm sure you'll get plenty of suggestions..! I've got a couple of reasonably-priced, well-supported dongles in mind myself that you may like to take a look at.


Mike. ;)
Post Reply

Return to “Programming”