Page 1 of 1

cross compiler question

Posted: Tue Aug 25, 2015 9:52 pm
by liangxiao
I current use x86-64 platform linux. My question is, can I use the default compiler to compile i386 program with option -m32 instead of building a single cross-compiler?

Best Regards

Re: cross compiler question

Posted: Tue Aug 25, 2015 10:24 pm
by Rusky
You can compile 32-bit applications that way, but assuming you want to do OS development you'd want a cross compiler whether you were targeting 64 or 32-bit.

Re: cross compiler question

Posted: Wed Aug 26, 2015 3:07 am
by liangxiao
That means I need cross compiler if I do os development no metter what platform I am targeting? Ever it's same as host platform(my case is x86-64)?

Thanks in advance

Re: cross compiler question

Posted: Wed Aug 26, 2015 3:24 am
by liangxiao
I read a article "Why do I need a Cross Compiler?" host on wiki. Refer to below section
If you are developing on 64-bit Linux, then you will get a response such as 'x86_64-unknown-linux-gnu'. This means that the compiler thinks it is creating code for Linux. If you use this gcc to build your kernel, it will use your system libraries, headers, the Linux libgcc, and it will make a lot of problematic Linux assumptions. If you use a cross-compiler such as i585-elf-gcc, then you get a response back such as 'i686-elf' that means the compiler knows it is doing something else and you can avoid a lot of problems easily and properly.
Do that can answer my previous question as "yes"?

Thanks in advance

Re: cross compiler question

Posted: Wed Aug 26, 2015 3:32 am
by Octocontrabass
Yes.