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

-Ofast not compatible with JUCE #11

Open
zsliu98 opened this issue Jan 21, 2025 · 1 comment
Open

-Ofast not compatible with JUCE #11

zsliu98 opened this issue Jan 21, 2025 · 1 comment

Comments

@zsliu98
Copy link

zsliu98 commented Jan 21, 2025

Hi! When compiling the code with a newer Clang version, I got the following warnings (I use Clang on Windows, but it should be the same):

D:\a\ZLTest\ZLTest\JUCE\modules\juce_core\text/juce_CharacterFunctions.h(225,30): warning: use of infinity is undefined behavior due to the currently enabled floating-point options [-Wnan-infinity-disabled]
  225 |         constexpr auto inf = std::numeric_limits<double>::infinity();
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
D:\a\ZLTest\ZLTest\JUCE\modules\juce_core\text/juce_CharacterFunctions.h(423,16): note: in instantiation of function template specialization 'juce::CharacterFunctions::readDoubleValue<juce::CharPointer_UTF32>' requested here
  423 |         return readDoubleValue (text);
      |                ^
D:\a\ZLTest\ZLTest\JUCE\modules\juce_core\text/juce_CharPointer_UTF32.h(349,78): note: in instantiation of function template specialization 'juce::CharacterFunctions::getDoubleValue<juce::CharPointer_UTF32>' requested here
  349 |     double getDoubleValue() const noexcept      { return CharacterFunctions::getDoubleValue (*this); }
      | 

And then I came across the following post:

https://forum.juce.com/t/windows-clangcl-build-warnings-in-8-0-3/64240

What do you think? It seems that the JUCE team is aware of this. Shall we do the modification suggested by the post or choose -O3 instead?

@zsliu98
Copy link
Author

zsliu98 commented Jan 21, 2025

Candidate for SharedCodeDefaults.cmake:

if (MSVC)
    # fast math and better simd support in RELEASE
    # https://learn.microsoft.com/en-us/cpp/build/reference/fp-specify-floating-point-behavior?view=msvc-170#fast
    target_compile_options(SharedCode INTERFACE $<$<CONFIG:RELEASE>:/fp:precise>)
else ()
    # See the implications here:
    # https://stackoverflow.com/q/45685487
    target_compile_options(SharedCode INTERFACE $<$<CONFIG:RELEASE>:-O3 -fno-signed-zeros -freciprocal-math -ffp-contract=fast>)
    target_compile_options(SharedCode INTERFACE $<$<CONFIG:RelWithDebInfo>:-O3 -fno-signed-zeros -freciprocal-math -ffp-contract=fast>)
endif ()

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

No branches or pull requests

1 participant