* sysdeps/unix/sysv/linux/m68k/dl-librecon.h: New file.
[glibc.git] / FAQ.in
blobe0e73422799ee5ab952ae6cac0cb15b0d776efb4
1             Frequently Asked Questions about the GNU C Library
3 This document tries to answer questions a user might have when
4 installing and using glibc.  Please make sure you read this before
5 sending questions or bug reports to the maintainers.
7 The GNU C library is very complex.  The installation process has not
8 been completely automated; there are too many variables. You can do
9 substantial damage to your system by installing the library
10 incorrectly.  Make sure you understand what you are undertaking before
11 you begin.
13 If you have any questions you think should be answered in this document,
14 please let me know.
16                                                   --drepper@cygnus.com
18 ? Compiling glibc
20 ??      What systems does the GNU C Library run on?
22 {UD} This is difficult to answer.  The file `README' lists the
23 architectures GNU libc was known to run on *at some time*.  This does
24 not mean that it still can be compiled and run on them now.
26 The systems glibc is known to work on as of this release, and most
27 probably in the future, are:
29         *-*-gnu                 GNU Hurd
30         i[3456]86-*-linux-gnu   Linux-2.x on Intel
31         m68k-*-linux-gnu        Linux-2.x on Motorola 680x0
32         alpha-*-linux-gnu       Linux-2.x on DEC Alpha
33         powerpc-*-linux-gnu     Linux and MkLinux on PowerPC systems
34         sparc-*-linux-gnu       Linux-2.x on SPARC
35         sparc64-*-linux-gnu     Linux-2.x on UltraSPARC
36         arm-*-none              ARM standalone systems
37         arm-*-linuxaout         Linux-2.x on ARM using a.out binaries
39 Ports to other Linux platforms are in development, and may in fact
40 work already, but no one has sent us success reports for them.
41 Currently no ports to other operating systems are underway, although a
42 few people have expressed interest.
44 If you have a system not listed above (or in the `README' file) and
45 you are really interested in porting it, contact
47         <bug-glibc@gnu.org>
49 ??      What compiler do I need to build GNU libc?
51 {UD} You must use GNU CC to compile GNU libc.  A lot of extensions of
52 GNU CC are used to increase portability and speed.
54 GNU CC is found, like all other GNU packages, on
55         ftp://ftp.gnu.org/pub/gnu
56 and the many mirror sites.  ftp.gnu.org is always overloaded, so try to find
57 a local mirror first.
59 You always should try to use the latest official release.  Older
60 versions may not have all the features GNU libc requires.  The current
61 releases of egcs (1.0.2) and GNU CC (2.8.1) should work with the GNU C
62 library (for powerpc see question ?powerpc).
64 ??      When I try to compile glibc I get only error messages.
65         What's wrong?
67 {UD} You definitely need GNU make to translate GNU libc.  No
68 other make program has the needed functionality.
70 We recommend version GNU make version 3.75.  Versions 3.76 and 3.76.1
71 have bugs which appear when building big projects like GNU libc.
72 Versions before 3.74 have bugs and/or are missing features.
74 ??      Do I need a special linker or archiver?
76 {UD} You may be able to use your system linker, but GNU libc works
77 best with GNU binutils.
79 On systems where the native linker does not support weak symbols you
80 will not get a fully ISO C compliant C library.  Generally speaking
81 you should use the GNU binutils if they provide at least the same
82 functionality as your system's tools.
84 Always get the newest release of GNU binutils available.  Older
85 releases are known to have bugs that prevent a successful compilation.
87 {ZW} As of release 2.1 a linker supporting symbol versions is
88 required.  For Linux, get binutils-2.8.1.0.23 or later.  Other systems
89 may have native linker support, but it's moot right now, because glibc
90 has not been ported to them.
92 ??powerpc       What tools do I need for powerpc?
94 {GK} For a successful installation you definitely need the most recent
95 tools. You can safely assume that anything earlier than binutils
96 2.8.1.0.17 and egcs-1.0 will have problems. We'd advise at the moment
97 binutils 2.8.1.0.18 and egcs-1.0.1.
99 In fact, egcs 1.0.1 currently has two serious bugs that prevent a
100 clean make; one relates to switch statement folding, for which there
101 is a temporary patch at
103 <http://discus.anu.edu.au/~geoffk/egcs-1.0-geoffk.diff.gz>
105 and the other relates to 'forbidden register spilled', for which the
106 workaround is to put
108 CFLAGS-condvar.c += -fno-inline
110 in configparms.  Later versions of egcs may fix these problems.
113 ??      Do I need some more things to compile GNU C Library?
115 {UD} Yes, there are some more :-).
117 * GNU gettext.  This package contains the tools needed to construct
118   `message catalog' files containing translated versions of system
119   messages. See ftp://ftp.gnu.org/pub/gnu or better any mirror
120   site.  (We distribute compiled message catalogs, but they may not be
121   updated in patches.)
123 * Some files depend on special tools.  E.g., files ending in .gperf
124   need a `gperf' program.  The GNU version (part of libg++) is known
125   to work while some vendor versions do not.
127   You should not need these tools unless you change the source files.
129 * Some scripts need perl5 - but at the moment those scripts are not
130   vital for building and installing GNU libc (some data files will not
131   be created).
133 * When compiling for Linux, the header files of the Linux kernel must
134   be available to the compiler as <linux/*.h> and <asm/*.h>.
136 * lots of disk space (~170MB for i?86-linux; more for RISC platforms).
138 * plenty of time.  Compiling just the shared and static libraries for
139   i?86-linux takes approximately 1h on an i586@133, or 2.5h on
140   i486@66, or 4.5h on i486@33.  Multiply this by 1.5 or 2.0 if you
141   build profiling and/or the highly optimized version as well.  For
142   Hurd systems times are much higher.
144   You should avoid compiling in a NFS mounted filesystem.  This is
145   very slow.
147   James Troup <J.J.Troup@comp.brad.ac.uk> reports a compile time of
148   45h34m for a full build (shared, static, and profiled) on Atari
149   Falcon (Motorola 68030 @ 16 Mhz, 14 Mb memory) and Jan Barte
150   <yann@plato.uni-paderborn.de> reports 22h48m on Atari TT030
151   (Motorola 68030 @ 32 Mhz, 34 Mb memory)
153   If you have some more measurements let me know.
155 ??      What version of the Linux kernel headers should be used?
157 {AJ,UD} The headers from the most recent Linux kernel should be used.
158 The headers used while compiling the GNU C library and the kernel
159 binary used when using the library do not need to match.  The GNU C
160 library runs without problems on kernels that are older than the
161 kernel headers used.  The other way round (compiling the GNU C library
162 with old kernel headers and running on a recent kernel) does not
163 necessarily work.  For example you can't use new kernel features when
164 using old kernel headers for compiling the GNU C library.
166 ??      When I run `nm -u libc.so' on the produced library I still
167         find unresolved symbols.  Can this be ok?
169 {UD} Yes, this is ok.  There can be several kinds of unresolved
170 symbols:
172 * magic symbols automatically generated by the linker.  These have names
173   like __start_* and __stop_*
175 * symbols starting with _dl_* come from the dynamic linker
177 * symbols resolved by using libgcc.a
178   (__udivdi3, __umoddi3, or similar)
180 * weak symbols, which need not be resolved at all (fabs for example)
182 Generally, you should make sure you find a real program which produces
183 errors while linking before deciding there is a problem.
185 ??addon What are these `add-ons'?
187 {UD} To avoid complications with export rules or external source
188 code some optional parts of the libc are distributed as separate
189 packages (e.g., the crypt package, see ?crypt).
191 To use these packages as part of GNU libc, just unpack the tarfiles in
192 the libc source directory and tell the configuration script about them
193 using the --enable-add-ons option.  If you give just --enable-add-ons
194 configure tries to find all the add-on packages in your source tree.
195 This may not work.  If it doesn't, or if you want to select only a
196 subset of the add-ons, give a comma-separated list of the add-ons to
197 enable:
199         configure --enable-add-ons=crypt,linuxthreads
201 for example.
203 Add-ons can add features (including entirely new shared libraries),
204 override files, provide support for additional architectures, and
205 just about anything else.  The existing makefiles do most of the work;
206 only some few stub rules must be written to get everything running.
208 ??      My XXX kernel emulates a floating-point coprocessor for me.
209         Should I enable --with-fp?
211 {ZW} An emulated FPU is just as good as a real one, as far as the C
212 library is concerned.  You only need to say --without-fp if your
213 machine has no way to execute floating-point instructions.
215 People who are interested in squeezing the last drop of performance
216 out of their machine may wish to avoid the trap overhead, but this is
217 far more trouble than it's worth: you then have to compile
218 *everything* this way, including the compiler's internal libraries
219 (libgcc.a for GNU C), because the calling conventions change.
221 ??      When compiling GNU libc I get lots of errors saying functions
222         in glibc are duplicated in libgcc.
224 {EY} This is *exactly* the same problem that I was having.  The
225 problem was due to the fact that configure didn't correctly detect
226 that the linker flag --no-whole-archive was supported in my linker.
227 In my case it was because I had run ./configure with bogus CFLAGS, and
228 the test failed.
230 One thing that is particularly annoying about this problem is that
231 once this is misdetected, running configure again won't fix it unless
232 you first delete config.cache.
234 {UD} Starting with glibc-2.0.3 there should be a better test to avoid
235 some problems of this kind.  The setting of CFLAGS is checked at the
236 very beginning and if it is not usable `configure' will bark.
238 ??      Why do I get messages about missing thread functions when I use
239         librt?  I don't even use threads.
241 {UD} In this case you probably mixed up your installation.  librt uses
242 threads internally and has implicit references to the thread library.
243 Normally these references are satisfied automatically but if the
244 thread library is not in the expected place you must tell the linker
245 where it is.  When using GNU ld it works like this:
247         gcc -o foo foo.c -Wl,-rpath-link=/some/other/dir -lrt
249 The `/some/other/dir' should contain the thread library.  `ld' will
250 use the given path to find the implicitly referenced library while not
251 disturbing any other link path.
253 ??      What's the problem with configure --enable-omitfp?
255 {AJ} When --enable-omitfp is set the libraries are built without frame
256 pointers. Some compilers produce buggy code for this model and
257 therefore we don't advise using it at the moment.
259 If you use --enable-omitfp, you're on your own. If you encounter
260 problems with a library that was build this way, we advise you to
261 rebuild the library without --enable-omitfp.  If the problem vanishes
262 consider tracking the problem down and report it as compiler failure.
264 Since a library build with --enable-omitfp is undebuggable on most
265 systems, debuggable libraries are also built - you can use it by
266 appending "_g" to the library names.
268 The compilation of these extra libraries and the compiler optimizations
269 slow down the build process and need more disk space.
271 ? Installation and configuration issues
273 ??      Can I replace the libc on my Linux system with GNU libc?
275 {UD} You cannot replace any existing libc for Linux with GNU
276 libc.  It is binary incompatible and therefore has a different major
277 version.  You can, however, install it alongside your existing libc.
279 For Linux there are three major libc versions:
280         libc-4          a.out libc
281         libc-5          original ELF libc
282         libc-6          GNU libc
284 You can have any combination of these three installed.  For more
285 information consult documentation for shared library handling.  The
286 Makefiles of GNU libc will automatically generate the needed symbolic
287 links which the linker will use.
289 ??      How do I configure GNU libc so that the essential libraries
290         like libc.so go into /lib and the other into /usr/lib?
292 {UD,AJ} Like all other GNU packages GNU libc is designed to use a base
293 directory and install all files relative to this.  The default is
294 /usr/local, because this is safe (it will not damage the system if
295 installed there).  If you wish to install GNU libc as the primary C
296 library on your system, set the base directory to /usr (i.e. run
297 configure --prefix=/usr <other_options>).  Note that this can damage
298 your system; see ?safety for details.
300 Some systems like Linux have a filesystem standard which makes a
301 difference between essential libraries and others.  Essential
302 libraries are placed in /lib because this directory is required to be
303 located on the same disk partition as /.  The /usr subtree might be
304 found on another partition/disk. If you configure for Linux with
305 --prefix=/usr, then this will be done automatically.
307 To install the essential libraries which come with GNU libc in /lib on
308 systems other than Linux one must explicitly request it.  Autoconf has
309 no option for this so you have to use a `configparms' file (see the
310 `INSTALL' file for details).  It should contain:
312 slibdir=/lib
313 sysconfdir=/etc
315 The first line specifies the directory for the essential libraries,
316 the second line the directory for system configuration files.
318 ??safety        How should I avoid damaging my system when I install GNU libc?
320 {ZW} If you wish to be cautious, do not configure with --prefix=/usr.
321 If you don't specify a prefix, glibc will be installed in /usr/local,
322 where it will probably not break anything.  (If you wish to be
323 certain, set the prefix to something like /usr/local/glibc2 which is
324 not used for anything.)
326 The dangers when installing glibc in /usr are twofold:
328 * glibc will overwrite the headers in /usr/include.  Other C libraries
329   install a different but overlapping set of headers there, so the
330   effect will probably be that you can't compile anything.  You need to
331   rename /usr/include out of the way first.  (Do not throw it away; you
332   will then lose the ability to compile programs against your old libc.)
334 * None of your old libraries, static or shared, can be used with a
335   different C library major version.  For shared libraries this is not a
336   problem, because the filenames are different and the dynamic linker
337   will enforce the restriction.  But static libraries have no version
338   information.  You have to evacuate all the static libraries in
339   /usr/lib to a safe location.
341 The situation is rather similar to the move from a.out to ELF which
342 long-time Linux users will remember.
344 ??      Do I need to use GNU CC to compile programs that will use the
345         GNU C Library?
347 {ZW} In theory, no; the linker does not care, and the headers are
348 supposed to check for GNU CC before using its extensions to the C
349 language.
351 However, there are currently no ports of glibc to systems where
352 another compiler is the default, so no one has tested the headers
353 extensively against another compiler.  You may therefore encounter
354 difficulties.  If you do, please report them as bugs.
356 Also, in several places GNU extensions provide large benefits in code
357 quality.  For example, the library has hand-optimized, inline assembly
358 versions of some string functions.  These can only be used with GCC.
359 See ?string for details.
361 ??crypt When linking with the new libc I get unresolved symbols
362         `crypt' and `setkey'.  Why aren't these functions in the
363         libc anymore?
365 {UD} The US places restrictions on exporting cryptographic programs
366 and source code.  Until this law gets abolished we cannot ship the
367 cryptographic functions together with glibc.
369 The functions are available, as an add-on (see ?addon).  People in the
370 US may get it from the same place they got GNU libc from.  People
371 outside the US should get the code from ftp://ftp.ifi.uio.no/pub/gnu,
372 or another archive site outside the USA.  The README explains how to
373 install the sources.
375 If you already have the crypt code on your system the reason for the
376 failure is probably that you did not link with -lcrypt.  The crypto
377 functions are in a separate library to make it possible to export GNU
378 libc binaries from the US.
380 ??      When I use GNU libc on my Linux system by linking against
381         the libc.so which comes with glibc all I get is a core dump.
383 {UD} On Linux, gcc sets the dynamic linker to /lib/ld-linux.so.1
384 unless the user specifies a -dynamic-linker argument.  This is the
385 name of the libc5 dynamic linker, which does not work with glibc.
387 For casual use of GNU libc you can just specify
388     -dynamic-linker=/lib/ld-linux.so.2
390 which is the glibc dynamic linker, on Linux systems.  On other systems
391 the name is /lib/ld.so.1.
393 To change your environment to use GNU libc for compiling you need to
394 change the `specs' file of your gcc.  This file is normally found at
396         /usr/lib/gcc-lib/<arch>/<version>/specs
398 In this file you have to change a few things:
400 - change `ld-linux.so.1' to `ld-linux.so.2'
402 - remove all expression `%{...:-lgmon}';  there is no libgmon in glibc
404 - fix a minor bug by changing %{pipe:-} to %|
406 Here is what the gcc-2.7.2 specs file should look like when GNU libc
407 is installed at /usr:
409 -----------------------------------------------------------------------
410 *asm:
411 %{V} %{v:%{!V:-V}} %{Qy:} %{!Qn:-Qy} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*}
413 *asm_final:
416 *cpp:
417 %{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{!m386:-D__i486__} %{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}
419 *cc1:
420 %{profile:-p}
422 *cc1plus:
425 *endfile:
426 %{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s
428 *link:
429 -m elf_i386 %{shared:-shared}   %{!shared:     %{!ibcs:       %{!static:        %{rdynamic:-export-dynamic}     %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}}  %{static:-static}}}
431 *lib:
432 %{!shared: %{pthread:-lpthread}         %{profile:-lc_p} %{!profile: -lc}}
434 *libgcc:
435 -lgcc
437 *startfile:
438 %{!shared:      %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s}                 %{!p:%{profile:gcrt1.o%s}                   %{!profile:crt1.o%s}}}}    crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}
440 *switches_need_spaces:
443 *signed_char:
444 %{funsigned-char:-D__CHAR_UNSIGNED__}
446 *predefines:
447 -D__ELF__ -Dunix -Di386 -Dlinux -Asystem(unix) -Asystem(posix) -Acpu(i386) -Amachine(i386)
449 *cross_compile:
452 *multilib:
453 . ;
455 -----------------------------------------------------------------------
457 Things get a bit more complicated if you have GNU libc installed in
458 some other place than /usr, i.e., if you do not want to use it instead
459 of the old libc.  In this case the needed startup files and libraries
460 are not found in the regular places.  So the specs file must tell the
461 compiler and linker exactly what to use.
463 Version 2.7.2.3 does and future versions of GCC will automatically
464 provide the correct specs.
466 ??      Looking through the shared libc file I haven't found the
467         functions `stat', `lstat', `fstat', and `mknod' and while
468         linking on my Linux system I get error messages.  How is
469         this supposed to work?
471 {RM} Believe it or not, stat and lstat (and fstat, and mknod)
472 are supposed to be undefined references in libc.so.6!  Your problem is
473 probably a missing or incorrect /usr/lib/libc.so file; note that this
474 is a small text file now, not a symlink to libc.so.6.  It should look
475 something like this:
477 GROUP ( libc.so.6 libc_nonshared.a )
479 ??      How can I compile gcc 2.7.2.1 from the gcc source code using
480         glibc 2.x?
482 {AJ} There's only correct support for glibc 2.0.x in gcc 2.7.2.3 or
483 later.  But you should get at least gcc 2.8.1 or egcs 1.0.2 (or later
484 versions) instead.
486 ??      The `gencat' utility cannot process the catalog sources which
487         were used on my Linux libc5 based system.  Why?
489 {UD} The `gencat' utility provided with glibc complies to the XPG
490 standard.  The older Linux version did not obey the standard, so they
491 are not compatible.
493 To ease the transition from the Linux version some of the non-standard
494 features are also present in the `gencat' program of GNU libc.  This
495 mainly includes the use of symbols for the message number and the automatic
496 generation of header files which contain the needed #defines to map the
497 symbols to integers.
499 Here is a simple SED script to convert at least some Linux specific
500 catalog files to the XPG4 form:
502 -----------------------------------------------------------------------
503 # Change catalog source in Linux specific format to standard XPG format.
504 # Ulrich Drepper <drepper@cygnus.com>, 1996.
506 /^\$ #/ {
507   h
508   s/\$ #\([^ ]*\).*/\1/
509   x
510   s/\$ #[^ ]* *\(.*\)/\$ \1/
513 /^# / {
514   s/^# \(.*\)/\1/
515   G
516   s/\(.*\)\n\(.*\)/\2 \1/
518 -----------------------------------------------------------------------
520 ??      Programs using libc have their messages translated, but other
521         behavior is not localized (e.g. collating order); why?
523 {ZW} Translated messages are automatically installed, but the locale
524 database that controls other behaviors is not.  You need to run
525 localedef to install this database, after you have run `make
526 install'.  For example, to set up the French Canadian locale, simply
527 issue the command
529     localedef -i fr_CA -f ISO-8859-1 fr_CA
531 Please see localedata/README in the source tree for further details.
533 ??      I have set up /etc/nis.conf, and the Linux libc 5 with NYS
534         works great.  But the glibc NIS+ doesn't seem to work.
536 {TK} The glibc NIS+ implementation uses a /var/nis/NIS_COLD_START
537 file for storing information about the NIS+ server and their public
538 keys, because the nis.conf file does not contain all the necessary
539 information.  You have to copy a NIS_COLD_START file from a Solaris
540 client (the NIS_COLD_START file is byte order independent) or generate
541 it with nisinit from the nis-tools package (available at
542 http://www-vt.uni-paderborn.de/~kukuk/linux/nisplus.html).
544 ??      I have killed ypbind to stop using NIS, but glibc
545         continues using NIS.
547 {TK} For faster NIS lookups, glibc uses the /var/yp/binding/ files
548 from ypbind.  ypbind 3.3 and older versions don't always remove these
549 files, so glibc will continue to use them.  Other BSD versions seem to
550 work correctly.  Until ypbind 3.4 is released, you can find a patch at
551 ftp://ftp.kernel.org/pub/linux/utils/net/NIS/ypbind-3.3-glibc3.diff.
553 ??     Under Linux/Alpha, I always get "do_ypcall: clnt_call:
554        RPC: Unable to receive; errno = Connection refused" when using NIS.
556 {TK} You need a ypbind version which is 64bit clean.  Some versions
557 are not 64bit clean.  A 64bit clean implementation is ypbind-mt.  For
558 ypbind 3.3, you need the patch from ftp.kernel.org (See the previous
559 question).  I don't know about other versions.
562 ??      After installing glibc name resolving doesn't work properly.
564 {AJ} You probably should read the manual section describing
565 nsswitch.conf (just type `info libc "NSS Configuration File"').
566 The NSS configuration file is usually the culprit.
568 ??      I have /usr/include/net and /usr/include/scsi as symlinks
569         into my Linux source tree.  Is that wrong?
571 {PB} This was necessary for libc5, but is not correct when using
572 glibc.  Including the kernel header files directly in user programs
573 usually does not work (see ?kerhdr).  glibc provides its own <net/*>
574 and <scsi/*> header files to replace them, and you may have to remove
575 any symlink that you have in place before you install glibc.  However,
576 /usr/include/asm and /usr/include/linux should remain as they were.
578 ??      Programs like `logname', `top', `uptime' `users', `w' and
579         `who', show incorrect information about the (number of)
580         users on my system.  Why?
582 {MK} See ?getlog.
584 ??      After upgrading to glibc 2.1 with symbol versioning I get
585         errors about undefined symbols.  What went wrong?
587 {AJ} The problem is caused either by wrong program code or tools.  In
588 the versioned libc a lot of symbols are now local that were global
589 symbols in previous versions.  It seems that programs linked against
590 older versions often accidentally used libc global variables --
591 something that should not happen.
593 The only way to fix this is to recompile your program. Sorry, that's
594 the price you might have to pay once for quite a number of advantages
595 with symbol versioning.
597 ??      When I start the program XXX after upgrading the library
598         I get
599           XXX: Symbol `_sys_errlist' has different size in shared
600           object, consider re-linking
601         Why?  What should I do?
603 {UD} As the message says, relink the binary.  The problem is that
604 a few symbols from the library can change in size and there is no way
605 to avoid this.  _sys_errlist is a good example.  Occasionally there are
606 new error numbers added to the kernel and this must be reflected at user
607 level, breaking programs that refer to them directly.
609 Such symbols should normally not be used at all.  There are mechanisms
610 to avoid using them.  In the case of _sys_errlist, there is the
611 strerror() function which should _always_ be used instead.  So the
612 correct fix is to rewrite that part of the application.
614 In some situations (especially when testing a new library release) it
615 might be possible that a symbol changed size when that should not have
616 happened.  So in case of doubt report such a warning message as a
617 problem.
619 ??      What do I need for C++ development?
621 {HJ,AJ} You need either egcs 1.0.2 or gcc-2.8.1 with libstdc++
622 2.8.1 (or more recent versions). libg++ 2.7.2 (and the Linux Versions
623 2.7.2.x) doesn't work very well with the GNU C library due to vtable thunks.
624 If you're upgrading from glibc 2.0.x to 2.1 you have to recompile
625 libstdc++ since the library compiled for 2.0 is not compatible due to the new
626 Large File Support (LFS) in version 2.1.
628 ? Source and binary incompatibilities, and what to do about them
630 ??      I expect GNU libc to be 100% source code compatible with
631         the old Linux based GNU libc.  Why isn't it like this?
633 {DMT,UD} Not every extension in Linux libc's history was well
634 thought-out.  In fact it had a lot of problems with standards compliance
635 and with cleanliness.  With the introduction of a new version number these
636 errors can now be corrected.  Here is a list of the known source code
637 incompatibilities:
639 * _GNU_SOURCE: glibc does not make the GNU extensions available
640   automatically.  If a program depends on GNU extensions or some
641   other non-standard functionality, it is necessary to compile it
642   with the C compiler option -D_GNU_SOURCE, or better, to put
643   `#define _GNU_SOURCE' at the beginning of your source files, before
644   any C library header files are included.  This difference normally
645   manifests itself in the form of missing prototypes and/or data type
646   definitions.  Thus, if you get such errors, the first thing you
647   should do is try defining _GNU_SOURCE and see if that makes the
648   problem go away.
650   For more information consult the file `NOTES' in the GNU C library
651   sources.
653 * reboot(): GNU libc sanitizes the interface of reboot() to be more
654   compatible with the interface used on other OSes.  reboot() as
655   implemented in glibc takes just one argument.  This argument
656   corresponds to the third argument of the Linux reboot system call.
657   That is, a call of the form reboot(a, b, c) needs to be changed into
658   reboot(c).  Beside this the header <sys/reboot.h> defines the needed
659   constants for the argument.  These RB_* constants should be used
660   instead of the cryptic magic numbers.
662 * swapon(): the interface of this function didn't change, but the
663   prototype is in a separate header file <sys/swap.h>.  This header
664   file also provides the SWAP_* constants defined by <linux/swap.h>;
665   you should use them for the second argument to swapon().
667 * errno: If a program uses the variable "errno", then it _must_
668   include <errno.h>.  The old libc often (erroneously) declared this
669   variable implicitly as a side-effect of including other libc header
670   files.  glibc is careful to avoid such namespace pollution, which,
671   in turn, means that you really need to include the header files that
672   you depend on.  This difference normally manifests itself in the
673   form of the compiler complaining about references to an undeclared
674   symbol "errno".
676 * Linux-specific syscalls: All Linux system calls now have appropriate
677   library wrappers and corresponding declarations in various header files.
678   This is because the syscall() macro that was traditionally used to
679   work around missing syscall wrappers are inherently non-portable and
680   error-prone.  The following table lists all the new syscall stubs,
681   the header-file declaring their interface and the system call name.
683        syscall name:    wrapper name:   declaring header file:
684        -------------    -------------   ----------------------
685        bdflush          bdflush         <sys/kdaemon.h>
686        syslog           ksyslog_ctl     <sys/klog.h>
688 * lpd: Older versions of lpd depend on a routine called _validuser().
689   The library does not provide this function, but instead provides
690   __ivaliduser() which has a slightly different interface.  Simply
691   upgrading to a newer lpd should fix this problem (e.g., the 4.4BSD
692   lpd is known to be working).
694 * resolver functions/BIND: like on many other systems the functions of
695   the resolver library are not included in libc itself.  There is a
696   separate library libresolv.  If you get undefined symbol errors for
697   symbols starting with `res_*' simply add -lresolv to your linker
698   command line.
700 * the `signal' function's behavior corresponds to the BSD semantic and
701   not the SysV semantic as it was in libc-5.  The interface on all GNU
702   systems shall be the same and BSD is the semantic of choice.  To use
703   the SysV behavior simply use `sysv_signal', or define _XOPEN_SOURCE.
704   See ?signal for details.
706 ??getlog        Why does getlogin() always return NULL on my Linux box?
708 {UD} The GNU C library has a format for the UTMP and WTMP file which
709 differs from what your system currently has.  It was extended to
710 fulfill the needs of the next years when IPv6 is introduced.  The
711 record size is different and some fields have different positions.
712 The files written by functions from the one library cannot be read by
713 functions from the other library.  Sorry, but this is what a major
714 release is for.  It's better to have a cut now than having no means to
715 support the new techniques later.
717 {MK} There is however a (partial) solution for this problem.  Please
718 take a look at the file `login/README.utmpd'.
720 ??      Where are the DST_* constants found in <sys/time.h> on many
721         systems?
723 {UD} These constants come from the old BSD days and are not used
724 anymore (libc5 does not actually implement the handling although the
725 constants are defined).
727 Instead GNU libc contains zone database support and compatibility code
728 for POSIX TZ environment variable handling.
730 ??      The prototypes for `connect', `accept', `getsockopt',
731         `setsockopt', `getsockname', `getpeername', `send',
732         `sendto', and `recvfrom' are different in GNU libc from
733         any other system I saw.  This is a bug, isn't it?
735 {UD} No, this is no bug.  This version of GNU libc already follows the
736 new Single Unix specifications (and I think the POSIX.1g draft which
737 adopted the solution).  The type for a parameter describing a size is
738 now `socklen_t', a new type.
740 ??kerhdr        On Linux I've got problems with the declarations in Linux
741         kernel headers.
743 {UD,AJ} On Linux, the use of kernel headers is reduced to the minimum.
744 This gives Linus the ability to change the headers more freely.  Also,
745 user programs are now insulated from changes in the size of kernel
746 data structures.
748 For example, the sigset_t type is 32 or 64 bits wide in the kernel.
749 In glibc it is 1024 bits wide.  This guarantees that when the kernel
750 gets a bigger sigset_t (for POSIX.1e realtime support, say) user
751 programs will not have to be recompiled.  Consult the header files for
752 more information about the changes.
754 Therefore you shouldn't include Linux kernel header files directly if
755 glibc has defined a replacement. Otherwise you might get undefined
756 results because of type conflicts.
758 ??      I don't include any kernel headers myself but the compiler
759         still complains about redeclarations of types in the kernel
760         headers.
762 {UD} The kernel headers before Linux 2.1.61 and 2.0.32 don't work
763 correctly with glibc.  Compiling C programs is possible in most cases
764 but C++ programs have (due to the change of the name lookups for
765 `struct's) problems.  One prominent example is `struct fd_set'.
767 There might be some problems left but 2.1.61/2.0.32 fix most of the
768 known ones.  See the BUGS file for other known problems.
770 ??signal        Why don't signals interrupt system calls anymore?
772 {ZW} By default GNU libc uses the BSD semantics for signal(),
773 unlike Linux libc 5 which used System V semantics.  This is partially
774 for compatibility with other systems and partially because the BSD
775 semantics tend to make programming with signals easier.
777 There are three differences:
779 * BSD-style signals that occur in the middle of a system call do not
780   affect the system call; System V signals cause the system call to
781   fail and set errno to EINTR.
783 * BSD signal handlers remain installed once triggered.  System V signal
784   handlers work only once, so one must reinstall them each time.
786 * A BSD signal is blocked during the execution of its handler.  In other
787   words, a handler for SIGCHLD (for example) does not need to worry about
788   being interrupted by another SIGCHLD.  It may, however, be interrupted
789   by other signals.
791 There is general consensus that for `casual' programming with signals, the
792 BSD semantics are preferable.  You don't need to worry about system calls
793 returning EINTR, and you don't need to worry about the race conditions
794 associated with one-shot signal handlers.
796 If you are porting an old program that relies on the old semantics, you can
797 quickly fix the problem by changing signal() to sysv_signal() throughout.
798 Alternatively, define _XOPEN_SOURCE before including <signal.h>.
800 For new programs, the sigaction() function allows you to specify precisely
801 how you want your signals to behave.  All three differences listed above are
802 individually switchable on a per-signal basis with this function.
804 If all you want is for one specific signal to cause system calls to fail
805 and return EINTR (for example, to implement a timeout) you can do this with
806 siginterrupt().
809 ??string        I've got errors compiling code that uses certain string
810         functions.  Why?
812 {AJ} glibc 2.1 has special string functions that are faster
813 than the normal library functions. Some of the functions are
814 implemented as inline functions and others as macros.
816 The optimized string functions are only used when compiling with
817 optimizations (-O1 or higher). The behavior can be changed with two
818 feature macros:
820 * __NO_STRING_INLINES: Don't do any string optimizations.
821 * __USE_STRING_INLINES: Use assembly language inline functions (might
822   increase code size dramatically).
824 Since some of these string functions are now additionally defined as
825 macros, code like "char *strncpy();" doesn't work anymore (and is
826 unnecessary, since <string.h> has the necessary declarations). Either
827 change your code or define __NO_STRING_INLINES.
829 {UD} Another problem in this area is that gcc still has problems on
830 machines with very few registers (e.g., ix86).  The inline assembler
831 code can require almost all the registers and the register allocator
832 cannot always handle this situation.
834 One can disable the string optimizations selectively.  Instead of writing
836         cp = strcpy (foo, "lkj");
838 one can write
840         cp = (strcpy) (foo, "lkj");
842 This disables the optimization for that specific call.
844 ?? I get compiler messages "Initializer element not constant" with
845         stdin/stdout/stderr. Why?
847 {RM,AJ} Constructs like:
848 static FILE *InPtr = stdin;
850 lead to this message. This is correct behaviour with glibc since stdin
851 is not a constant expression. Please note that a strict reading of ISO
852 C does not allow above constructs.
854 One of the advantages of this is that you can assign to stdin, stdout,
855 and stderr just like any other global variable (e.g. `stdout =
856 my_stream;'), which can be very useful with custom streams that you
857 can write with libio (but beware this is not necessarily
858 portable). The reason to implement it this way were versioning
859 problems with the size of the FILE structure.
862 ??      I can't compile with gcc -traditional (or
863         -traditional-cpp). Why?
865 {AJ} glibc2 does break -traditional and -traditonal-cpp - and will continue
866 to do so. For example constructs of the form:
867 enum {foo
868 #define foo foo
870 are  useful for debugging purposes (you can use foo with your debugger
871 that's why we need the enum) and for compatibility (other systems use
872 defines and check with #ifdef).
874 ??      I get some errors with `gcc -ansi'. Isn't glibc ANSI compatible?
876 {AJ} The GNU C library is compatible with the ANSI/ISO C standard.  If
877 you're using `gcc -ansi', the glibc includes which are specified in
878 the standard follow the standard. The ANSI/ISO C standard defines what
879 has to be in the include files - and also states that nothing else
880 should be in the include files (btw. you can still enable additional
881 standards with feature flags).
883 The GNU C library is conforming to ANSI/ISO C - if and only if you're
884 only using the headers and library functions defined in the standard.
886 ??      I can't access some functions anymore.  nm shows that they do
887         exist but linking fails nevertheless.
889 {AJ} With the introduction of versioning in glibc 2.1 it is possible
890 to export only those identifiers (functions, variables) that are
891 really needed by application programs and by other parts of glibc.
892 This way a lot of internal interfaces are now hidden.  nm will still
893 show those identifiers but marking them as internal.  ISO C states
894 that identifiers beginning with an underscore are internal to the
895 libc.  An application program normally shouldn't use those internal
896 interfaces (there are exceptions, e.g. __ivaliduser).  If a program
897 uses these interfaces, it's broken.  These internal interfaces might
898 change between glibc releases or dropped completely.
901 ? Miscellaneous
903 ??      After I changed configure.in I get `Autoconf version X.Y.
904         or higher is required for this script'.  What can I do?
906 {UD} You have to get the specified autoconf version (or a later one)
907 from your favorite mirror of ftp.gnu.org.
909 ??      When I try to compile code which uses IPv6 headers and
910         definitions on my Linux 2.x.y system I am in trouble.
911         Nothing seems to work.
913 {UD} The problem is that IPv6 development still has not reached a
914 point where the headers are stable.  There are still lots of
915 incompatible changes made and the libc headers have to follow.
917 Also, make sure you have a suitably recent kernel.  As of the 970401
918 snapshot, according to Philip Blundell <Philip.Blundell@pobox.com>, the
919 required kernel version is at least 2.1.30.
922 Answers were given by:
923 {UD} Ulrich Drepper, <drepper@cygnus.com>
924 {DMT} David Mosberger-Tang, <davidm@AZStarNet.com>
925 {RM} Roland McGrath, <roland@gnu.org>
926 {AJ} Andreas Jaeger, <aj@arthur.rhein-neckar.de>
927 {EY} Eric Youngdale, <eric@andante.jic.com>
928 {PB} Phil Blundell, <Philip.Blundell@pobox.com>
929 {MK} Mark Kettenis, <kettenis@phys.uva.nl>
930 {ZW} Zack Weinberg, <zack@rabi.phys.columbia.edu>
931 {TK} Thorsten Kukuk, <kukuk@vt.uni-paderborn.de>
932 {GK} Geoffrey Keating, <Geoff.Keating@anu.edu.au>
933 {HJ} H.J. Lu, <hjl@gnu.org>
935 Local Variables:
936  mode:outline
937  outline-regexp:"\\?"
938 End: