Re: Problem with commit deda2e81961e96be4f2c09328baca4710a2fd1a0

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Mikael Pettersson
Date: Friday, August 13, 2010 - 1:45 am

Larry Finger writes:
 > On 08/12/2010 03:26 PM, Linus Torvalds wrote:
 > > On Thu, Aug 12, 2010 at 1:18 PM, Larry Finger <Larry.Finger@lwfinger.net> wrote:
 > >>
 > >> With the above commit, building an i386 version of the kernel results in the
 > >> following from the build:
 > >>
 > >> kernel/built-in.o: In function `logarithmic_accumulation':
 > >> /home/finger/linux-realtek/kernel/time/timekeeping.c:715: undefined reference to
 > >> `__umoddi3'
 > >> /home/finger/linux-realtek/kernel/time/timekeeping.c:715: undefined reference to
 > >> `__udivdi3'
 > >> make: *** [.tmp_vmlinux1] Error 1
 > >>
 > >> Reverting the patch allows the system to build correctly.
 > > 
 > > Damn. It's your compiler turning a while-loop into a divide. Which
 > > likely isn't even an optimization, but whatever.
 > > 
 > > John: I think that while-loop needs to be something like
 > > 
 > >    if (raw_nsecs >= NSEC_PER_SEC) {
 > >       u64 raw_secs = raw_nsecs;
 > >       raw_nsecs = do_div(raw_secs, NSEC_PER_SEC);
 > >       raw_time.tv_sec += taw_secs;
 > >   }
 > >   raw_time.tc_nsec = raw_nsecs;
 > > 
 > > which is sad and overly complicated, but the simple thing seems to get
 > > messed up by the compiler.
 > > 
 > > Untested. Maybe I got the complex do_div() semantics wrong. Somebody
 > > needs to check.
 > 
 > I'll try it. The system with the problem has gcc (SUSE Linux) 4.3.2
 > [gcc-4_3-branch revision 141291]. That is on a 64-bit system cross compiling
 > with ARCH=i386.
 > 
 > The real 32-bit system with gcc (SUSE Linux) 4.5.0 20100604 [gcc-4_5-branch
 > revision 160292] builds OK. It just wasn't finished when I wrote the first message.

The loops-turns-into-div is a known bug in early gcc-4.3 releases,
possibly only with -Os.  It's fixed in 4.4 and 4.3.latest.  I can
probably dig up the gcc PR number if needed.

/Mikael
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: Problem with commit deda2e81961e96be4f2c09328baca4710a ..., Mikael Pettersson, (Fri Aug 13, 1:45 am)