Skip to content

Replace make_tables by C++11 constexpr arrays#1620

Merged
derselbst merged 22 commits intomasterfrom
byebye-gentables
Aug 22, 2025
Merged

Replace make_tables by C++11 constexpr arrays#1620
derselbst merged 22 commits intomasterfrom
byebye-gentables

Conversation

@derselbst
Copy link
Member

@derselbst derselbst commented Aug 3, 2025

Bye bye make_tables. This PR proposes to replace the auto-generated lookup tables (using the hacky ExternalProject CMake approach) with C++11 lookup tables.

References gcem as submodule for C++11 constexpr math, making it necessary to update all CI pipeline to check out submodules.

When this PR is merged, a C++11 compliant compiler will be required to compile fluidsynth!

Currently, this PR is in a PoC state as it's incomplete:

  • Port the 2D DSP lookup tables
  • Compare the contents of the new array with the old array.

Yet, it compiles fine on all platforms and passes the unit tests. For the latter point, I wrote a unit test to compare with the old lookup tables. It passed with a maximum difference of 1e-4. Since I don't want to add 8000 lines of code, I'll revert it again, as the C++ lookuptable implementation is unlikely to change. For future reference, the commit was b263b24.

@derselbst derselbst changed the title Replace gentables by C++11 constexpr arrays Replace make_tables by C++11 constexpr arrays Aug 3, 2025
@komh
Copy link
Contributor

komh commented Aug 4, 2025

Hi/2.

I've encountered the following error on OS/2:

[ 10%] Building CXX object src/CMakeFiles/libfluidsynth-OBJ.dir/gentables/fluid_ct2hz.cpp.o
F:/lang/work/fluidsynth/fluidsynth.git/src/gentables/fluid_ct2hz.cpp:5:10: fatal error: gcem.hpp: No such file or directory
    5 | #include "gcem.hpp"
      |          ^~~~~~~~~~
compilation terminated.
make[2]: *** [src/CMakeFiles/libfluidsynth-OBJ.dir/build.make:152: src/CMakeFiles/libfluidsynth-OBJ.dir/gentables/fluid_ct2hz.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....

@derselbst
Copy link
Member Author

Looks like you forgot to run git submodule update --init

@komh
Copy link
Contributor

komh commented Aug 4, 2025

Thanks, it fixed. This step is automated later ?

Anyway, unfortunately, this pr does not produce any sounds at all on my machine.

@derselbst
Copy link
Member Author

derselbst commented Aug 4, 2025

Thanks, it fixed. This step is automated later ?

No. I have never seen this automated via e.g. hooks or CMake. It's the developers responsibility to deal with the repository and its content. Triggering git submodule update automatically might unintentionally override / revert changes made to the submodule.

Since the content of the gcem submodule is unlikely to change, using git subtree might be a reasonable alternative. git submodule would still be used for versioning the testdata of fluidsynth's manual testsuite. So for me personally it wouldn't make a difference. If I ever figure out a reliable way to automatically validate the rendering results of the manual testsuite, I would still have to enable submodule checkout in all CI pipelines.

unfortunately, this pr does not produce any sounds at all on my machine

I will investigate next weekend. Yet I'm glad it compiles for OS/2 as well :)

@derselbst derselbst force-pushed the byebye-gentables branch 5 times, most recently from a17238c to 70fb035 Compare August 19, 2025 20:56
@derselbst derselbst marked this pull request as ready for review August 19, 2025 21:48
@sonarqubecloud
Copy link

@derselbst derselbst added this to the 2.5 milestone Aug 22, 2025
@derselbst derselbst merged commit 015e537 into master Aug 22, 2025
90 checks passed
@derselbst derselbst deleted the byebye-gentables branch August 22, 2025 18:21
@white-axe
Copy link
Contributor

Is there a way to do this without the compile-time long double arithmetic in fluid_cb2amp.cpp, fluid_concave.cpp, fluid_convex.cpp and fluid_pan.cpp? Why not just use regular double? This pull request has caused FluidSynth to fail to build with GCC on PowerPC targets that use the IBM floating-point ABI, such as Debian and Ubuntu, because GCC doesn't have compile-time long double division implemented for this ABI. Clang still works, though.

Splendide-Imaginarius added a commit to Splendide-Imaginarius/mkxp that referenced this pull request Aug 29, 2025
…ixed

Upstream FluidSynth broke GCC/POWER builds due to long double ABI issues.
For now we can use an older commit until this is sorted out upstream.

The broken PR is FluidSynth/fluidsynth#1620

Thanks to white-axe for analysis.
@derselbst
Copy link
Member Author

derselbst commented Aug 29, 2025

Thanks for the hint. Using long double is a leftover from #512. It at least compiles fine for OpenSuse ppc64le. I see no problem to demote it to double now, PR welcome. Since we have no CI build for your particular target platform and ABI, we cannot guarantee that fluidsynth will compile fine. Feel free to contribute a CI build as well.

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.

3 participants