File: 4.html

package info (click to toggle)
lg-issue62 2-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,516 kB
  • ctags: 141
  • sloc: sh: 237; makefile: 34
file content (333 lines) | stat: -rw-r--r-- 13,429 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
<!--startcut ======================================================= -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<META NAME="generator" CONTENT="lgazmail v1.3E.n">
<TITLE>The Answer Gang 62: <TT>/usr/src/linux</TT> symlink considered harmful</TITLE>
</HEAD><BODY BGCOLOR="#FFFFFF" TEXT="#000000"
	LINK="#3366FF" VLINK="#A000A0">
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<P> <hr> 
<CENTER>
<!-- *** BEGIN navbar *** -->
<!-- *** END navbar *** -->
</CENTER>
</p>
<P> <hr> <P>
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<center>
<H1><A NAME="answer">
	<img src="../../gx/dennis/qbubble.gif" alt="(?)" 
		border="0" align="middle">
	<font color="#B03060">The Answer Gang</font>
	<img src="../../gx/dennis/bbubble.gif" alt="(!)" 
		border="0" align="middle">
</A></H1> 
<BR>
<H4>By Jim Dennis, Ben Okopnik, Dan Wilder, Breen Mullins, Mitchell Bruntel,
	the Editors of Linux Gazette... 
	and You!
<br>Send questions (or interesting answers) to
	<a href="mailto:linux-questions-only@ssc.com">linux-questions-only@ssc.com</a>
</H4>
</center>

<p><hr><p>
<!--  endcut ======================================================= -->
<!-- begin 4 -->
<H3 align="left"><img src="../../gx/dennis/qbubble.gif" 
	height="50" width="60" alt="(?) " border="0"
	><TT>/usr/src/linux</TT> symlink considered harmful</H3>
<h4 align="center">some right answers become wrong, eventually.</h4>

<em>
<p>While it's normally the practice here to state who's asking and
who's answering, on this issue, that itself was a hot topic.</p>

<p>While answering "A rather unique query" last month, Mike dispensed
some common wisdom... which has, it seems, become unwise, at least unless 
you are <strong>exceedingly</strong> careful of the context.</p>

<p>Thanks to <strong>Michal Jaegermann</strong> from the kernel list for
bringing it to more serious attention (can we say flame war here in the
land of curmudgeons? knew ya could), everyone from the Gang who hopped in,
and, especially, <strong>Breen Mullins</strong> and <strong>Dan Wilder</strong>
for providing clearer detail into the nature of the problem.  And my 
apologies to anyone who feels a need to get grumpy that I ruined all concept
of timeline in this thread, in favor of clarity to the readers.</p>

<p>Distro vendors and anyone who tends to build themselves kernels of different
vintages (mixing 2.0 with 2.2, etc) should pay special attention.</p>
</em>

<hr width="40%" align="center">

<STRONG><P><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
	HEIGHT="28" WIDTH="50" BORDER="0"
	> [Mike]
This is the normal Linux convention. Actually, you can place
your build tree anywhere, but you should make <TT>/usr/src/linux</TT> a
symlink to it so that the compiler will find the include files. 
</STRONG></P>

<BLOCKQUOTE><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
	HEIGHT="28" WIDTH="50" BORDER="0"
	> [Michal]
Actually no, you SHOULDN'T!!  Please do not spread an incorrect
information in TAG or Linus will come and will haunt you for the
rest of your lives.
</BLOCKQUOTE>

<p><em>I'll spare the readership the flame war on his flight into 
	hyperbole. -- Heather</em></p>

<STRONG><P><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
	HEIGHT="28" WIDTH="50" BORDER="0"
	> [Mike]
(Is this [headers in /usr/src/linux/include/] still required now that 
glibc has its own kernel headers?)
</STRONG></P>
<BLOCKQUOTE><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
	HEIGHT="28" WIDTH="50" BORDER="0"
	> [Michal]
Headers in <TT>/usr/include/linux</TT> are "private" but these should be those
headers which were used in a compilation of your libraries (notably
glibc) and hacking around the with a link in <TT>/usr/src</TT> is a mistake as
Linus tried to explain many times - sometimes quite forcibly.  Headers
used in a kernel compilation are NOT searched for in subdirectories of
<TT>/usr/src/linux</TT> but are specific to a kernel version and can be
drastically different between different versions, or at least you do not
have any guarantees that they are not.  If you happen to have sources to
one of 2.2 kernels and one of 2.4 then <TT>/usr/src/linux</TT> link is 
supposed to mean what?
</blockquote>

<p><em>Good question... building a kernel vs. building other things, this
	link does or doesn't exist or is real instead of a link; some other 
	link named "build" in the modules subtree does or doesn't exist, and 
	if it does, what's a good link look like?  [hot topic compression 
	algorithm, kinda lossy but hopefully sufficient.]</em></p>

<!-- sig -->

<STRONG><P><IMG SRC="../../gx/dennis/qbub.gif" ALT="(?)"
	HEIGHT="28" WIDTH="50" BORDER="0"
	> [Mike]
OK tag, what do you think?  Is it time to stop linking 
<TT>/usr/src/linux</TT> to
<TT>/usr/src/linux-VERSION</TT> ?
</STRONG></P>
<BLOCKQUOTE><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
	HEIGHT="28" WIDTH="50" BORDER="0"
	> [Michal]
AFAIK this time was at least like two years ago.  Some things
just have a big inertia. 
<IMG SRC="../../gx/dennis/smily.gif" ALT=":-)" 
		height="24" width="20" align="middle">
</BLOCKQUOTE>
<BLOCKQUOTE><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
	HEIGHT="28" WIDTH="50" BORDER="0"
	> [Breen]
That does seem to be the official answer.
</BLOCKQUOTE>
<BLOCKQUOTE>
From the 2.4.0 release, in linux/README:
</BLOCKQUOTE>
<BLOCKQUOTE><Pre>
INSTALLING the kernel:

- If you install the full sources, put the kernel tarball in a
directory where you have permissions (eg. your home directory) and
unpack it:

gzip -cd linux-2.4.XX.tar.gz | tar xvf -

Replace "XX" with the version number of the latest kernel.

Do NOT use the <TT>/usr/src/linux</TT> area! This area has a (usually
incomplete) set of kernel headers that are used by the library header
files.  They should match the library, and not get messed up by
whatever the kernel-du-jour happens to be.
</Pre></BLOCKQUOTE>

<BLOCKQUOTE><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
	HEIGHT="28" WIDTH="50" BORDER="0"
	> [Dan]
Yes.  No.  Maybe.
</BLOCKQUOTE>
<BLOCKQUOTE>
Many userland programs need (or think they need) kernel includes.
They usually get these through <TT>/usr/include/asm</TT> 
and <TT>/usr/include/linux</TT>, which are often themselves symlinks:
</BLOCKQUOTE>
<BLOCKQUOTE><pre>
/usr/include/asm -&gt; /usr/src/linux/include/asm
/usr/include/linux -&gt; /usr/src/linux/include/linux
</pre></BLOCKQUOTE>
<BLOCKQUOTE>
Perhaps this is wrong, and either
</BLOCKQUOTE>
<ul>
<li> The userland stuff shouldn't be relying on kernel includes, or
<li> <TT>/usr/include/asm</TT> and <TT>/usr/include/linux</TT> should not be 
	symlinks, but instead should be directories containing stable
descriptions that won't change with kernel version, (!?!)
of kernel-ish things the userland needs.
</ul>
<BLOCKQUOTE>
In the one case, the application developers are at fault, and
should be told to mend their ways.  In the other, blame the
distributions.
</BLOCKQUOTE>
<BLOCKQUOTE><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
	HEIGHT="28" WIDTH="50" BORDER="0"
	> [Michal]
<A HREF="http://www.debian.org/">Debian</A> does not provide bad links for 
a long time.  Red Hat also recently caught itself on a mistake.  I do not 
know details of other distributions but if they not fixed that already then 
likely they will soon.
</BLOCKQUOTE>

<BLOCKQUOTE>
Some source packages indeed search for <TT>/usr/src/linux</TT> for 
configuration purposes.  If this is not just a default which could, and 
should, be adjusted then they are simply wrong.  Current 2.2 kernels will 
install 'build' link in its <TT>/lib/modules</TT> subdirectory to indicate 
where sources for a given version are/were.  This is not a foolproof either 
but still better than alternatives.
</BLOCKQUOTE>

<BLOCKQUOTE><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
	HEIGHT="28" WIDTH="50" BORDER="0"
	> [Dan]
In either case the poor end user can't be faulted for tolerating
those links into the kernel source.  The conscientious user might be
praised for complaining to the program maintainer.
</BLOCKQUOTE>
<BLOCKQUOTE>
Recent application source trees exhibiting things like
</BLOCKQUOTE>
<BLOCKQUOTE><BLOCKQUOTE><CODE>
#include &lt;linux/...
</CODE></BLOCKQUOTE></BLOCKQUOTE>
<BLOCKQUOTE>
include (just for starters) autofs, cdrecord, 
<A HREF="http://www.dosemu.org/">DOSEMU</A>, gnupg, kde,
mysql, ntp, pgp, procps, python, samba, util-linux, wu-ftpd.
</BLOCKQUOTE>

<p><em>Perhaps we need a userland API?  oh yeah, right, got that, called
glibc.  Sigh.  I think we can grant that procps has to know what /proc is 
really up to, though.</em></p>

<BLOCKQUOTE><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
	HEIGHT="28" WIDTH="50" BORDER="0"
	> [Dan]
Or maybe we just say there exist, though perhaps there should not,
applications that depend on kernel version.  And they pick that up
through symlinks into the kernel source tree.
</BLOCKQUOTE>
<P><Strong><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
	HEIGHT="28" WIDTH="50" BORDER="0"
	> [Mike]
None of my systems have ever had a <TT>/usr/src/linux</TT> directory at all.
(Otherwise, I would not have been able to make the symlink without
erasing stuff first.)
</strong></p>

<p><em>So the thread at the end of this month still carries some questions:</em></p>
<ul>
<li>glibc does or does not have its own set of linux-kernel-like headers?
<li>Is the new kernel different enough that those are now a trap lying in wait
	for a newly-built-from-source userland application?
<li>Is procps (for example) really a userland application, in that context?
<li>If you lack this mystic version of headers where would you get them, 
	obviously (?) real kernel sources are not the right place?
<li>If distros are evading /usr/src/linux entirely how will apps like procps
	build correctly at all if we want to get the source?
<li>what sort of specialty symptoms happen from screwing this up, so that
	we of the Answer Gang and our faithful readers can put some spark
	of sense in our toolkit.  "You say it's doing <strong>what</strong>?  
	Hmmm are you sure you don't have a bogus /usr/src/linux?"
</ul>

<BLOCKQUOTE><IMG SRC="../../gx/dennis/bbub.gif" ALT="(!)"
	HEIGHT="28" WIDTH="50" BORDER="0"
	> [Dan]
What's a poor user to do?
</BLOCKQUOTE>

<p><em>At the very least, folks, while you're building new kernels out there,
here's a few safety tips:</em></p> 
<ul>
<li> when you put your kernel in place don't forget to put the matching
	System.map in with it.  Don't toast it when you toss the source 
	tree out for some space.  That's your real symbol table, 
	/proc/ksyms probably is a poor substitute.
<li> keep constantly up to date on modutils, it tries to be good across the
	2.x.x range of kernels
<li> when you tweak <tt>/etc/lilo.conf</tt> don't forget to actually 
	<em>run</em> <tt>/sbin/lilo</tt>... before you reboot!
<li> after you boot on the new kernel, run 
	<br><code>depmod -a -F /path/to/correct/System.map </code>
	<br>so you <em>really</em> know that your modules aren't missing
	any symbols.
<li> backups are good things.  Always keep your old kernel binary and its
	modules around for a little while.
</ul>

<p><em>If anyone has some good checklist points to look out for when 
	compiling userland apps, or a clearer description of what's going 
	on in glibc's tiny brain when it reaches for "headers", 
	let us know!</em></p>

<!-- end 4 -->
<!--startcut ======================================================= -->
<P> <hr> </p>
<!-- *** BEGIN copyright *** -->
<H5 align="center">This page edited and maintained by the Editors
        of <I>Linux Gazette</I>
<a href="http://www.linuxgazette.com/copying.html"
        >Copyright &copy;</a> 2001
<BR>Published in issue 62 of <I>Linux Gazette</I> February 2001</H5>
<H6 ALIGN="center">HTML script maintained by
        <A HREF="mailto:star@starshine.org">Heather Stern</a> of
        Starshine Technical Services,
        <A HREF="http://www.starshine.org/">http://www.starshine.org/</A>
</H6>
<!-- *** END copyright *** -->
<P> <hr> 
<!-- begin tagnav ::::::::::::::::::::::::::::::::::::::::::::::::::-->
<p align="center">
<table width="100%" border="0"><tr>
<td align="right" valign="center"
	><IMG ALT="" SRC="../../gx/navbar/left.jpg"
        WIDTH="14" HEIGHT="45" BORDER="0" ALIGN="middle" border="0">
<A HREF="../lg_answer62.html"
	><IMG SRC="../../gx/dennis/answertoc.jpg" align="middle"
              ALT="[ Answer Guy Current Index ]" border="0"></A></td>
<td align="center" valign="center"><A HREF="../lg_answer62.html#greeting"><img align="middle"
	src="../../gx/dennis/smily.gif" alt="greetings" border="0"></A> &nbsp;
  <A HREF="1.html">1</A> &nbsp;
  <A HREF="2.html">2</A> &nbsp;
  <A HREF="3.html">3</A> &nbsp;
  <A HREF="4.html">4</A> &nbsp;
  <A HREF="5.html">5</A> &nbsp;
  <A HREF="6.html">6</A> &nbsp;
  <A HREF="7.html">7</A></td>
<td align="left" valign="center"><A HREF="../../tag/kb.html"
	><IMG SRC="../../gx/dennis/answerpast.jpg" align="middle"
              ALT="[ Index of Past Answers ]" border="0"></A>
<IMG ALT="" SRC="../../gx/navbar/right.jpg" align="middle"
        WIDTH="14" HEIGHT="45" BORDER="0"></td></tr></table>
</p>
<!-- end tagnav ::::::::::::::::::::::::::::::::::::::::::::::::::::-->
<P> <hr> 
<CENTER>
<!-- *** BEGIN navbar *** -->
<!-- *** END navbar *** -->
</CENTER>
</p>
<!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
</BODY></HTML>
<!--endcut ========================================================= -->