ardupilotwaf: properly configure double precision tasks

There might be multiple copies of the flags, so remove all of them. Also
pull the setup into a helper function to avoid duplicating the logic.

On ChibiOS boards, this fixes SITL (which had issues with position
quantization) and affects the SBF GPS driver (which was probably fine
before but does change slightly).
This commit is contained in:
Thomas Watson 2024-12-29 19:42:43 -06:00 committed by Andrew Tridgell
parent 88754798eb
commit 084661d099
2 changed files with 19 additions and 7 deletions

View File

@ -277,13 +277,7 @@ def double_precision_check(tasks):
double_library = t.env.DOUBLE_PRECISION_LIBRARIES.get(src[0],False)
if double_library or src in double_tasks:
t.env.CXXFLAGS = t.env.CXXFLAGS[:]
for opt in ['-fsingle-precision-constant', '-cl-single-precision-constant']:
try:
t.env.CXXFLAGS.remove(opt)
except ValueError:
pass
t.env.CXXFLAGS.append("-DALLOW_DOUBLE_MATH_FUNCTIONS")
t.env.CXXFLAGS = ap.set_double_precision_flags(t.env.CXXFLAGS)
def gsoap_library_check(bld, tasks):

View File

@ -146,6 +146,24 @@ def get_legacy_defines(sketch_name, bld):
'AP_BUILD_TARGET_NAME="' + sketch_name + '"',
]
def set_double_precision_flags(flags):
# set up flags for double precision files:
# * remove all single precision constant flags
# * set define to allow double precision math in AP headers
flags = flags[:] # copy the list to avoid affecting other builds
# remove GCC and clang single precision constant flags
for opt in ('-fsingle-precision-constant', '-cl-single-precision-constant'):
while True: # might have multiple copies from different sources
try:
flags.remove(opt)
except ValueError:
break
flags.append("-DALLOW_DOUBLE_MATH_FUNCTIONS")
return flags
IGNORED_AP_LIBRARIES = [
'doc',
'AP_Scripting', # this gets explicitly included when it is needed and should otherwise never be globbed in