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