This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch/rfc] building glibc fails when gcc is tuned by default to target i686+

if you configure gcc at build time with the '--with-arch' option and specify 
i686 or better, then glibc will fail to build.  the reason for this is that 
gcc will automatically define '__i686' to '1' for all i686 and better 
targets.  so when an asm (.S) file that uses the SETUP_PIC_REG macro, the 
build bombs because the '__i686' in the section name is replaced with a '1':
../sysdeps/i386/elf/setjmp.S: Assembler messages:
../sysdeps/i386/elf/setjmp.S:63: Error: junk at end of line, first 
unrecognized character is `1'

this issue is not seen normally with a default gcc build as the default target 
is i386 (or i486 for Debian users), and glibc ignores CFLAGS optimizations 
when compiling .S files (so CFLAGS='-march=i686' is safe).

one way to fix this as proposed by Thomas <> is to add '-U__i686' 
to the toplevel Makeconfig.  since i'm *pretty* sure this wont fly, i wrote a 
patch that undefines __i686 in the x86-specific sysdep.h file.  undefining 
this preprocessor is OK as the glibc code looks at '__i686__', not '__i686'.  
this covers everything but the code that generates the .init/.fini sections 
for the threading lib (both nptl and linuxthreads).  so i updated the common 
pt-initfini.c to pull in the 'sysdep.h' file.  of course, i'd like to see 
what other solutions people have :)
If gcc is configured to generate i686 code or better by default (like 
when using the --with-arch=pentium3 configure option), then the __i686
macro will always be defined automatically and thus screw up the
compilation of some .S files.

2006-04-25  Mike Frysinger  <>

	* sysdeps/i386/sysdep.h (__i686): Undefine.

--- sysdeps/i386/sysdep.h
+++ sysdeps/i386/sysdep.h
@@ -1,5 +1,6 @@
 /* Assembler macros for i386.
-   Copyright (C) 1991-93,95,96,98,2002,2003,2005 Free Software Foundation, Inc.
+   Copyright (C) 1991-93,95,96,98,2002,2003,2005,2006
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    The GNU C Library is free software; you can redistribute it and/or
@@ -17,6 +18,14 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
+ * When building for i686 targets or better, gcc automatically defines
+ * '__i686' to '1' for us which causes trouble when using section names
+ * like '__i686.get_pc_thunk.reg'.  Since we check for __i686__ in the
+ * code, killing '__i686' shouldn't be a problem.
+ */
+#undef __i686
 #include <sysdeps/generic/sysdep.h>
 #ifdef	__ASSEMBLER__

2006-04-25  Mike Frysinger  <>

	* sysdeps/pthread/pt-initfini.c: Include sysdep.h.

--- nptl/sysdeps/pthread/pt-initfini.c
+++ nptl/sysdeps/pthread/pt-initfini.c
@@ -1,5 +1,5 @@
 /* Special .init and .fini section support.  Linuxthread version.
-   Copyright (C) 1995,1996,1997,2000,2001,2002 Free Software Foundation, Inc.
+   Copyright (C) 1995-1997,2000-2002,2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    The GNU C Library is free software; you can redistribute it
@@ -45,6 +45,9 @@
 /* Embed an #include to pull in the alignment and .end directives. */
 asm ("\n#include \"defs.h\"");
+/* Embed an #include to pull in asm settings. */
+asm ("\n#include <sysdep.h>");
 /* The initial common code ends here. */
 asm ("\n/*@HEADER_ENDS*/");

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]