⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cross compiling gcc for powerpc.htm

📁 Linux下创建Powerpc的交叉编译链
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:v = 
"urn:schemas-microsoft-com:vml" xmlns:o = 
"urn:schemas-microsoft-com:office:office" xmlns:w = 
"urn:schemas-microsoft-com:office:word"><HEAD><TITLE>Cross Compiling Gcc for PowerPC</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content=Word.Document name=ProgId>
<META content="MSHTML 6.00.2900.3157" name=GENERATOR>
<META content="Microsoft Word 11" name=Originator><LINK 
href="cross-compile_files/filelist.xml" rel=File-List><LINK 
href="cross-compile_files/editdata.mso" rel=Edit-Time-Data><!--[if !mso]>
<STYLE>v\:* {behavior:url(#default#VML);}o\:* {behavior:url(#default#VML);}w\:* {behavior:url(#default#VML);}.shape {behavior:url(#default#VML);}</STYLE>
<![endif]--><!--[if gte mso 9]><xml> <o:DocumentProperties>  <o:Author>Sharad Gupta</o:Author>  <o:Template>Normal</o:Template>  <o:LastAuthor>Sharad Gupta</o:LastAuthor>  <o:Revision>8</o:Revision>  <o:TotalTime>16</o:TotalTime>  <o:Created>2003-11-28T03:39:00Z</o:Created>  <o:LastSaved>2003-11-28T03:58:00Z</o:LastSaved>  <o:Pages>1</o:Pages>  <o:Words>541</o:Words>  <o:Characters>3084</o:Characters>  <o:Company>Drexel University</o:Company>  <o:Lines>25</o:Lines>  <o:Paragraphs>7</o:Paragraphs>  <o:CharactersWithSpaces>3618</o:CharactersWithSpaces>  <o:Version>11.5703</o:Version> </o:DocumentProperties></xml><![endif]--><!--[if gte mso 9]><xml> <w:WordDocument>  <w:DisplayBackgroundShape/>  <w:ActiveWritingStyle Lang="EN-US" VendorID="64" DLLVersion="131078"   NLCheck="1">1</w:ActiveWritingStyle>  <w:GrammarState>Clean</w:GrammarState>  <w:ValidateAgainstSchemas/>  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument></xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles></xml><![endif]-->
<STYLE><!-- /* Font Definitions */ @font-face	{font-family:Courier;	panose-1:2 7 4 9 2 2 5 2 4 4;	mso-font-charset:0;	mso-generic-font-family:modern;	mso-font-format:other;	mso-font-pitch:fixed;	mso-font-signature:3 0 0 0 1 0;}@font-face	{font-family:Tahoma;	panose-1:2 11 6 4 3 5 4 4 2 4;	mso-font-charset:0;	mso-generic-font-family:swiss;	mso-font-pitch:variable;	mso-font-signature:1627421319 -2147483648 8 0 66047 0;}@font-face	{font-family:"Comic Sans MS";	panose-1:3 15 7 2 3 3 2 2 2 4;	mso-font-charset:0;	mso-generic-font-family:script;	mso-font-pitch:variable;	mso-font-signature:647 0 0 0 159 0;}@font-face	{font-family:"Trebuchet MS";	panose-1:2 11 6 3 2 2 2 2 2 4;	mso-font-charset:0;	mso-generic-font-family:swiss;	mso-font-pitch:variable;	mso-font-signature:647 0 0 0 159 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal	{mso-style-parent:"";	margin:0in;	margin-bottom:.0001pt;	mso-pagination:widow-orphan;	font-size:12.0pt;	font-family:"Times New Roman";	mso-fareast-font-family:"Times New Roman";}h1	{mso-margin-top-alt:auto;	margin-right:0in;	mso-margin-bottom-alt:auto;	margin-left:0in;	mso-pagination:widow-orphan;	mso-outline-level:1;	font-size:24.0pt;	font-family:"Times New Roman";}span.GramE	{mso-style-name:"";	mso-gram-e:yes;}@page Section1	{size:8.5in 11.0in;	margin:1.0in 1.25in 1.0in 1.25in;	mso-header-margin:.5in;	mso-footer-margin:.5in;	mso-paper-source:0;}div.Section1	{page:Section1;}--></STYLE>
<!--[if gte mso 10]><style> /* Style Definitions */ table.MsoNormalTable	{mso-style-name:"Table Normal";	mso-tstyle-rowband-size:0;	mso-tstyle-colband-size:0;	mso-style-noshow:yes;	mso-style-parent:"";	mso-padding-alt:0in 5.4pt 0in 5.4pt;	mso-para-margin:0in;	mso-para-margin-bottom:.0001pt;	mso-pagination:widow-orphan;	font-size:10.0pt;	font-family:"Times New Roman";	mso-ansi-language:#0400;	mso-fareast-language:#0400;	mso-bidi-language:#0400;}</style><![endif]--></HEAD>
<BODY lang=EN-US style="tab-interval: .5in" vLink=blue link=blue>
<DIV class=Section1>
<P class=MsoNormal><B style="mso-bidi-font-weight: normal"><U><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-family: Arial">Cross 
Compiling Gcc for PowerPC<o:p></o:p></SPAN></U></B></P>
<P class=MsoNormal><B style="mso-bidi-font-weight: normal"><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-family: Arial"><o:p>&nbsp;</o:p></SPAN></B></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-family: Arial">Download 
the latest sources from <A href="ftp://ftp.gnu.org">ftp://<SPAN 
class=GramE>ftp.gnu.org </SPAN></A>. <o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-family: Arial">I 
tested the build with binutils-2.14, gcc-3.3.2, glibc-2.3.2, 
glibc-linuxthreads-2.3.2 and (optionally gdb-6.0). <o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-family: Arial"><BR>1.)<U> 
<B style="mso-bidi-font-weight: normal">Binutils</B></U><BR><SPAN 
class=GramE>As</SPAN> most of the sites suggest, start by building the toolchain 
in separate directories from where you downloaded and unzipped the sources. So, 
I do build-binutils, build-gcc and so on... Also, you can specify the PATH you 
want the cross-compiled binaries to go with --prefix option. The most convenient 
way is to do configure --help to know the oft needed arguments for 
configuration. The next step is to configure the binutils for powerpc as 
target.<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-family: Arial"><BR></SPAN><SPAN 
class=GramE><SPAN 
style="FONT-SIZE: 10pt; BACKGROUND: silver; FONT-FAMILY: Courier; mso-bidi-font-family: Tahoma; mso-highlight: silver">mkdir</SPAN></SPAN><SPAN 
style="FONT-SIZE: 10pt; BACKGROUND: silver; FONT-FAMILY: Courier; mso-bidi-font-family: Tahoma; mso-highlight: silver"> 
build-binutils &amp; cd build-binutils<BR>../binutils-2.14/configure 
--target=powerpc-linux --prefix=/opt/buckeye/powerpc-linux <BR>make all 
install</SPAN><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-family: Arial"><BR><BR>2.) 
<B style="mso-bidi-font-weight: normal"><U>Minimal Gcc</U></B><BR><SPAN 
class=GramE>After</SPAN> binutils is done, add the cross-compiled binaries to 
your PATH by <o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-family: Arial"><BR></SPAN><SPAN 
class=GramE><SPAN 
style="FONT-SIZE: 10pt; BACKGROUND: silver; FONT-FAMILY: Courier; mso-bidi-font-family: Arial; mso-highlight: silver">export</SPAN></SPAN><SPAN 
style="FONT-SIZE: 10pt; BACKGROUND: silver; FONT-FAMILY: Courier; mso-bidi-font-family: Arial; mso-highlight: silver"> 
PATH=$PATH:/opt/buckeye/powerpc-linux<BR>mkdir build-gcc &amp; cd 
build-gcc<BR>../gcc-3.3.2/configure --target=powerpc-linux 
--prefix=/opt/buckeye/powerpc-linux --disable-shared --disable-threads \ 
<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 10pt; BACKGROUND: silver; FONT-FAMILY: Courier; mso-bidi-font-family: Arial; mso-highlight: silver">--enable-languages=c 
--with-newlib<BR>make all-gcc install-gcc</SPAN><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"><o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-family: Arial"><BR>You 
can very well cross-compile Linux kernel with this minimal gcc, though may not 
be able to compile other applications.<BR><BR>3.) <B 
style="mso-bidi-font-weight: normal"><U>Glibc</U></B><BR>After the minimal gcc 
is done; the next major step is to cross-compile glibc. I have had troubles 
compiling glibc in the past what with some of the patches not being applied to 
the glibc tree. But after some help from googling, I was able to put the right 
combination of arguments in place. Be sure to download glibc-linuxthreads and 
unzip it in the glibc source directory. I found out that glibc needs 
linuxthreads to compile correctly. It might not be this way but I could not 
compile it otherwise. So, here is what to do<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-family: Arial"><BR></SPAN><SPAN 
class=GramE><SPAN 
style="FONT-SIZE: 10pt; BACKGROUND: silver; FONT-FAMILY: Courier; mso-bidi-font-family: Arial; mso-highlight: silver">mkdir</SPAN></SPAN><SPAN 
style="FONT-SIZE: 10pt; BACKGROUND: silver; FONT-FAMILY: Courier; mso-bidi-font-family: Arial; mso-highlight: silver"> 
build-glibc &amp; cd build-glibc<BR>tar xv{zj}f 
../glibc-linuxthreads-2.3.2.tar.{gb}z{2<SPAN class=GramE>} 
..</SPAN>/glibc-2.3.2/<BR><SPAN class=GramE>..</SPAN>/glibc-2.3.2/configure 
--prefix=/opt/buckeye/powerpc-linux --target=powerpc-linux --host=powerpc-<SPAN 
class=GramE>linux <SPAN 
style="mso-spacerun: yes">&nbsp;</SPAN>\</SPAN><o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 10pt; BACKGROUND: silver; FONT-FAMILY: Courier; mso-bidi-font-family: Arial; mso-highlight: silver">--enable-add-ons=linuxthreads 
--with-headers=${Path_to_your_powerpc_linux_kernel_tree}/linuxppc_2_4_devel/<SPAN 
class=GramE>include <SPAN 
style="mso-spacerun: yes">&nbsp;</SPAN>\</SPAN><o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 10pt; BACKGROUND: silver; FONT-FAMILY: Courier; mso-bidi-font-family: Arial; mso-highlight: silver">--with-binutils=/opt/buckeye/powerpc-linux/powerpc-linux/bin<BR>make 
all install</SPAN><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"><o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-family: Arial"><BR><SPAN 
class=GramE>glibc</SPAN> would give a compile error for 
glibc-2.3.2/stdio-common/sscanf.c ... you have to change the parameter 
declaration for sscaf function in sscanf.c to <o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-family: Arial"><BR></SPAN><SPAN 
class=GramE><SPAN 
style="FONT-SIZE: 10pt; BACKGROUND: silver; FONT-FAMILY: Courier; mso-bidi-font-family: Arial; mso-highlight: silver">int</SPAN></SPAN><SPAN 
style="FONT-SIZE: 10pt; BACKGROUND: silver; FONT-FAMILY: Courier; mso-bidi-font-family: Arial; mso-highlight: silver"><BR>sscanf 
(const char *s, const char *format, ...)</SPAN><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"><o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Comic Sans MS'; mso-bidi-font-family: Arial"><BR></SPAN><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-family: Arial">It 
should be a breeze after that.<BR>It was worth noting that --target option does 
not work with glibc, you have to use --host<SPAN 
class=GramE>={</SPAN>target-platform}-linux for glibc to work. At my machine, 
glibc libraries were installed in /opt/buckeye/powerpc-linux/lib, but gcc would 
expect them to be at /opt/buckeye/powerpc-linux/powerpc-linux/lib ... so you 
might either make a symlink to the correct path or change the glibc configure 
option --libdir to point to the right place. <o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-family: Arial"><BR>4.) 
<B style="mso-bidi-font-weight: normal"><U>Complete Gcc</U></B><BR>After glibc 
is compiled, you can reconfigure gcc as<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-family: Arial"><BR></SPAN><SPAN 
style="FONT-SIZE: 10pt; BACKGROUND: silver; FONT-FAMILY: Courier; mso-bidi-font-family: Arial; mso-highlight: silver">../gcc-3.3.2/configure 
--target=powerpc-linux --prefix=/opt/buckeye/powerpc-linux --enable-shared 
--enable-threads \<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 10pt; BACKGROUND: silver; FONT-FAMILY: Courier; mso-bidi-font-family: Arial; mso-highlight: silver">--enable-languages=c<BR>make 
all install</SPAN><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"><o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Comic Sans MS'; mso-bidi-font-family: Arial"><BR></SPAN><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-family: Arial">Now 
you should have a complete working version of gcc.<BR><BR>5.) <B 
style="mso-bidi-font-weight: normal"><U>Gdb</U></B> and other graphical 
debuggers like insight<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-family: Arial"><BR></SPAN><SPAN 
class=GramE><SPAN 
style="FONT-SIZE: 10pt; BACKGROUND: silver; FONT-FAMILY: Courier; mso-bidi-font-family: Arial; mso-highlight: silver">mkdir</SPAN></SPAN><SPAN 
style="FONT-SIZE: 10pt; BACKGROUND: silver; FONT-FAMILY: Courier; mso-bidi-font-family: Arial; mso-highlight: silver"> 
build-gdb &amp; cd build-gdb<BR>../gdb-6.0/configure --target=powerpc-linux 
--enable-sim-powerpc --prefix=/opt/buckeye/gdb (any dir of your choice<SPAN 
class=GramE>)</SPAN><BR>make all install</SPAN><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-bidi-font-family: Arial"><o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Comic Sans MS'; mso-bidi-font-family: Arial"><BR></SPAN><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-family: Arial">--enable-sim-powerpc 
builds gdb with inbuilt powerpc instruction set 
simulator.<BR><o:p></o:p></SPAN></P>
<DIV class=MsoNormal><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-family: Arial">
<HR align=left width="100%" SIZE=2>
</SPAN></DIV>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-family: Arial"><A 
href="mailto:sharadg@ece.drexel.edu">Sharad Gupta</A><o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Trebuchet MS'; mso-bidi-font-family: Arial"><!-- Created: Fri Nov 14 00:17:49 EST 2003 --><!-- hhmts start -->Last 
modified: Thu Nov 27 20:52:41 EST 2003 
<o:p></o:p></SPAN></P><!-- hhmts end --></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -