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