Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable -ffast-math for iOS builds #2176

Closed

Conversation

ThomasDebrunner
Copy link
Contributor

@ThomasDebrunner ThomasDebrunner commented Nov 13, 2023

This PR disables the -ffast-math option for iOS builds.

We found that for all MAVSDK 1.4.7+, this option has been breaking std::isfinite in the code.

This breaks the mission upload logic, which checks with std::isfinite to decide wheter speed or gimbal attitude has changed.

We do not enable -ffast-math on any other platform.

Specifically this line breaks:

if (std::isfinite(item.speed_m_s)) {

With -ffast-math enabled on iOS, this check will return true, despite the value being NaN. T

This is allowed, since -ffast-math implies -ffinite-math-only, which is explicitly allowed to do this. However, apple clang must only recently have started doing this optimization, hence the problem not present on CI builds for MAVSDK <= 1.4.7.

Copy link
Collaborator

@MaEtUgR MaEtUgR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see a specific requirement for this to be enabled from the history 👀

@ThomasDebrunner
Copy link
Contributor Author

I believe it was enabled by accident for iOS because the iOS toolchain file was copied over from another project

@julianoes
Copy link
Collaborator

Thanks for the patch! Nice catch. We should probably fix CI first, so that we know the changes don't break more than they fix.

The toolchain comes from https://github.com/leetal/ios-cmake/blob/master/ios.toolchain.cmake and it looks like fast-math was removed there as well, see: https://github.com/leetal/ios-cmake/pull/143/files

I suggest we update the whole file to the latest upstream instead of just patching this.

Copy link
Collaborator

@JonasVautherin JonasVautherin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Julian that the toolchain should be updated from upstream instead of patched, unless there is a good reason not to do it.

The problem with patching it is that next time we update the toolchain from upstream, we may just lose those patches. Unless somebody wants to maintain a fork of the toolchain, but I would really prefer to keep as close as possible to upstream 😇.

@julianoes
Copy link
Collaborator

Fixed in v1.4 but for v2, we'll try to update this properly with #2184.

@julianoes julianoes closed this Dec 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants