Skip to contentSkip to conversation

kernel: provide module.lds for out of tree builds in v5.10+

PATCH Superseded Bruce Ashfield 3 participants 9 messages Nov 13, 2020 – Nov 16, 2020 2 messages not in the archive

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel: provide module.lds for out of tree builds in v5.10+

From: Bruce Ashfield <[email protected]>

The upstream commit 596b0474d3d [kbuild: preprocess module linker script], adds a dependency on module.lds for external module building.

Since module.lds is generated as part of 'modules_prepare', we must make it available with the other kernel artifacts in the kernel shared workdir, otherwise out of tree builds fail.

This fixes errors like:

    | make[4]: *** No rule to make target 'scripts/module.lds', needed by
        'build/tmp/work/qemuarm64-poky-linux/cryptodev-module/1.11-r0/git/cryptodev.ko'.
        Stop.
    | make[4]: *** Waiting for unfinished jobs....

We also ensure that kernel-devsrc has a copy to support on target module builds that are often prepared with 'make scripts prepare'. Those targets won't regenerate it, so the build fails. If 'make modules_prepare' is used, the file will be regenerated and overwrite our copy (as expected).

---
 meta/classes/kernel.bbclass                | 1 +
 meta/recipes-kernel/linux/kernel-devsrc.bb | 6 ++++++
 2 files changed, 7 insertions(+)
