[Vm-dev] fdlibm is not C99 conformant

David T. Lewis lewis at mail.msen.com
Thu Dec 30 20:02:25 UTC 2010


On Thu, Dec 30, 2010 at 02:25:01PM -0500, David T. Lewis wrote:
> On Thu, Dec 30, 2010 at 01:48:55AM +0100, Nicolas Cellier wrote:
> >  
> > >
> > > OK, got it, you have to compile with -D__LITTLE_ENDIAN
> > > This macro is set automatically in fdlibm.h when compiled ith -m32 but
> > > not when compiled with -m64
> > >
> > > Nicolas
> > >
> > 
> > We can add something like
> >   || defined(__x86_64)
> > in fdlibm.h
> > 
> > your macro definitions can be obtained via
> > gcc -E -dM - < /dev/null
> > 
> > Nicolas
> 
> Bravo, good catch! This solves the problem, and all KernelTests-Numbers
> are now green with a 64-bit Linux VM.
> 
> Patching fdlibm.h solves the problem, but it is probably not good policy
> to be making local patches to the library, so I think a more general fix
> is to set __LITTLE_ENDIAN properly in the build system.
> 
> Attached is a platforms/unix/plugins/FloatMathPlugin/config.cmake that
> addresses this, and that also sets the -O0 flag to disable gcc optimization.

Checking Mantis 7592, I note Andreas' earlier recommendation to also
use -mno-fused-madd. Updated config.cmake attached.

Dave


> 
> I'll forward this to Ian also for the platforms/unix update.
> 
> Igor and Esteban, you may need to do something similar if you build a
> 32/64 bit Mac VM.
> 
> Eliot, I'm not sure if something needs to be done for the Cog platform
> tree, but if so I would expect that it is a matter of adjusting the
> makefiles to use " -D__LITTLE_ENDIAN=1 -O0" 
> 
> Dave
> 

> PLUGIN_DEFINITIONS (-DNO_ISNAN=1)
> TEST_BIG_ENDIAN(IS_BIGENDER)
> IF (NOT IS_BIGENDER)
> 	# fdlibm.h does not handle x86_64, so set it here for all platforms
> 	PLUGIN_DEFINITIONS (-D__LITTLE_ENDIAN=1)
> ENDIF()
> # The fdlibm library must be compiled with no gcc optimization. Add -O0 to
> # the CFLAGS string to override the optimization setting.
> SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")

-------------- next part --------------
PLUGIN_DEFINITIONS (-DNO_ISNAN=1)
TEST_BIG_ENDIAN(IS_BIGENDER)
IF (NOT IS_BIGENDER)
	# fdlibm.h does not handle x86_64, so set it here for all platforms
	PLUGIN_DEFINITIONS (-D__LITTLE_ENDIAN=1)
ENDIF()
# The fdlibm library must be compiled with no gcc optimization. Add -O0 to
# the CFLAGS string to override the optimization setting.
# Also add -mno-fused-madd per Andreas Raab recommendation
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -mno-fused-madd")


More information about the Vm-dev mailing list