972
edits
[unchecked revision] | [unchecked revision] |
(Add first draft of zig cc page) |
m (Bot: Replace deprecated source tag with syntaxhighlight) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1:
If you want to write an operating system in C, you'll [[Why_do_I_need_a_Cross_Compiler|need a cross-compiler]]. However, [[GCC_Cross-Compiler|building a GCC cross-compiler]] can be painful. If you just want to write C (not C++), you can use [https://andrewkelley.me/post/zig-cc-powerful-drop-in-replacement-gcc-clang.html <kbd>zig cc</kbd>] - a C cross-compiler that comes with the [https://ziglang.org/ Zig programming language]. There are [https://ziglang.org/download/ pre-compiled binaries] for Windows, Linux, MacOS, and FreeBSD.
This section describes how to build [[Bare Bones]] using <kbd>zig cc</kbd>. First off, install the following software:
* [https://ziglang.org/download/ Zig] (tested with version 0.6.0)
*
* [[NASM]]
<
This should create a <kbd>kernel.o</kbd> file, just the same as if you had used gcc.
When you get to the linking step, we won't be able to use <kbd>i686-elf-gcc</kbd>, but luckily, modern versions of [[LD|GNU <kbd>ld</kbd>]] are able to emulate almost any other linker, so we can use the system <kbd>ld</kbd> like so:
<
And at that point, you can carry on with [[Bare Bones]], and you should have an operating system, compiled without having to compile your own cross-compiler!
[[Category:Compilers]]
[[Category:Zig]]
|