[Vm-dev] fdlibm is not C99 conformant

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


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.

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

-------------- 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.
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")


More information about the Vm-dev mailing list