1 |
flameeyes 08/07/31 09:41:56 |
2 |
|
3 |
Modified: asneeded.xml |
4 |
Log: |
5 |
Improve the section about ./configure failure. |
6 |
Name and note problems related to using LDFLAGS variable to pass libraries during tests. |
7 |
|
8 |
Revision Changes Path |
9 |
1.16 xml/htdocs/proj/en/qa/asneeded.xml |
10 |
|
11 |
file : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/proj/en/qa/asneeded.xml?rev=1.16&view=markup |
12 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/proj/en/qa/asneeded.xml?rev=1.16&content-type=text/plain |
13 |
diff : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/proj/en/qa/asneeded.xml?r1=1.15&r2=1.16 |
14 |
|
15 |
Index: asneeded.xml |
16 |
=================================================================== |
17 |
RCS file: /var/cvsroot/gentoo/xml/htdocs/proj/en/qa/asneeded.xml,v |
18 |
retrieving revision 1.15 |
19 |
retrieving revision 1.16 |
20 |
diff -u -r1.15 -r1.16 |
21 |
--- asneeded.xml 31 Jul 2008 08:45:47 -0000 1.15 |
22 |
+++ asneeded.xml 31 Jul 2008 09:41:56 -0000 1.16 |
23 |
@@ -1,6 +1,6 @@ |
24 |
<?xml version="1.0" encoding="UTF-8"?> |
25 |
<!DOCTYPE guide SYSTEM "http://www.gentoo.org/dtd/guide.dtd"> |
26 |
-<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/proj/en/qa/asneeded.xml,v 1.15 2008/07/31 08:45:47 flameeyes Exp $ --> |
27 |
+<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/proj/en/qa/asneeded.xml,v 1.16 2008/07/31 09:41:56 flameeyes Exp $ --> |
28 |
|
29 |
<guide link="/proj/en/qa/asneeded.xml" lang="en"> |
30 |
<title>--as-needed introduction and fixing guide</title> |
31 |
@@ -18,7 +18,7 @@ |
32 |
<!-- See http://creativecommons.org/licenses/by-sa/2.5 --> |
33 |
<license/> |
34 |
|
35 |
-<version>0.9</version> |
36 |
+<version>0.11</version> |
37 |
<date>2008-07-31</date> |
38 |
|
39 |
<chapter> <!-- Introduction --> |
40 |
@@ -304,30 +304,37 @@ |
41 |
<body> |
42 |
|
43 |
<p> |
44 |
-This is hopefully the less frequent failure but it's also one of the most |
45 |
-impractical to find, although is no different to fix than other failures. |
46 |
-Basically the <c>./configure</c> script of an autotooled package can fail to |
47 |
-find a given library (and thus abort if the support is a strict requirement, or |
48 |
-simply ignore the presence of a library) if that library does not link against |
49 |
-its right dependencies. |
50 |
+Albeit less common than other kind of failures, <c>./configure</c> |
51 |
+execution can fail because of <c>--as-needed</c> too. With this kind |
52 |
+of failures, though, it's difficult to give a single and simple |
53 |
+solution, as there are multiple reasons that might make the script |
54 |
+fail. |
55 |
</p> |
56 |
|
57 |
<p> |
58 |
-The quickest way to find possible failures because of the above is to look into |
59 |
-<path>AC_CHECK_LIB</path> calls inside the configure script; when the fifth |
60 |
-parameter is used (<e>other-libraries</e>) it often means that those libraries |
61 |
-need to be linked in the same binary with the one to check, as they are not |
62 |
-linked in automatically. While this works in a normal situation, when using the |
63 |
-<c>--as-needed</c> flag, they are probably dropped because they are not used by |
64 |
-the test program. |
65 |
+The most common option between those that we have now is that a |
66 |
+library is checked for, but that library wasn't linked to all its |
67 |
+prerequisites (and thus required them to be passed afterward). As |
68 |
+<c>--as-needed</c> makes the linker ignore all the libraries not |
69 |
+needed by the current target, the prerequisites will result missing. |
70 |
</p> |
71 |
|
72 |
<p> |
73 |
-The fixes are the usual ones explained above, but instead of being applied to |
74 |
-the failing package they have to be applied to the library that's failing to be |
75 |
-detected. |
76 |
+To check a <path>configure.ac</path> or <path>configure.in</path> file |
77 |
+for this kind of failures, you can look for the <c>AC_CHECK_LIB</c> |
78 |
+macro, and see whether the fifth parameter is used |
79 |
+(<e>other-libraries</e>). When it is, it often means that those |
80 |
+libraries need to be linked in the final binary to satisfy the |
81 |
+dependencies of the library to check for. At that point, the library |
82 |
+need to be fixed. |
83 |
</p> |
84 |
|
85 |
+<pre caption="example of AC_CHECK_LIB call with fifth-parameter"> |
86 |
+AC_CHECK_LIB([foo], [foo_something], |
87 |
+ [have_foo=yes], [have_foo=no], |
88 |
+ [-ldl -lnsl]) |
89 |
+</pre> |
90 |
+ |
91 |
<note> |
92 |
While applying patches to libraries to fix <c>--as-needed</c> support, it is |
93 |
usually not the case to apply a revision bump: those who don't want to use the |
94 |
@@ -336,6 +343,33 @@ |
95 |
libraries are rebuilt. |
96 |
</note> |
97 |
|
98 |
+<p> |
99 |
+Another possible failure during <c>./configure</c> execution happens |
100 |
+when the code is going to check for functions or other particular |
101 |
+items (symbols, behaviour) and mistakenly pass the dependency |
102 |
+libraries through the <path>LDFLAGS</path> variable. |
103 |
+</p> |
104 |
+ |
105 |
+<pre caption="example of mistake in library checks"> |
106 |
+PKG_CHECK_MODULES([FOO], [foo]) |
107 |
+ |
108 |
+... |
109 |
+ |
110 |
+save_LDFLAGS=$LDFLAGS |
111 |
+LDFLAGS="$LDFLAGS $FOO_LIBS" |
112 |
+ |
113 |
+AC_CHECK_FUNCS([foo_choice1 foo_choice2 foo_choice3]) |
114 |
+ |
115 |
+LDFLAGS=$save_LDFLAGS |
116 |
+</pre> |
117 |
+ |
118 |
+<p> |
119 |
+In this case the solution is very quick: just replace LDFLAGS with |
120 |
+LIBS in both saving and restoring. This way the libraries will be |
121 |
+passed in the correct order (see the following section for more |
122 |
+insight about this kind of problem). |
123 |
+</p> |
124 |
+ |
125 |
</body> |
126 |
</section> |
127 |
<section> <!-- Importance of linking order --> |