meta/classes/kernel.bbclass +1 -0
index be93a258f6..ccd74e61e8 100644
@@ -494,6 +494,7 @@ do_shared_workdir () {
 	# Copy files required for module builds
 	cp System.map $kerneldir/System.map-${KERNEL_VERSION}
 	[ -e Module.symvers ] && cp Module.symvers $kerneldir/
+	[ -e scripts/module.lds ] && install -Dm 0644 scripts/module.lds $kerneldir/scripts/module.lds
 	cp .config $kerneldir/
 	mkdir -p $kerneldir/include/config
 	cp include/config/kernel.release $kerneldir/include/config/kernel.release
meta/recipes-kernel/linux/kernel-devsrc.bb +6 -0
index 81b1e36041..5f0dedbdf7 100644
@@ -100,6 +100,12 @@ do_install() {
 	# be dealt with.
 	# cp -a scripts $kerneldir/build
 
+	# although module.lds can be regenerated on target via 'make modules_prepare'
+	# there are several places where 'makes scripts prepare' is done, and that won't
+	# regenerate the file. So we copy it onto the target as a migration to using
+	# modules_prepare
+	cp -a --parents scripts/module.lds $kerneldir/build/ 2>/dev/null || :
+
         if [ -d arch/${ARCH}/scripts ]; then
 	    cp -a arch/${ARCH}/scripts $kerneldir/build/arch/${ARCH}
 	fi
Signature · 1 line
2.19.1
Tested-by on v1 1/1
#1 lore raw

Thanks, works for me building external kernel modules.

Quoted 23 lines · Bruce Ashfield

From: Bruce Ashfield <[email protected]>

The upstream commit 596b0474d3d [kbuild: preprocess module linker script], adds a dependency on module.lds for external module building.

Since module.lds is generated as part of 'modules_prepare', we must make it available with the other kernel artifacts in the kernel shared workdir, otherwise out of tree builds fail.

This fixes errors like:

    | make[4]: *** No rule to make target 'scripts/module.lds', needed by
        'build/tmp/work/qemuarm64-poky-linux/cryptodev-module/1.11-r0/git/cryptodev.ko'.
        Stop.
    | make[4]: *** Waiting for unfinished jobs....

We also ensure that kernel-devsrc has a copy to support on target module builds that are often prepared with 'make scripts prepare'. Those targets won't regenerate it, so the build fails. If 'make modules_prepare' is used, the file will be regenerated and overwrite our copy (as expected).

Quoted 3 lines
Quoted 37 lines
---
 meta/classes/kernel.bbclass                | 1 +
 meta/recipes-kernel/linux/kernel-devsrc.bb | 6 ++++++
 2 files changed, 7 insertions(+)
meta/classes/kernel.bbclass +1 -0
index be93a258f6..ccd74e61e8 100644
@@ -494,6 +494,7 @@ do_shared_workdir () {
 	# Copy files required for module builds
 	cp System.map $kerneldir/System.map-${KERNEL_VERSION}
 	[ -e Module.symvers ] && cp Module.symvers $kerneldir/
+	[ -e scripts/module.lds ] && install -Dm 0644 scripts/module.lds $kerneldir/scripts/module.lds
 	cp .config $kerneldir/
 	mkdir -p $kerneldir/include/config
 	cp include/config/kernel.release $kerneldir/include/config/kernel.release
meta/recipes-kernel/linux/kernel-devsrc.bb +6 -0
index 81b1e36041..5f0dedbdf7 100644
@@ -100,6 +100,12 @@ do_install() {
 	# be dealt with.
 	# cp -a scripts $kerneldir/build
 
+	# although module.lds can be regenerated on target via 'make modules_prepare'
+	# there are several places where 'makes scripts prepare' is done, and that won't
+	# regenerate the file. So we copy it onto the target as a migration to using
+	# modules_prepare
+	cp -a --parents scripts/module.lds $kerneldir/build/ 2>/dev/null || :
+
         if [ -d arch/${ARCH}/scripts ]; then
 	    cp -a arch/${ARCH}/scripts $kerneldir/build/arch/${ARCH}
 	fi
#2 lore raw

Sorry, spoke too soon.  Doesn't seem to work from a clean build now.

Quoted 68 lines · Scott Branden

Thanks, works for me building external kernel modules.

Quoted 23 lines · Bruce Ashfield

From: Bruce Ashfield <[email protected]>

The upstream commit 596b0474d3d [kbuild: preprocess module linker script], adds a dependency on module.lds for external module building.

Since module.lds is generated as part of 'modules_prepare', we must make it available with the other kernel artifacts in the kernel shared workdir, otherwise out of tree builds fail.

This fixes errors like:

    | make[4]: *** No rule to make target 'scripts/module.lds', needed by
        'build/tmp/work/qemuarm64-poky-linux/cryptodev-module/1.11-r0/git/cryptodev.ko'.
        Stop.
    | make[4]: *** Waiting for unfinished jobs....

We also ensure that kernel-devsrc has a copy to support on target module builds that are often prepared with 'make scripts prepare'. Those targets won't regenerate it, so the build fails. If 'make modules_prepare' is used, the file will be regenerated and overwrite our copy (as expected).

Quoted 3 lines
Quoted 37 lines
---
 meta/classes/kernel.bbclass                | 1 +
 meta/recipes-kernel/linux/kernel-devsrc.bb | 6 ++++++
 2 files changed, 7 insertions(+)
meta/classes/kernel.bbclass +1 -0
index be93a258f6..ccd74e61e8 100644
@@ -494,6 +494,7 @@ do_shared_workdir () {
 	# Copy files required for module builds
 	cp System.map $kerneldir/System.map-${KERNEL_VERSION}
 	[ -e Module.symvers ] && cp Module.symvers $kerneldir/
+	[ -e scripts/module.lds ] && install -Dm 0644 scripts/module.lds $kerneldir/scripts/module.lds
 	cp .config $kerneldir/
 	mkdir -p $kerneldir/include/config
 	cp include/config/kernel.release $kerneldir/include/config/kernel.release
meta/recipes-kernel/linux/kernel-devsrc.bb +6 -0
index 81b1e36041..5f0dedbdf7 100644
@@ -100,6 +100,12 @@ do_install() {
 	# be dealt with.
 	# cp -a scripts $kerneldir/build
 
+	# although module.lds can be regenerated on target via 'make modules_prepare'
+	# there are several places where 'makes scripts prepare' is done, and that won't
+	# regenerate the file. So we copy it onto the target as a migration to using
+	# modules_prepare
+	cp -a --parents scripts/module.lds $kerneldir/build/ 2>/dev/null || :
+
         if [ -d arch/${ARCH}/scripts ]; then
 	    cp -a arch/${ARCH}/scripts $kerneldir/build/arch/${ARCH}
 	fi
#3 lore raw
Quoted 3 lines · Scott Branden

Sorry, spoke too soon. Doesn't seem to work from a clean build now.

How so ? Works on repeated clean builds here. For 5.4/5.8 and 5.10

Bruce

Quoted 75 lines · Scott Branden

Thanks, works for me building external kernel modules.

On 2020-11-12 10:32 p.m., Bruce Ashfield wrote:

From: Bruce Ashfield <[email protected]>

The upstream commit 596b0474d3d [kbuild: preprocess module linker script], adds a dependency on module.lds for external module building.

Since module.lds is generated as part of 'modules_prepare', we must make it available with the other kernel artifacts in the kernel shared workdir, otherwise out of tree builds fail.

This fixes errors like:

    | make[4]: *** No rule to make target 'scripts/module.lds', needed by
        'build/tmp/work/qemuarm64-poky-linux/cryptodev-module/1.11-r0/git/cryptodev.ko'.
        Stop.
    | make[4]: *** Waiting for unfinished jobs....

We also ensure that kernel-devsrc has a copy to support on target module builds that are often prepared with 'make scripts prepare'. Those targets won't regenerate it, so the build fails. If 'make modules_prepare' is used, the file will be regenerated and overwrite our copy (as expected).

---
 meta/classes/kernel.bbclass                | 1 +
 meta/recipes-kernel/linux/kernel-devsrc.bb | 6 ++++++
 2 files changed, 7 insertions(+)
meta/classes/kernel.bbclass +1 -0
index be93a258f6..ccd74e61e8 100644
@@ -494,6 +494,7 @@ do_shared_workdir () {
  # Copy files required for module builds
  cp System.map $kerneldir/System.map-${KERNEL_VERSION}
  [ -e Module.symvers ] && cp Module.symvers $kerneldir/
+ [ -e scripts/module.lds ] && install -Dm 0644 scripts/module.lds $kerneldir/scripts/module.lds
  cp .config $kerneldir/
  mkdir -p $kerneldir/include/config
  cp include/config/kernel.release $kerneldir/include/config/kernel.release
meta/recipes-kernel/linux/kernel-devsrc.bb +6 -0
index 81b1e36041..5f0dedbdf7 100644
@@ -100,6 +100,12 @@ do_install() {
  # be dealt with.
  # cp -a scripts $kerneldir/build
 
+ # although module.lds can be regenerated on target via 'make modules_prepare'
+ # there are several places where 'makes scripts prepare' is done, and that won't
+ # regenerate the file. So we copy it onto the target as a migration to using
+ # modules_prepare
+ cp -a --parents scripts/module.lds $kerneldir/build/ 2>/dev/null || :
+
         if [ -d arch/${ARCH}/scripts ]; then
     cp -a arch/${ARCH}/scripts $kerneldir/build/arch/${ARCH}
  fi
Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw
Quoted 9 lines · Bruce Ashfield via lists.openembedded.org
Quoted 3 lines · Scott Branden

Sorry, spoke too soon. Doesn't seem to work from a clean build now.

How so ? Works on repeated clean builds here. For 5.4/5.8 and 5.10

I have a theory on this. Did you directly bitbake your external module ? versus building the kernel first and then the module ?

I'll see what I can come up with.

Bruce

Quoted 86 lines

Bruce

Quoted 65 lines · Scott Branden

Thanks, works for me building external kernel modules.

On 2020-11-12 10:32 p.m., Bruce Ashfield wrote:

From: Bruce Ashfield <[email protected]>

The upstream commit 596b0474d3d [kbuild: preprocess module linker script], adds a dependency on module.lds for external module building.

Since module.lds is generated as part of 'modules_prepare', we must make it available with the other kernel artifacts in the kernel shared workdir, otherwise out of tree builds fail.

This fixes errors like:

    | make[4]: *** No rule to make target 'scripts/module.lds', needed by
        'build/tmp/work/qemuarm64-poky-linux/cryptodev-module/1.11-r0/git/cryptodev.ko'.
        Stop.
    | make[4]: *** Waiting for unfinished jobs....

We also ensure that kernel-devsrc has a copy to support on target module builds that are often prepared with 'make scripts prepare'. Those targets won't regenerate it, so the build fails. If 'make modules_prepare' is used, the file will be regenerated and overwrite our copy (as expected).

---
 meta/classes/kernel.bbclass                | 1 +
 meta/recipes-kernel/linux/kernel-devsrc.bb | 6 ++++++
 2 files changed, 7 insertions(+)
meta/classes/kernel.bbclass +1 -0
index be93a258f6..ccd74e61e8 100644
@@ -494,6 +494,7 @@ do_shared_workdir () {
  # Copy files required for module builds
  cp System.map $kerneldir/System.map-${KERNEL_VERSION}
  [ -e Module.symvers ] && cp Module.symvers $kerneldir/
+ [ -e scripts/module.lds ] && install -Dm 0644 scripts/module.lds $kerneldir/scripts/module.lds
  cp .config $kerneldir/
  mkdir -p $kerneldir/include/config
  cp include/config/kernel.release $kerneldir/include/config/kernel.release
meta/recipes-kernel/linux/kernel-devsrc.bb +0 -0
index 81b1e36041..5f0dedbdf7 100644
@@ -100,6 +100,12 @@ do_install() {
  # be dealt with.
  # cp -a scripts $kerneldir/build

meta/recipes-kernel/linux/kernel-devsrc.bb do_install() { · line 111

Quoted 10 lines
meta/recipes-kernel/linux/kernel-devsrc.bb +6 -0
 
+ # although module.lds can be regenerated on target via 'make modules_prepare'
+ # there are several places where 'makes scripts prepare' is done, and that won't
+ # regenerate the file. So we copy it onto the target as a migration to using
+ # modules_prepare
+ cp -a --parents scripts/module.lds $kerneldir/build/ 2>/dev/null || :
+
         if [ -d arch/${ARCH}/scripts ]; then
     cp -a arch/${ARCH}/scripts $kerneldir/build/arch/${ARCH}
  fi

--
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end
- "Use the force Harry" - Gandalf, Star Trek II

Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw
Quoted 11 lines · Bruce Ashfield via lists.openembedded.org
Quoted 7 lines · Bruce Ashfield via lists.openembedded.org
Quoted 3 lines · Scott Branden

Sorry, spoke too soon. Doesn't seem to work from a clean build now.

Quoted 7 lines
Quoted 2 lines

How so ? Works on repeated clean builds here. For 5.4/5.8 and 5.10

I have a theory on this. Did you directly bitbake your external module ? versus building the kernel first and then the module ?

I'll see what I can come up with.

Confirmed.

I have it sorted now. Doing one more clean build and will send a v2.

Thanks for the follow up!!

Bruce

Quoted 98 lines

Bruce

Quoted 75 lines

Bruce

Quoted 73 lines · Scott Branden

Thanks, works for me building external kernel modules.

On 2020-11-12 10:32 p.m., Bruce Ashfield wrote:

From: Bruce Ashfield <[email protected]>

The upstream commit 596b0474d3d [kbuild: preprocess module linker script], adds a dependency on module.lds for external module building.

Since module.lds is generated as part of 'modules_prepare', we must make it available with the other kernel artifacts in the kernel shared workdir, otherwise out of tree builds fail.

This fixes errors like:

    | make[4]: *** No rule to make target 'scripts/module.lds', needed by
        'build/tmp/work/qemuarm64-poky-linux/cryptodev-module/1.11-r0/git/cryptodev.ko'.
        Stop.
    | make[4]: *** Waiting for unfinished jobs....

We also ensure that kernel-devsrc has a copy to support on target module builds that are often prepared with 'make scripts prepare'. Those targets won't regenerate it, so the build fails. If 'make modules_prepare' is used, the file will be regenerated and overwrite our copy (as expected).

---
 meta/classes/kernel.bbclass                | 1 +
 meta/recipes-kernel/linux/kernel-devsrc.bb | 6 ++++++
 2 files changed, 7 insertions(+)
meta/classes/kernel.bbclass +1 -0
index be93a258f6..ccd74e61e8 100644
@@ -494,6 +494,7 @@ do_shared_workdir () {
  # Copy files required for module builds
  cp System.map $kerneldir/System.map-${KERNEL_VERSION}
  [ -e Module.symvers ] && cp Module.symvers $kerneldir/
+ [ -e scripts/module.lds ] && install -Dm 0644 scripts/module.lds $kerneldir/scripts/module.lds
  cp .config $kerneldir/
  mkdir -p $kerneldir/include/config
  cp include/config/kernel.release $kerneldir/include/config/kernel.release
meta/recipes-kernel/linux/kernel-devsrc.bb +6 -0
index 81b1e36041..5f0dedbdf7 100644
@@ -100,6 +100,12 @@ do_install() {
  # be dealt with.
  # cp -a scripts $kerneldir/build
 
+ # although module.lds can be regenerated on target via 'make modules_prepare'
+ # there are several places where 'makes scripts prepare' is done, and that won't
+ # regenerate the file. So we copy it onto the target as a migration to using
+ # modules_prepare
+ cp -a --parents scripts/module.lds $kerneldir/build/ 2>/dev/null || :
+
         if [ -d arch/${ARCH}/scripts ]; then
     cp -a arch/${ARCH}/scripts $kerneldir/build/arch/${ARCH}
  fi
Quoted 11 lines
Quoted 2 lines

--
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end
- "Use the force Harry" - Gandalf, Star Trek II

--
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end
- "Use the force Harry" - Gandalf, Star Trek II

Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II
#8 lore raw
Quoted 6 lines · Bruce Ashfield
Quoted 3 lines · Bruce Ashfield via lists.openembedded.org

On Fri, Nov 13, 2020 at 11:27 PM Bruce Ashfield via lists.openembedded.org <[email protected]> wrote:

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines · Scott Branden

Sorry, spoke too soon. Doesn't seem to work from a clean build now.

How so ? Works on repeated clean builds here. For 5.4/5.8 and 5.10

I have a theory on this. Did you directly bitbake your external module ? versus building the kernel first and then the module ?

Yes, I was doing a direct bitbake of the external module.

Quoted 5 lines
Quoted 2 lines

I'll see what I can come up with.

Confirmed.

I have it sorted now. Doing one more clean build and will send a v2.

Glad you were able to reproduce.

Quoted 2 lines

Thanks for the follow up!!

Looks to be merged to master now.
Will pickup the latest and if anything still not working let you know.

Quoted 99 lines

Bruce

Quoted 95 lines

Bruce

Quoted 74 lines

Bruce

Quoted 72 lines · Scott Branden

Thanks, works for me building external kernel modules.

On 2020-11-12 10:32 p.m., Bruce Ashfield wrote:

From: Bruce Ashfield <[email protected]>

The upstream commit 596b0474d3d [kbuild: preprocess module linker script], adds a dependency on module.lds for external module building.

Since module.lds is generated as part of 'modules_prepare', we must make it available with the other kernel artifacts in the kernel shared workdir, otherwise out of tree builds fail.

This fixes errors like:

    | make[4]: *** No rule to make target 'scripts/module.lds', needed by
        'build/tmp/work/qemuarm64-poky-linux/cryptodev-module/1.11-r0/git/cryptodev.ko'.
        Stop.
    | make[4]: *** Waiting for unfinished jobs....

We also ensure that kernel-devsrc has a copy to support on target module builds that are often prepared with 'make scripts prepare'. Those targets won't regenerate it, so the build fails. If 'make modules_prepare' is used, the file will be regenerated and overwrite our copy (as expected).

---
 meta/classes/kernel.bbclass                | 1 +
 meta/recipes-kernel/linux/kernel-devsrc.bb | 6 ++++++
 2 files changed, 7 insertions(+)
meta/classes/kernel.bbclass +1 -0
index be93a258f6..ccd74e61e8 100644
@@ -494,6 +494,7 @@ do_shared_workdir () {
  # Copy files required for module builds
  cp System.map $kerneldir/System.map-${KERNEL_VERSION}
  [ -e Module.symvers ] && cp Module.symvers $kerneldir/
+ [ -e scripts/module.lds ] && install -Dm 0644 scripts/module.lds $kerneldir/scripts/module.lds
  cp .config $kerneldir/
  mkdir -p $kerneldir/include/config
  cp include/config/kernel.release $kerneldir/include/config/kernel.release
meta/recipes-kernel/linux/kernel-devsrc.bb +6 -0
index 81b1e36041..5f0dedbdf7 100644
@@ -100,6 +100,12 @@ do_install() {
  # be dealt with.
  # cp -a scripts $kerneldir/build
 
+ # although module.lds can be regenerated on target via 'make modules_prepare'
+ # there are several places where 'makes scripts prepare' is done, and that won't
+ # regenerate the file. So we copy it onto the target as a migration to using
+ # modules_prepare
+ cp -a --parents scripts/module.lds $kerneldir/build/ 2>/dev/null || :
+
         if [ -d arch/${ARCH}/scripts ]; then
     cp -a arch/${ARCH}/scripts $kerneldir/build/arch/${ARCH}
  fi
Quoted 11 lines
Quoted 3 lines

--
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end
- "Use the force Harry" - Gandalf, Star Trek II

--
- Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end
- "Use the force Harry" - Gandalf, Star Trek II

#9 lore raw
In reply to Bruce Ashfield
Quoted 49 lines · Bruce Ashfield

From: Bruce Ashfield <[email protected]>

The upstream commit 596b0474d3d [kbuild: preprocess module linker script], adds a dependency on module.lds for external module building.

Since module.lds is generated as part of 'modules_prepare', we must make it available with the other kernel artifacts in the kernel shared workdir, otherwise out of tree builds fail.

This fixes errors like:

    | make[4]: *** No rule to make target 'scripts/module.lds', needed by
        'build/tmp/work/qemuarm64-poky-linux/cryptodev-module/1.11-r0/git/cryptodev.ko'.
        Stop.
    | make[4]: *** Waiting for unfinished jobs....

We also ensure that kernel-devsrc has a copy to support on target module builds that are often prepared with 'make scripts prepare'. Those targets won't regenerate it, so the build fails. If 'make modules_prepare' is used, the file will be regenerated and overwrite our copy (as expected).

---
 meta/classes/kernel.bbclass                | 1 +
 meta/recipes-kernel/linux/kernel-devsrc.bb | 6 ++++++
 2 files changed, 7 insertions(+)
meta/classes/kernel.bbclass +1 -0
index be93a258f6..ccd74e61e8 100644
@@ -494,6 +494,7 @@ do_shared_workdir () {
        # Copy files required for module builds
        cp System.map $kerneldir/System.map-${KERNEL_VERSION}
        [ -e Module.symvers ] && cp Module.symvers $kerneldir/
+       [ -e scripts/module.lds ] && install -Dm 0644 scripts/module.lds $kerneldir/scripts/module.lds
        cp .config $kerneldir/
        mkdir -p $kerneldir/include/config
        cp include/config/kernel.release $kerneldir/include/config/kernel.release
meta/recipes-kernel/linux/kernel-devsrc.bb +0 -0
index 81b1e36041..5f0dedbdf7 100644

meta/recipes-kernel/linux/kernel-devsrc.bb do_install() { · line 108

Quoted 9 lines
meta/recipes-kernel/linux/kernel-devsrc.bb +6 -0
@@ -100,6 +100,12 @@ do_install() {
        # be dealt with.
        # cp -a scripts $kerneldir/build
 
+       # although module.lds can be regenerated on target via 'make modules_prepare'
+       # there are several places where 'makes scripts prepare' is done, and that won't
+       # regenerate the file. So we copy it onto the target as a migration to using
+       # modules_prepare
+       cp -a --parents scripts/module.lds $kerneldir/build/ 2>/dev/null || :
+

I see there are more occurrence of cp -a in this recipe but I thought I will mention it
cp -a could be perhaps made more portable with cp --preserve=mode,timestamps -R

Quoted 9 lines
meta/recipes-kernel/linux/kernel-devsrc.bb +0 -1
         if [ -d arch/${ARCH}/scripts ]; then
            cp -a arch/${ARCH}/scripts $kerneldir/build/arch/${ARCH}
        fi
--

2.19.1

#10 lore raw
Quoted 55 lines · Khem Raj
Quoted 52 lines · Bruce Ashfield

From: Bruce Ashfield <[email protected]>

The upstream commit 596b0474d3d [kbuild: preprocess module linker script], adds a dependency on module.lds for external module building.

Since module.lds is generated as part of 'modules_prepare', we must make it available with the other kernel artifacts in the kernel shared workdir, otherwise out of tree builds fail.

This fixes errors like:

    | make[4]: *** No rule to make target 'scripts/module.lds', needed by
        'build/tmp/work/qemuarm64-poky-linux/cryptodev-module/1.11-r0/git/cryptodev.ko'.
        Stop.
    | make[4]: *** Waiting for unfinished jobs....

We also ensure that kernel-devsrc has a copy to support on target module builds that are often prepared with 'make scripts prepare'. Those targets won't regenerate it, so the build fails. If 'make modules_prepare' is used, the file will be regenerated and overwrite our copy (as expected).

---
 meta/classes/kernel.bbclass                | 1 +
 meta/recipes-kernel/linux/kernel-devsrc.bb | 6 ++++++
 2 files changed, 7 insertions(+)
meta/classes/kernel.bbclass +1 -0
index be93a258f6..ccd74e61e8 100644
@@ -494,6 +494,7 @@ do_shared_workdir () {
        # Copy files required for module builds
        cp System.map $kerneldir/System.map-${KERNEL_VERSION}
        [ -e Module.symvers ] && cp Module.symvers $kerneldir/
+       [ -e scripts/module.lds ] && install -Dm 0644 scripts/module.lds $kerneldir/scripts/module.lds
        cp .config $kerneldir/
        mkdir -p $kerneldir/include/config
        cp include/config/kernel.release $kerneldir/include/config/kernel.release
meta/recipes-kernel/linux/kernel-devsrc.bb +0 -0
index 81b1e36041..5f0dedbdf7 100644
@@ -100,6 +100,12 @@ do_install() {
        # be dealt with.
        # cp -a scripts $kerneldir/build
 
Quoted 10 lines

meta/recipes-kernel/linux/kernel-devsrc.bb do_install() { · line 108

Quoted 6 lines
meta/recipes-kernel/linux/kernel-devsrc.bb +6 -0
+       # although module.lds can be regenerated on target via 'make modules_prepare'
+       # there are several places where 'makes scripts prepare' is done, and that won't
+       # regenerate the file. So we copy it onto the target as a migration to using
+       # modules_prepare
+       cp -a --parents scripts/module.lds $kerneldir/build/ 2>/dev/null || :
+

I see there are more occurrence of cp -a in this recipe but I thought I will mention it
cp -a could be perhaps made more portable with cp --preserve=mode,timestamps -R

They've been there since the beginning.

But I'll keep it in mind next time I'm doing a bigger update to the devsrc!

Bruce

Quoted 10 lines
Quoted 10 lines
meta/recipes-kernel/linux/kernel-devsrc.bb +0 -1
         if [ -d arch/${ARCH}/scripts ]; then
            cp -a arch/${ARCH}/scripts $kerneldir/build/arch/${ARCH}
        fi
--

2.19.1

Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II