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 1392

Summary: Debian patch: do not propagate -lpthread
Product: SDL Reporter: manuel.montezelo
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: parasti+libsdl
Version: 2.0.0   
Hardware: Other   
OS: Linux   
Attachments: dont_propagate_lpthread.diff
SDL2_dont_propagate_lpthread.diff

Description manuel.montezelo 2012-01-22 10:33:54 UTC
Created attachment 795 [details]
dont_propagate_lpthread.diff

Hello,

Since the bug report[1] in 2006 Debian is shipping the patch attached.

[1] http://bugs.debian.org/375822

Maybe nowadays you don't propagate that library for linking, so maybe the patch should be dropped, but at the moment I do not have an easy/quick way to check it.

So I am submitting this report in the case that you consider it useful (even if maybe the patch itself has to be reworked), or otherwise learn if the patch is unneeded or even harmful.

Regards.
Comment 1 Sam Lantinga 2012-01-22 10:54:21 UTC
At some point it was required that multi-threaded programs using pthreads on Linux link directly to the pthread library.  I don't remember all the details, but it had something to do with initializing C runtime variables correctly.

I'm sure it's not an issue anymore, but I'd rather not apply this patch in 1.2.  I'll go ahead and make this change in 1.3 though.

Thanks!
Comment 2 manuel.montezelo 2013-10-19 23:48:31 UTC
This affects SDL2, it seems that it was not fixed, or the fix reverted.

Comparing the current Debian packages for SDL2 (patched) and the one removing the patch:

------
$ diff -u /usr/bin/sdl2-config /tmp/libsdl2_next/usr/bin/sdl2-config 
--- /usr/bin/sdl2-config        2013-08-30 19:23:38.000000000 +0100
+++ /tmp/libsdl2_next/usr/bin/sdl2-config       2013-10-19 22:09:40.000000000 +0100
@@ -45,7 +45,7 @@
       echo -I${prefix}/include/SDL2   -D_REENTRANT
       ;;
     --libs)
-      echo -L${prefix}/lib/x86_64-linux-gnu  -lSDL2
+      echo -L${prefix}/lib/x86_64-linux-gnu  -lSDL2  -lpthread
       ;;
     --static-libs)
 #    --libs|--static-libs)
------

Same for pkg-config files:

------
--- /usr/lib/x86_64-linux-gnu/pkgconfig/sdl2.pc 2013-08-30 19:23:38.000000000 +0100
+++ /tmp/libsdl2_next/usr/lib/x86_64-linux-gnu/pkgconfig/sdl2.pc        2013-10-19 22:09:40.000000000 +0100
@@ -13 +13 @@
-Libs: -L${libdir}  -lSDL2
+Libs: -L${libdir}  -lSDL2  -lpthread
------

The patch (attached) that we're applying is the same, but adapted for SDL2.
Comment 3 manuel.montezelo 2013-10-19 23:49:21 UTC
Created attachment 1381 [details]
SDL2_dont_propagate_lpthread.diff
Comment 4 Sam Lantinga 2013-10-20 17:20:31 UTC
I'm applying this patch.  We'll see if we get any reports of issues on modern systems.
http://hg.libsdl.org/SDL/rev/b5d893a07471

Thanks!
Comment 5 Sam Lantinga 2013-10-20 17:21:05 UTC
Closing bug.
Comment 6 Jānis Rūcis 2013-10-21 16:18:50 UTC
Reopening as this patch broke linking under MinGW due to missing -lSDLmain and -mwindows.

A better solution is probably to remove $pthread_lib from SDL_LIBS in configure.in rather than to modify the generated scripts.
Comment 7 Sam Lantinga 2013-10-21 17:35:03 UTC
Reverted and awaiting a better fix.

Thanks Jānis!
Comment 8 Sam Lantinga 2015-05-26 13:33:21 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/2a9739ca6440