Skip to contentSkip to conversation

kbuild: add debug package to pacman PKGBUILD

PATCH Superseded Jose Fernandez 4 participants 8 messages Aug 17, 2024 – Aug 24, 2024

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 kbuild: add debug package to pacman PKGBUILD

Add a new debug package to the PKGBUILD for the pacman-pkg target. The debug package includes the non-stripped vmlinux file, providing access to debug symbols needed for kernel debugging and profiling. The vmlinux file will be installed to /usr/src/debug/${pkgbase}. The debug package will be built by default and can be excluded by overriding PACMAN_EXTRAPACKAGES.

---
v1->v2:
- Use the new PACMAN_EXTRAPACKAGES [1] variable to allow users to disable the debug package if desired, instead of always including it.

[1] https://lore.kernel.org/lkml/20240813185900.GA140556@thelio-3990X/T/

 scripts/package/PKGBUILD | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
scripts/package/PKGBUILD +10 -1
index fbd7eb10a52c..d40d282353de 100644
@@ -5,7 +5,7 @@
 pkgbase=${PACMAN_PKGBASE:-linux-upstream}
 pkgname=("${pkgbase}")
 
-_extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers}
+_extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers debug}
 for pkg in $_extrapackages; do
 	pkgname+=("${pkgbase}-${pkg}")
 done
@@ -106,6 +106,15 @@ _package-api-headers() {
 	${MAKE} headers_install INSTALL_HDR_PATH="${pkgdir}/usr"
 }
 
+_package-debug(){
+	pkgdesc="Non-stripped vmlinux file for the ${pkgdesc} kernel"
+	depends=(${pkgbase}-headers)
+
+	cd "${objtree}"
+	mkdir -p "$pkgdir/usr/src/debug/${pkgbase}"
+	install -Dt "$pkgdir/usr/src/debug/${pkgbase}" -m644 vmlinux
+}
+
 for _p in "${pkgname[@]}"; do
 	eval "package_$_p() {
 		$(declare -f "_package${_p#$pkgbase}")

base-commit: 869679673d3bbaaf1c2a43dba53930f5241e1d30

Signature · 1 line
2.46.0
#1 lore raw
Quoted 34 lines · Jose Fernandez

Add a new debug package to the PKGBUILD for the pacman-pkg target. The debug package includes the non-stripped vmlinux file, providing access to debug symbols needed for kernel debugging and profiling. The vmlinux file will be installed to /usr/src/debug/${pkgbase}. The debug package will be built by default and can be excluded by overriding PACMAN_EXTRAPACKAGES.

---
v1->v2:
- Use the new PACMAN_EXTRAPACKAGES [1] variable to allow users to disable the debug package if desired, instead of always including it.

[1] https://lore.kernel.org/lkml/20240813185900.GA140556@thelio-3990X/T/

 scripts/package/PKGBUILD | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
scripts/package/PKGBUILD +1 -1
index fbd7eb10a52c..d40d282353de 100644
@@ -5,7 +5,7 @@
 pkgbase=${PACMAN_PKGBASE:-linux-upstream}
 pkgname=("${pkgbase}")
 
-_extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers}
+_extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers debug}
 for pkg in $_extrapackages; do
 	pkgname+=("${pkgbase}-${pkg}")
 done
@@ -106,6 +106,15 @@ _package-api-headers() {
 	${MAKE} headers_install INSTALL_HDR_PATH="${pkgdir}/usr"
 }

scripts/package/PKGBUILD _package-api-headers() { · line 117

Quoted 10 lines
scripts/package/PKGBUILD +9 -0
 
+_package-debug(){
+	pkgdesc="Non-stripped vmlinux file for the ${pkgdesc} kernel"
+	depends=(${pkgbase}-headers)
+
+	cd "${objtree}"
+	mkdir -p "$pkgdir/usr/src/debug/${pkgbase}"
+	install -Dt "$pkgdir/usr/src/debug/${pkgbase}" -m644 vmlinux
+}
+

If you like to also include debug stuff for kernel modules, you might want to have a look at scripts/package/builddeb's install_linux_image_dbg.

Kind regards,
Nicolas

#2 lore raw
Quoted 36 lines · Nicolas Schier
Quoted 35 lines · Jose Fernandez

Add a new debug package to the PKGBUILD for the pacman-pkg target. The debug package includes the non-stripped vmlinux file, providing access to debug symbols needed for kernel debugging and profiling. The vmlinux file will be installed to /usr/src/debug/${pkgbase}. The debug package will be built by default and can be excluded by overriding PACMAN_EXTRAPACKAGES.

---
v1->v2:
- Use the new PACMAN_EXTRAPACKAGES [1] variable to allow users to disable the debug package if desired, instead of always including it.

[1] https://lore.kernel.org/lkml/20240813185900.GA140556@thelio-3990X/T/

 scripts/package/PKGBUILD | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
scripts/package/PKGBUILD +1 -1
index fbd7eb10a52c..d40d282353de 100644
@@ -5,7 +5,7 @@
 pkgbase=${PACMAN_PKGBASE:-linux-upstream}
 pkgname=("${pkgbase}")
 
-_extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers}
+_extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers debug}
 for pkg in $_extrapackages; do
 	pkgname+=("${pkgbase}-${pkg}")
 done
@@ -106,6 +106,15 @@ _package-api-headers() {
 	${MAKE} headers_install INSTALL_HDR_PATH="${pkgdir}/usr"
 }
 
Quoted 12 lines

scripts/package/PKGBUILD _package-api-headers() { · line 117

Quoted 9 lines
scripts/package/PKGBUILD +9 -0
+_package-debug(){
+	pkgdesc="Non-stripped vmlinux file for the ${pkgdesc} kernel"
+	depends=(${pkgbase}-headers)
+
+	cd "${objtree}"
+	mkdir -p "$pkgdir/usr/src/debug/${pkgbase}"
+	install -Dt "$pkgdir/usr/src/debug/${pkgbase}" -m644 vmlinux
+}
+

If you like to also include debug stuff for kernel modules, you might want to have a look at scripts/package/builddeb's install_linux_image_dbg.

Hi Nicolas, thank you for the suggestion. I'll iterate on the debug stuff for kernel modules in a follow-up patch to keep this one focused on vmlinux.

#3 lore raw
In reply to Jose Fernandez
Quoted 32 lines · Jose Fernandez

Add a new debug package to the PKGBUILD for the pacman-pkg target. The debug package includes the non-stripped vmlinux file, providing access to debug symbols needed for kernel debugging and profiling. The vmlinux file will be installed to /usr/src/debug/${pkgbase}. The debug package will be built by default and can be excluded by overriding PACMAN_EXTRAPACKAGES.

---
v1->v2:
- Use the new PACMAN_EXTRAPACKAGES [1] variable to allow users to disable the debug package if desired, instead of always including it.

[1] https://lore.kernel.org/lkml/20240813185900.GA140556@thelio-3990X/T/

 scripts/package/PKGBUILD | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
scripts/package/PKGBUILD +1 -1
index fbd7eb10a52c..d40d282353de 100644
@@ -5,7 +5,7 @@
 pkgbase=${PACMAN_PKGBASE:-linux-upstream}
 pkgname=("${pkgbase}")
 
-_extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers}
+_extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers debug}
 for pkg in $_extrapackages; do
 	pkgname+=("${pkgbase}-${pkg}")
 done

