Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Following are the steps to build GCC..
1. Build binutils
2. Build gcc
3. Build C-library
4. Again Build GCC
My qestions:
1. Why we build gcc twice, before and after c-library?
2. Why exactly we need C-Library especially if we are building toolchain for non-OS like arm-none-eabi??
This looks somewhat similar to the way LFS builds its toolchain. You start by building a statically linked gcc and binutils. The --with-newlib option tells the compiler not to use your host's libc. You use the new tools to build libc, then rebuild gcc to link to it. In LFS, you do that with binutils too.
You might like to compare with the Cross-LFS book at http://trac.clfs.org/wiki/read#CLFS3.0.0. I couldn't find a version of this book for ARM, but any of the versions will give you a general idea of how CLFS does it and why.
You need a C library on any system, whatever kind of processor you are using. It's the one library that every program needs to use.
@Hazel, thank you so much for your kind reply. Let me explain what i understood from your answer.
We build GCC without any library, than using this newly build compiler to build c library. Then we build gcc again to link recently build c library to gcc.
BUT again:
Can you please explain a little bit how every C program uses C library?? What it offers to every program??
As far as i know only runtime library is required for every program which provide starup code for program... while the library we link is standard library. So how every program needs it?
It would be very hard to write a program that didn't use the standard C library! libc provides:
1) All the functions for input and output (screen, keyboard or files)
2) All the arithmetic functions
3) Functions for opening and closing files and using directories
4) Functions for handling time differences
5) Functions for handling character sets in different languages
6) Functions for communicating with the kernel (system calls) and with other processes
It would be very hard to write a program that didn't use the standard C library! libc provides:
1) All the functions for input and output (screen, keyboard or files)
2) All the arithmetic functions
3) Functions for opening and closing files and using directories
4) Functions for handling time differences
5) Functions for handling character sets in different languages
6) Functions for communicating with the kernel (system calls) and with other processes
Thanks Hazel. It means the data types are also defined by C library?? And arent there special instructions for arithematic operation like ADD, MUL, SUB. Which are independent of C library.
Thanks Hazel. It means the data types are also defined by C library?? And arent there special instructions for arithematic operation like ADD, MUL, SUB. Which are independent of C library.
Basic data types like int, float and char are defined by the C language. The language also provides standard arithmetical operators like +, -, * and /. But all mathematical functions (trigonometry, logs, square roots and so on) come from the math library which is part of libc.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.