Page 1 of 1

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

Posted: Mon Sep 28, 2020 7:53 pm
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.

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

Posted: Mon Sep 28, 2020 8:19 pm
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.

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

Posted: Mon Sep 28, 2020 8:23 pm
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. ;)

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

Posted: Thu Oct 01, 2020 3:25 am
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:

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

Posted: Tue Oct 06, 2020 3:52 am
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.

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

Posted: Tue Oct 06, 2020 11:19 am
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.

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

Posted: Wed Oct 07, 2020 4:20 pm
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

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

Posted: Wed Oct 07, 2020 6:53 pm
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. ;)

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

Posted: Thu Oct 08, 2020 9:24 am
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

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

Posted: Thu Oct 08, 2020 9:59 am
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. ;)