Porting GCC to your OS: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content added Content deleted
(Rewrite page with some basic pointers instead of the useless stuff that was already there, the sysroot stuff is pretty important here, other articles covers the rest)
No edit summary
 
(One intermediate revision by one other user not shown)
Line 7: Line 7:
* 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++]].
* 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]].
* Cross-compile libgmp, libmpc, libmpfr and other dependencies with instructions in [[Cross-Porting Software]].
* Likewise cross-compile [[Binutils]] and [[GCC]], but pass the special confifigure options <tt>--with-sysroot-build=/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.
* 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.
* Become self-hosting and complete [[Bare_Bones#Bare_Bones_II|Bare Bones II]]. Congratulations.


Line 19: Line 19:
* [[Sysroot]]
* [[Sysroot]]


[[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.

See Also