Article title: kernel research: CLFS2.0 principle analysis. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Preface:
In fact, when I first saw CLFS2.0 two or three weeks ago, I felt similar and uncomfortable, so I only saw the compilation of two or three packages after the toolchain was completed, and I felt like I understood the principle, because I tried the CLFS2.0 production method myself, at that time, I wanted to develop a method different from the LFS method to build the system. although some achievements were made at that time, but I felt unsuccessful (the most important thing was that I didn't know the -- with-sysroot parameter at the time), but there were also a lot of gains, and I thought I was not wrong at the time, in my previous two articles, "LFS with small size and single function" and "LFS reverse analysis", we can see the shadows of this method, the subsequent package production method is similar to the packaging method in the package manager, so I feel that the CLFS2.0 method is not only suitable for cross compilation, it is also applicable in the case of non-crossover.
I will summarize my understanding of the CLFS2.0 method below. I hope my friends who are interested in CLFS will be helpful, at the same time, I added the PowerPC and MIPS tool chain parts I made based on CLFS2.0's principles. However, due to limitations in capabilities and understanding, there will inevitably be errors. I hope that you will promptly raise the issue after discovering it, for timely modification. thank you.
Update: Due to the long length, it is inevitable that some errors or misoperations may occur and new content may be added. Therefore, it is inevitable that some content will be modified or deleted, if this article has been reproduced or you find that it has been updated for a long time, you can check the latest version in LFS of www.linuxsir.org or in your Blog.
Linuxsir:Http://www.linuxsir.org/bbs/showthread.php? T = 267672
My Blog:Http://youbest.cublog.cn
If this document must be reproduced, please indicate that the author is chongtianfeibao (youbest) and provide the source for reprinting.
Good start:
Environment variables are set to be common for subsequent compilation parameters, which facilitates input and is not prone to errors.
Note that
Cat> ~ /. Bashrc <"EOF"
Set + h
Umask 022
CLFS =/mnt/clfs
LC_ALL = POSIX
PATH =$ {CLFS}/cross-tools/bin:/usr/bin
Export CLFS LC_ALL PATH
EOF
This PATH setting remains unchanged until the production process ends. this is different from LFS's use of different paths in Chapter 5 and Chapter 6. this question will be answered later in the article.
Another important setting is
Export CLFS_HOST = "$ (echo $ MACHTYPE | sed" s/$ (echo $ MACHTYPE | cut-d--f2)/cross /")"
Export CLFS_TARGET = "arm-unknown-linux-gnu"
This setting will be different for different system platforms. the appendix of the article contains the definition of the other two system platforms.
Note: For the time being, we refer to Chapter 5 of CLFS2.0 as the cross tool chain and Chapter 6 as the target system platform.
Sysroot parameter in CLFS2.0
The sysroot parameter appears three times in total, but the usage of these three times completely changes the previous method for creating a complete tool chain.
The purpose of sysroot is actually very simple:
The directory specified by -- with-sysroot is used as the root directory.
We will see in the article how sysroot is used to achieve the goal.
Analysis start:
First, copy some header files to usr/include in $ {CLFS}. this step seems to be no different from the previous one, but I personally think it is a step shorter, add a sentence before copying.
Code:
make include/linux/version.h
Next, we will install binutils. this package aims to connect the target file to an executable file, so when we compile binutils for the first time, we will start to use the "magic" parameter -- with-sysroot.
../Binutils-2.17/configure -- prefix =$ {CLFS}/cross-tools \
-- Host =$ {CLFS_HOST} -- target =$ {CLFS_TARGET} -- with-sysroot =$ {CLFS }\
-- Disable-nls -- enable-shared -- disable-multilib
It is understood from the parameter that binutls will be installed in $ {CLFS}/cross-tools (-- prefix =$ {CLFS}/cross-tools ), the compiled binary file runs on the platform specified by $ {CLFS_HOST} (-- host =$ {CLFS_HOST }), the connected executable file runs on the platform specified by $ {CLFS_TARGET} (-- target =$ {CLFS_TARGET}) to shield international support (-- disable-nls ), the shared link library (-- enable-shared) is compiled at the same time, and multiple architecture libraries (-- disable-multilib) are not supported ), use the directory defined by $ {CLFS} as the root directory (-- with-sysroot)
The subsequent make configure-host should not be missing, so that you can use the parameters set earlier to fully configure all the parts to be compiled in binutils.
Binutils is compiled using binutils and gcc of the main system. the main system is in the i386 structure. Therefore, this time weThe compiled binutils is compiled using the tool chain of the main system, and the compiled program runs on i386..
This section is illustrated below
Screen. width-300) {this. width = screen. width-300; this. alt = '��������������������������������������;} "border = 0>
As we can see, in fact, the binutils compilation process does not use the kernel header file of the target system, so it does not matter to copy the kernel's target system header file and compile the binutils sequence.
[1] [2] [3] [4] [5] [6] [7] [8] Next page