scripts/package/PKGBUILD _package-api-headers() { · line 113

Quoted 8 lines
scripts/package/PKGBUILD +5 -0
@@ -106,6 +106,15 @@ _package-api-headers() {
 	${MAKE} headers_install INSTALL_HDR_PATH="${pkgdir}/usr"
 }
 
+_package-debug(){
+	pkgdesc="Non-stripped vmlinux file for the ${pkgdesc} kernel"
+	depends=(${pkgbase}-headers)
+
+	cd "${objtree}"

This should make use of _prologue() from
"kbuild: pacman-pkg: move common commands to a separate function"

https://lore.kernel.org/lkml/[email protected]/

It's not yet part of the kbuild tree, but I guess will be soon.

scripts/package/PKGBUILD _package-api-headers() { · line 114

Quoted 1 line
scripts/package/PKGBUILD +1 -0
+	mkdir -p "$pkgdir/usr/src/debug/${pkgbase}"

The mkdir shouldn't be necessary, as install -D is used.

scripts/package/PKGBUILD _package-api-headers() { · line 115

Quoted 1 line
scripts/package/PKGBUILD +1 -0
+	install -Dt "$pkgdir/usr/src/debug/${pkgbase}" -m644 vmlinux

Can you also add a symlink to /usr/lib/modules/$(uname -r)/build/vmlinux for compatibility with the vanilla package?

Quoted 10 lines
scripts/package/PKGBUILD +2 -0
+}
+
 for _p in "${pkgname[@]}"; do
 	eval "package_$_p() {
 		$(declare -f "_package${_p#$pkgbase}")

base-commit: 869679673d3bbaaf1c2a43dba53930f5241e1d30

Signature · 1 line
2.46.0
#4 lore raw
Quoted 45 lines · Thomas Weißschuh
Quoted 32 lines · Jose Fernandez

Add a new debug package to the PKGBUILD for the pacman-pkg target. The debug package includes the non-stripped vmlinux file, providing access to debug symbols needed for kernel debugging and profiling. The vmlinux file will be installed to /usr/src/debug/${pkgbase}. The debug package will be built by default and can be excluded by overriding PACMAN_EXTRAPACKAGES.

---
v1->v2:
- Use the new PACMAN_EXTRAPACKAGES [1] variable to allow users to disable the debug package if desired, instead of always including it.

[1] https://lore.kernel.org/lkml/20240813185900.GA140556@thelio-3990X/T/

 scripts/package/PKGBUILD | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
scripts/package/PKGBUILD +1 -1
index fbd7eb10a52c..d40d282353de 100644
@@ -5,7 +5,7 @@
 pkgbase=${PACMAN_PKGBASE:-linux-upstream}
 pkgname=("${pkgbase}")
 
-_extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers}
+_extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers debug}
 for pkg in $_extrapackages; do
 	pkgname+=("${pkgbase}-${pkg}")
 done

scripts/package/PKGBUILD _package-api-headers() { · line 113

Quoted 8 lines
scripts/package/PKGBUILD +5 -0
@@ -106,6 +106,15 @@ _package-api-headers() {
 	${MAKE} headers_install INSTALL_HDR_PATH="${pkgdir}/usr"
 }
 
+_package-debug(){
+	pkgdesc="Non-stripped vmlinux file for the ${pkgdesc} kernel"
+	depends=(${pkgbase}-headers)
+
+	cd "${objtree}"

This should make use of _prologue() from
"kbuild: pacman-pkg: move common commands to a separate function"

Quoted 3 lines

https://lore.kernel.org/lkml/[email protected]/

It's not yet part of the kbuild tree, but I guess will be soon.

Ack. I'll wait for that to be merged before I send out v3.

Quoted 5 lines

scripts/package/PKGBUILD _package-api-headers() { · line 114

Quoted 1 line
scripts/package/PKGBUILD +1 -0
+	mkdir -p "$pkgdir/usr/src/debug/${pkgbase}"

The mkdir shouldn't be necessary, as install -D is used.

scripts/package/PKGBUILD _package-api-headers() { · line 115

Quoted 1 line
scripts/package/PKGBUILD +1 -0
+	install -Dt "$pkgdir/usr/src/debug/${pkgbase}" -m644 vmlinux

I'll remove the mkdir line in v3.

Quoted 2 lines

Can you also add a symlink to /usr/lib/modules/$(uname -r)/build/vmlinux for compatibility with the vanilla package?

Yes, will do.

Quoted 10 lines
Quoted 10 lines
scripts/package/PKGBUILD +2 -0
+}
+
 for _p in "${pkgname[@]}"; do
 	eval "package_$_p() {
 		$(declare -f "_package${_p#$pkgbase}")

base-commit: 869679673d3bbaaf1c2a43dba53930f5241e1d30

Signature · 1 line
2.46.0
#5 lore raw
In reply to Jose Fernandez
Quoted 33 lines · Jose Fernandez

Add a new debug package to the PKGBUILD for the pacman-pkg target. The debug package includes the non-stripped vmlinux file, providing access to debug symbols needed for kernel debugging and profiling. The vmlinux file will be installed to /usr/src/debug/${pkgbase}. The debug package will be built by default and can be excluded by overriding PACMAN_EXTRAPACKAGES.

---
v1->v2:
- Use the new PACMAN_EXTRAPACKAGES [1] variable to allow users to disable the debug package if desired, instead of always including it.

[1] https://lore.kernel.org/lkml/20240813185900.GA140556@thelio-3990X/T/

 scripts/package/PKGBUILD | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
scripts/package/PKGBUILD +1 -1
index fbd7eb10a52c..d40d282353de 100644
@@ -5,7 +5,7 @@
 pkgbase=${PACMAN_PKGBASE:-linux-upstream}
 pkgname=("${pkgbase}")
 
-_extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers}
+_extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers debug}
 for pkg in $_extrapackages; do
        pkgname+=("${pkgbase}-${pkg}")
 done

scripts/package/PKGBUILD _package-api-headers() { · line 111

Quoted 6 lines
scripts/package/PKGBUILD +3 -0
@@ -106,6 +106,15 @@ _package-api-headers() {
        ${MAKE} headers_install INSTALL_HDR_PATH="${pkgdir}/usr"
 }
 
+_package-debug(){
+       pkgdesc="Non-stripped vmlinux file for the ${pkgdesc} kernel"
+       depends=(${pkgbase}-headers)

Why is this dependency necessary?

Quoted 15 lines
scripts/package/PKGBUILD +6 -0
+
+       cd "${objtree}"
+       mkdir -p "$pkgdir/usr/src/debug/${pkgbase}"
+       install -Dt "$pkgdir/usr/src/debug/${pkgbase}" -m644 vmlinux
+}
+
 for _p in "${pkgname[@]}"; do
        eval "package_$_p() {
                $(declare -f "_package${_p#$pkgbase}")

base-commit: 869679673d3bbaaf1c2a43dba53930f5241e1d30 --
2.46.0

Signature · 2 lines
Best Regards
Masahiro Yamada
#6 lore raw
Quoted 38 lines · Masahiro Yamada
Quoted 36 lines · Jose Fernandez

Add a new debug package to the PKGBUILD for the pacman-pkg target. The debug package includes the non-stripped vmlinux file, providing access to debug symbols needed for kernel debugging and profiling. The vmlinux file will be installed to /usr/src/debug/${pkgbase}. The debug package will be built by default and can be excluded by overriding PACMAN_EXTRAPACKAGES.

---
v1->v2:
- Use the new PACMAN_EXTRAPACKAGES [1] variable to allow users to disable the debug package if desired, instead of always including it.

[1] https://lore.kernel.org/lkml/20240813185900.GA140556@thelio-3990X/T/

 scripts/package/PKGBUILD | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
scripts/package/PKGBUILD +1 -1
index fbd7eb10a52c..d40d282353de 100644
@@ -5,7 +5,7 @@
 pkgbase=${PACMAN_PKGBASE:-linux-upstream}
 pkgname=("${pkgbase}")
 
-_extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers}
+_extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers debug}
 for pkg in $_extrapackages; do
        pkgname+=("${pkgbase}-${pkg}")
 done
@@ -106,6 +106,15 @@ _package-api-headers() {
        ${MAKE} headers_install INSTALL_HDR_PATH="${pkgdir}/usr"
 }
 
Quoted 7 lines

scripts/package/PKGBUILD _package-api-headers() { · line 111

Quoted 3 lines
scripts/package/PKGBUILD +3 -0
+_package-debug(){
+       pkgdesc="Non-stripped vmlinux file for the ${pkgdesc} kernel"
+       depends=(${pkgbase}-headers)

Why is this dependency necessary?

Hi Masahiro,
My thinking was that you may need System.map in combination with vmlinux for debugging with tools like crash. I don't have a strong opinions on this, so I'm I can remove it if you or others think it's not necessary.

Quoted 20 lines
Quoted 15 lines
scripts/package/PKGBUILD +6 -0
+
+       cd "${objtree}"
+       mkdir -p "$pkgdir/usr/src/debug/${pkgbase}"
+       install -Dt "$pkgdir/usr/src/debug/${pkgbase}" -m644 vmlinux
+}
+
 for _p in "${pkgname[@]}"; do
        eval "package_$_p() {
                $(declare -f "_package${_p#$pkgbase}")

base-commit: 869679673d3bbaaf1c2a43dba53930f5241e1d30 --
2.46.0

Signature · 2 lines
Best Regards
Masahiro Yamada
#7 lore raw
Quoted 47 lines · Jose Fernandez
Quoted 38 lines · Masahiro Yamada
Quoted 36 lines · Jose Fernandez

Add a new debug package to the PKGBUILD for the pacman-pkg target. The debug package includes the non-stripped vmlinux file, providing access to debug symbols needed for kernel debugging and profiling. The vmlinux file will be installed to /usr/src/debug/${pkgbase}. The debug package will be built by default and can be excluded by overriding PACMAN_EXTRAPACKAGES.

---
v1->v2:
- Use the new PACMAN_EXTRAPACKAGES [1] variable to allow users to disable the debug package if desired, instead of always including it.

[1] https://lore.kernel.org/lkml/20240813185900.GA140556@thelio-3990X/T/

 scripts/package/PKGBUILD | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
scripts/package/PKGBUILD +1 -1
index fbd7eb10a52c..d40d282353de 100644
@@ -5,7 +5,7 @@
 pkgbase=${PACMAN_PKGBASE:-linux-upstream}
 pkgname=("${pkgbase}")
 
-_extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers}
+_extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers debug}
 for pkg in $_extrapackages; do
        pkgname+=("${pkgbase}-${pkg}")
 done
@@ -106,6 +106,15 @@ _package-api-headers() {
        ${MAKE} headers_install INSTALL_HDR_PATH="${pkgdir}/usr"
 }
 
Quoted 7 lines

scripts/package/PKGBUILD _package-api-headers() { · line 111

Quoted 3 lines
scripts/package/PKGBUILD +3 -0
+_package-debug(){
+       pkgdesc="Non-stripped vmlinux file for the ${pkgdesc} kernel"
+       depends=(${pkgbase}-headers)

Why is this dependency necessary?

Quoted 4 lines

Hi Masahiro,
My thinking was that you may need System.map in combination with vmlinux for debugging with tools like crash. I don't have a strong opinions on this, so I'm I can remove it if you or others think it's not necessary.

It is better to not add unnecessary code.

Signature · 2 lines
Best Regards
Masahiro Yamada