Getting Xorg to work, even with glxgears!!

Kevin Day msu-kday at student.mcneese.edu
Sun Oct 23 13:46:34 PDT 2005


Okay, for some reason using the commands mentioned by you guys in Xorg,
compilation works, but when i "startx" the sceen goes black and locks up.

I decided to spend some in depth time solving this.  I managed to apply a
few hacks or mods to xorg and learned how to get glxgears and many other
things to compile successfully (but again..when I type startx under my
compilation, the same problem happens!)

So, I am still .. u disgruntled about xorg locking up.  Any Ideas on this?

Now, I will explain how these 3 days of xorg compiling managed to work with 
glxgears and whatnot.

Xorg so happens to assume that the libc on the system is glibc, in doing so,
it make many modifications to how it installs based on what different glibc
versions support (from the ground up).  Xorg's Imakefile detects a glibc
version of 0.0.0; Thus disable most of the necessary features to get stuff to
work!

Now, there is the file, linux.cf, that resides next to host.def;  This file,
does not check whether or not all of its #defines exist already before
assigning whatever values they need. In addition, this file contains many
glibc-assumed scans.  I made a patch that supplies the following defines:

IsNoGlibcSystem  <-- disables all of the scans, but in doing so, some new
options need to be manually added to host.def to make things work (or I
could re-diff the patch with the fixes built in there..but adding them to
host.def seems easier to me)
LinuxLocaleDefines
BuildLibGlxWithoutPIC <-- these two defines don't check whether or not they
are already defined before screwing around with them. The patch fixes that.
(and without BuildLibGlxWithoutPIC used, glxgears seems to compile
effortlessly)

During compile time, the programs: ico, glxinfo, glxgears, and xdriinfo all
require pthreads when the option is enabled but never link to it!  I added
a few sed commands to fix the Imakefiles..
 
Now that those are done, we need to edit host.def to make sure all of the now
disable glibc assumptions can work!
Here is a copy of the import aspects of my host.def. (Notice I got all drivers
to compile, but I had problems compiling some input devices, and I was tired of
spending another four hours or so to compile X again to get those input devices
working):

/*********************BEGIN HOST.DEF*********************/
#define LinuxCLibMajorVersion 0
#define LinuxCLibMinorVersion 9
/* #define XorgServer YES */

/* Xorg seems to assume that you are only using glibc.  Anything else can get
screwed up settings, as with uClib */
/* Here is my attempts to fix this problem */
#define IsNoGlibcSystem /* Hack */
#define LinuxLocaleDefines -DX_LOCALE
#define LinuxSourceDefines -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE
-D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE LinuxAdditionalIncludes
LinuxGnuSourceDefines LinuxLocaleDefines
/* Make sure you have HAS_WCHAR removed if you did not compile it into uclibc
*/
#define XawI18nDefines -DHAS_WCHAR_H -DHAS_WCTYPE_H -DNO_WIDEC_H /* replace
-DHAS_WCHAR_H with -DUSE_XWCHAR_STRING if wchar is not compiled in uclibc */
#define HasPosixThreads YES
#define ThreadedX YES
#define HasThreadSafeAPI YES
#define ThreadsLibrary -lpthread
#define SystemMTDefines -D_REENTRANT
#define HasLibCrypt YES
#define HasPoll NO
#define HasBasename YES
#define BuildIPv6 YES /* Set to NO if uclibc doesn't have ipv6 compiled in */
#define HasAgpGart YES
#define BuildLibGlxWithoutPIC NO
#define HasMTRRSupport YES
#define HasShadowPasswd YES
#define MakeDllModules YES
#define HardenedGccSpec YES
#define ProPoliceSupport YES
#define LinuxUsesNcurses YES
#define BuildDmx YES
#define SpecialMalloc NO
#define UseInternalMalloc NO
#define BaseShLibReqs -lc

/* Compiler options */
#define DefaultGcc2i386Opt -O2 -fno-strength-reduce -fno-strict-aliasing
-march=i686
/* #define DefaultGccAMD64Opt -Os -fno-strength-reduce -fno-strict-aliasing */
/* define DefaultGccIncludeDir */

/* HAS Commands */
#define HasNCurses YES
#define HasGroff YES
#define HasFreetype2 YES
#define HasFontconfig YES
#define HasExpat YES
#define HasLibpng YES
#define HasZlib YES
#define HasLibCrypt YES
#define HasPam YES
#define HasX86Support YES
#define HasMMXSupport YES
#define Has3DNowSupport YES
#define HasMTRRSupport YES
#define HasLinuxJoystick YES /* broken, but worth a try */

/* BUILD Commands */
#define BuildXprint NO
#define BuildXF86DRI YES
#define BuildLibraries YES
#define BuildLibrariesForXServers YES
#define BuildLibrariesForConfigTools YES
#define BuildXprintClients NO

/* Other Commands */
#define DefaultUserPath /bin:/usr/bin:/usr/toolchain/bin
#define DefaultSystemPath /bin:/usr/bin:/usr/toolchain/bin /* Xorg default
seems to have /etc in here...wtf? */
#define DoLoadableServer YES
#define XprtServer NO
#define XnestServer YES
#define XVirtualFramebufferServer YES
#define BourneShell /bin/bash -e

/* Don't include use these 4 commands if you wish to install to the normal
/usr/X11R6 directories */
#define ProjectRoot /usr
#define LinkGLToUsrInclude NO
#define LinkGLToUsrLib NO
#define FontDir /usr/share/fonts

/* DRIVERS TO BUILD */
#define XF86CardDrivers apm ark ati chips cirrus cyrix fbdev glint i128 i740
i810 imstt mga neomagic newport nsc nv rendition s3 s3virge savage
siliconmotion sis tdfx tga trident tseng via vesa vga vmware XF86OSCardDrivers
XF86ExtraCardDrivers
#define XInputDrivers keyboard mouse void
/*#define XInputDrivers calcomp citron digitaledge dmc dynapro elographics fpit
keyboard microtouch mouse mutouch palmax penmount spaceorb summa tek4957 ur98
void wacom */ /* fails to load: aiptex */

/* DRI drivers are built from Mesa CVS */
#define DriDrivers gamma i810 i915 mach64 mga r128 radeon tdfx savage sis ffb
#define DevelDRIDrivers
/*********************END HOST.DEF*********************/

Here is the patch I used to get Xorg to compile:
/*********************BEGIN NOGLIBC PATCH*********************/
Submitted By:            Kevin Day <kevin AT kevux DOT org>
Date:                    2005-10-18
Initial Package Version: 5.5
Upstream Status:         Not Submitted
Description:             Xorg assumes system's libc is glibc and based
judgement from whatever version it finds.  This causes numerous problems with
uClibc.  In addition, many #defines are not checking if they have been defined
already.  This causes more problems with uClibc if these #DEFINE's must be
changed (which they do). I added the #DEFINE IsNoGlibcSystem to allow override
of glibc scans, so that options specified in host.def can be used without being
overwritten by Xorg's assumptions.
--- Xorg-6.8.2/config/cf/linux.cf.orig	2005-10-14 09:20:22.000000000 +0000
+++ Xorg-6.8.2/config/cf/linux.cf	2005-10-14 09:32:10.000000000 +0000
@@ -206,11 +206,15 @@
 # define BinUtilsMajorVersion	LinuxBinUtilsMajorVersion
 #endif
 
+#ifndef LinuxLocaleDefines
+#ifndef IsNoGlibcSystem
 #if (LinuxCLibMajorVersion >= 6 || LinuxDistribution == LinuxSuSE)
 # define LinuxLocaleDefines	/**/
 #else
 # define LinuxLocaleDefines	-DX_LOCALE
 #endif
+#endif
+#endif
 
 #ifndef  LinuxAdditionalIncludes
 # define LinuxAdditionalIncludes	/**/
@@ -224,6 +228,7 @@
 # endif
 #endif
 
+#ifndef IsNoGlibcSystem
 #if LinuxCLibMajorVersion >= 6
 # define LinuxSourceDefines	-D_POSIX_C_SOURCE=199309L \
 				-D_POSIX_SOURCE -D_XOPEN_SOURCE \
@@ -259,6 +264,7 @@
 #  define DefaultCCOptions	GccWarningOptions
 # endif
 #endif
+#endif
 
 #ifndef InstallXloadSetGID
 #define InstallXloadSetGID	NO
