hwg wrote:
So the tutorial I posted works because the operating system being compiled on the same arch for which it was written? So an ARM OS would not compile properly, correct?
Correct.
hwg wrote:
You said that it would involve reimplementing stdint.h, but I thought stdint.h was implementation dependent. Does the standard not specify the minimum size of bytes and not the max?
stdint.h is specific to the toolchain and the architecture. If you're using the host's toolchain and you're targeting the host's architecture, it's safe to use the host's stdint.h.
Honestly I think the wiki article on cross-compilers is a little extreme (it goes on and on about shorter command-lines, for example). So long as you set your CFLAGS and LDFLAGS appropriately to ensure the compiler won't link against anything from the host system, you're fine. Some headers from the host system may still be useful, others (that refer to libraries pre-built for the host OS that you can't easily recompile for your OS) won't be.
In my opinion the downsides of using the host's toolchains are:
- Developers new to "bare-metal" development will get confused about what they're really compiling and targeting.
- If/when you eventually target a different architecture, or other developers with incompatible host toolchains get involved in your OS, you'll have refactor your build scripts.
So a cross-compiler is a good idea in general, but it's not "dangerous" to start with the host's toolchain.