Bug 12576 - Error building custom 4.14 kernel caused by do_shared_workdir
Summary: Error building custom 4.14 kernel caused by do_shared_workdir
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: kernel (show other bugs)
Version: 2.5
Hardware: x86 ppc64
: Medium+ normal
Target Milestone: 4.99
Assignee: Bruce Ashfield
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2018-03-01 14:53 UTC by Guillermo
Modified: 2018-09-26 10:58 UTC (History)
3 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments
Custom kernel 4.14 recipe (5.18 KB, application/octet-stream)
2018-03-01 15:45 UTC, Guillermo
no flags Details
Layers (69.65 MB, application/gzip)
2018-03-06 00:47 UTC, Guillermo
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Guillermo 2018-03-01 14:53:15 UTC
When comiling a custom kernel using 4.14 source from git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git an error occurs executing the task do_shared_workdir:

ERROR: linux-kernel-4.14.23-r0 do_shared_workdir: Function failed: do_shared_workdir (log file is located at /home/guille/Documentos/Yocto/build-ppc64/tmp/work/powermacg5-poky-linux/linux-kernel/4.14.23-r0/temp/log.do_shared_workdir.8575)
ERROR: Logfile of failure stored in: /home/guille/Documentos/Yocto/build-ppc64/tmp/work/powermacg5-poky-linux/linux-kernel/4.14.23-r0/temp/log.do_shared_workdir.8575
Log data follows:
| DEBUG: Executing shell function do_shared_workdir
| cp: cannot stat 'arch/powerpc/lib/crtsavres.o': No such file or directory
| WARNING: /home/guille/Documentos/Yocto/build-ppc64/tmp/work/powermacg5-poky-linux/linux-kernel/4.14.23-r0/temp/run.do_shared_workdir.8575:1 exit 1 from 'cp arch/powerpc/lib/crtsavres.o $kerneldir/arch/powerpc/lib/crtsavres.o'
| ERROR: Function failed: do_shared_workdir (log file is located at /home/guille/Documentos/Yocto/build-ppc64/tmp/work/powermacg5-poky-linux/linux-kernel/4.14.23-r0/temp/log.do_shared_workdir.8575)
ERROR: Task (/home/guille/Documentos/Yocto/poky/meta-progress-bsp/recipes-kernel/linux/linux-kernel_4.14.bb:do_shared_workdir) failed with exit code '1'

The error is caused by the following code in meta/classes/kernel.bbclass

# As of Linux kernel version 3.0.1, the clean target removes
# arch/powerpc/lib/crtsavres.o which is present in
# KBUILD_LDFLAGS_MODULE, making it required to build external modules.
if [ ${ARCH} = "powerpc" ]; then
		mkdir -p $kerneldir/arch/powerpc/lib/
		cp arch/powerpc/lib/crtsavres.o $kerneldir/arch/powerpc/lib/crtsavres.o
fi

There is a change in the kernel (4.14) source that makes the previous code fail. The code can be found at arch/powerpc/lib/Makefile

obj-$(CONFIG_PPC32)	+= div64.o copy_32.o crtsavres.o

# See corresponding test in arch/powerpc/Makefile
# 64-bit linker creates .sfpr on demand for final link (vmlinux),
# so it is only needed for modules, and only for older linkers which
# do not support --save-restore-funcs
ifeq ($(call ld-ifversion, -lt, 225000000, y),y)
extra-$(CONFIG_PPC64)	+= crtsavres.o
endif

This makes behave different ppc32 and ppc64 regarding crtsavres.o

A possible fix is to repace the if condition in meta/classes/kernel.bbclass by

# As of Linux kernel version 3.0.1, the clean target removes
# arch/powerpc/lib/crtsavres.o which is present in
# KBUILD_LDFLAGS_MODULE, making it required to build external modules.
if [ ${ARCH} = "powerpc" ] && [ -e arch/powerpc/lib/crtsavres.o ]; then
		mkdir -p $kerneldir/arch/powerpc/lib/
		cp arch/powerpc/lib/crtsavres.o $kerneldir/arch/powerpc/lib/crtsavres.o
fi
Comment 1 Bruce Ashfield 2018-03-01 15:32:32 UTC
You need to attach your kernel recipe. We are building 4.14, 4.15 and 4.16 for qemuppc without any issues.

I need to reproduce the error here, before considering any changes. Yes, adding more checks for some of the files make sense, but again, not until I've reproduced the error.

qemuppc login: root
root@qemuppc:~# uname -a
Linux qemuppc 4.15.0-yocto-standard #1 PREEMPT Thu Mar 1 10:10:29 EST 2018 ppc GNU/Linux
root@qemuppc:~#
Comment 2 Guillermo 2018-03-01 15:45:28 UTC
Created attachment 4220 [details]
Custom kernel 4.14 recipe

If I'm not wrong qemuppc is ppc32 and should not fail when executing do_shared_workdir.
I'm using a maching called powermacg5 which is a custom definition of a ppc64 machine.

I can provide a tar.gz with all the layers if required
Comment 3 Bruce Ashfield 2018-03-01 15:47:18 UTC
I'm also building ppc64 as arch testing, and so far so good.

I'll have a look at the attachment and create a patch based on my findings.
Comment 4 Bruce Ashfield 2018-03-05 20:12:03 UTC
Can I get your BSP layer attached to the bug ?

My reference ppc64 platform, using the 4.15 kernel and the default gcc/linker combo in master are still building crtsavres.o

Yes, I understand why and I could absolutely make this code change and only test that it doesn't break my ppc64 case, but I'd also like to test it against yours as well.
Comment 5 Guillermo 2018-03-06 00:47:49 UTC
Created attachment 4223 [details]
Layers

Sure! Find all the layers I'm using here. The BSP is called meta-progres-bsp and I'm including my local.conf within the build-ppc64 directory. 

I haven't tried 4.15 yet. If it helps this is the commit introducing the change in  kernel 4.15 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/arch/powerpc/lib?h=v4.15.7&id=efe0160cfd40a99c052a00e174787c1f4158a9cd
Comment 6 Bruce Ashfield 2018-03-06 05:09:27 UTC
Fantastic. I expect to have a patch by end of day.
Comment 7 Bruce Ashfield 2018-03-06 07:58:25 UTC
What branch are you seeing this error ?

I'm now building your BSP layer without issues (or my change).

So it must be the linker that is triggering the different behaviour, and I want to remove that last doubt.
Comment 8 Guillermo 2018-03-06 08:34:04 UTC
I'm using rocko branch
Comment 9 Ross Burton 2018-09-26 10:58:17 UTC
Merged with oe-core af58819253a2d4526dc8871a17e1492bd1d92951