Porting GCC to your OS: Difference between revisions
Jump to navigation
Jump to search
[unchecked revision] | [unchecked revision] |
Content added Content deleted
m (Remove reference to newlib in favor of the generic article) |
No edit summary |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 2: | Line 2: | ||
{{In Progress}} |
{{In Progress}} |
||
* Read [[GCC Cross-Compiler]]. |
|||
:''Note that the [[GCC Cross-Compiler]] page is intended to include the information below (as well as filling in the To-Dos) once it is finished. Unless someone else does it first, I'll do so once my PDCLib is finished.'' - [[User:Solar|MartinBaute]] |
|||
* Make a [[OS Specific Toolchain]]. |
|||
* Read [[Hosted GCC Cross-Compiler]]. |
|||
* Have a sufficient [[C Library]]. GCC is fairly portable and needs the C standard library, and some extensions from POSIX. It needs fork and exec, for instance, to run the assembler and linker. You will need a C++ standard library (such as libstdc++) as GCC is now written in [[C++]]. |
|||
* Cross-compile libgmp, libmpc, libmpfr and other dependencies with instructions in [[Cross-Porting Software]]. |
|||
* Likewise cross-compile [[Binutils]] and [[GCC]], but pass the special configure options <tt>--with-build-sysroot=/your/sysroot</tt> and <tt>--with-sysroot=/</tt>. The option <tt>--with-build-sysroot</tt> option uses that [[sysroot]] for the duration of the build, but the final program does not remember it. <tt>--with-sysroot=/</tt> should not be needed or should be set to the empty string, but some binutils/gcc versions are buggy and require it, which has the disadvantage the final toolchain might use <tt>//foo</tt> instead of <tt>/foo</tt>. You should ''only'' pass these options to the Binutils and GCC builds, some other packages also have a <tt>--with-sysroot</tt> option, but it instead means a libtool feature you should ''not'' use. |
|||
* Become self-hosting and complete [[Bare_Bones#Bare_Bones_II|Bare Bones II]]. Congratulations. |
|||
⚫ | |||
First, you should understand [[How kernel, compiler, and C library work together]]. If any of the next steps gives you trouble, the information given in that document should give you an idea of what is missing. |
|||
* [[Binutils]] |
|||
* [[Cross-Porting Software]] |
|||
Next, you should build a [[GCC Cross-Compiler]] for your platform. |
|||
* [[GCC]] |
|||
* [[GCC Cross-Compiler]] |
|||
:''ToDo: elaborate on [[GCC]]'s platform description, and how to set up your own if you don't want to use an existing one.'' |
|||
* [[Hosted GCC Cross-Compiler]] |
|||
* [[OS Specific Toolchain]] |
|||
Then, you need a C standard library for your platform - at least those parts required by GCC. |
|||
* [[Sysroot]] |
|||
To do this you need a [[C Library]] for your OS. |
|||
Finally, you would use the cross-compiler to compile [[GCC]] ''to run on your platform''. |
|||
Just to be sure, you would use that "native" [[GCC]] to compile itself (to be sure it could, and for weeding out any issues that might arise from cross-compilation). Congratulations, you are now what people call "self-hosted", i.e. you no longer need some other OS to do development work. (Provided you have a working editor for your platform.) |
|||
⚫ | |||
===External Links=== |
|||
*[http://www.scratchbox.org Scratch Box] |
|||
*[http://libosdk.berlios.de/wiki/index.php/Binutils LibOSDK Wiki] |
|||
[[Category:Porting]] |
|||
[[Category:Compilers]] |
[[Category:Compilers]] |
Latest revision as of 20:22, 10 July 2023
Difficulty level |
---|
![]() Master |
This page is a work in progress.
This page may thus be incomplete. Its content may be changed in the near future.
- Read GCC Cross-Compiler.
- Make a OS Specific Toolchain.
- Read Hosted GCC Cross-Compiler.
- Have a sufficient C Library. GCC is fairly portable and needs the C standard library, and some extensions from POSIX. It needs fork and exec, for instance, to run the assembler and linker. You will need a C++ standard library (such as libstdc++) as GCC is now written in C++.
- Cross-compile libgmp, libmpc, libmpfr and other dependencies with instructions in Cross-Porting Software.
- Likewise cross-compile Binutils and GCC, but pass the special configure options --with-build-sysroot=/your/sysroot and --with-sysroot=/. The option --with-build-sysroot option uses that sysroot for the duration of the build, but the final program does not remember it. --with-sysroot=/ should not be needed or should be set to the empty string, but some binutils/gcc versions are buggy and require it, which has the disadvantage the final toolchain might use //foo instead of /foo. You should only pass these options to the Binutils and GCC builds, some other packages also have a --with-sysroot option, but it instead means a libtool feature you should not use.
- Become self-hosting and complete Bare Bones II. Congratulations.