On Wed, 19 Dec 2018, Geert Uytterhoeven wrote:
Hi Finn,
On Wed, Dec 19, 2018 at 9:39 AM Finn Thain <fthain@xxxxxxxxxxxxxxxxxxx> wrote:
On Tue, 18 Dec 2018, John Paul Adrian Glaubitz wrote:
Could someone quickly remind me how to fix the linking issue when building Linux 4.19
on m68k [1]?
Here's the patch that I use. I don't know what the best fix is.
https://github.com/fthain/linux/commit/8fa8322eb20f8d1fdd4228742e45d0400e1dfa15
Porbably the best fix is to follow Andreas' advice, and replace the
calls to strncmp() by direct calls to strcmp()?
Taking the view that the call sites are buggy means fixing these failures
as and when new ones get added, indefinitely. And in principle, this
problem is not confined to m68k. Also, the problem could get worse over
time as new optimizations get added to the compiler.
If you ban strncmp(a, b, n) where a or b are constant then you may as well
ban it where a or b are macros subject to build-time configuration too. If
you or Andreas can make the argument that strncmp is bad style in general,
then this could be solved in checkpatch.pl.
Andreas said the error happened when the new compiler expanded a
__bultin_strcmp call to a strcmp call.
https://lore.kernel.org/lkml/87in513wbt.fsf@xxxxxxxxx/
The new compiler seems to assume that a strcmp symbol exists in the final
link. I don't see how that kind of assumption is valid here.
So I think the real bug is the lack of -ffreestanding. That omission
allows the compiler to assume that libc is available in the final link.
(At least, I imagine that's what the compiler authors had in mind.)
Anyway, the use of -ffreestanding certainly avoids this optimization.
--
--
+ ld -m m68kelf --build-id -X -o .tmp_vmlinux1 -T ./arch/m68k/kernel/vmlinux.lds --whole-archive built-in.a --no-whole-archive --start-group lib/lib.a arch/m68k/lib/lib.a --end-group
/usr/bin/ld: block/partitions/ldm.o: in function `ldm_parse_tocblock':
./debian/build/build_m68k_none_m68k/./block/partitions/ldm.c:153: undefined reference to `strcmp'
/usr/bin/ld: ./debian/build/build_m68k_none_m68k/./block/partitions/ldm.c:163: undefined reference to `strcmp'
/usr/bin/ld: drivers/rtc/rtc-proc.o: in function `is_rtc_hctosys':
./debian/build/build_m68k_none_m68k/./drivers/rtc/rtc-proc.c:33: undefined reference to `strcmp'
Gr{oetje,eeting}s,
Geert