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

Build failure on Alpine Linux #1229

Closed
PureTryOut opened this issue Apr 4, 2023 · 8 comments · Fixed by #1245
Closed

Build failure on Alpine Linux #1229

PureTryOut opened this issue Apr 4, 2023 · 8 comments · Fixed by #1245
Labels

Comments

@PureTryOut
Copy link

FluidSynth version

2.3.2

Describe the bug

Build failure.

ninja: job failed: /usr/lib/ccache/bin/gcc  -I/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/build -I/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/build/include -I/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src -I/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/drivers -I/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/synth -I/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/rvoice -I/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/midi -I/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/utils -I/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/sfloader -I/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/bindings -I/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/include -isystem /usr/include/glib-2.0 -isystem /usr/lib/glib-2.0/include -isystem /usr/include/pipewire-0.3 -isystem /usr/include/spa-0.2 -isystem /usr/include/dbus-1.0 -isystem /usr/lib/dbus-1.0/include -isystem /usr/include/readline -Os -fomit-frame-pointer -Wall -W -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wno-unused-parameter -Wdeclaration-after-statement -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Wbad-function-cast -Wcast-align -O2 -g -DNDEBUG -std=gnu90 -fPIC -fvisibility=hidden -fopenmp -pthread -D_REENTRANT -D_POSIX_C_SOURCE=199506L -DNCURSES_WIDECHAR -MD -MT src/CMakeFiles/libfluidsynth-OBJ.dir/bindings/fluid_ladspa.c.o -MF src/CMakeFiles/libfluidsynth-OBJ.dir/bindings/fluid_ladspa.c.o.d -o src/CMakeFiles/libfluidsynth-OBJ.dir/bindings/fluid_ladspa.c.o -c /home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/bindings/fluid_ladspa.c
In file included from /home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/utils/fluid_sys.h:42,
                 from /home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/bindings/fluid_ladspa.h:24,
                 from /home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/bindings/fluid_ladspa.c:28:
/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/bindings/fluid_ladspa.c: In function 'get_node':
/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/utils/fluidsynth_priv.h:258:34: error: implicit declaration of function 'strcasecmp' [-Werror=implicit-function-declaration]
  258 | #define FLUID_STRCASECMP         strcasecmp
      |                                  ^~~~~~~~~~
/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/bindings/fluid_ladspa.c:1137:12: note: in expansion of macro 'FLUID_STRCASECMP'
 1137 |         if(FLUID_STRCASECMP(node->name, name) == 0)
      |            ^~~~~~~~~~~~~~~~
/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/bindings/fluid_ladspa.c: In function 'get_effect_port_idx':
/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/utils/fluidsynth_priv.h:264:35: error: implicit declaration of function 'strncasecmp' [-Werror=implicit-function-declaration]
  264 | #define FLUID_STRNCASECMP         strncasecmp
      |                                   ^~~~~~~~~~~
/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/bindings/fluid_ladspa.c:1174:12: note: in expansion of macro 'FLUID_STRNCASECMP'
 1174 |         if(FLUID_STRNCASECMP(effect->desc->PortNames[i], name, FLUID_STRLEN(name)) == 0)
      |            ^~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/midi/fluid_midi.c: In function 'fluid_player_set_bpm':
/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/midi/fluid_midi.c:2532:5: warning: 'fluid_player_set_midi_tempo' is deprecated [-Wdeprecated-declarations]
 2532 |     return fluid_player_set_midi_tempo(player, 60000000L / bpm);
      |     ^~~~~~
/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/midi/fluid_midi.c:2509:5: note: declared here
 2509 | int fluid_player_set_midi_tempo(fluid_player_t *player, int tempo)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
ninja: job failed: /usr/lib/ccache/bin/gcc  -I/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/build -I/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/build/include -I/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src -I/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/drivers -I/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/synth -I/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/rvoice -I/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/midi -I/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/utils -I/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/sfloader -I/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/bindings -I/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/include -isystem /usr/include/glib-2.0 -isystem /usr/lib/glib-2.0/include -isystem /usr/include/pipewire-0.3 -isystem /usr/include/spa-0.2 -isystem /usr/include/dbus-1.0 -isystem /usr/lib/dbus-1.0/include -isystem /usr/include/readline -Os -fomit-frame-pointer -Wall -W -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wno-unused-parameter -Wdeclaration-after-statement -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Wbad-function-cast -Wcast-align -O2 -g -DNDEBUG -std=gnu90 -fPIC -fvisibility=hidden -fopenmp -pthread -D_REENTRANT -D_POSIX_C_SOURCE=199506L -DNCURSES_WIDECHAR -MD -MT src/CMakeFiles/libfluidsynth-OBJ.dir/bindings/fluid_cmd.c.o -MF src/CMakeFiles/libfluidsynth-OBJ.dir/bindings/fluid_cmd.c.o.d -o src/CMakeFiles/libfluidsynth-OBJ.dir/bindings/fluid_cmd.c.o -c /home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/bindings/fluid_cmd.c
In file included from /home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/utils/fluid_sys.h:42,
                 from /home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/bindings/fluid_cmd.h:24,
                 from /home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/bindings/fluid_cmd.c:21:
