| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | <!-- $NetBSD: fixes.xml,v 1.151 2020/01/28 05:07:58 rillig Exp $ --> | | 1 | <!-- $NetBSD: fixes.xml,v 1.152 2020/02/23 16:52:02 rillig Exp $ --> |
2 | | | 2 | |
3 | <chapter id="fixes"> <?dbhtml filename="fixes.html"?> | | 3 | <chapter id="fixes"> <?dbhtml filename="fixes.html"?> |
4 | <title>Making your package work</title> | | 4 | <title>Making your package work</title> |
5 | | | 5 | |
6 | <sect1 id="general-operation"> | | 6 | <sect1 id="general-operation"> |
7 | <title>General operation</title> | | 7 | <title>General operation</title> |
8 | | | 8 | |
9 | <para>One appealing feature of pkgsrc is that it runs on many | | 9 | <para>One appealing feature of pkgsrc is that it runs on many |
10 | different platforms. As a result, it is important to ensure, | | 10 | different platforms. As a result, it is important to ensure, |
11 | where possible, that packages in pkgsrc are portable. This | | 11 | where possible, that packages in pkgsrc are portable. This |
12 | chapter mentions some particular details you should pay | | 12 | chapter mentions some particular details you should pay |
13 | attention to while working on pkgsrc.</para> | | 13 | attention to while working on pkgsrc.</para> |
14 | | | 14 | |
| @@ -1339,26 +1339,135 @@ SunPro C++ __SUNPRO_CC (0x580 for Sun C | | | @@ -1339,26 +1339,135 @@ SunPro C++ __SUNPRO_CC (0x580 for Sun C |
1339 | <para>Typically, a workaround involves testing the | | 1339 | <para>Typically, a workaround involves testing the |
1340 | <varname>MACHINE_ARCH</varname> and compiler version, disabling | | 1340 | <varname>MACHINE_ARCH</varname> and compiler version, disabling |
1341 | optimisation for that combination of file, | | 1341 | optimisation for that combination of file, |
1342 | <varname>MACHINE_ARCH</varname> and compiler.</para> | | 1342 | <varname>MACHINE_ARCH</varname> and compiler.</para> |
1343 | | | 1343 | |
1344 | <para>This used to be a big problem in the past, but is rarely | | 1344 | <para>This used to be a big problem in the past, but is rarely |
1345 | needed now as compiler technology has matured. If you still need | | 1345 | needed now as compiler technology has matured. If you still need |
1346 | to add a compiler specific workaround, please do so in the file | | 1346 | to add a compiler specific workaround, please do so in the file |
1347 | <filename>hacks.mk</filename> and describe the symptom and | | 1347 | <filename>hacks.mk</filename> and describe the symptom and |
1348 | compiler version as detailed as possible.</para> | | 1348 | compiler version as detailed as possible.</para> |
1349 | | | 1349 | |
1350 | </sect2> | | 1350 | </sect2> |
1351 | | | 1351 | |
| | | 1352 | <sect2 id="fixes.build.header"> |
| | | 1353 | <title>No such file or directory</title> |
| | | 1354 | |
| | | 1355 | <para>Compilation sometimes fails with an error message like this:</para> |
| | | 1356 | |
| | | 1357 | <programlisting> |
| | | 1358 | .../x11/gtk3/work/gtk+-3.24.12/gdk/gdktypes.h:35:10: |
| | | 1359 | fatal error: pango/pango.h: No such file or directory |
| | | 1360 | </programlisting> |
| | | 1361 | |
| | | 1362 | <para>The proper way to fix this problem depends on the type of the |
| | | 1363 | header, which is described in the following sections.</para> |
| | | 1364 | |
| | | 1365 | <sect3 id="fixes.build.header.bl3"> |
| | | 1366 | <title>Headers from other packages</title> |
| | | 1367 | |
| | | 1368 | <para>If the header name looks like it comes from a different package, |
| | | 1369 | that other package should be included via the buildlink3 |
| | | 1370 | framework.</para> |
| | | 1371 | |
| | | 1372 | <para>First, look whether the header is somewhere in the buildlink3 |
| | | 1373 | directory below <varname>WRKDIR</varname>. In the above case of |
| | | 1374 | the missing Pango header:</para> |
| | | 1375 | |
| | | 1376 | <programlisting> |
| | | 1377 | &uprompt; find work/.buildlink/ -print | grep -F pango/pango.h |
| | | 1378 | </programlisting> |
| | | 1379 | |
| | | 1380 | <para>In the case of Pango, the output is:</para> |
| | | 1381 | |
| | | 1382 | <programlisting> |
| | | 1383 | work/.buildlink/include/pango-1.0/pango/pango.h |
| | | 1384 | </programlisting> |
| | | 1385 | |
| | | 1386 | <para>If the <filename>pango/pango.h</filename> file were placed directly |
| | | 1387 | in the <filename>.buildlink</filename> directory, it would have been |
| | | 1388 | found automatically. There is an extra <filename>pango-1.0</filename> |
| | | 1389 | path component though, which means that the compiler command line must |
| | | 1390 | contain an option of the form |
| | | 1391 | <literal>-I${BUILDLINK3_PREFIX.pango}/include/pango-1.0</literal>. In |
| | | 1392 | most cases this option is generated by the configure script, which can be examined using:</para> |
| | | 1393 | |
| | | 1394 | <programlisting> |
| | | 1395 | &uprompt; $ grep -o '[-]I[^[:space:]]*/pango[^[:space:]]*' work/*/Makefile |
| | | 1396 | -I/usr/pkg/include/pango-1.0 |
| | | 1397 | -I/usr/pkg/include/pango-1.0 |
| | | 1398 | -I/usr/pkg/include/pango-1.0 |
| | | 1399 | -I/usr/pkg/include/pango-1.0 |
| | | 1400 | -I/usr/pkg/include/pango-1.0 |
| | | 1401 | </programlisting> |
| | | 1402 | |
| | | 1403 | <para>This looks good. These options are transformed by the buildlink |
| | | 1404 | wrapper to refer to the correct path inside |
| | | 1405 | <filename>work/.buildlink</filename>.</para> |
| | | 1406 | |
| | | 1407 | <para>Since the compilation fails though, examine the compiler command |
| | | 1408 | lines in <filename>work/.work.log</filename> to see whether the |
| | | 1409 | <literal>-I</literal> option is included in the particular command |
| | | 1410 | line.</para> |
| | | 1411 | |
| | | 1412 | <para>To further analyze the situation, run <command>bmake |
| | | 1413 | build-env</command>, which sets up an interactive, realistic environment |
| | | 1414 | including all the pkgsrc wrapper commands and environment variables. From |
| | | 1415 | there, try to compile some simple example programs that use the |
| | | 1416 | header.</para> |
| | | 1417 | |
| | | 1418 | </sect3> |
| | | 1419 | |
| | | 1420 | <sect3 id="fixes.build.header.gen"> |
| | | 1421 | <title>Headers generated during the build</title> |
| | | 1422 | |
| | | 1423 | <para>If the name of the header seems to come from the package itself, |
| | | 1424 | and if the build is run with parallel jobs, the package may have some |
| | | 1425 | undeclared dependencies between the <filename>.c</filename> and the |
| | | 1426 | <filename>.h</filename> files, and a C file is compiled before its |
| | | 1427 | required header is generated.</para> |
| | | 1428 | |
| | | 1429 | <para>To see whether the build runs with parallel jobs, run |
| | | 1430 | <command>bmake show-all-build | grep JOBS</command>. Its output looks |
| | | 1431 | like this:</para> |
| | | 1432 | |
| | | 1433 | <programlisting> |
| | | 1434 | usr MAKE_JOBS= 7 |
| | | 1435 | pkg MAKE_JOBS_SAFE # undefined |
| | | 1436 | def _MAKE_JOBS_N= 7 |
| | | 1437 | </programlisting> |
| | | 1438 | |
| | | 1439 | <para>In this case the pkgsrc user has asked pkgsrc to build packages |
| | | 1440 | with 7 jobs in parallel (<varname>MAKE_JOBS</varname>). The |
| | | 1441 | package could have disabled parallel builds by setting |
| | | 1442 | <varname>MAKE_JOBS_SAFE</varname> to <literal>no</literal>, but |
| | | 1443 | in this case it hasn't.</para> |
| | | 1444 | |
| | | 1445 | <para>To see whether the build failure is caused by parallel builds, |
| | | 1446 | first save the exact error message and a bit of context, maybe you need |
| | | 1447 | it later for reporting a bug. Next, run:</para> |
| | | 1448 | |
| | | 1449 | <programlisting> |
| | | 1450 | MAKE_JOBS_SAFE=no bmake clean build |
| | | 1451 | </programlisting> |
| | | 1452 | |
| | | 1453 | <para>If that succeeds, <ulink |
| | | 1454 | url="https://www.NetBSD.org/cgi-bin/sendpr.cgi?gndb=netbsd">file a bug |
| | | 1455 | report</ulink> against the pkgsrc package, including the exact error |
| | | 1456 | message and the contents of your &mk.conf; file.</para> |
| | | 1457 | |
| | | 1458 | </sect3> |
| | | 1459 | </sect2> |
| | | 1460 | |
1352 | <sect2 id="undefined-reference"> | | 1461 | <sect2 id="undefined-reference"> |
1353 | <title>Undefined reference to <quote>...</quote></title> | | 1462 | <title>Undefined reference to <quote>...</quote></title> |
1354 | | | 1463 | |
1355 | <para>This error message often means that a package did not | | 1464 | <para>This error message often means that a package did not |
1356 | link to a shared library it needs. The following functions are | | 1465 | link to a shared library it needs. The following functions are |
1357 | known to cause this error message over and over.</para> | | 1466 | known to cause this error message over and over.</para> |
1358 | | | 1467 | |
1359 | <informaltable id="undefined-reference-functions"> | | 1468 | <informaltable id="undefined-reference-functions"> |
1360 | <tgroup cols="3"> | | 1469 | <tgroup cols="3"> |
1361 | <thead><row><entry>Function</entry><entry>Library</entry><entry>Affected platforms</entry></row></thead> | | 1470 | <thead><row><entry>Function</entry><entry>Library</entry><entry>Affected platforms</entry></row></thead> |
1362 | <tbody> | | 1471 | <tbody> |
1363 | <row><entry>accept, bind, connect</entry><entry>-lsocket</entry><entry>Solaris</entry></row> | | 1472 | <row><entry>accept, bind, connect</entry><entry>-lsocket</entry><entry>Solaris</entry></row> |
1364 | <row><entry>crypt</entry><entry>-lcrypt</entry><entry>DragonFly, NetBSD</entry></row> | | 1473 | <row><entry>crypt</entry><entry>-lcrypt</entry><entry>DragonFly, NetBSD</entry></row> |