We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4393

Summary: Linux build fails with --disable-threads
Product: SDL Reporter: Daniel Scharrer <daniel>
Component: threadAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: fontaine.fabrice, icculus, sezeroz
Version: 2.0.9   
Hardware: x86_64   
OS: Linux   
Attachments: fix build with --disable-threads

Description Daniel Scharrer 2018-11-20 04:04:22 UTC
$ ./configure --disable-threads
$ make
[...]
  LTLINK build/libSDL2.la
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: build/.libs/SDL_dynapi.o: in function `initialize_jumptable':
/home/dscharrer/SDL2-2.0.9/src/dynapi/SDL_dynapi_procs.h:34: undefined reference to `SDL_LinuxSetThreadPriority_REAL'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: build/.libs/SDL_waylanddatamanager.o: in function `write_pipe':
/home/dscharrer/SDL2-2.0.9/src/video/wayland/SDL_waylanddatamanager.c:56: undefined reference to `pthread_sigmask'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /home/dscharrer/SDL2-2.0.9/src/video/wayland/SDL_waylanddatamanager.c:73: undefined reference to `pthread_sigmask'
collect2: error: ld returned 1 exit status
make: *** [Makefile:147: build/libSDL2.la] Error 1
Comment 1 Fabrice Fontaine 2018-11-23 21:20:19 UTC
Created attachment 3502 [details]
fix build with --disable-threads
Comment 2 Fabrice Fontaine 2018-11-23 21:21:55 UTC
This issue is raised by SDL_LinuxSetThreadPriority() which has been added since version 2.0.9 and https://github.com/SDL-mirror/SDL/commit/f25a7fa870bdceb339e5105973f689606bcb9086

This function is used in src/dynapi/SDL_dynapi_procs.h even
when SDL_THREADS_DISABLED

However, when SDL_THREADS_DISABLED is set, SDL_LinuxSetThreadPriority is
not defined because thread/pthread/SDL_systhread.c is not built

So SDL_THREADS_DISABLED should be checked in addition to __LINUX__ (see attachment for a patch)

Fixes:
 - http://autobuild.buildroot.org/results/539cb9ab6c605dc6be73ebe90debab1a998f2451
Comment 3 Ryan C. Gordon 2018-11-23 22:21:45 UTC
(In reply to Fabrice Fontaine from comment #2)
> This function is used in src/dynapi/SDL_dynapi_procs.h even
> when SDL_THREADS_DISABLED

This needs to be in SDL_dynapi_procs.h even if the subsystem is disabled; the function must still exist for binary compatibility, but it can just "return SDL_Unsupported();" or whatever if threads are disabled.

--ryan.
Comment 4 Ryan C. Gordon 2018-12-01 15:37:37 UTC
This is fixed in https://hg.libsdl.org/SDL/rev/fa17d3d76431, thanks!

--ryan.
Comment 5 Ozkan Sezer 2018-12-03 06:41:55 UTC
New warning:

In file included from src/thread/pthread/../../SDL_internal.h:45:0,
                 from src/thread/pthread/SDL_systhread.c:22:
src/thread/pthread/SDL_systhread.c: In function 'SDL_SYS_SetThreadPriority':
src/thread/pthread/../../dynapi/SDL_dynapi_overrides.h:673:36: warning: implicit declaration of function 'SDL_LinuxSetThreadPriority_REAL'; did you mean 'SDL_SetThreadPriority_REAL'? [-Wimplicit-function-declaration]
 #define SDL_LinuxSetThreadPriority SDL_LinuxSetThreadPriority_REAL
                                    ^
src/thread/pthread/SDL_systhread.c:206:12: note: in expansion of macro 'SDL_LinuxSetThreadPriority'
     return SDL_LinuxSetThreadPriority(thread, value);
            ^~~~~~~~~~~~~~~~~~~~~~~~~~
Comment 6 Ryan C. Gordon 2018-12-03 07:17:00 UTC
I have this fixed locally, will clean up and commit in the morning.

--ryan.
Comment 7 Ryan C. Gordon 2019-03-01 00:14:48 UTC
(In reply to Ryan C. Gordon from comment #6)
> I have this fixed locally, will clean up and commit in the morning.

...and I did, but forgot to resolve this bug.

Fixed in https://hg.libsdl.org/SDL/rev/f8041c025fd3 and https://hg.libsdl.org/SDL/rev/5d56e3a2a3e4

--ryan.