Commit 11f537ae authored by Maxime Perrotin's avatar Maxime Perrotin

Add support for double in C when using Cortex M4

ARM Cortex M4's FPU does not support double precision, leading to
application crash when C code use them.
Added a flag to shorten double and make them processed as floats.
parent 20d1c00a
...@@ -272,6 +272,9 @@ def mflags(node): ...@@ -272,6 +272,9 @@ def mflags(node):
result += " -msoft-float " result += " -msoft-float "
if kind.startswith("PLATFORM_ARM_CORTEX"): if kind.startswith("PLATFORM_ARM_CORTEX"):
result += " -mfloat-abi=hard " result += " -mfloat-abi=hard "
# Cortex M4's FPU does not support double precision! if C code uses double,
# it must be forced to use float instead:
result += " -fshort-double "
return result return result
...@@ -1158,8 +1161,10 @@ def InvokeOcarinaMakefiles( ...@@ -1158,8 +1161,10 @@ def InvokeOcarinaMakefiles(
userCFlags = keepOnlyFirstCompilationOption(userCFlags) userCFlags = keepOnlyFirstCompilationOption(userCFlags)
userLDFlags = keepOnlyFirstCompilationOption(userLDFlags) userLDFlags = keepOnlyFirstCompilationOption(userLDFlags)
if "ARM_CORTEX" in platformType: if "ARM_CORTEX" in platformType:
userCFlags = userCFlags.replace(" -mfloat-abi=hard ", "") # Not supported by AdaCore's CertyFlie... userCFlags = userCFlags.replace(" -mfloat-abi=hard ", "") # Not supported when compiling Ada
userLDFlags = userLDFlags.replace(" -mfloat-abi=hard ", "") # Not supported by AdaCore's CertyFlie... userLDFlags = userLDFlags.replace(" -mfloat-abi=hard ", "") # Not supported when compiling Ada
userCFlags = userCFlags.replace("-fshort-double", "") # Not supported when compiling Ada
userLDFlags = userLDFlags.replace("-fshort-double", "") # Not supported when compiling Ada
customFlags = (' USER_CFLAGS="${USER_CFLAGS}%s" USER_LDFLAGS="${USER_LDFLAGS}%s"' % (userCFlags, userLDFlags)) customFlags = (' USER_CFLAGS="${USER_CFLAGS}%s" USER_LDFLAGS="${USER_LDFLAGS}%s"' % (userCFlags, userLDFlags))
mysystem((cmd % customFlags) + extra + externals + "\" make") mysystem((cmd % customFlags) + extra + externals + "\" make")
return AdaIncludePath return AdaIncludePath
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment