* Re: [m68k] in modpost: "strlen" [iscsi_target_mod.ko] undefined! (and others) [not found] ` <Pine.BSM.4.64L.1201012310590.20109@herc.mirbsd.org> @ 2012-01-01 23:39 ` Jonathan Nieder 2012-01-01 23:45 ` Thorsten Glaser 0 siblings, 1 reply; 4+ messages in thread From: Jonathan Nieder @ 2012-01-01 23:39 UTC (permalink / raw) To: Thorsten Glaser Cc: Nicholas Bellinger, Greg Ungerer, linux-kernel, linux-m68k, target-devel Thorsten Glaser wrote[1]: > Dixi quod… >> So, please, compile the Linux kernel with -ffreestanding, too. > > Just to keep this bugreport in the loop: that fixes the FTBFS error. Yep, sounds like a reasonable idea, though these calls to "strncat(buf, str, strlen(str))" in the iscsi driver are still a little insane. Could you suggest a patch to arch/m68k/Makefile to do that? Thanks, Jonathan [1] http://bugs.debian.org/648996 Background: commit 6edfba1b33c7 Author: Andi Kleen <ak@suse.de> Date: Sat Mar 25 16:29:49 2006 +0100 [PATCH] x86_64: Don't define string functions to builtin gcc should handle this anyways, and it causes problems when sprintf is turned into strcpy by gcc behind our backs and the C fallback version of strcpy is actually defining __builtin_strcpy Then drop -ffreestanding from the main Makefile because it isn't needed anymore and implies -fno-builtin, which is wrong now. (it was only added for x86-64, so dropping it should be safe) ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [m68k] in modpost: "strlen" [iscsi_target_mod.ko] undefined! (and others) 2012-01-01 23:39 ` [m68k] in modpost: "strlen" [iscsi_target_mod.ko] undefined! (and others) Jonathan Nieder @ 2012-01-01 23:45 ` Thorsten Glaser 2012-01-02 0:10 ` Jonathan Nieder 0 siblings, 1 reply; 4+ messages in thread From: Thorsten Glaser @ 2012-01-01 23:45 UTC (permalink / raw) To: Jonathan Nieder Cc: Nicholas Bellinger, Greg Ungerer, linux-kernel, linux-m68k, target-devel Jonathan Nieder dixit: >Could you suggest a patch to arch/m68k/Makefile to do that? No, I patched it in debian/config/m68k/defines instead. I’d rather know why upstream doesn’t use -ffreestanding on _all_ architectures. A kernel is _not_ a hosted environment, and GCC is right to bring in problems like this. > Then drop -ffreestanding from the main Makefile because it isn't > needed anymore and implies -fno-builtin, which is wrong now. This is wrong, GCC builtins are only valid on hosted platforms, not on freestanding platforms. (Nobody prevents GCC from using a memcpy builtin that uses, say, SSE instructions, which must not be used inside kernel code, for an example on a better-known architecture.) A kernel must always be compiled freestanding, as do bootloaders. At least since the advent of gcc 3.[34]. bye, //mirabilos -- “It is inappropriate to require that a time represented as seconds since the Epoch precisely represent the number of seconds between the referenced time and the Epoch.” -- IEEE Std 1003.1b-1993 (POSIX) Section B.2.2.2 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [m68k] in modpost: "strlen" [iscsi_target_mod.ko] undefined! (and others) 2012-01-01 23:45 ` Thorsten Glaser @ 2012-01-02 0:10 ` Jonathan Nieder 2012-01-02 0:19 ` Thorsten Glaser 0 siblings, 1 reply; 4+ messages in thread From: Jonathan Nieder @ 2012-01-02 0:10 UTC (permalink / raw) To: Thorsten Glaser Cc: Nicholas Bellinger, Greg Ungerer, linux-kernel, linux-m68k, target-devel Thorsten Glaser wrote: > I’d rather know why upstream doesn’t use -ffreestanding on > _all_ architectures. A kernel is _not_ a hosted environment, > and GCC is right to bring in problems like this. It's to make optimizations that use the builtin functions (e.g., memcpy) work with less fuss. If the kernel implements all the relevant library functions, then it can be considered hosted as far as GCC cares. [...] > (Nobody prevents GCC from using > a memcpy builtin that uses, say, SSE instructions Doesn't -mno-sse take care of that? However, if you (this is the general "you", not just Thorsten) find the following reasoning[1] compelling, feel free to propose a patch to Makefile instead of arch/m68k/Makefile. If others agree, some patches for the x86 string functions to get the optimizations back could follow, leaving everyone happy. Ciao, Jonathan [1] commit d6326c18 Author: Adrian Bunk <bunk@stusta.de> Date: Tue Jan 4 05:29:33 2005 -0800 [PATCH] compile with -ffreestanding For the kernel, it would be logical to use -ffreestanding. The kernel is not a hosted environment with a standard C library. The gcc option -ffreestanding is supported by both gcc 2.95 and 3.4, which covers the whole range of currently supported compilers. Regarding changes caused by this patch: Andi Kleen reported: Newer gcc rewrites sprintf(buf,"%s",str) to strcpy(buf,str) transparently. This is only true with unit-at-a-time (disabled on i386 but enabled on x86_64). The Linux kernel doesn't offer a standard C library, and such transparent replacements of kernel functions with builtins are quite fragile. Even with -ffreestanding, it's still possilble to explicitely use a gcc builtin if desired. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [m68k] in modpost: "strlen" [iscsi_target_mod.ko] undefined! (and others) 2012-01-02 0:10 ` Jonathan Nieder @ 2012-01-02 0:19 ` Thorsten Glaser 0 siblings, 0 replies; 4+ messages in thread From: Thorsten Glaser @ 2012-01-02 0:19 UTC (permalink / raw) To: Jonathan Nieder Cc: Nicholas Bellinger, Greg Ungerer, linux-kernel, linux-m68k, target-devel Jonathan Nieder dixit: >Makefile instead of arch/m68k/Makefile. If others agree, some patches >for the x86 string functions to get the optimizations back could >follow, leaving everyone happy. […] > Even with -ffreestanding, it's still possilble to explicitely use a gcc > builtin if desired. Just call them, like this: tg@zigo:~/Xl/linux-2.6-3.2~rc7 $ fgrep -A 3 "define strcpy" arch/m68k/include/asm/string.h #define strcpy(d, s) (__builtin_constant_p(s) && \ __builtin_strlen(s) <= 32 ? \ __builtin_strcpy(d, s) : \ __kernel_strcpy(d, s)) Of course, the parameters when to call which may differ. (The choice about being a hosted environment is not just about having libc-like functions available.) bye, //mirabilos -- Solange man keine schmutzigen Tricks macht, und ich meine *wirklich* schmutzige Tricks, wie bei einer doppelt verketteten Liste beide Pointer XORen und in nur einem Word speichern, funktioniert Boehm ganz hervorragend. -- Andreas Bogk über boehm-gc in d.a.s.r ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-01-02 0:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20111116181424.14920.7730.reportbug@ara5.mirbsd.org>
[not found] ` <Pine.BSM.4.64L.1111301751500.12725@herc.mirbsd.org>
[not found] ` <CAMuHMdW8t8Q7OqxJM602iLG4aSv1KMTY-fhiGS7hyy8xBReh1A@mail.gmail.com>
[not found] ` <Pine.BSM.4.64L.1112181741430.856@herc.mirbsd.org>
[not found] ` <Pine.BSM.4.64L.1112181929380.856@herc.mirbsd.org>
[not found] ` <Pine.BSM.4.64L.1201012310590.20109@herc.mirbsd.org>
2012-01-01 23:39 ` [m68k] in modpost: "strlen" [iscsi_target_mod.ko] undefined! (and others) Jonathan Nieder
2012-01-01 23:45 ` Thorsten Glaser
2012-01-02 0:10 ` Jonathan Nieder
2012-01-02 0:19 ` Thorsten Glaser
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox