home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / src / linux-headers-2.6.17-6 / debian / pkg / headers / README < prev   
Encoding:
Text File  |  2005-06-08  |  21.7 KB  |  450 lines

  1.  
  2.     $Id: README.headers,v 1.8 2002/05/03 21:17:06 srivasta Exp $
  3.  
  4.  This is the Debian GNU/Linux prepackaged version of the Linux kernel
  5.  headers. Linux was written by Linus Torvalds <torvalds@transmeta.com>
  6.  and others.
  7.  
  8.  
  9.  The kernel sources may be retrieved from ftp.us.kernel.org:/pub/linux/kernel/
  10.  
  11.  This package contains the Linux kernel header files. 
  12.  
  13.  
  14.          Kernel Headers and libc6-dev package
  15.                  ____________________________________
  16.                  ====================================
  17.  
  18.             Need for kernel include files
  19.                     ==== === ====== ======= =====
  20.    
  21.     Even though GNU libc 2.0 (a.k.a. libc6) provides an uniform
  22.  interface to C programmers, one should realize that it needs
  23.  different underpinnings on different architectures and operating
  24.  systems (remember, glibc2 is multi-OS).
  25.  
  26.     glibc provides all the standard files that the C standard and
  27.  POSIX require, and those in turn call in OS and platform specific
  28.  headers as required transparently to the user. There is an a complete
  29.  divorce of the kernel-level interface from the user-level interface:
  30.  the application programmer does not need to know kernel level details
  31.  at all.
  32.  
  33.      But this has been taken by some to mean that
  34.  /usr/include/{linux,asm} would be superfluous, which is a technical
  35.  impossibility given that glibc2 is not an architecture and OS
  36.  specific library.
  37.  
  38.         I do not believe it is easy for glibc to present an interface
  39.  that does not match the underlying OS, and quite possibly people just
  40.  punted. If there is a mismatch between the user level structures and
  41.  the kernel level structures, then libc6 library shall have to install
  42.  translating wrappers around system calls (not such a great idea for
  43.  high performance systems). I can foresee cases where it would not be
  44.  possible to implement these wrappers, given a sufficiently large set
  45.  of architectures and OS's.
  46.  
  47.     In the case of Linux, the kernel header files are the
  48.  underpinnings of the architecture independent interface.
  49.  
  50.     Take a simple general ANSI C include file like <errno.h>. This
  51.  in turn includes /usr/include/errnos.h, which includes
  52.  /usr/include/linux/errno.h, which in turn includes
  53.  /usr/include/asm/errno.h. See? A simple, standard include file like
  54.  <errno.h>, and one needs kernel include files for that.
  55.  
  56.            Traditional two symlink approach
  57.                    =========== === ======= ========          
  58.  
  59.      Under libc5, it was standard for part of the user interface to
  60.  libc to be exported from the kernel includes, via /usr/include/linux
  61.  and /usr/include/asm.  Traditionally, this was done by linking those
  62.  two directories to the appropriate directories in
  63.  /usr/src/linux/include.  This is the method documented in the install
  64.  instructions for the kernel sources, even today.
  65.  
  66.  
  67.                Why that is bad
  68.                            === ==== == ===
  69.  
  70.      Kernel headers no longer make sense exporting to user space
  71.  (in early days of Linux, that was not true). It is beginning to get
  72.  harder to synchronize the libc and the kernel headers as in the old
  73.  days; now linking with the latest kernel headers may subtly break new
  74.  code since the headers linked with are different from the compiled
  75.  library. In addition, the specter of programs breaking with new
  76.  kernel headers was preventing needed new features from being added to
  77.  the kernel (and damping innovative experimentation in kernel
  78.  development) (see appendix A for details).
  79.   
  80.       Besides, the kernel itself no longer needs /usr/include/linux/* 
  81.   at all, so keeping the libc and kernel headers the same aren't
  82.   needed for kernel development.
  83.  
  84.         The headers were included in Debian's libc5-dev after a rash
  85.  of very buggy alpha kernel releases (1.3.7* or something like that)
  86.  that proceeded to break compilations, etc.  Kernel versions are
  87.  changed far more rapidly than libc is, and there are higher chances
  88.  that people install a custom kernel than they install custom libc.
  89.  
  90.         Add to that the fact that few programs really need the more
  91.  volatile elements of the header files (that is, things that really
  92.  change from kernel version to kernel version), [before you reject
  93.  this, consider: programs compiled on one kernel version usually work
  94.  on other kernels]. For the few that do need specific kernel headers,
  95.  use -I/usr/src/kernel-headers-<version> or some thing for a specific
  96.  kernel version, or -I/usr/src/linux/include for the latest set of
  97.  headers installed..
  98.  
  99.         Most programs, even if they include <linux/something.h>, do
  100.  not really depend on the version of the kernel, as long as the kernel
  101.  versions are not too far off, they will work. And the headers
  102.  provided in libc5-dev (and libc6-dev) are just that. 
  103.  
  104.      Consider this: Namespace contention between the C library and
  105.  the kernel (GNU libc is not a Linux only entity) Also, different
  106.  library versions want different #defines and type defines in
  107.  different places. Some libraries want to define their own FD_SET,
  108.  while older ones want to get the kernel ones.
  109.  
  110.      This is a mess. Kernel headers can't change anymore, even when
  111.  the interfaces are not really changing, since one does not know
  112.  what breaks in userland libraries. 
  113.  
  114.  
  115.  
  116.      The solution is to separate out the two sets of header files:
  117.  the kernel uses one frequently changing set, and a set of headers is
  118.  provided from a known good kernel version, which is tested, known to
  119.  be stable, and that is sufficient for compiling most programs, (it
  120.  also makes the compile time environments for programs on Debian
  121.  machines a well known one, easing the process of dealing with problem
  122.  reports).
  123.  
  124.             Debian's libc5 method
  125.                         ======== ===== ======
  126.  
  127.     It was decided, then, to have libc5 development package include
  128.  files found one specific kernel-sources to insulate most systems from
  129.  the vagaries of bleeding edge kernel sources, and to prevent subtle
  130.  breakage introduced by the difference in the headers a program is
  131.  compiled versus headers the libc was compiled with. As mentioned
  132.  before, most programs are not coupled tightly enough to kernel data
  133.  structures, and would continue to work even if the user upgrades the
  134.  kernel (and presumably the libc development package is not allowed to
  135.  lag too far behind current kernels).
  136.  
  137.         There are two different capabilities which are the issue, and
  138.  the kernel-packages and libc5-dev address different ones:
  139.  
  140.  a) The kernel packages try to provide a stable, well behaved kernel
  141.     and modules, and may be upgraded whenever there are significant
  142.     advances in those directions (bug fixes, more/better module
  143.     support, etc).  These, however, may not have include files that
  144.     are non-broken as far as non-kernel programs are concerned, and
  145.     the quality of the development/compilation environment is not the
  146.     kernel packages priority (Also, please note that the kernel
  147.     packages are tied together, so kernel-source, headers, and image
  148.     are produced in sync)
  149.  
  150.  b) Quality of the development/compilation environment is the priority
  151.     of libc development package, and it tries to ensure that the headers it
  152.     provides would be stable and not break non-kernel programs. This
  153.     assertion may fail for alpha kernels, which may otherwise be
  154.     perfectly stable, hence the need for a different set of known-good
  155.     kernel include files.
  156.  
  157.            Shortcoming of the libc5 method
  158.                    =========== == === ===== ======
  159.  
  160.     Unfortunately, the proposal for libc5 is beginning to unravel
  161.  at the edges, since Debian is going truly multi-architecture (and there
  162.  are murmurs of multi-OS Debian). 
  163.  
  164.     The reason I say that the solution is unraveling at the edges
  165.  is that the kernel header files are getting to be quite architecture
  166.  dependent. We still want to make libc6-dev include headers (or depend
  167.  on a package that includes these headers) from a well known stable
  168.  kernel source. But there is no one set of headers to install, since
  169.  different architectures need different (sometimes radically
  170.  different) files.
  171.  
  172.     If libc development packages continued to include kernel
  173.  headers explicitly, we would need different headers for different
  174.  architectures, resulting in libc6-dev-i386, libc6-dev-m68k, et. al.
  175.  Or we could maintain all the files in libc6-dev as a set of (quite
  176.  large) arch dependent patches. But those files are precisely the
  177.  files contained in kernel-headers-2.0.32.
  178.  
  179.     Even in the case of more than one architecture sharing a
  180.  common kernel-header file set, all I say is that this invariant is
  181.  not guaranteed for any future releases. Kernel headers need not be the
  182.  same for any two given architectures. Any solution would do well to
  183.  address that.
  184.  
  185.     However, the following still remains true: the libc
  186.  development packages should include a static, stable, tested, known
  187.  good kernel headers to insulate developers from the vagaries of
  188.  unstable kernel headers (and the subtler pitfall of compiling with
  189.  headers that do not match the libc being linked with).
  190.  
  191.               Debian's old libc6 method
  192.               ======== === ===== ======
  193.  
  194.     The previous solution was a variant of the original, bad,
  195.  symlink solution. The variation was that we link to header files from
  196.  a specific kernel version, namely 2.0.32, which are the headers that
  197.  libc was compiled with. Whereas we used to link to any old kernel in
  198.  the original libc5 symlink, the new libc6 symlink was to
  199.  /usr/src/kernel-header-2.0.32, which holds headers from a *static,
  200.  well known*, *supported*, tested kernel version, and we let the
  201.  kernel-headers package handle architecture dependencies (which it had
  202.  to anyway).
  203.  
  204.     One should also consider that the libc maintainer has enough
  205.  on their plates, and should not be expected to be responsible for the
  206.  creation and testing of the arch dependent diffs.
  207.  
  208.     Coupled with the fact that the afore-mentioned diffs are
  209.  exactly what is there in kernel-headers package, it exists already,
  210.  and requires no work on the part of the libc maintainer.
  211.  
  212.         So, a dependency was created on kernel headers rather than
  213.  create kernel header sized architecture dependent diffs. The
  214.  dependency was such that it libc6-dev linked to the directory
  215.  /usr/src/kernel-header-2.0.32. 
  216.  
  217.     At one point libc6-dev pointed to /usr/src/linux-2.0.32, which
  218.  was a symbolic link. This link was provided by just the packages
  219.  kernel-source-2.0.32 or kernel-headers-2.0.32, and *no other* kernel
  220.  package. However, that was pointed out to be an error, since the
  221.  headers required are architecture dependent, as is
  222.  kernel-headers-<version>, but kernel-source-<version> is an arch: all
  223.  (arch independent package), and hence does not provide kernel headers
  224.  that meet libc6 requirements.
  225.  
  226.      So, libc6-dev depends could then provide 2.0.32 kernel
  227.  headers *for all architectures*, with no messy architecture dependent
  228.  patches, we always had fixed, static, known good headers in
  229.  /usr/include/{linux,asm}, and this was goodness. Or was it?
  230.  
  231.         This was a working technical solution to having libc
  232.  development package contain/depend on a well known static set of
  233.  kernel headers (insulating the vast majority of programs that are not
  234.  closely tied to kernel version specific internal data structures),
  235.  while allowing the kernel headers to vary from architecture to
  236.  architecture, and still allowing device driver authors from having
  237.  any set of kernel headers they want on the machine through the simple
  238.  artifice of adding a -I flag to the compilation flags.
  239.  
  240.     Indeed, had we thought of the this solution in libc5
  241.  days it would have been cleaner (and produced less confusion now).
  242.  The solution of having libc5-dev depend on kernel-headers-X.XX.XX
  243.  wold have worked just as well in the libc5 case as it did in the libc6
  244.  case.  I don't see a change in the situation, just a switch to an
  245.  equivalent, possibly cleaner, solution.  
  246.  
  247.          Shortcoming of the old libc6 method
  248.          =========== == === === ===== ======
  249.     Even though the method for libc6 outlined above was a working
  250.  technical solution, it was confusing to the users, who did not
  251.  understand why the kernel sources could not be substituited in place,
  252.  and what happened when the went to a new kernel version. This
  253.  confusion led us to believe that human factors dictated that a new,
  254.  less confusing solution had to be implemented.
  255.  
  256.           Variations on the old libc6 method
  257.           ========== == === === ===== ======
  258.  
  259.     The interim solution was an amalgam of the libc5 and the old
  260.  libc6 solutions. A new package, libc-kheaders, was created, and
  261.  libc6-dev depended on it. libc-kheaders contained the a well known
  262.  static set of kernel headers, which were identical to the set of
  263.  headers used in the libc6 solution outlined above, except that the
  264.  headers unpacked in /usr/include/{linux,asm}, and no symbolic links
  265.  were used at all. So, in some respects, we reverted to the libc5
  266.  solution of no symlinks in /usr/include, while retaining the
  267.  flexibility of allowing for the different needs for different
  268.  architectures. It was my hope that this method would be less
  269.  confusing.
  270.  
  271.  
  272.                       Debian's New libc6 method
  273.                       ======== === ===== ======
  274.     Unfortunatly, it turned out that having libc depend on an
  275.  external package was too confusing for some users. Getting rather
  276.  weary of answering the questions on the users list, and explaining
  277.  again why a separation between the kernel and application headers was
  278.  desirable, the decision was made to ship *ALL* headers, irrspective
  279.  of architecture, for a particular kernel version in libc6 package
  280.  itself (and, later, in a package that libc-dev depends on -- namely,
  281.  linux-kernel-headers). So, no external packages. So much for the
  282.  elegance of the old libc6 method. We are now back to brute force,
  283.  including all headers for every architecture.
  284.  
  285.  
  286.   Authors response to complaints that Debian is doing it's own thing
  287.   ======= ======== == ========== ==== ====== == ===== ==== === =====
  288.  
  289.        Yes, Debian is different. It has a package management
  290.  system. Different part of Debian work with each other. There are
  291.  assumptions part of the distribution make about itself, and because
  292.  of this set of co-operating assumptions, or rules, or policy, Debian
  293.  is better integrated than most Linux distributions I have seen. 
  294.  
  295.         We often do not do things the "standard" way. Like when we
  296.  started including /usr/include/{linux,asm} directories instead of
  297.  having symlinks. It is different. And was acknowledged to be
  298.  technically superior. 
  299.  
  300.         Again, we are making changes that shall not be reflected in
  301.  other distributions. I think we are making the technically superior
  302.  choice. But we shall be different again.
  303.  
  304.        I think this solution works. It is not as elegant as depending
  305.  on an externel libc-kheaders package, but we can't have everything.
  306.  
  307. ______________________________________________________________________
  308.  
  309.                   Appendix A
  310.                               ======== =
  311.  
  312.         This document contains comments from Linus Torvalds (made in
  313.  an ``off-the-cuff'' personal email) to help clarify the rationale
  314.  behind the Debian way of handling symlinks, but this should not be
  315.  seen as an official policy statement by Linus. I'm attaching a
  316.  disclaimer in his own words.
  317.  
  318.         The only reason that Linus's message is quoted in here is that
  319.  he can explain the technical reasons with far more lucidity than I
  320.  can, and now that I have permission to include his mail, I am
  321.  removing most of my far less facile efforts in that regard. 
  322.  
  323.  
  324.     Need for isolating the C development Library from volatile
  325.     kernel headers
  326.  
  327. ----------------------------------------------------------------------------
  328. >> "David" == David Engel <david@sw.ods.com> said on Mon, 24 Feb 1997
  329. >> "Linus" == Linus Torvalds said on Mon, 24 Feb 1997
  330.  
  331. David> Hi Linus,
  332. David> No matter how well we try to explain ourselves, the symlinks issue
  333. David> keeps coming up.  Would you mind if we used your message below in
  334. David> our responses?
  335.  
  336. Linus> Sure. Don't make it "the word of God" - please point out that
  337. Linus> it was a off-the-bat personal reply to a question concerning
  338. Linus> this, and while I'm more than happy to have the email
  339. Linus> circulated it shouldn't be seen as a "official" document in any
  340. Linus> way..
  341. Linus> Linus
  342. ---------------------------------------------------------------------------
  343.  
  344. >> "Linus" == Linus Torvalds said on Wed, 22 Jan 1997:
  345.  
  346. Linus> The kernel headers used to make sense exporting to user space,
  347. Linus> but the user space thing has grown so much that it's really not
  348. Linus> practical any more. The problem with Debian is just that they
  349. Linus> are different, not that they are doing anything wrong. That
  350. Linus> leads to differences between the distributions, and that in
  351. Linus> turn obviously can result in subtle problems.
  352.  
  353. Linus> As of glibc, the kernel headers will really be _kernel_
  354. Linus> headers, and user level includes are user level
  355. Linus> includes. Matthias Ulrich did that partly because I've asked
  356. Linus> him to, but mainly just because it is no longer possible to try
  357. Linus> to synchronize the libc and the kernel the way it used to
  358. Linus> be. The symlinks have been a bad idea for at least a year now,
  359. Linus> and the problem is just how to get rid of them
  360. Linus> gracefully. Personally, I'm counting on glibc, which we are
  361. Linus> already using on alpha.
  362.  
  363. Linus> Just to give you some idea of exactly why the includes really
  364. Linus> can't be handled by simple symlinks: the main problem is
  365. Linus> version skew. Lots of people want to upgrade their library
  366. Linus> without affecting the kernel, and probably even more people
  367. Linus> want to be able to upgrade their kernel without affecting their
  368. Linus> compilation environment. Right now doing that has been
  369. Linus> extremely fragile.
  370.  
  371. Linus> Just to give _one_ example of why the symlinks are bad: NR_OPEN
  372. Linus> and "fd_set". I have had no end of problems making NR_OPEN
  373. Linus> larger in the kernel, exactly _because_ of the damn
  374. Linus> sym-links. If I just make NR_OPEN larger (the right thing to
  375. Linus> do), the problem is that people with old libraries will now
  376. Linus> compile against a header file that doesn't match the library
  377. Linus> any more. And when the library internally uses another  NR_OPEN
  378. Linus> than the new program does, "interesting" things happen.
  379.  
  380. Linus> In contrast, with separate header files, this doesn't make any
  381. Linus> difference.  If I change NR_OPEN in the kernel, the compilation
  382. Linus> environment won't notice UNTIL the library and associated
  383. Linus> header files are changed: thus the user will continue to compile
  384. Linus> with the old values, but because we'll still be binary
  385. Linus> compatible, the worst thing that happens is that new programs
  386. Linus> won't take advantage of new features unless the developer has
  387. Linus> upgraded his library. Compare that to breaking subtly.
  388.  
  389. Linus> NR_OPEN is just _one_ example, and actually it's one of the
  390. Linus> easier ones to handle (because the only thing that really makes
  391. Linus> much of a difference when it comes to NR_OPEN is the fd_set
  392. Linus> size - but it certainly bit some people). Another major problem
  393. Linus> is name-space pollution: the POSIX/ANSI/XOpen rules are not
  394. Linus> only complex, but they are actually contradictory too. And the
  395. Linus> kernel header files really can't reasonably support all of the
  396. Linus> intricacies very cleanly.
  397.  
  398. Linus> One specific example of why we want separate header files for
  399. Linus> libraries and kernel is offered by glibc: Matthias wanted to
  400. Linus> have a "sigset_t" that will suffice for the future when the
  401. Linus> POSIX.1b realtime signals are implemented. But at the same time
  402. Linus> he obviously wants to be able to support programming on
  403. Linus> Linux-2.0 and the current 2.1 that do not have that support.
  404.  
  405. Linus> The _only_ reasonably clean way to handle these kinds of
  406. Linus> problems is to have separate header files: user programs see a
  407. Linus> larger sigset_t, and then the library interaction with the
  408. Linus> kernel doesn't necessarily use all of the bits, for
  409. Linus> example. Then later, when the kernel support is actually there,
  410. Linus> it's just a matter of getting a new shared library, and voila,
  411. Linus> all the realtime signals work.
  412.  
  413. Linus> The symlink approach simply wouldn't work for the above: that
  414. Linus> would have required everybody who uses the library to have a
  415. Linus> recent enough kernel that whatever magic all the above entails
  416. Linus> would be available in the kernel header files. But not only
  417. Linus> don't I want to pollute the kernel header files with user level
  418. Linus> decisions, it's actually possible that somebody wants to run
  419. Linus> glibc on a 1.2.x kernel, for example. We _definitely_ do not
  420. Linus> want him to get a 32-bit sigset_t just because he is happy with
  421. Linus> an old kernel.
  422.  
  423. Linus> Anyway, this email got longer than intended, but I just wanted
  424. Linus> to make clear that the symlinks will eventually be going away
  425. Linus> even in non-Debian distributions. Debian just happened to do it
  426. Linus> first - probably because Debian seems to be more interested in
  427. Linus> technical reasons than any old traditions. And technically, the
  428. Linus> symlinks really aren't very good.
  429.  
  430. Linus> The _only_ reason for the symlinks is to immediately give
  431. Linus> access to new features in the kernel when those happen. New
  432. Linus> ioctl numbers etc etc. That was an overriding concern early on:
  433. Linus> the kernel interfaces expanded so rapidly even in "normal"
  434. Linus> areas that having the synchronization that symlinks offered was
  435. Linus> a good thing.
  436.  
  437. Linus> However, the kernel interfaces aren't really supposed to change
  438. Linus> all that quickly any more, and more importantly: the technical
  439. Linus> users know how to fix things any way they want, so if they want
  440. Linus> a new ioctl number to show up they can actually edit the header
  441. Linus> files themselves, for example. But having separation is good
  442. Linus> for the non-technical user, because there are less surprises
  443. Linus> and package dependencies.
  444.  
  445. Linus> Anyway, something like the patch that David suggested will
  446. Linus> certainly go in, although I suspect I'll wait for it to become
  447. Linus> "standard" and the glibc first real release to take place.
  448.  
  449.  
  450.