@@ -268,19 +274,23 @@
  * XXX Check which versions of Linux really have IPv6.  glibc 2.0 on
  * Red Hat 5.2 doesn't.
  */
+#ifndef IsNoGlibcSystem
 #if LinuxCLibMajorVersion < 6 || \
     (LinuxCLibMajorVersion == 6 && LinuxCLibMinorVersion == 0)
 #define BuildIPv6		NO
 #endif
+#endif
 
 /* <linux/input.h> support mainly for USB support */
 #ifndef HasLinuxInput
+#ifndef IsNoGlibcSystem
 # if OSMajorVersion > 2 || (OSMajorVersion == 2 && OSMinorVersion >= 4)
 #  define HasLinuxInput YES
 # else
 #  define HasLinuxInput NO
 # endif
 #endif
+#endif
 
 /* <linux/joystick.h> appeared in 2.1.45 (officially) */
 #ifndef JoystickSupport
@@ -366,11 +376,13 @@
  * Build shared libGL and the DRI modules without -fPIC on some architectures.
  * This improves performance.
  */
+#ifndef BuildLibGlxWithoutPIC
 #if BuildXF86DRI
 # if defined(i386Architecture)
 #  define BuildLibGlxWithoutPIC	YES
 # endif
 #endif
+#endif
 
 #ifndef HasAgpGart
 #  if defined(i386Architecture) || defined(ia64Architecture) ||
defined(AMD64Architecture)
@@ -388,11 +400,13 @@
  */
 #ifndef HasSSESupport
 #  if defined(i386Architecture)
+#  ifndef IsNoGlibcSystem
 #    if OSMajorVersion > 2 || (OSMajorVersion == 2 && OSMinorVersion >= 4)
 #      define HasSSESupport		YES
 #    else
 #      define HasSSESupport		NO
 #    endif
+#  endif
 #  else
 #    define HasSSESupport		NO
 #  endif
@@ -404,11 +418,13 @@
  */
 #ifndef HasMMXSupport
 #  if defined(i386Architecture)
+#  ifndef IsNoGlibcSystem
 #    if (LinuxCLibMajorVersion > 5)
 #      define HasMMXSupport		YES
 #    else
 #      define HasMMXSupport		NO
 #    endif
+#  endif
 #  else
 #    define HasMMXSupport		NO
 #  endif
@@ -422,11 +438,13 @@
  */
 #ifndef Has3DNowSupport
 #  if defined(i386Architecture)
+#  ifndef IsNoGlibcSystem
 #    if (LinuxCLibMajorVersion > 5)
 #      define Has3DNowSupport		YES
 #    else
 #      define Has3DNowSupport		NO
 #    endif
+#  endif
 #  else
 #    define Has3DNowSupport		NO
 #  endif
@@ -731,6 +749,7 @@
  * test, but this handles the older Red Hat releases at least.
  */
 #ifndef CppCmd
+#ifndef IsNoGlibcSystem
 # if (LinuxDistribution == LinuxRedHat) && \
      ((LinuxCLibMajorVersion < 6) || \
       (LinuxCLibMajorVersion == 6 && LinuxCLibMinorVersion < 1))
@@ -739,6 +758,7 @@
 #  define CppCmd		cpp
 # endif
 #endif
+#endif
 
 /* Some Linux distributions have yacc, some don't. All have bison. */
 #define YaccCmd			bison -y
--- Xorg-6.8.2/config/cf/lnxLib.rules.orig	2005-10-14 09:36:50.000000000 +0000
+++ Xorg-6.8.2/config/cf/lnxLib.rules	2005-10-14 09:37:34.000000000 +0000
@@ -21,6 +21,7 @@
 
 #if UseElfFormat
 
+#ifndef IsNoGlibcSystem
 # if (LinuxCLibMajorVersion >= 5 && LinuxCLibMinorVersion >= 4) ||
LinuxCLibMajorVersion >= 6
 #  ifndef SpecialMalloc
 #   define SpecialMalloc NO
@@ -54,6 +55,7 @@
 /* With GNU libc 2 this works fine. */
 #  define BaseShLibReqs	-lc
 # endif
+#endif
 
 # ifndef SharedDataSeparation
 #  define SharedDataSeparation NO
/*********************END NOGLIBC PATCH*********************/

