home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fs.zip / octave / kpathsea / doc / bugs.tex < prev    next >
Text File  |  2000-01-15  |  34KB  |  878 lines

  1. @ifclear version
  2. @defcodeindex fl
  3. @defcodeindex op
  4. @end ifclear
  5.  
  6. @node Reporting bugs
  7. @section Reporting bugs
  8.  
  9. @cindex reporting bugs
  10. @cindex bugs, reporting
  11.  
  12. @ifset version
  13. (A copy of this chapter is in the file @file{kpathsea/BUGS}.)
  14. @end ifset
  15.  
  16. @flindex tex-k@@mail.tug.org @r{(bug address)}
  17. @cindex bug address
  18. If you have problems or suggestions, please report them to
  19. @email{tex-k@@mail.tug.org} using the bug checklist below.
  20.  
  21. Please report bugs in the documentation; not only factual errors or
  22. inconsistent behavior, but unclear or incomplete explanations, typos,
  23. wrong fonts, @dots{}
  24.  
  25. @menu
  26. * Bug checklist::       What to include in a good bug report.
  27. * Mailing lists::       Joining the bugs or announcements mailing lists.
  28. * Debugging::           Analyzing runtime problems.
  29. * Logging::             Recording searches.
  30. * Common problems::     When things go wrong.
  31. @end menu
  32.  
  33.  
  34. @node Bug checklist
  35. @subsection Bug checklist
  36.  
  37. @cindex checklist for bug reports
  38. @cindex bug checklist
  39.  
  40. Before reporting a bug, please check below to be sure it isn't already
  41. known (@pxref{Common problems}).
  42.  
  43. Bug reports should be sent via electronic mail to
  44. @email{tex-k@@mail.tug.org}, or by postal mail to 135 Center Hill Road /
  45. Plymouth, MA 02360 / USA.
  46.  
  47. The general principle is that a good bug report includes all the
  48. information necessary for reproduction.  Therefore, to enable
  49. investigation, your report should include the following:
  50.  
  51. @itemize @bullet
  52. @item
  53. @cindex version numbers, determining
  54. The version number(s) of the program(s) involved, and of Kpathsea
  55. itself.  You can get the former by giving a sole option @samp{--version}
  56. to the program, and the latter by running @samp{kpsewhich --version}.
  57. The @file{NEWS} and @file{ChangeLog} files also contain the version
  58. number.
  59.  
  60. @item
  61. @pindex uname
  62. The hardware, operating system (including version number), compiler, and
  63. @code{make} program you are using (the output of @code{uname -a} is a
  64. start on the first two, though often incomplete).  If the bug involves
  65. the X window system, include X version and supplier information as well
  66. (examples: X11R6 from MIT; X11R4 from HP; OpenWindows 3.3 bundled with
  67. SunOS 4.1.4).
  68.  
  69. @item
  70. @flindex config.log
  71. Any options you gave to @code{configure}.  This is recorded in the
  72. @file{config.status} files.
  73.  
  74. @cindex configuration bugs
  75. @flindex config.status
  76. If you are reporting a bug in @samp{configure} itself, it's probably
  77. system-dependent, and it will be unlikely the maintainers can do
  78. anything useful if you merely report that thus-and-such is broken.
  79. Therefore, you need to do some additional work: for some bugs, you can
  80. look in the file @file{config.log} where the test that failed should
  81. appear, along with the compiler invocation and source program in
  82. question.  You can then compile it yourself by hand, and discover why
  83. the test failed.  Other @samp{configure} bugs do not involve the
  84. compiler; in that case, the only recourse is to inspect the
  85. @code{configure} shell script itself, or the Autoconf macros that
  86. generated @code{configure}.
  87.  
  88. @item
  89. The log of all debugging output, if the bug is in path searching.  You
  90. can get this by setting the environment variable @code{KPATHSEA_DEBUG}
  91. to @samp{-1} before running the program.  Please look at the log
  92. yourself to make sure the behavior is really a bug before reporting it;
  93. perhaps ``old'' environment variable settings are causing files not to
  94. be found, for example.
  95.  
  96. @item
  97. The contents of any input files necessary to reproduce the bug.  For
  98. bugs in DVI-reading programs, for example, this generally means a DVI
  99. file (and any EPS or other files it uses)---@TeX{} source files are
  100. helpful, but the DVI file is necessary, because that's the actual
  101. program input.
  102.  
  103. @cindex shar@r{, recommended}
  104. GNU @code{shar}, available from @url{ftp://prep.ai.mit.edu/pub/gnu} is
  105. a convenient way of packaging multiple (possibly binary) files for
  106. electronic mail.  If you feel your input files are too big to send by
  107. email, you can ftp them to @url{ftp://ftp.tug.org/incoming} (that
  108. directory is writable, but not readable).
  109.  
  110. @item
  111. @cindex context diff
  112. @cindex sending patches
  113. @flindex ChangeLog @r{entry}
  114. If you are sending a patch (do so if you can!), please do so in the form
  115. of a context diff (@samp{diff -c}) against the original distribution
  116. source.  Any other form of diff is either not as complete or harder for
  117. me to understand.  Please also include a @file{ChangeLog} entry.
  118.  
  119. @item
  120. @cindex stack trace
  121. @cindex debugger
  122. @cindex crashes, reporting
  123. @cindex core dumps, reporting
  124. @cindex null pointers, dereferencing
  125. @pindex gdb@r{, recommended}
  126. If the bug involved is an actual crash (i.e., core dump), it is easy and
  127. useful to include a stack trace from a debugger (I recommend the GNU
  128. debugger GDB, available from @url{ftp://prep.ai.mit.edu/pub/gnu}).  If
  129. the cause is apparent (a @code{NULL} value being dereferenced, for
  130. example), please send the details along.  If the program involved is
  131. @TeX{} or Metafont, and the crash is happening at apparently-sound code,
  132. however, the bug may well be in the compiler, rather than in the program
  133. or the library (@pxref{TeX or Metafont failing,, @TeX{} or Metafont
  134. failing}).
  135.  
  136. @item
  137. Any additional information that will be helpful in reproducing,
  138. diagnosing, or fixing the bug.
  139. @end itemize
  140.  
  141.  
  142. @node Mailing lists
  143. @subsection Mailing lists
  144.  
  145. @cindex mailing lists
  146. @cindex bug mailing list
  147. @cindex announcement mailing list
  148.  
  149. Web2c and Kpathsea in general are discussed on the mailing list
  150. @email{tex-k@@mail.tug.org}.
  151. @flindex tex-k-request@@mail.tug.org
  152. To join, email @email{tex-k-request@@mail.tug.org} with a line
  153. consisting of
  154.  
  155. @example
  156. subscribe @var{you}@@@var{your.preferred.email.address}
  157. @end example
  158.  
  159. @noindent in the body of the message.
  160.  
  161. You do not need to join to submit a report, nor will it affect whether
  162. you get a response.  There is no Usenet newsgroup equivalent (if you can
  163. be the one to set this up, email @samp{tex-k-request}).  Traffic on the
  164. list is fairly light, and is mainly bug reports and enhancement requests
  165. to the software.  The best way to decide if you want to join or not is
  166. read some of the archives from @url{ftp://ftp.tug.org/mail/archives/tex-k/}.
  167.  
  168. Be aware that large data files are sometimes included in bug reports.
  169. If this is a problem for you, do not join the list.
  170.  
  171. @flindex tex-archive@@math.utah.edu
  172. @cindex announcement mailing list
  173. If you only want announcements of new releases, not bug reports and
  174. discussion, join @email{tex-archive@@math.utah.edu} (via mail to
  175. @email{tex-archive-request@@math.utah.edu}).
  176.  
  177. @cindex @TeX{} help mailing list
  178. @cindex La@TeX{} help mailing list
  179. @cindex Usenet @TeX{} newsgroup
  180. @cindex newsgroup for @TeX{}
  181. @cindex help, mailing list for general @TeX{}
  182. @flindex info-tex@@shsu.edu
  183. @flindex comp.text.tex
  184. If you are looking for general @TeX{} help, such as how to use La@TeX{},
  185. please use the mailing list @email{info-tex@@shsu.edu} mailing list,
  186. which is gatewayed to the @samp{comp.text.tex} Usenet newsgroup (or post
  187. to the newsgroup; the gateway is bidirectional).
  188.  
  189.  
  190. @node Debugging
  191. @subsection Debugging
  192.  
  193. @cindex debugging
  194. @cindex runtime debugging
  195. @cindex options for debugging
  196.  
  197. @vindex kpathsea_debug
  198. @flindex debug.h
  199. Kpathsea provides a number of runtime debugging options, detailed below
  200. by their names and corresponding numeric values.  When the files you
  201. expect aren't being found, the thing to do is enable these options and
  202. examine the output.
  203.  
  204. You can set these with some runtime argument (e.g., @samp{-d}) to the
  205. program; in that case, you should use the numeric values described in
  206. the program's documentation (which, for Dvipsk and Xdvik, are different
  207. than those below).  It's best to give the @samp{-d} (or whatever) option
  208. first, for maximal output.  Dvipsk and Xdvik have additional
  209. program-specific debugging options as well.
  210.  
  211. @vindex KPATHSEA_DEBUG
  212. @vindex kpathsea_debug
  213. You can also set the environment variable @code{KPATHSEA_DEBUG}; in this
  214. case, you should use the numbers below.  If you run the program under a
  215. debugger and set the variable @code{kpathsea_debug}, also use the numbers
  216. below.
  217.  
  218. @kindex -1 @r{debugging value}
  219. In any case, by far the simplest value to use is @samp{-1}, which will
  220. turn on all debugging output.  This is usually better than guessing
  221. which particular values will yield the output you need.
  222.  
  223. @cindex debugging output
  224. @cindex standard error and debugging output
  225. Debugging output always goes to standard error, so you can redirect it
  226. easily.  For example, in Bourne-compatible shells:
  227. @example
  228. dvips -d -1 @dots{} 2>/tmp/debug
  229. @end example
  230.  
  231. @cindex Kpsewhich, and debugging
  232. It is sometimes helpful to run the standalone Kpsewhich utility
  233. (@pxref{Invoking kpsewhich}), instead of the original program.
  234.  
  235. @cindex numeric debugging values
  236. In any case, you can @emph{not} use the @emph{names} below; you must
  237. always use somebody's numbers.  (Sorry.)  To set more than one
  238. option, just sum the corresponding numbers.
  239.  
  240. @vtable @code
  241. @item KPSE_DEBUG_STAT @r{(1)}
  242. Report @samp{stat}(2) calls. This is useful for verifying that your
  243. directory structure is not forcing Kpathsea to do many additional file
  244. tests (@pxref{Slow path searching}, and @pxref{Subdirectory
  245. expansion}). If you are using an up-to-date @file{ls-R} database
  246. (@pxref{Filename database}), this should produce no output unless a
  247. nonexistent file that must exist is searched for.
  248.  
  249. @item KPSE_DEBUG_HASH @r{(2)}
  250. Report lookups in all hash tables: @file{ls-R} and @file{aliases}
  251. (@pxref{Filename database}); font aliases (@pxref{Fontmap}); and config
  252. file values (@pxref{Config files}).  Useful when expected values are not
  253. being found, e.g.., file searches are looking at the disk instead of
  254. using @file{ls-R}.
  255.  
  256. @item KPSE_DEBUG_FOPEN @r{(4)}
  257. @findex fopen@r{, redefined}
  258. Report file openings and closings. Especially useful when your system's
  259. file table is full, for seeing which files have been opened but never
  260. closed. In case you want to set breakpoints in a debugger: this works by
  261. redefining @samp{fopen} (@samp{fclose}) to be @samp{kpse_fopen_trace}
  262. (@samp{kpse_fclose_trace}).
  263.  
  264. @item KPSE_DEBUG_PATHS @r{(8)}
  265. @tindex kpse_format_info_type
  266. Report general path information for each file type Kpathsea is asked to
  267. search. This is useful when you are trying to track down how a
  268. particular path got defined---from @file{texmf.cnf}, @file{config.ps},
  269. an environment variable, the compile-time default, etc.  This is the
  270. contents of the @code{kpse_format_info_type} structure defined in
  271. @file{tex-file.h}.
  272.  
  273. @item KPSE_DEBUG_EXPAND @r{(16)}
  274. Report the directory list corresponding to each path element Kpathsea
  275. searches. This is only relevant when Kpathsea searches the disk, since
  276. @file{ls-R} searches don't look through directory lists in this way.
  277.  
  278. @item KPSE_DEBUG_SEARCH @r{(32)}
  279. Report on each file search: the name of the file searched for, the path
  280. searched in, whether or not the file must exist (when drivers search for
  281. @file{cmr10.vf}, it need not exist), and whether or not we are
  282. collecting all occurrences of the file in the path (as with, e.g.,
  283. @file{texmf.cnf} and @file{texfonts.map}), or just the first (as with
  284. most lookups).  This can help you correlate what Kpathsea is doing with
  285. what is in your input file.
  286.  
  287. @item KPSE_DEBUG_VARS @r{(64)}
  288. Report the value of each variable Kpathsea looks up.  This is useful for
  289. verifying that variables do indeed obtain their correct values.
  290.  
  291. @item GSFTOPK_DEBUG @r{(128)}
  292. Activates debugging printout specific to @code{gsftopk} program.
  293.  
  294. @item MAKETEX_DEBUG @r{(512)}
  295. If you use the optional @code{mktex} programs instead of the
  296. traditional shell scripts, this will report the name of the site file
  297. (@file{mktex.cnf} by default) which is read, directories created by
  298. @code{mktexdir}, the full path of the @file{ls-R} database built by
  299. @code{mktexlsr}, font map searches, @code{MT_FEATURES} in effect,
  300. parameters from @code{mktexnam}, filenames added by
  301. @code{mktexupd}, and some subsidiary commands run by the programs.
  302.  
  303. @item MAKETEX_FINE_DEBUG @r{(1024)}
  304. When the optional @code{mktex} programs are used, this will print
  305. additional debugging info from functions internal to these programs.
  306. @end vtable
  307.  
  308. @cindex @samp{kdebug:}
  309. @vindex hash_summary_only @r{variable for debugging}
  310. @cindex hash table buckets, printing
  311. Debugging output from Kpathsea is always written to standard error, and
  312. begins with the string @samp{kdebug:}. (Except for hash table buckets,
  313. which just start with the number, but you can only get that output
  314. running under a debugger. See comments at the @code{hash_summary_only}
  315. variable in @file{kpathsea/db.c}.)
  316.  
  317.  
  318. @node Logging
  319. @subsection Logging
  320.  
  321. @cindex log file
  322.  
  323. @cindex logging successful searches
  324. @cindex recording successful searches
  325. @cindex usage patterns, finding
  326. @cindex disk usage, reducing
  327. Kpathsea can record the time and filename found for each successful
  328. search.  This may be useful in finding good candidates for deletion when
  329. your filesystem is full, or in discovering usage patterns
  330. at your site.
  331.  
  332. @vindex TEXMFLOG
  333. To do this, define the environment or config file variable
  334. @code{TEXMFLOG}.  The value is the name of the file to append the
  335. information to.  The file is created if it doesn't exist, and appended
  336. to if it does.
  337.  
  338. @cindex epoch, seconds since
  339. @findex time @r{system call}
  340. Each successful search turns into one line in the log file: two words
  341. separated by a space. The first word is the time of the search, as the
  342. integer number of seconds since ``the epoch'', i.e., UTC midnight 1
  343. January 1970 (more precisely, the result of the @code{time} system
  344. call). The second word is the filename.
  345.  
  346. For example, after @code{setenv TEXMFLOG /tmp/log}, running Dvips on
  347. @file{story.dvi} appends the following lines:
  348.  
  349. @example
  350. 774455887 /usr/local/share/texmf/dvips/config.ps
  351. 774455887 /usr/local/share/texmf/dvips/psfonts.map
  352. 774455888 /usr/local/share/texmf/dvips/texc.pro
  353. 774455888 /usr/local/share/texmf/fonts/pk/ljfour/public/cm/cmbx10.600pk
  354. 774455889 /usr/local/share/texmf/fonts/pk/ljfour/public/cm/cmsl10.600pk
  355. 774455889 /usr/local/share/texmf/fonts/pk/ljfour/public/cm/cmr10.600pk
  356. 774455889 /usr/local/share/texmf/dvips/texc.pro
  357. @end example
  358.  
  359. @cindex privacy, semblance of
  360. @noindent Only filenames that are absolute are recorded, to preserve
  361. some semblance of privacy.
  362.  
  363.  
  364. @node Common problems
  365. @subsection Common problems
  366.  
  367. @cindex common problems
  368. @cindex problems, common
  369. @cindex FAQ, Kpathsea
  370.  
  371. Here are some common problems with configuration, compilation, linking,
  372. execution, @dots{}
  373.  
  374. @menu
  375. * Unable to find files::        If your program can't find fonts (or whatever).
  376. * Slow path searching::         If it takes forever to find anything.
  377. * Unable to generate fonts::    If mktexpk fails.
  378. * TeX or Metafont failing::     Likely compiler bugs.
  379.  
  380. * Empty Makefiles::                When configure produces empty makefiles.
  381. * XtStrings::                   When _XtStrings is undefined.
  382. * dlopen::                      When dlopen is undefined.
  383. * ShellWidgetClass::            For dynamic linking troubles under OpenWindows.
  384. * Pointer combination warnings::  For old compilers that don't grok char *.
  385. @end menu
  386.  
  387. @node Unable to find files
  388. @subsubsection Unable to find files
  389.  
  390. @cindex unable to find files
  391. @cindex files, unable to find
  392.  
  393. If a program complains it cannot find fonts (or other input files), any
  394. of several things might be wrong.  In any case, you may find the
  395. debugging options helpful.  @xref{Debugging}.
  396.  
  397. @itemize @bullet
  398. @item
  399. Perhaps you simply haven't installed all the necessary files; the basic
  400. fonts and input files are distributed separately from the programs.
  401. @xref{unixtex.ftp}.
  402.  
  403. @item
  404. @flindex /etc/profile
  405. @cindex environment variables, old
  406. You have (perhaps unknowingly) told Kpathsea to use search paths that
  407. don't reflect where the files actually are.  One common cause is having
  408. environment variables set from a previous installation, thus overriding
  409. what you carefully set in @file{texmf.cnf} (@pxref{Supported file
  410. formats}).  System @file{/etc/profile} or other files such may be the
  411. culprit.
  412.  
  413. @item
  414. @cindex symbolic links not found
  415. @cindex leaf directories wrongly guessed
  416. Your files reside in a directory that is only pointed to via a symbolic
  417. link, in a leaf directory and is not listed in @file{ls-R}.
  418.  
  419. Unfortunately, Kpathsea's subdirectory searching has an irremediable
  420. deficiency: If a directory @var{d} being searched for subdirectories
  421. contains plain files and symbolic links to other directories, but no
  422. true subdirectories, @var{d} will be considered a leaf directory, i.e.,
  423. the symbolic links will not be followed.  @xref{Subdirectory expansion}.
  424.  
  425. You can work around this problem by creating an empty dummy subdirectory
  426. in @var{d}. Then @var{d} will no longer be a leaf, and the symlinks will
  427. be followed.
  428.  
  429. The directory immediately followed by the @samp{//} in the path
  430. specification, however, is always searched for subdirectories, even if
  431. it is a leaf.  Presumably you would not have asked for the directory to
  432. be searched for subdirectories if you didn't want it to be.
  433.  
  434. @item
  435. If the fonts (or whatever) don't already exist, @code{mktexpk} (or
  436. @code{mktexmf} or @code{mktextfm}) will try to create them.  If
  437. these rather complicated shell scripts fail, you'll eventually get an
  438. error message saying something like @samp{Can't find font
  439. @var{fontname}}. The best solution is to fix (or at least report) the
  440. bug in @code{mktexpk}; the workaround is to generate the necessary
  441. fonts by hand with Metafont, or to grab them from a CTAN site
  442. (@pxref{unixtex.ftp}).
  443.  
  444. @item
  445. There is a bug in the library. @xref{Reporting bugs}.
  446. @end itemize
  447.  
  448.  
  449. @node Slow path searching
  450. @subsubsection Slow path searching
  451.  
  452. @cindex excessive startup time
  453. @cindex slow startup time
  454. @cindex startup time, excessive
  455.  
  456. If your program takes an excessively long time to find fonts or other
  457. input files, but does eventually succeed, here are some possible culprits:
  458.  
  459. @itemize @bullet
  460. @item
  461. Most likely, you just have a lot of directories to search, and that
  462. takes a noticeable time. The solution is to create and maintain a
  463. separate @file{ls-R} file that lists all the files in your main @TeX{}
  464. hierarchy.  @xref{Filename database}.  Kpathsea always uses @file{ls-R}
  465. if it's present; there's no need to recompile or reconfigure any of the
  466. programs.
  467.  
  468. @item
  469. Your recursively-searched directories (e.g.,
  470. @file{/usr/local/share/texmf/fonts//}), contain a mixture of files and
  471. directories. This prevents Kpathsea from using a useful optimization
  472. (@pxref{Subdirectory expansion}).
  473.  
  474. It is best to have only directories (and perhaps a @file{README}) in the
  475. upper levels of the directory structure, and it's very important to have
  476. @emph{only} files, and no subdirectories, in the leaf directories where
  477. the dozens of TFM, PK, or whatever files reside.
  478. @end itemize
  479.  
  480. In any case, you may find the debugging options helpful in determining
  481. precisely when the disk or network is being pounded.  @xref{Debugging}.
  482.  
  483.  
  484. @node Unable to generate fonts
  485. @subsubsection Unable to generate fonts
  486.  
  487. @cindex unable to generate fonts
  488. @cindex font generation failures
  489.  
  490. This can happen if either @code{mktexpk} hasn't been installed
  491. properly, or if the local installation of Metafont isn't correct.
  492.  
  493. @cindex Metafont installation
  494. If @code{mf} is a command not found by @code{mktexpk}, then you need
  495. to install Metafont (@pxref{unixtex.ftp}).
  496.  
  497. @cindex Metafont using the wrong resolution
  498. @cindex resolution, wrong
  499. If Metafont runs, but generates fonts at the wrong resolution, you need
  500. to be sure the @samp{M} and @samp{D} lines in your Dvips configuration
  501. file match (@pxref{Config files,,, dvips, Dvips}).  For example, if
  502. @code{mktexpk} is generating 300@dmn{dpi} fonts, but you need
  503. 600@dmn{dpi} fonts, you should have:
  504. @example
  505. M ljfour
  506. D 600
  507. @end example
  508.  
  509. @flindex .2602gf
  510. @flindex 2602gf
  511. @cindex Metafont making too-large fonts
  512. @cindex proof mode
  513. @cindex online Metafont display, spurious
  514. If Metafont runs but generates fonts at a resolution of 2602@dmn{dpi}
  515. (and prints out the name of each character as well as just a character
  516. number, and maybe tries to display the characters), then your Metafont
  517. base file probably hasn't been made properly.  (It's using the default
  518. @code{proof} mode, instead of an actual device mode.)  To make a proper
  519. @file{plain.base}, assuming the local mode definitions are contained in
  520. a file @file{modes.mf}, run the following command (assuming Unix):
  521.  
  522. @example
  523. inimf "plain; input modes; dump"
  524. @end example
  525.  
  526. @noindent
  527. @flindex plain.base
  528. Then copy the @file{plain.base} file from the current directory to where
  529. the base files are stored on your system
  530. (@file{/usr/local/share/texmf/web2c} by default), and make a link
  531. (either hard or soft) from @file{plain.base} to @file{mf.base} in that
  532. directory.
  533. @xref{inimf invocation,,, web2c, Web2c}.
  534.  
  535.  
  536. @node TeX or Metafont failing
  537. @subsubsection @TeX{} or Metafont failing
  538.  
  539. @cindex @TeX{} failures
  540. @cindex Metafont failures
  541. @cindex compiler bugs
  542. If @TeX{} or Metafont get a segmentation fault or otherwise fail while
  543. running a normal input file, the problem is usually a compiler bug
  544. (unlikely as that may sound).  Even if the trip and trap tests are
  545. passed, problems may lurk.  Optimization occasionally causes trouble in
  546. programs other than @TeX{} and Metafont themselves, too.
  547.  
  548. Insufficient swap space may also cause core dumps or other erratic
  549. behavior.
  550.  
  551. @cindex optimization caveat
  552. For a workaround, if you enabled any optimization flags, it's best to
  553. omit optimization entirely.  In any case, the way to find the facts is
  554. to run the program under the debugger and see where it's failing.
  555.  
  556. @cindex GNU C compiler bugs
  557. @cindex system C compiler bugs
  558. Also, if you have trouble with a system C compiler, I advise trying the
  559. GNU C compiler. And vice versa, unfortunately; but in that case I also
  560. recommend reporting a bug to the GCC mailing list; see @ref{Bugs,,, gcc,
  561. Using and Porting GNU CC}.
  562.  
  563. @cindex compiler bugs, finding
  564. To report compiler bugs effectively requires perseverance and
  565. perspicacity: you must find the miscompiled line, and that usually
  566. involves delving backwards in time from the point of error, checking
  567. through @TeX{}'s (or whatever program's) data structures.  Things are
  568. not helped by all-too-common bugs in the debugger itself.  Good luck.
  569.  
  570. @cindex ANSI C
  571. @cindex HP-UX, compiling on
  572. @cindex compiling on HP-UX
  573. One known cause of trouble is the way arrays are handled.  Some of the
  574. Pascal arrays have a lower index other than 0, and the C code will take
  575. the pointer to the allocated memory, subtract the lower index, and use
  576. the resulting pointer for the array.  While this trick often works, ANSI
  577. C doesn't guarantee that it will.  It it known to fail on HP-UX 10
  578. mchines when the native compiler is used, unless the @samp{+u} compiler
  579. switch was specified.  Using GCC will work on this platform as well.
  580.  
  581. @node Empty Makefiles
  582. @subsubsection Empty Makefiles
  583.  
  584. @cindex Makefiles, empty
  585. @pindex sed @r{error from @code{configure}}
  586. @pindex configure @r{error from @code{sed}}
  587. @cindex NetBSD @code{configure} error
  588. @cindex FreeBSD @code{configure} error
  589. @cindex Mach10 @code{configure} error
  590. @cindex AIX 4.1 @code{configure} error
  591. @cindex NeXT @code{sed} error
  592.  
  593. On some systems (NetBSD, FreeBSD, AIX 4.1, and Mach10), @code{configure}
  594. may fail to properly create the Makefiles. Instead, you get an error
  595. which looks something like this:
  596.  
  597. @example
  598. prompt$ ./configure
  599. @dots{}
  600. creating Makefile
  601. sed: 1: "\\@@^ac_include make/pat ...": \ can not be used as a string delimiter
  602. @end example
  603.  
  604. So far as I know, the bug here is in @code{/bin/sh} on these systems. I
  605. don't have access to a machine running any of them, so if someone can
  606. find a workaround that avoids the quoting bug, I'd be most
  607. grateful. (Search for @code{ac_include} in the @code{configure} script
  608. to get to the problematic code.)
  609.  
  610. It should work to run @code{bash configure}, instead of using
  611. @code{/bin/sh}. You can get Bash from
  612. @url{ftp://prep.ai.mit.edu/pub/gnu} and mirrors.
  613.  
  614. Another possible cause (reported for NeXT) is a bug in the @code{sed}
  615. command.  In that case the error may look like this:
  616.  
  617. @example
  618. Unrecognized command: \@@^ac_include make/paths.make@@r make/paths.make
  619. @end example
  620.  
  621. In this case, installing GNU @code{sed} should solve the problem.  You
  622. can get GNU @code{sed} from the same places as Bash.
  623.  
  624. @ignore
  625. @node wchar_t
  626. @subsubsection @code{wchar_t}
  627.  
  628. @vindex FOIL_X_WCHAR_T
  629. @tindex wchar_t
  630.  
  631. The upshot of all the following is that if you get error messages
  632. regarding @code{wchar_t}, try defining @code{NO_FOIL_X_WCHAR_T} (for
  633. Web2c) or @code{FOIL_X_WCHAR_T} (for everything else), as in:
  634.  
  635. @example
  636. make XCFLAGS=-DNO_FOIL_X_WCHAR_T @var{other-make-options}
  637. @end example
  638.  
  639. @flindex Xlib.h
  640. @flindex stddef.h
  641. @code{wchar_t} has caused infinite trouble. None of my code ever uses
  642. @code{wchar_t}; all I want to do is include X header files and various
  643. system header files, possibly compiling with GCC. This seems an
  644. impossible task! The basic problem is that the X11 header
  645. @file{<Xlib.h>} and GCC's @file{<stddef.h>} have conflicting definitions
  646. for @code{wchar_t}.
  647.  
  648. The particulars: @file{<X11/Xlib.h>} from MIT X11R5 defines
  649. @code{wchar_t} if @code{X_WCHAR} is defined, which is defined if
  650. @code{X_NOT_STDC_ENV} is defined, and we define @emph{that} if
  651. @code{STDC_HEADERS} is not defined (@samp{configure} decides if
  652. @code{STDC_HEADERS} gets defined).  But when compiling with GCC on SunOS
  653. 4.1.x, @code{STDC_HEADERS} is not defined (@file{string.h} doesn't
  654. declare the @samp{mem}* functions), so we do get X's
  655. @code{wchar_t}---and we also get GCC's @code{wchar_t} from its
  656. @file{<stddef.h>}.  Conflict.
  657.  
  658. On the other hand, SunOS 4.1.1 with some other X configurations actually
  659. needs GCC to define @code{wchar_t}, and fails otherwise.
  660.  
  661. My current theory is to define @code{wchar_t} to a nonsense symbol
  662. before the X include files are read; that way its definition (if any)
  663. will be ignored by other system include files.  Going along with that,
  664. define @code{X_WCHAR} to tell X not to use @file{<stddef.h>}, that we've
  665. already included, but instead to make its own definition.
  666.  
  667. But this is not the end of the story. The X11 include files distributed
  668. with DG/UX 5.4.2 for the Aviion have been modified to include
  669. @file{<_int_wchar_t.h>} if @code{X_WCHAR}, so our @code{#define} will
  670. not have any typedef to change---but the uses of @code{wchar_t} in the X
  671. include files will be changed to reference this undefined symbol. So
  672. there's nothing to foil in this case. I don't know how to detect this
  673. automatically, so it's up to you to define @code{NO_FOIL_X_WCHAR_T}
  674. yourself.
  675. @end ignore
  676.  
  677. @node XtStrings
  678. @subsubsection @code{XtStrings}
  679.  
  680. @findex XtStrings
  681. You may find that linking X programs results in an error from the linker
  682. that @samp{XtStrings} is undefined, something like this:
  683.  
  684. @example
  685. gcc -o virmf @dots{}
  686. @dots{}/x11.c:130: undefined reference to `XtStrings'
  687. @end example
  688.  
  689. This generally happens because of a mismatch between the X include files
  690. with which you compiled and the X libraries with which you linked;
  691. often, the include files are from MIT and the libraries from Sun.
  692.  
  693. The solution is to use the same X distribution for compilation and
  694. linking.  Probably @samp{configure} was unable to guess the proper
  695. directories from your installation.  You can use the @code{configure}
  696. options @samp{--x-includes=@var{path}} and
  697. @samp{--x-libraries=@var{path}} to explicitly specify them.
  698.  
  699.  
  700. @node dlopen
  701. @subsubsection @code{dlopen}
  702.  
  703. @cindex static linking and @code{dlsym}
  704. @flindex dlopen
  705. @flindex dlsym
  706. @flindex dlclose
  707. @flindex wcstombs
  708. @flindex libdl.a
  709. (This section adapted from the file @file{dlsym.c} in the X distribution.)
  710.  
  711. The @code{Xlib} library uses the standard C function @code{wcstombs}.
  712. Under SunOS 4.1, @code{wcstombs} uses the @samp{dlsym} interface defined
  713. in @file{libdl.so}.  Unfortunately, the SunOS 4.1 distribution does not
  714. include a static @samp{libdl.a} library.
  715.  
  716. As a result, if you try to link an X program statically under SunOS, you
  717. may get undefined references to @code{dlopen}, @code{dlsym}, and
  718. @code{dlclose}.  One workaround is to include these definitions
  719. when you link:
  720.  
  721. @example
  722. void *dlopen() @{ return 0; @}
  723. void *dlsym()  @{ return 0; @}
  724. int dlclose()  @{ return -1; @}
  725. @end example
  726.  
  727. @flindex dlsym.c
  728. @noindent These are contained in the @file{dlsym.c} file in the MIT X
  729. distribution.
  730.  
  731.  
  732. @node ShellWidgetClass
  733. @subsubsection @code{ShellWidgetClass}
  734.  
  735. @cindex dynamic linking problems with OpenWin libraries
  736. @cindex OpenWin libraries, dynamic linking problems
  737. @findex get_wmShellWidgetClass
  738. @findex get_applicationShellWidgetClass
  739.  
  740. @flindex comp.sys.sun.admin @r{FAQ}
  741. @cindex FAQ, @t{comp.sys.sun.admin}
  742. (This section adapted from the @t{comp.sys.sun.admin} FAQ.)
  743.  
  744. If you are linking with Sun's OpenWindows libraries in SunOS 4.1.x, you
  745. may get undefined symbols @code{_get_wmShellWidgetClass} and
  746. @code{_get_applicationShellWidgetClass} when linking. This problem does
  747. not arise using the standard MIT X libraries under SunOS.
  748.  
  749. @findex Xmu @r{library problems}
  750. The cause is bugs in the @code{Xmu} shared library as shipped from Sun.
  751. There are several fixes:
  752.  
  753. @itemize @bullet
  754.  
  755. @item Install the free MIT distribution from @samp{ftp.x.org} and mirrors.
  756.  
  757. @item Get the OpenWindows patches listed below.
  758.  
  759. @item Statically link the @code{Xmu} library into the executable.
  760.  
  761. @item Avoid using @code{Xmu} at all. If you are compiling
  762. Metafont, see @ref{Online Metafont graphics,,, web2c, Web2c}. If you are
  763. compiling Xdvi, see the @code{-DNOTOOL} option in @file{xdvik/INSTALL}.
  764.  
  765. @item Ignore the errors. The binary runs fine regardless.
  766.  
  767. @end itemize
  768.  
  769. @cindex Sun OpenWin patches
  770. @cindex patches, Sun OpenWin
  771. Here is the information for getting the two patches:
  772.  
  773. @display
  774. Patch ID: 100512-02
  775. Bug ID's: 1086793, 1086912, 1074766
  776. Description: 4.1.x OpenWindows 3.0 @code{libXt} jumbo patch
  777.  
  778. Patch ID: 100573-03
  779. Bug ID: 1087332
  780. Description: 4.1.x OpenWindows 3.0 undefined symbols when using shared @code{libXmu}.
  781. @end display
  782.  
  783. @cindex static linking
  784. The way to statically link with @code{libXmu} depends on whether you are
  785. using a Sun compiler (e.g., @code{cc}) or @code{gcc}. If the latter,
  786. alter the @code{x_libs} Make variable to include
  787.  
  788. @opindex -static
  789. @opindex -dynamic
  790. @example
  791. -static -lXmu -dynamic
  792. @end example
  793.  
  794. @opindex -Bstatic
  795. @opindex -Bdynamic
  796. If you are using the Sun compiler, use @samp{-Bstatic} and @samp{-Bdynamic}.
  797.  
  798.  
  799. @node Pointer combination warnings
  800. @subsubsection Pointer combination warnings
  801.  
  802. @cindex warnings, pointer combinations
  803. @cindex pointer combination warnings
  804. @cindex illegal pointer combination warnings
  805. @pindex cc @r{warnings}
  806. When compiling with old C compilers, you may get some warnings about
  807. ``illegal pointer combinations''.  These are spurious; just ignore them.
  808. I decline to clutter up the source with casts to get rid of them.
  809.  
  810. @c This isn't worth including any more, OSF 1.x is too old.
  811. @c The other XtInherit problem (R4 Xlib on Suns) should never come up,
  812. @c but the answer from the X faq is included anyway.
  813. @c
  814. @c @node XtInherit
  815. @c @subsubsection @code{XtInherit}
  816. @c 
  817. @c @findex XtInherit @r{bug on OSF/1}
  818. @c @cindex OSF/1 loader bug and @code{XtInherit}
  819. @c @cindex Alpha OSF/1 loader bug and @code{XtInherit}
  820. @c 
  821. @c On DEC OSF/1 1.x systems, the loader has a bug that manifests itself in
  822. @c the following error (all on one line, but for the sake of the paper
  823. @c width it's broken here):
  824. @c 
  825. @c @example
  826. @c xdvik/xdvi: /sbin/loader: Fatal Error: search_for_undefineds: 
  827. @c      symbol _XtInherit should not have any relocation entry
  828. @c @end example
  829. @c 
  830. @c @noindent According to Michael Rickabaugh @code{<mjr@@quarry.enet.dec.com>}:
  831. @c 
  832. @c @quotation
  833. @c This is a bug fixed in DEC OSF/1 2.0.
  834. @c 
  835. @c If you know how, installing @file{/sbin/loader} from a 2.0 system onto a
  836. @c 1.3 system will work.  Make sure that @file{/usr} is @emph{not} mounted
  837. @c when you do this.  (If you forget about umounting @code{/usr}, it is
  838. @c possible most of your filesystems will become corrupted.)
  839. @c 
  840. @c Otherwise, I suggest getting a later CD and running
  841. @c @file{/usr/sbin/installupdate}.
  842. @c @end quotation
  843. @c 
  844. @c Alternatively, you may be able to use the freely available X11 libraries
  845. @c that come with the MIT distribution (on @file{ftp.x.org}, for example).
  846. @c 
  847. @c Linking statically, perhaps only with some of the X libraries, may also
  848. @c work.
  849. @c 
  850. @c The Sun XtInherit weirdness, from the comp.windows.x FAQ:
  851. @c Subject: 126)! What are these problems with "*_XtInherit* not found" on the Sun?
  852. @c When I link a X program that I wrote on a SunOS 4.0.3 or 4.1 machine I get the 
  853. @c error "ld.so: symbol not found *_XtInherit*".
  854. @c 
  855. @c      What you are seeing is a side-effect of a kludge in the R4 libXt.a to 
  856. @c get Sun shared libraries working.  Apparently, you can't share a function that 
  857. @c is both called and compared, as *_XtInherit* is. This was handled by putting 
  858. @c *_XtInherit* in the same file as a function that is always used, thereby 
  859. @c guaranteeing that it would be loaded -- that is, in Initialize.c, where 
  860. @c XtToolkitInitialize() and XtInitialize() reside. These routines would normally
  861. @c be called.
  862. @c 
  863. @c      You are probably seeing this error because your program is not a normal
  864. @c Xt-based program and does not call XtToolkitInitialize() anywhere. 
  865. @c      1) it may be a program that uses Xt functions but never opens a 
  866. @c connection to the X server.  [OSF/Motif's 1.1.0 UIL had this problem; it called
  867. @c XtMalloc() and other Xt functions.] The solution is to add the call to your 
  868. @c program; the function does not have to be executed, just linked in.
  869. @c      2) alternatively, your program doesn't need any Xt functions and is
  870. @c correct in not calling XtToolkitInitialize() -- it may be an Xlib or XView 
  871. @c program. In this case, you can remove -lXt from your link command. 
  872. @c 
  873. @c      It should not be necessary to link the shared libraries statically,
  874. @c although this will certainly solve the problem.
  875.  
  876. @c * Empty Makefiles::             If configure gives you sed errors.
  877. @c * wchar_t::                     For wchar_t difficulties.
  878.