2008-07-10 19:49:36

by Sergei Trofimovich

[permalink] [raw]
Subject: uml: sparse inlines gcc-4.{2,3} compilation hack

Hi!

Small ARCH=um SUBARCH=i386 .config is in attach.
How to fix properly such kind of miscompilation? (gcc-4.3.1)
Now I have to use hacks like this:

uml: sparse inlines gcc-4.{2,3} compilation fix.

Patch fixes stuff like this:

CC mm/filemap.o
/mnt/ext/backup3/dev/git/linux-2.6/mm/filemap.c: In function '__generic_file_aio_write_nolock':
/mnt/ext/backup3/dev/git/linux-2.6/mm/filemap.c:1838: sorry, unimplemented: inlining failed in call to 'generic_write_checks': function body not available
/mnt/ext/backup3/dev/git/linux-2.6/mm/filemap.c:2390: sorry, unimplemented: called from here
make[2]: *** [mm/filemap.o] Error 1
make[1]: *** [mm] Error 2

Signed-off-by: Sergei Trofimovich <[email protected]>

fs/block_dev.c | 2 +-
fs/buffer.c | 2 +-
mm/filemap.c | 2 +-
mm/page_alloc.c | 2 +-
net/ipv4/ip_output.c | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 10d8a0a..9248ae0 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -39,7 +39,7 @@ static inline struct bdev_inode *BDEV_I(struct inode *inode)
return container_of(inode, struct bdev_inode, vfs_inode);
}

-inline struct block_device *I_BDEV(struct inode *inode)
+struct block_device *I_BDEV(struct inode *inode)
{
return &BDEV_I(inode)->bdev;
}
diff --git a/fs/buffer.c b/fs/buffer.c
index 0f51c0f..2a9a554 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -46,7 +46,7 @@ static int fsync_buffers_list(spinlock_t *lock, struct list_head *list);

#define BH_ENTRY(list) list_entry((list), struct buffer_head, b_assoc_buffers)

-inline void
+void
init_buffer(struct buffer_head *bh, bh_end_io_t *handler, void *private)
{
bh->b_end_io = handler;
diff --git a/mm/filemap.c b/mm/filemap.c
index 1e6a7d3..110b1bc 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1834,7 +1834,7 @@ EXPORT_SYMBOL(iov_iter_single_seg_count);
* Returns appropriate error code that caller should return or
* zero in case that write should be allowed.
*/
-inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk)
+int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk)
{
struct inode *inode = file->f_mapping->host;
unsigned long limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index f32fae3..66b636e 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2611,7 +2611,7 @@ static int zone_batchsize(struct zone *zone)
return batch;
}

-inline void setup_pageset(struct per_cpu_pageset *p, unsigned long batch)
+void setup_pageset(struct per_cpu_pageset *p, unsigned long batch)
{
struct per_cpu_pages *pcp;

diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index e527628..9a74088 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -85,7 +85,7 @@
int sysctl_ip_default_ttl __read_mostly = IPDEFTTL;

/* Generate a checksum for an outgoing IP datagram. */
-__inline__ void ip_send_check(struct iphdr *iph)
+void ip_send_check(struct iphdr *iph)
{
iph->check = 0;
iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);


Attachments:
(No filename) (3.16 kB)
.config (13.85 kB)
Download all attachments

2008-07-10 20:43:42

by Jeff Dike

[permalink] [raw]
Subject: Re: uml: sparse inlines gcc-4.{2,3} compilation hack

On Thu, Jul 10, 2008 at 03:50:29PM +0300, Sergei Trofimovich wrote:
> Small ARCH=um SUBARCH=i386 .config is in attach.
> How to fix properly such kind of miscompilation? (gcc-4.3.1)
> Now I have to use hacks like this:

Use the patch below instead.

Jeff

--
Work email - jdike at linux dot intel dot com


commit 4f81c5350b44bcc501ab6f8a089b16d064b4d2f6
Author: Jeff Dike <[email protected]>
Date: Mon Jul 7 13:36:56 2008 -0400

[UML] fix gcc ICEs and unresolved externs

There are various constraints on the use of unit-at-a-time:
- i386 uses no-unit-at-a-time for pre-4.0 (not 4.3)
- x86_64 uses unit-at-a-time always

Uli reported a crash on x86_64 with gcc 4.1.2 with unit-at-a-time,
resulting in commit c0a18111e571138747a98af18b3a2124df56a0d1

Ingo reported a gcc internal error with gcc 4.3 with no-unit-at-a-timem,
resulting in 22eecde2f9034764a3fd095eecfa3adfb8ec9a98

Benny Halevy is seeing extern inlines not resolved with gcc 4.3 with
no-unit-at-a-time

This patch reintroduces unit-at-a-time for gcc >= 4.0, bringing back the
possibility of Uli's crash. If that happens, we'll debug it.

I started seeing both the internal compiler errors and unresolved
inlines on Fedora 9. This patch fixes both problems, without so far
reintroducing the crash reported by Uli.

Signed-off-by: Jeff Dike <[email protected]>
Cc: Benny Halevy <[email protected]>
Cc: Adrian Bunk <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Ulrich Drepper <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>

diff --git a/arch/um/Makefile b/arch/um/Makefile
index dbeab15..ca40397 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -77,7 +77,6 @@ include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
KERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \
-Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES))
KBUILD_CFLAGS += $(KERNEL_DEFINES)
-KBUILD_CFLAGS += $(call cc-option,-fno-unit-at-a-time,)

PHONY += linux

diff --git a/arch/um/Makefile-i386 b/arch/um/Makefile-i386
index 561e373..302cbe5 100644
--- a/arch/um/Makefile-i386
+++ b/arch/um/Makefile-i386
@@ -32,4 +32,11 @@ cflags-y += $(call cc-option,-mpreferred-stack-boundary=2)
# an unresolved reference.
cflags-y += -ffreestanding

+# Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
+# a lot more stack due to the lack of sharing of stacklots. Also, gcc
+# 4.3.0 needs -funit-at-a-time for extern inline functions.
+KBUILD_CFLAGS += $(shell if [ $(call cc-version) -lt 0400 ] ; then \
+ echo $(call cc-option,-fno-unit-at-a-time); \
+ else echo $(call cc-option,-funit-at-a-time); fi ;)
+
KBUILD_CFLAGS += $(cflags-y)
diff --git a/arch/um/Makefile-x86_64 b/arch/um/Makefile-x86_64
index 8ed362f..a9cd7e7 100644
--- a/arch/um/Makefile-x86_64
+++ b/arch/um/Makefile-x86_64
@@ -21,3 +21,6 @@ HEADER_ARCH := x86

LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib64
LINK-y += -m64
+
+# Do unit-at-a-time unconditionally on x86_64, following the host
+KBUILD_CFLAGS += $(call cc-option,-funit-at-a-time)