And Finally, my installation scripts:
/*********************BEGIN INSTALL SCRIPT*********************/
#!/bin/bash
cd ${t_WORK} &&
cd xc &&
patch -Np1 -i ${t_PATCHES}/xorg-6.8.2-nonow-1.patch &&
patch -Np1 -i ${t_PATCHES}/xorg-6.8.2-libGL_PIC-1.patch &&
patch -Np1 -i ${t_PATCHES}/xorg-6.8.2-BUSmemcpy_PIC-1.patch &&
patch -Np1 -i ${t_PATCHES}/xorg-6.8.2-no_Glibc-1.patch &&
find programs/ -type f -name Imakefile | sed -e '/Xserver/d' | xargs sed -e
'1,0s/^/CFLAGS+=-pie -fpie\n&/' -i && 
sed -i -e "s|\$(XLIB)|\$(XLIB) -lpthread|g" programs/ico/Imakefile &&
sed -i -e "s|\$(XLIB)|\$(XLIB) -lpthread|g" programs/glxinfo/Imakefile &&
sed -i -e "s|\$(XLIB)|\$(XLIB) -lpthread|g" programs/glxgears/Imakefile &&
sed -i -e "s|\$(XLIB)|\$(XLIB) -lpthread|g" programs/xdriinfo/Imakefile &&
sed -e '1,0s/^/CFLAGS+=-pie -fpie\n&/' -i programs/Xserver/Imakefile &&
sed -e 's/^CFLAGS.*$/&-pie -fpie/' -i programs/xterm/Makefile.in &&
sed -i '/^SUBDIRS =/s/ etc$//' programs/Xserver/Xprint/Imakefile &&
sed -i -e "s/-DNEEDCEILF//g" lib/GLU/libnurbs/internals/Imakefile &&
sed -e 's/^CFLAGS .*$/& -pie -fpie/' -i config/util/Makefile.ini &&
pushd config/util &&
make -f Makefile.ini lndir &&
cp -v lndir /usr/bin/ &&
popd &&
mkdir -p ../xcbuild &&
cd ../xcbuild &&
lndir ../xc &&
cd ${t_WORK}/xcbuild &&
cp -vf ${t_SCRIPTS}/premade/X/host.def config/cf/ &&
sed -i -e "s@#include <linux/config.h>@/* & */@" `grep -lr linux/config.h *` &&
( make World 2>&1 | tee xorg-compile.log && exit $PIPESTATUS ) &&
make install &&
make install.man &&
rm -v /usr/lib/lib{Xau,Xdmcp,oldX,dmx,fntstubs,xf86config,Xfont}.a &&
ldconfig &&
echo "/tmp/.ICE-unix dir 1777 root root" >> /etc/sysconfig/createfiles &&
cp -vd ${t_SCRIPTS}/premade/X/xorg.conf* /etc/X11 &&
cp -vR ${t_SCRIPTS}/premade/X/startx /etc/skel/.startx &&
cp -vR ${t_SCRIPTS}/premade/X/startx /root/.startx &&
rm -v /usr/bin/lndir
/*********************END INSTALL SCRIPT*********************/

Sorry about the extremely long e-mail, but for every single error I had, that
was another 4 hours of recompiling.  I spent three days getting this to work.
At it was sweet when it finished installing!  I could probably clean up the
patches, scripts, and host.def, but I do not feel like compiling Xorg again for
some time.
I'll attatch all the files listed here. (host.def is called host.def.c for easy
readibility in vim and other syntax coloring editors)
-- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: host.def.c
Type: application/octet-stream
Size: 3384 bytes
Desc: not available
URL: <http://lists.linuxfromscratch.org/pipermail/hlfs-dev/attachments/20051023/5d8097cc/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xorg
Type: application/octet-stream
Size: 1766 bytes
Desc: not available
URL: <http://lists.linuxfromscratch.org/pipermail/hlfs-dev/attachments/20051023/5d8097cc/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xorg-6.8.2-no_Glibc-1.patch
Type: application/octet-stream
Size: 4501 bytes
Desc: not available
URL: <http://lists.linuxfromscratch.org/pipermail/hlfs-dev/attachments/20051023/5d8097cc/attachment-0002.obj>


More information about the hlfs-dev mailing list