[bootlin/training-materials updates] master: Kernel slides: need CROSS_COMPILE at compile time now (a759b47d)
Thomas Petazzoni
thomas.petazzoni at bootlin.com
Fri Oct 29 10:46:37 CEST 2021
Repository : https://github.com/bootlin/training-materials
On branch : master
Link : https://github.com/bootlin/training-materials/commit/a759b47d702224a3335ede12e73343566ef78a1e
>---------------------------------------------------------------
commit a759b47d702224a3335ede12e73343566ef78a1e
Author: Michael Opdenacker <michael.opdenacker at bootlin.com>
Date: Thu May 6 12:21:26 2021 +0200
Kernel slides: need CROSS_COMPILE at compile time now
- Explain CROSS_COMPILE earlier
- Update overview diagram
Signed-off-by: Michael Opdenacker <michael.opdenacker at bootlin.com>
>---------------------------------------------------------------
a759b47d702224a3335ede12e73343566ef78a1e
.../kernel-building-overview.dia | Bin 2376 -> 2223 bytes
.../sysdev-kernel-building.tex | 137 +++++++++++----------
2 files changed, 70 insertions(+), 67 deletions(-)
diff --git a/slides/sysdev-kernel-building/kernel-building-overview.dia b/slides/sysdev-kernel-building/kernel-building-overview.dia
index eb2ef65d..23d06a60 100644
Binary files a/slides/sysdev-kernel-building/kernel-building-overview.dia and b/slides/sysdev-kernel-building/kernel-building-overview.dia differ
diff --git a/slides/sysdev-kernel-building/sysdev-kernel-building.tex b/slides/sysdev-kernel-building/sysdev-kernel-building.tex
index 83e68823..7c1e8920 100644
--- a/slides/sysdev-kernel-building/sysdev-kernel-building.tex
+++ b/slides/sysdev-kernel-building/sysdev-kernel-building.tex
@@ -21,6 +21,28 @@
\end{itemize}
\end{frame}
+\begin{frame}
+ \frametitle{Kernel configuration and build system}
+ \begin{itemize}
+ \item The kernel configuration and build system is based on multiple
+ Makefiles
+ \item One only interacts with the main \kfile{Makefile}, present at
+ the {\bf top directory} of the kernel source tree
+ \item Interaction takes place
+ \begin{itemize}
+ \item using the \code{make} tool, which parses the Makefile
+ \item through various {\bf targets}, defining which action should
+ be done (configuration, compilation, installation, etc.). Run
+ \code{make help} to see all available targets.
+ \end{itemize}
+ \item Example
+ \begin{itemize}
+ \item \code{cd linux-4.14.x/}
+ \item \code{make <target>}
+ \end{itemize}
+ \end{itemize}
+\end{frame}
+
\begin{frame}
\frametitle{Specifying the target architecture}
First, specify the architecture for the kernel to build
@@ -40,25 +62,56 @@
\end{itemize}
\end{frame}
+\begin{frame}[fragile]
+ \frametitle{Choose a compiler}
+ The compiler invoked by the kernel Makefile is \code{$(CROSS_COMPILE)gcc}
+ \begin{itemize}
+ \item Specifying the compiler is already needed at configuration
+ time, as some kernel configuration options depend on the
+ capabilities of the compiler.
+ \item When compiling natively
+ \begin{itemize}
+ \item Leave \code{CROSS_COMPILE} undefined and the kernel
+ will be natively compiled for the host architecture
+ using \code{gcc}.
+ \end{itemize}
+ \item When using a cross-compiler
+ \begin{itemize}
+ \item To make the difference with a native compiler, cross-compiler
+ executables are prefixed by the name of the target system,
+ architecture and sometimes library. Examples:\\
+ \small
+ \code{mips-linux-gcc}: the prefix is \code{mips-linux-}\\
+ \code{arm-linux-gnueabi-gcc}: the prefix is \code{arm-linux-gnueabi-}
+ \item So, you can specify your cross-compiler as follows:\\
+ \code{export CROSS_COMPILE=arm-linux-gnueabi-}
+ \end{itemize}
+ \end{itemize}
+ \code{CROSS_COMPILE} is actually the prefix of the cross compiling tools\\
+ (\code{gcc}, \code{as}, \code{ld}, \code{objcopy}, \code{strip}...).
+\end{frame}
+
\begin{frame}
- \frametitle{Kernel configuration and build system}
+ \frametitle{Specifying ARCH and CROSS\_COMPILE}
+ There are actually two ways of defining \code{ARCH} and \code{CROSS_COMPILE}:
\begin{itemize}
- \item The kernel configuration and build system is based on multiple
- Makefiles
- \item One only interacts with the main \kfile{Makefile}, present at
- the {\bf top directory} of the kernel source tree
- \item Interaction takes place
- \begin{itemize}
- \item using the \code{make} tool, which parses the Makefile
- \item through various {\bf targets}, defining which action should
- be done (configuration, compilation, installation, etc.). Run
- \code{make help} to see all available targets.
- \end{itemize}
- \item Example
- \begin{itemize}
- \item \code{cd linux-4.14.x/}
- \item \code{make <target>}
- \end{itemize}
+ \item Pass \code{ARCH} and \code{CROSS_COMPILE} on the \code{make}
+ command line: \\
+ \code{make ARCH=arm CROSS_COMPILE=arm-linux- ...} \\
+ Drawback: it is easy to forget to pass these variables when
+ you run any \code{make} command, causing your build and
+ configuration to be screwed up.
+ \item Define \code{ARCH} and \code{CROSS_COMPILE} as environment
+ variables: \\
+ \code{export ARCH=arm} \\
+ \code{export CROSS_COMPILE=arm-linux-} \\
+ Drawback: it only works inside the current
+ shell or terminal. You could put these settings in a file
+ that you source every time you start working on the project.
+ If you only work on a single architecture with always the
+ same toolchain, you could even put these settings in your
+ \code{~/.bashrc} file to make them permanent and visible from
+ any terminal.
\end{itemize}
\end{frame}
@@ -337,56 +390,6 @@ CONFIG_NTFS_RW=y
\subsection{Compiling and installing the kernel}
-\begin{frame}
- \frametitle{Choose a compiler}
- The compiler invoked by the kernel Makefile is \code{$(CROSS_COMPILE)gcc}
- \begin{itemize}
- \item When compiling natively
- \begin{itemize}
- \item Leave \code{CROSS_COMPILE} undefined and the kernel
- will be natively compiled for the host architecture
- using \code{gcc}.
- \end{itemize}
- \item When using a cross-compiler
- \begin{itemize}
- \item To make the difference with a native compiler, cross-compiler
- executables are prefixed by the name of the target system,
- architecture and sometimes library. Examples:\\
- \small
- \code{mips-linux-gcc}: the prefix is \code{mips-linux-}\\
- \code{arm-linux-gnueabi-gcc}: the prefix is \code{arm-linux-gnueabi-}
- \item So, you can specify your cross-compiler as follows:\\
- \code{export CROSS_COMPILE=arm-linux-gnueabi-}
- \end{itemize}
- \end{itemize}
- \code{CROSS_COMPILE} is actually the prefix of the cross compiling
-tools (\code{gcc}, \code{as}, \code{ld}, \code{objcopy}, \code{strip}...).
-\end{frame}
-
-\begin{frame}
- \frametitle{Specifying ARCH and CROSS\_COMPILE}
- There are actually two ways of defining \code{ARCH} and \code{CROSS_COMPILE}:
- \begin{itemize}
- \item Pass \code{ARCH} and \code{CROSS_COMPILE} on the \code{make}
- command line: \\
- \code{make ARCH=arm CROSS_COMPILE=arm-linux- ...} \\
- Drawback: it is easy to forget to pass these variables when
- you run any \code{make} command, causing your build and
- configuration to be screwed up.
- \item Define \code{ARCH} and \code{CROSS_COMPILE} as environment
- variables: \\
- \code{export ARCH=arm} \\
- \code{export CROSS_COMPILE=arm-linux-} \\
- Drawback: it only works inside the current
- shell or terminal. You could put these settings in a file
- that you source every time you start working on the project.
- If you only work on a single architecture with always the
- same toolchain, you could even put these settings in your
- \code{~/.bashrc} file to make them permanent and visible from
- any terminal.
- \end{itemize}
-\end{frame}
-
\begin{frame}[fragile]
\frametitle{Kernel compilation}
\begin{columns}
More information about the training-materials-updates
mailing list