kosmas12 / kOS

A test operating system made for fun
GNU General Public License v2.0
0 stars 1 forks source link

Compiling. #2

Closed ghost closed 3 years ago

ghost commented 3 years ago

Use the normal cc/gcc/clang with the -m32 to compile into 32bit binaries, or -march=native to compile to system's native architecture, instead of finding a specific compiler binary/link. This will support the kernel being built on all systems instead of just yours.

More issues will be fixed with this too, and compiling will be a lot simpler.

Note for cc: /usr/bin/cc is generally a link to a system's main compiler — GCC, Clang, or any other — the user can choose. This is used as s smarter way to compile how you and a user wants.

kosmas12 commented 3 years ago

@caverym Greetings!

First of all I want to say that I appreciate your feedback a lot. Stuff like this is always welcome.

Now about the issue itself, I have a question.

If we used the regular system C compiler, then wouldn't that produce a binary meant to run in the target operating system?

This is meant to run on bare metal of course, and a cross compiler for 32-bit ELF binaries is expected to be used. Perhaps you're thinking of some way to make the "regular" compiler output bare metal binaries?

Again, thank you for the feedback!

ghost commented 3 years ago

GCC and Clang can both produce bare-metal binaries. Linux uses either gcc or clang (LLVM). Redox uses rustc, which uses LLVM technology.

kosmas12 commented 3 years ago

Very interesting, I didn't know this is possible with the system compiler. Many thanks, I will look into it!

ghost commented 3 years ago

Of course. I do mostly recommend using Clang, or having the option to detect automatically between gcc or clang (and prefer clang) because I'm slightly biased due to Rust. But here is some information to help

I don't have anything for GCC specifically. It produces a binary as you'd expect.

kosmas12 commented 3 years ago

I also prefer Clang for day-to-day development, and only use GCC for this because that's what most people use for operating systems. The links you provided look useful, thank you!

kosmas12 commented 3 years ago

Finally fixed in commit 5b82d065966b572fbf17bcd8c8e5f7f9a53b8abd.