/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/bindings/fluid_cmd.c: In function 'fluid_handle_set':
/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/utils/fluidsynth_priv.h:258:34: error: implicit declaration of function 'strcasecmp' [-Werror=implicit-function-declaration]
  258 | #define FLUID_STRCASECMP         strcasecmp
      |                                  ^~~~~~~~~~
/home/bart/Documents/Git/alpine/aports/community/fluidsynth/src/fluidsynth-2.3.2/src/bindings/fluid_cmd.c:2022:16: note: in expansion of macro 'FLUID_STRCASECMP'
 2022 |             if(FLUID_STRCASECMP(av[1], "yes") == 0
      |                ^~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
ninja: subcommands failed

Expected behavior

The build to succeed.

Steps to reproduce

Build fluidsynth on a fully updated Alpine Linux edge system.

@PureTryOut PureTryOut added the bug label Apr 4, 2023
@derselbst derselbst changed the title Build failure of 2.3.2 on Alpine Linux "implicit declaration of function 'strcasecmp'" Build failure on Alpine Linux Apr 4, 2023
@derselbst
Copy link
Member

Thanks for the report. However, this is not specific to a certain version of fluidsynth, it rather affects all of them, as I am not aware of anyone having ever tried to compile this on a non-glibc based distribution. Also, all of our Linux-CI builds are compiled against glibc. Apparently, musl handles these old BSD functions strncasecmp and friends differently. As a workaround, could you let me know whether adding the line

#include <strings.h>

below this line

#include <string.h>

makes it work?

@nekopsykose
Copy link

it does, then after:

src/bindings/fluid_rtkit.c:55:20: error: implicit declaration of function 'syscall' [-Werror=implicit-function-declaration]
   55 |     return (pid_t) syscall(SYS_gettid);
      |                    ^~~~~~~

@derselbst
Copy link
Member

Ok, so no quick fix, I see. Then we have to approach it step by step, whereas the first step would be to add a CI build which compiles fluidsynth inside an Alpine Linux Docker container. It will take a bit before I find time to do so.

@nekopsykose
Copy link

nekopsykose commented Apr 5, 2023

the latter is fixed by setting -D_GNU_SOURCE as a compiler define (instead of inside a file, like what src/bindings/fluid_rtkit.c does).

the reason why is that fluid_rtkit.h/fluid_sys.h already includes some system headers, then later the _GNU_SOURCE is set in .c before including more system headers, but the headers have already been included. this mixes some definitions, and in this case fails to expose syscall (since including the headers a second time just skips any further definitions via include guards).

one solution is to move the define above every include in the .c (before the fluid_rtkit.h inclusion), another is to set it globally in cmake instead of inside these files.

@derselbst
Copy link
Member

I finally found some time for setting up a CI build. Unfortunately, I'm not able to reproduce the build failure reported by @PureTryOut.

I'm using this Dockerfile which builds the container and runs the build in this pipeline. But as you can see in Azure DevOps, the build succeeds (there are some minor warnings though).

I'm not using Alpine edge, as I believe it's better to use a stable version for CI builds. Any idea what else I might be missing or why gcc doesn't complain about strncasecmp ? @PureTryOut were you passing any special flags to cmake?

@thesamesam
Copy link

Indeed, musl's string.h includes strings.h with:

#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
#include <strings.h>
#endif

so it'll depend on the compiler used and the -std=... setting. It may vary based on musl version as well. I can't reproduce with the same options as in the Gentoo bug report (https://bugs.gentoo.org/906150) so it's probably baased on some option being enabled/disabled automagically when a dependency is installed.

@derselbst
Copy link
Member

I finally got it reproduced. The macro _POSIX_C_SOURCE=199506L apparently changes some preprocessor expansion logic, causing either _GNU_SOURCE or _BSD_SOURCE to be not defined implicitly and therefore causing the build to fail. I'll fix it later.

@derselbst
Copy link
Member

Will be fixed in 2.3.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants