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 1769 - libX11-1.5.99.901 has changed prototype of _XData32, SDL-1.2 does not build
Summary: libX11-1.5.99.901 has changed prototype of _XData32, SDL-1.2 does not build
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: build (show other bugs)
Version: 1.2.15
Hardware: x86_64 Linux
: P5 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
: 1875 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-03-27 11:03 UTC by Petr Pisar
Modified: 2018-07-31 08:31 UTC (History)
7 users (show)

See Also:


Attachments
Proposed fix (646 bytes, patch)
2013-03-27 11:24 UTC, Petr Pisar
Details | Diff
libsdl-1.2-fix-compilation-libX11.patch (2.20 KB, patch)
2013-06-02 11:05 UTC, Azamat H. Hackimov
Details | Diff
libsdl2-fix-compilation-libX11.patch (5.08 KB, patch)
2013-06-02 11:06 UTC, Azamat H. Hackimov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Pisar 2013-03-27 11:03:30 UTC
When building libsdl-1.2.15 against libX11-1.5.99.901 on x86_64, I get error on mismatching _XData32 declaration:

gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -I./include -D_GNU_SOURCE=1 -fvisibility=hidden -D_REENTRANT -DXTHREADS -D_REENTRANT -DHAVE_LINUX_VERSION_H -Wall -c ./src/video/x11/SDL_x11dyn.c  -fPIC -DPIC -o build/.libs/SDL_x11dyn.o
./src/video/x11/SDL_x11sym.h:168:17: error: conflicting types for '_XData32'
 SDL_X11_SYM(int,_XData32,(Display *dpy,register long *data,unsigned len),(dpy,data,len),return)
                 ^
