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