cross compiler question

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
liangxiao
Posts: 3
Joined: Tue Aug 25, 2015 7:49 pm

cross compiler question

Post 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
User avatar
Rusky
Member
Member
Posts: 792
Joined: Wed Jan 06, 2010 7:07 pm

Re: cross compiler question

Post 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.
liangxiao
Posts: 3
Joined: Tue Aug 25, 2015 7:49 pm

Re: cross compiler question

Post 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
liangxiao
Posts: 3
Joined: Tue Aug 25, 2015 7:49 pm

Re: cross compiler question

Post 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
Last edited by liangxiao on Wed Aug 26, 2015 4:31 am, edited 2 times in total.
Octocontrabass
Member
Member
Posts: 5588
Joined: Mon Mar 25, 2013 7:01 pm

Re: cross compiler question

Post by Octocontrabass »

Yes.
Post Reply