Bug 175

Summary: a libX11 Makefile overrides CC variable
Product: xorg Reporter: J.P. Larocque <piranha-fdo-bz>
Component: Lib/XlibAssignee: Jim Gettys <jg>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: high CC: astrand, pb
Version: unspecified   
Hardware: All   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description J.P. Larocque 2004-02-02 10:01:11 UTC
In the process of following the X server build instructions at
http://www.freedesktop.org/Software/XserverInstallGuide , I tried compiling
libX11 from a CVS checkout I made this morning.  I'm attempting this on a Debian
Woody system, with both gcc 2.95.4 (named 'gcc') and 3.0.4 (named 'gcc-3.0')
installed.  I'd previously set and exported the variable 'CC' to 'gcc-3.0' in my
shell, before running autogen.sh.  Shortly into executing 'make', this was printed:

cd util; make 
make[2]: Entering directory
`/home/piranha/build/fdo/freedesktop.org-x_server-cvs-20040202/X11/src/util' 
if gcc -DHAVE_CONFIG_H -I. -I. -I../../src    -Wall -Wpointer-arith
-Wstrict-prototypes         -Wmissing-prototypes -Wmissing-declarations        
-Wnested-externs -fno-strict-aliasing   
-I/usr/local/stow/fdo-XExtensions-cvs20040202/include
-I/usr/local/stow/fdo-xtrans-cvs20040202/include/X11/Xtrans
-I/usr/local/stow/fdo-xtrans-cvs20040202/include
-I/usr/local/stow/fdo-Xau-cvs20040202/include  
-I/usr/local/stow/fdo-Xproto-cvs20040202/include   -g -O2 -MT
makekeys-makekeys.o -MD -MP -MF ".deps/makekeys-makekeys.Tpo" \                
                                                          
  -c -o makekeys-makekeys.o `test -f 'makekeys.c' || echo './'`makekeys.c; \ 
then mv -f ".deps/makekeys-makekeys.Tpo" ".deps/makekeys-makekeys.Po"; \    
else rm -f ".deps/makekeys-makekeys.Tpo"; exit 1; \ 
fi 
gcc: cannot specify -o with -c or -S and multiple compilations 
make[2]: *** [makekeys-makekeys.o] Error 1 
make[2]: Leaving directory
`/home/piranha/build/fdo/freedesktop.org-x_server-cvs-20040202/X11/src/util' 
make[1]: *** [../src/util/makekeys] Error 2 
make[1]: Leaving directory
`/home/piranha/build/fdo/freedesktop.org-x_server-cvs-20040202/X11/src' 
make: *** [all-recursive] Error 1 

The syntax for the gcc command seemed incorrect, according to the gcc 2.95 man
page.  I noticed one option ('-MT' perhaps) was not mentioned in the gcc 2.95
man page, but was in the gcc 3.0 man page.  I tried running the
previously-failed gcc command with gcc-3.0, and it succeeded.  I commented out
the line 'override CC = gcc' in src/util/Makefile, which seemed to be forcing
the use of 'gcc', and re-ran make.  As far as I can tell, the build completed
successfully--make returned 0 on exit, after several minutes of compiling--but
being new to compiling components of the X11 system myself, I won't be confident
in that conclusion until I'm done building and can run the freedesktop.org X server.

Not being a developer, I have no idea why that line was in the Makefile.in.  If
there isn't a reason for it to be there, I recommend removing it.
Comment 1 Jim Gettys 2004-02-06 09:05:38 UTC
Phil, I believe this is your doing.

I know we talked about it once.  What is the correct fix?
Comment 2 Phil Blundell 2004-02-06 09:41:19 UTC
Yes, this was indeed my doing.  The issue here is that, when cross-compiling, 
the stuff in the "util" directory needs to be built with the host compiler 
rather than the target one.

I gather from the autotools people that, with a sufficiently new version of 
automake, writing "host_PROGRAM" in the Makefile.am ought to cause everything 
to just work.  I'll try this out and see if it does the right thing; if so, the 
offending override of CC can certainly be removed.
Comment 3 Jim Gettys 2004-02-06 10:23:36 UTC
Well, we already depend on some pretty recent versions of tools; if we
have to update one more, so be it.  
Comment 4 Benedikt Spranger 2005-10-09 16:31:09 UTC
This BUG bites me once more while crosscompiling (add to PTXdist)
Maybe the following patch is a acceptable workaraound:
diff -ruN libX11-0.99.0.orig/src/util/Makefile.am libX11-0.99.0/src/util/Makefil
e.am
--- libX11-0.99.0.orig/src/util/Makefile.am     2005-08-01 22:15:26.000000000 +0
200
+++ libX11-0.99.0/src/util/Makefile.am  2005-10-10 01:00:38.836860355 +0200
@@ -1,8 +1,12 @@
 # $XdotOrg$
 
-noinst_PROGRAMS=makekeys
+# evil hack
+AM_CFLAGS=$(CFLAGS_FOR_BUILD)
+AM_LDFLAGS=$(LDFLAGS_FOR_BUILD)
+
+CC=$(CC_FOR_BUILD)
+LIBTOOL = @LIBTOOL@ --tag=CC
 
-makekeys_CFLAGS=$(X11_CFLAGS) $(BIGREQS_CFLAGS)
+noinst_PROGRAMS=makekeys
 
-#override CC = gcc
-LINK = $(CC) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+# makekeys_CFLAGS=$(X11_CFLAGS) $(BIGREQS_CFLAGS)
Comment 5 Jeremy Huddleston Sequoia 2011-09-24 20:59:04 UTC
This was fixed at some point since I know it works for me.

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.