Do you have to build a new compiler for the new operating system?

I want to build an operating system at some point in the future, and now want some lightweight sketches of how it will be. I’m almost already working on C code compiled for the Windows environment (and Some small Java). If I want to run it under Linux, I will have to recompile any of my C programs. Therefore, the binary file (compiled product) must be different for each operating system. If I start from scratch Designing a brand new operating system, whether it is for hobby or academic purposes, does not use the Linux kernel or any known basic code of the operating system, what I understand is that due to my operating system, I cannot compile my C with GCC The program will not be one of its target systems. There is a question about the title here. Thanks in advance for any tips.
this It depends. You can easily choose to reuse existing compilers, such as ancient GCC examples, to reap the benefits of existing compilers. But some important additional conditions must be removed.

Whatever Whether you choose to build a new compiler, the challenge is still to port the C library. Technically, you can use C without a standard library (such as the Linux kernel or any self-hosted examples), but for the intention to be under the operating system This is a ridiculous claim for the running program, because most systems impose memory restrictions, etc., which means you can’t just have full restrictions on the use of memory. Therefore, you need C library calls such as malloc. /p>

Because any program under your kernel (probably 99% of your operating system) needs a set of link functions, porting the C library is your biggest task. The C library is a huge boulder, writing Your own will be quite stupid, especially many implementations already available, the most famous is GCC. So, the question you really should ask is, do you want to write my own version of libc? (The answer is almost always no. Most alternative implementations are for niche use cases.) In addition, if you want to make your OS POSIX compatible, then you will have to implement more features, which increases the trouble.

Whether you write your own compiler for your own operating system is a subtle detail compared to the C library included in it. You can always use your own compiler with the C library implementation you have written.

My suggestion to your opinion-based question is: No. Port an existing compiler, such as GCC or clang, and then use it. In addition, this has several advantages:

> Compatibility with existing tools and toolchains
>Familiar programs (users don’t need to learn how to use a new compiler)
>They are open source-though, you are not crazy at all. Oops, even if it is Apple integrated two existing compilers-GCC and clang-into their toolchain instead of doing it yourself, and they are a multi-billion dollar company.

Check out this page. It demonstrates how to use Newlib as a C library to port GCC to your operating system.

I want to build an operating system at some point in the future, and now I want to know something about A lightweight sketch of how it will be. I’m almost already compiling C code (and some little Java) for the Windows environment. If I want to run it under Linux, I will have to recompile any of my C programs. Therefore, For each operating system, the binary files (compiled products) must be different. If I design a brand new operating system from scratch, whether it is for hobby or academic purposes, without using the Linux kernel or any known basics of the operating system The code, what I understand is that due to my operating system, I cannot compile my C program with GCC and it won’t be one of its target systems. There is a question about the title here. Thanks in advance for any hints.

< p>

It depends. You can easily choose to reuse existing compilers, such as ancient GCC examples, to reap the benefits of existing compilers. However, some important additional conditions must be removed. < p>

Regardless of whether you choose to build a new compiler, the challenge is still to port the C library. Technically, you can use C without a standard library (such as the Linux kernel or any self-hosted Example), but for programs that intend to run under the operating system, this is a ridiculous claim, because most systems impose memory restrictions, etc., which means you can’t just have full restrictions on the use of memory. Therefore, you need C library calls such as malloc.

Since any program under your kernel (probably 99% of your operating system) requires a set of link functions, porting the C library is your biggest task . The C library is a huge boulder, write your own Would be quite stupid, especially many implementations already available, the most famous is GCC. So, the question you should really ask is, do you want to write my own version of libc? (The answer is almost always no. Most alternative implementations are for niche use cases.) In addition, if you want to make your OS POSIX compatible, then you will have to implement more features, which increases the trouble.

Whether you write your own compiler for your own operating system is a subtle detail compared to the C library included in it. You can always use your own compiler with the C library implementation you have written.

My suggestion to your opinion-based question is: No. Port an existing compiler, such as GCC or clang, and use it. In addition, this has several advantages:

> Compatibility with existing tools and toolchains
>Familiar programs (users don’t need to learn how to use a new compiler)
>They are open source-though, you are not crazy at all. Oops, even if it is Apple integrated two existing compilers-GCC and clang-into their toolchain instead of doing it yourself, and they are a multi-billion dollar company.

Check out this page. It demonstrates how to use Newlib as a C library to port GCC to your operating system.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5361 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.