On Fri, Mar 01, 2019 at 04:10:12PM +0100, Geert Uytterhoeven wrote:
Hi Günter,
(this time without the bogus "h" ;-)
On Fri, Mar 1, 2019 at 3:33 PM Guenter Roeck <linux@xxxxxxxxxxxx> wrote:
On 3/1/19 12:04 AM, Geert Uytterhoeven wrote:
On Thu, Feb 28, 2019 at 9:52 PM Guenter Roeck <linux@xxxxxxxxxxxx> wrote:
when trying to build m68k:defconfig with gcc-8.3.0 (built using buildall),
I get the following error.
m68k-linux-ld: drivers/rtc/rtc-proc.o: in function `is_rtc_hctosys.isra.0':
rtc-proc.c:(.text+0x2a0): undefined reference to `strcmp'
rtc-proc.c doesn't actually call strcmp(); it calls strncmp(),
but it looks like the compiler optimizes it away.
The same problem is also seen in a few other places when trying to build
m68k:allmodconfig. In each instance, the compiler replaces strncmp() with
strcmp(). I don't see the build failure with any other target, even though
the same optimization happens there as well.
Do you have an idea what is going on, and what I might have to do to fix
the problem (presumably in the toolchain) ?
A fix for this is queued in my for-v5.1 branch:
https://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k.git/commit/?h=for-v5.1&id=28713169d879b67be2ef2f84dcf54905de238294
("m68k: Add -ffreestanding to CFLAGS").
Hmm, yes, that should fix the problem. But why only strncmp, and why don't other
Also snprintf(), IIRC.
Doesn't look like it - see below.
architectures suffer from the same problem ? I see that x86 uses a builtin,
but, for example, ppc with gcc 8.3.0 also generates a call to strcmp() but
doesn't suffer from the same problem.
PPC doesn't #define __HAVE_ARCH_STRCMP, and thus uses strcmp()
from lib/string.c, which includes an EXPORT_SYMBOL(strcmp).
An alternative solution is to add EXPORT_SYMBOL(strcmp) on m68k.
I think the underlying problem may be that strcmp() is static
inline for m68k. That is fatal if the compiler replaces strncmp()
with strcmp().
Another possible fix might be to write a 'static inline int strncmp()'
function for non-coldfire code. I am not familiar enough with m68k
assembler to do that, unfortunately. However, I did a simple test and
added a dummy strncmp() into arch/m68k/include/asm/string.h, and it
compiles clean. I think that would be a preferrable solution.
Thanks,
Guenter