Skip to contentSkip to conversation

scripts: Explain the difference between linux-headers and standard-headers

PATCH Applied Peter Maydell 5 participants 6 messages Dec 9, 2021 – Jan 28, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 scripts: Explain the difference between linux-headers and standard-headers

If you don't know it, it's hard to figure out the difference between the linux-headers folder and the include/standard-headers folder. So let's add a short explanation to clarify the difference.

---
v1 of this was from Thomas; I suggested some expanded wording and since that made the patch pretty much entirely my text Thomas suggested I send this under my name.

---
 scripts/update-linux-headers.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
scripts/update-linux-headers.sh +16 -0
index fea4d6eb655..d23851e1d3b 100755
@@ -9,6 +9,22 @@
 #
 # This work is licensed under the terms of the GNU GPL version 2.
 # See the COPYING file in the top-level directory.
+#
+# The script will copy the headers into two target folders:
+#
+# - linux-headers/ for files that are required for compiling on a
+#   Linux host.  Generally we have these so we can use kernel structs
+#   and defines that are more recent than the headers that might be
+#   in /usr/include/linux on the host system.  Usually this script
+#   can do simple file copies for these headers.
+#
+# - include/standard-headers/ for files that are used for guest
+#   device emulation and are required on all hosts.  For instance, we
+#   get our definitions of the virtio structures from the Linux
+#   kernel headers, but we need those definitions regardless of which
+#   host OS we are building on.  This script has to be careful to
+#   sanitize the headers to remove any use of Linux-specifics such as
+#   types like "__u64".  This work is done in the cp_portable function.
 
 tmpdir=$(mktemp -d)
 linux="$1"
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 28 lines · Peter Maydell

If you don't know it, it's hard to figure out the difference between the linux-headers folder and the include/standard-headers folder. So let's add a short explanation to clarify the difference.

---
v1 of this was from Thomas; I suggested some expanded wording and since that made the patch pretty much entirely my text Thomas suggested I send this under my name.

---
  scripts/update-linux-headers.sh | 16 ++++++++++++++++
  1 file changed, 16 insertions(+)
scripts/update-linux-headers.sh +6 -0
index fea4d6eb655..d23851e1d3b 100755
@@ -9,6 +9,22 @@
  #
  # This work is licensed under the terms of the GNU GPL version 2.
  # See the COPYING file in the top-level directory.
+#
+# The script will copy the headers into two target folders:
+#
+# - linux-headers/ for files that are required for compiling on a
+#   Linux host.  Generally we have these so we can use kernel structs
+#   and defines that are more recent than the headers that might be

scripts/update-linux-headers.sh line 27

Quoted 10 lines
scripts/update-linux-headers.sh +10 -0
+#   in /usr/include/linux on the host system.  Usually this script
+#   can do simple file copies for these headers.
+#
+# - include/standard-headers/ for files that are used for guest
+#   device emulation and are required on all hosts.  For instance, we
+#   get our definitions of the virtio structures from the Linux
+#   kernel headers, but we need those definitions regardless of which
+#   host OS we are building on.  This script has to be careful to
+#   sanitize the headers to remove any use of Linux-specifics such as
+#   types like "__u64".  This work is done in the cp_portable function.

Thanks!

Reviewed-by on v2 1/1
#2 lore raw
In reply to Peter Maydell
Quoted 6 lines · Peter Maydell

If you don't know it, it's hard to figure out the difference between the linux-headers folder and the include/standard-headers folder. So let's add a short explanation to clarify the difference.

Quoted 7 lines

---
v1 of this was from Thomas; I suggested some expanded wording and since that made the patch pretty much entirely my text Thomas suggested I send this under my name.

---
 scripts/update-linux-headers.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
#3 lore raw
In reply to Peter Maydell
Quoted 6 lines · Peter Maydell

If you don't know it, it's hard to figure out the difference between the linux-headers folder and the include/standard-headers folder. So let's add a short explanation to clarify the difference.

A couple of minor tweaks: what matters is which platform we are building for I think.

Quoted 13 lines

---
v1 of this was from Thomas; I suggested some expanded wording and since that made the patch pretty much entirely my text Thomas suggested I send this under my name.

---
 scripts/update-linux-headers.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
scripts/update-linux-headers.sh +0 -0
index fea4d6eb655..d23851e1d3b 100755

scripts/update-linux-headers.sh line 15

Quoted 7 lines
scripts/update-linux-headers.sh +4 -0
@@ -9,6 +9,22 @@
 #
 # This work is licensed under the terms of the GNU GPL version 2.
 # See the COPYING file in the top-level directory.
+#
+# The script will copy the headers into two target folders:
+#
+# - linux-headers/ for files that are required for compiling on a

I think it's more of a "for a Linux host"

scripts/update-linux-headers.sh

Quoted 3 lines
scripts/update-linux-headers.sh +3 -0
+#   Linux host.  Generally we have these so we can use kernel structs
+#   and defines that are more recent than the headers that might be
+#   in /usr/include/linux 

I'd just say "installed". Path does not matter.

scripts/update-linux-headers.sh

Quoted 8 lines

on the host system. Usually this script

scripts/update-linux-headers.sh +7 -0
+#   can do simple file copies for these headers.
+#
+# - include/standard-headers/ for files that are used for guest
+#   device emulation and are required on all hosts.  For instance, we
+#   get our definitions of the virtio structures from the Linux
+#   kernel headers, but we need those definitions regardless of which
+#   host OS we are building on.

we are building for

Quoted 8 lines

This script has to be careful to

scripts/update-linux-headers.sh +2 -0
+#   sanitize the headers to remove any use of Linux-specifics such as
+#   types like "__u64".  This work is done in the cp_portable function.
 
 tmpdir=$(mktemp -d)
 linux="$1"
Signature · 1 line
2.25.1
author Applied
#5 lore raw
In reply to Peter Maydell
Quoted 11 lines · Peter Maydell

If you don't know it, it's hard to figure out the difference between the linux-headers folder and the include/standard-headers folder. So let's add a short explanation to clarify the difference.

---
v1 of this was from Thomas; I suggested some expanded wording and since that made the patch pretty much entirely my text Thomas suggested I send this under my name.

Applied to target-arm.next with the minor tweaks MST suggested applied.

thanks
-- PMM