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