We must build from source as our OS does not have a package manager.
configure
- will create a Makefile based off of user input. Checks for appropriate dependancies and compilers.make
- calls compilers and complies the code.make install
- copies compiled binaries to correct location
Bootstrapping is essentially using host OS tools (without creating dependancies on the host) to create a temporary toolchain in the LFS env. This allows us to use a temporary toolchain to build our OS.
Why is bin-utils installed first? It creates some things we need such as the assember to create the executable and ldd which links to libc.so. Bin-utils is needed to compile the compiler.
How C compilation works?
- Dumps all of c header files into <program_name>.i file
- Compiler converts the <program_name>.i file to assembly
- bin-utils provides an assembler used to convert assembly to binary or <program_name>.o
- bin-utils utility ld or linker to convert object file into an executable format <program_name>.o a. Check the os and links shared lib to the a.o b. in LFS libc.so which is provided by glibc
- libc.so is needed or is considered a dependancy on disk
This is why you can't run on windows. <program_file>.o is relocatable and ldd has not made libc.so a dependancy. This can be copied and run after particular libray is avaiable on disk provided by the OS. In linux this is glibc but windows or other OS's can provide there own.
- API - is a set of structured functions that can be consumed from an application
- Linux Kernel handles the inner hardware
- glibc interacts with the kernel through system calls
- This has to be exposed through API (Header files are the Linux API)
- Provides the list of shared libraries
- libc.so is included
- provides basic system routines (memory, pattern matching, etc.)
- Works very closely with kernel
- System calls all go through glibc even though they are implemented by the kernel