Why is a cross compiler "needed"?
Posted: Tue Jul 09, 2024 11:38 pm
So this is going to come off like a silly question, but bear with me. I've dabbled with my hobby OS for something like 15 years now.
Basically, I compile with `-mcmodel=kernel -ffreestanding -nostdinc` plus a boat load of other flags and use a custom linker script. I've written my own "libc" and my own "libstdc++" and provide their include paths and link to them when building. I also link to `-lgcc` just in case the compiler decides to use a builtin that requires its support library.
This works! It's kinda always worked, and AFAIK, is basically what the linux folks do too right?
So how come (at least in the past few years), the primary advice I see in this forum, the wiki, and even on r/osdev, is that people should **definitely** be using a cross compiler? What am I missing? Is it just to make certain things simpler instead of manually providing all the libraries and paths, the triplet will make the compiler just "know" what you prefer?
I've read: https://wiki.osdev.org/GCC_Cross-Compil ... _necessary
And it just basically just says "unless a lot of problematic options are passed to it, which will create a lot of problems in the future" which is kinda vague. Like I said, I've had the same build process for like 15 years and haven't run into any issues (that I know of), so what am I missing?
Basically, I compile with `-mcmodel=kernel -ffreestanding -nostdinc` plus a boat load of other flags and use a custom linker script. I've written my own "libc" and my own "libstdc++" and provide their include paths and link to them when building. I also link to `-lgcc` just in case the compiler decides to use a builtin that requires its support library.
This works! It's kinda always worked, and AFAIK, is basically what the linux folks do too right?
So how come (at least in the past few years), the primary advice I see in this forum, the wiki, and even on r/osdev, is that people should **definitely** be using a cross compiler? What am I missing? Is it just to make certain things simpler instead of manually providing all the libraries and paths, the triplet will make the compiler just "know" what you prefer?
I've read: https://wiki.osdev.org/GCC_Cross-Compil ... _necessary
And it just basically just says "unless a lot of problematic options are passed to it, which will create a lot of problems in the future" which is kinda vague. Like I said, I've had the same build process for like 15 years and haven't run into any issues (that I know of), so what am I missing?