Bug 47971

Summary: git version of xserver fails to compile with -O2 and #define _GNU_SOURCE 1
Product: xorg Reporter: Sérgio M. Basto <sergio>
Component: Server/GeneralAssignee: Xorg Project Team <xorg-team>
Status: RESOLVED NOTOURBUG QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium CC: sergio
Version: git   
Hardware: Other   
OS: Linux (All)   
Whiteboard: 2012BRB_Reviewed
i915 platform: i915 features:
Attachments:
Description Flags
fail without #define HAVE_STRNDUP 1
none
better look of fail without #define HAVE_STRNDUP 1 none

Description Sérgio M. Basto 2012-03-27 17:51:12 UTC
seems the same error of bug #43235
git version in fedora rawhide from today so may also be a problem with new gcc 4.7
the sample got #define _GNU_SOURCE 1 

cat teste.c 
#define _GNU_SOURCE 1
#include <xf86.h>

So: 
gcc -c -I/usr/include/x11 -I/usr/include/xorg -I/usr/include/pixman-1 -I/usr/include/GL -I/usr/include/xorg -I/usr/include/pixman-1 -I/usr/include/drm -I/usr/include/libdrm teste.c

compiles no problem, but with -O2

gcc -c -I/usr/include/x11 -I/usr/include/xorg -I/usr/include/pixman-1 -I/usr/include/GL -I/usr/include/xorg -I/usr/include/pixman-1 -I/usr/include/drm -I/usr/include/libdrm teste.c -O2

In file included from /usr/include/xorg/misc.h:111:0,
                 from /usr/include/xorg/xf86str.h:37,
                 from /usr/include/xorg/xf86.h:44,
                 from teste.c:3:
/usr/include/xorg/os.h:496:55: error: expected identifier or ‘(’ before ‘__extension__’


don't compile .
Comment 1 Sérgio M. Basto 2012-03-29 20:16:39 UTC
gcc say is source fault . 

strndup is a macro in glibc header files.  Use (strndup) to disable the macro
function.

This is not a GCC bug or a glibc bug (since you supply  _GNU_SOURCE which says
define this macro) as the header is using something in the GNU_SOURCE
namespace.


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52785#c4
Comment 2 Alan Coopersmith 2012-03-29 20:21:59 UTC
I don't see what this has to do with building the X server - all the snippets
here are headers out of context.

When building the X server, the configure script detects if your platform has
strndup and defines HAVE_STRNDUP in dix-config.h & xorg-config.h, which xf86.h
includes when used inside the X server builds.

What are you really doing when you see this error?
Comment 3 Sérgio M. Basto 2012-03-29 20:40:37 UTC
(In reply to comment #2)
> What are you really doing when you see this error?

I am trying compile VirtualBox-OSE-4.1.10 for Fedora 17, rpmfusion.org packages 

but I reduce the problem to 
teste.c 
#define _GNU_SOURCE 1
#include <xf86.h>

> When building the X server, the configure script detects if your platform has
> strndup and defines HAVE_STRNDUP in dix-config.h & xorg-config.h, which xf86.h
> includes when used inside the X server builds.

I also add 
#define HAVE_STRNDUP 1 to source and finally could compile the VirtualBox.   

./configure add defines, seems to me that is not the best way, but I don't know, I have to think and I'm not an expert. 
Thanks,
Comment 4 Sérgio M. Basto 2012-04-12 21:48:11 UTC

(In reply to comment #2)
> I don't see what this has to do with building the X server - all the snippets
> here are headers out of context.
> 
> When building the X server, the configure script detects if your platform has
> strndup and defines HAVE_STRNDUP in dix-config.h & xorg-config.h, which xf86.h
> includes when used inside the X server builds.
> 
> What are you really doing when you see this error?

since all problem is not define HAVE_STRNDUP
are you saying ? that  
/usr/share/xorg-x11-server-source/include/xorg-config.h
and 
/usr/share/xorg-x11-server-source/include/dix-config.h
should define HAVE_STRNDUP ?
I want compile X11 parts of VirtualBox with Fedora X11 server sources.
Comment 5 Alan Coopersmith 2012-04-13 09:03:58 UTC
I have no idea what you put in /usr/share/xorg-x11-server-source, but if you 
download the sources X.Org provides for the X server and run the configure 
script, it should put

#define HAVE_STRNDUP 1

in include/dix-config.h and include/xorg-server.h if your platform supports
strndup().
Comment 6 Sérgio M. Basto 2012-04-13 09:13:40 UTC
(In reply to comment #5)
> I have no idea what you put in /usr/share/xorg-x11-server-source,

rpm -qf /usr/share/xorg-x11-server-source

xorg-x11-server-source-1.11.4-2.fc16.noarch

Neither do I, I use xorg-x11-server-source provide by Fedora 17 

> but if you 
> download the sources X.Org provides for the X server and run the configure 
> script, it should put
> 
> #define HAVE_STRNDUP 1
> 
> in include/dix-config.h and include/xorg-server.h if your platform supports
> strndup().

seems don't have it
Comment 7 Sérgio M. Basto 2014-03-16 18:55:40 UTC
Created attachment 95897 [details]
fail without #define HAVE_STRNDUP 1

For Compile VirtualBox-4.3.8 for Fedora 21 . I still need define HAVE_STRNDUP

#define HAVE_STRNDUP 1

I manage to drop Buildrequires of xorg-x11-server-source-1.15.0-5.fc21 

Now we just need :
BuildRequires:  libdrm-devel
BuildRequires:  libpciaccess-devel
BuildRequires:  mesa-libGL-devel
BuildRequires:  mesa-libOSMesa-devel
BuildRequires:  pixman-devel
BuildRequires:  xorg-x11-proto-devel
BuildRequires:  xorg-x11-server-devel
BuildRequires:  libXcursor-devel
BuildRequires:  libXcomposite-devel
BuildRequires:  libXmu-devel

Please ask for more info and what information that you need ?
Comment 8 Sérgio M. Basto 2014-03-16 21:17:47 UTC
Created attachment 95900 [details]
better look of fail without #define HAVE_STRNDUP 1
Comment 9 Sérgio M. Basto 2014-03-18 04:16:25 UTC
Hi , I think that find what I'm missing is include :

#include "/usr/share/xorg-x11-server-source/include/xorg-server.h"

to compile X11 drv for guest system (vm) of Fedora on VirtualBox

so this can bug report can be closed ?

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.