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