./src/video/x11/SDL_x11dyn.c:95:5: note: in definition of macro 'SDL_X11_SYM'
  rc fn params { ret p##fn args ; }
     ^
In file included from ./src/video/x11/SDL_x11dyn.h:34:0,
                 from ./src/video/x11/SDL_x11dyn.c:26:
/usr/include/X11/Xlibint.h:595:12: note: previous declaration of '_XData32' was here
 extern int _XData32(
            ^
make: *** [build/SDL_x11dyn.lo] Error 1


This is due to changes in libX11 coming with commit:

commit f0b171c8ea7b055ba520272ea9a2604e18841ac7
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date:   Fri Feb 15 23:34:40 2013 -0800

    Preserve constness in casting arguments through the Data*() routines
    
    Casts were annoying gcc by dropping constness when changing types,
    when routines simply either copy data into the request buffer or
    send it directly to the X server, and never modify the input.
    
    Fixes gcc warnings including:
    ChProp.c: In function 'XChangeProperty':
    ChProp.c:65:6: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
    ChProp.c:65:6: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
    ChProp.c:74:6: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
    ChProp.c:74:6: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
    ChProp.c:83:6: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
    SetHints.c: In function 'XSetStandardProperties':
    SetHints.c:262:20: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
    SetPntMap.c: In function 'XSetPointerMapping':
    SetPntMap.c:46:5: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
    SetPntMap.c:46:5: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
    StBytes.c: In function 'XStoreBuffer':
    StBytes.c:97:33: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
    StName.c: In function 'XStoreName':
    StName.c:40:27: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
    StName.c: In function 'XSetIconName':
    StName.c:51:27: warning: cast discards '__attribute__((const))' qualifier from pointer target type [-Wcast-qual]
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>

Relevant change in <X11/Xlibint.h> is:

 extern int _XData32(
             Display *dpy,
-            register long *data,
+            register _Xconst long *data,
             unsigned len
 );

Reading SDL 1.2 and 2 hg repositories, I believe both of them are affected.
Comment 1 Petr Pisar 2013-03-27 11:24:46 UTC
Created attachment 1078 [details]
Proposed fix
Comment 2 Nikos Chantziaras 2013-05-29 04:31:26 UTC
Bug is still there in SDL 2.0.0 RC1.
Comment 3 Sam Lantinga 2013-05-29 06:29:01 UTC
Ryan, can you fix this for SDL 2.0 release?

Thanks!
Comment 4 Ellie 2013-06-01 07:56:03 UTC
I filed #1875 for SDL 2
Comment 5 Ellie 2013-06-01 07:57:39 UTC
*** Bug 1875 has been marked as a duplicate of this bug. ***
Comment 6 Azamat H. Hackimov 2013-06-02 07:16:49 UTC
Proposed patch is not backward compatible with libX11 < 1.5.99.901.
Comment 7 Azamat H. Hackimov 2013-06-02 11:05:44 UTC
Created attachment 1166 [details]
libsdl-1.2-fix-compilation-libX11.patch

This patch for SDL 1.2 is backward compatible with old libX11 version. Please test it.
Comment 8 Azamat H. Hackimov 2013-06-02 11:06:41 UTC
Created attachment 1167 [details]
libsdl2-fix-compilation-libX11.patch

Patch for SDL2, cmake and autotools.
Comment 9 Sam Lantinga 2013-06-02 23:14:09 UTC
Fix looks good, thanks! :)
Comment 10 Azamat H. Hackimov 2013-06-02 23:52:39 UTC
Will you apply patch for SDL 1.2?
Comment 11 Marcus von Appen 2013-06-05 04:50:25 UTC
(In reply to comment #10)
> Will you apply patch for SDL 1.2?

Badly needed for any platform with a recent xorg :-).
Comment 12 Sam Lantinga 2013-06-06 02:41:53 UTC
Yep, added 1.2 patch, thanks!
http://hg.libsdl.org/SDL/rev/91ad7b43317a
Comment 13 Vicente Olivert Riera 2014-01-08 17:10:51 UTC
(In reply to Sam Lantinga from comment #12)
> Yep, added 1.2 patch, thanks!
> http://hg.libsdl.org/SDL/rev/91ad7b43317a

In that patch you are modifying configure.in to define SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32, so autoreconf should be ran to make those changes take effect. The problem is that autoreconf fails: https://bugzilla.libsdl.org/show_bug.cgi?id=2340
Comment 14 Azamat H. Hackimov 2014-01-08 19:21:18 UTC
(In reply to Vicente Olivert Riera from comment #13)
> (In reply to Sam Lantinga from comment #12)
> > Yep, added 1.2 patch, thanks!
> > http://hg.libsdl.org/SDL/rev/91ad7b43317a
> 
> In that patch you are modifying configure.in to define
> SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32, so autoreconf should be ran to
> make those changes take effect. The problem is that autoreconf fails:
> https://bugzilla.libsdl.org/show_bug.cgi?id=2340

Your problem not directly related to this bug, I added comment to your bug.
Comment 15 WSC 2016-05-18 09:21:11 UTC
There is a regression in v1.2.15, xdata32 patch disappeared:

arch: x86_64
uname -r: 4.5.2-1
libX11-6: 1.6.3-2.14
--------------------
wget -O - http://www.libsdl.org/release/SDL-1.2.15.tar.gz | gunzip | tar -xf -
cd SDL-1.2.15
grep -i xdata32 configure.in || echo 'No such!'
No such!




---------

/bin/sh ./libtool --mode=compile gcc -g -O2  -I./include -D_GNU_SOURCE=1 -fvisibility=hidden   -D_REENTRANT  -DXTHREADS -D_REENTRANT -DHAVE_LINUX_VERSION_H -Wall -c ./src/video/x11/SDL_x11dyn.c  -o build/SDL_x11dyn.lo
libtool: compile:  gcc -g -O2 -I./include -D_GNU_SOURCE=1 -fvisibility=hidden -D_REENTRANT -DXTHREADS -D_REENTRANT -DHAVE_LINUX_VERSION_H -Wall -c ./src/video/x11/SDL_x11dyn.c  -fPIC -DPIC -o build/.libs/SDL_x11dyn.o
./src/video/x11/SDL_x11sym.h:168:17: error: conflicting types for '_XData32'
 SDL_X11_SYM(int,_XData32,(Display *dpy,register long *data,unsigned len),(dpy,data,len),return)
                 ^
./src/video/x11/SDL_x11dyn.c:95:5: note: in definition of macro 'SDL_X11_SYM'
  rc fn params { ret p##fn args ; }
     ^
In file included from ./src/video/x11/SDL_x11dyn.h:34:0,
                 from ./src/video/x11/SDL_x11dyn.c:26:
/usr/include/X11/Xlibint.h:681:12: note: previous declaration of '_XData32' was here
 extern int _XData32(
            ^
build-deps:1178: recipe for target 'build/SDL_x11dyn.lo' failed
make: *** [build/SDL_x11dyn.lo] Error 1
Comment 16 Azamat H. Hackimov 2016-05-18 09:28:10 UTC
This patch intended to appear in 1.2.16, not in 1.2.15. If you have problems with 1.2.15, you need apply patch manually.
Comment 17 Ozkan Sezer 2018-07-31 08:31:21 UTC
Closing this: the fix is already in SDL-1.2 branch.