[tlbuild] ICU build error on FreeBSD 11.1

Mojca Miklavec mojca.miklavec.lists at gmail.com
Mon Apr 2 14:45:25 CEST 2018


Hi,

I figured out that ICU build errors seem to be ignored somehow.

The command that eventually fails is the following:

/bin/sh ./libtool  --tag=CC   --mode=link cc -Wimplicit -Wreturn-type
-Wdeclaration-after-statement -Wno-unknown-pragmas -g -O2   -o
xdvi-bin main.o libxdvi.a /path/to/Work/texk/kpathsea/libkpathsea.la
/path/to/Work/libs/freetype2/libfreetype.a -L/usr/local/lib -Xlinker
--allow-multiple-definition  -lXaw -lXmu -lXt -lSM -lICE -lXext -lXpm
-lX11   -lm
libtool: link: cc  -o xdvi-bin main.o -Wl,--allow-multiple-definition
libxdvi.a /path/to/Work/texk/kpathsea/.libs/libkpathsea.a
/path/to/Work/libs/freetype2/libfreetype.a -L/usr/local/lib -lXaw
-lXmu -lXt -lSM -lICE -lXext -lXpm -lX11 -lm
libxdvi.a(util.o): In function `iconv_convert_string':
/path/to/Work/texk/xdvik/../../../texk/xdvik/util.c:1829: undefined
reference to `libiconv_open'
/path/to/Work/texk/xdvik/../../../texk/xdvik/util.c:1846: undefined
reference to `libiconv'
/path/to/Work/texk/xdvik/../../../texk/xdvik/util.c:1857: undefined
reference to `libiconv_close'
/path/to/Work/texk/xdvik/../../../texk/xdvik/util.c:1852: undefined
reference to `libiconv_close'
libxdvi.a(encodings.o): In function `cjk2unicode':
/path/to/Work/texk/xdvik/../../../texk/xdvik/encodings.c:3059:
undefined reference to `libiconv'
/path/to/Work/texk/xdvik/../../../texk/xdvik/encodings.c:3044:
undefined reference to `libiconv_open'
libxdvi.a(encodings.o): In function `close_iconv':
/path/to/Work/texk/xdvik/../../../texk/xdvik/encodings.c:3021:
undefined reference to `libiconv_close'
cc: error: linker command failed with exit code 1 (use -v to see invocation)


I then figured out that if I explicitly add "-liconv" to

cc -Wimplicit -Wreturn-type -Wdeclaration-after-statement
-Wno-unknown-pragmas -g -O2 -o xdvi-bin main.o
-Wl,--allow-multiple-definition  libxdvi.a
/path/to/Work/texk/kpathsea/.libs/libkpathsea.a
/path/to/Work/libs/freetype2/libfreetype.a -L/usr/local/lib -lXaw
-lXmu -lXt -lSM -lICE -lXext -lXpm -lX11 -lm

then the build succeeds and the build completes.

Now, I tried to come up with a proper patch for this, but I'm super confused.

The code to take care of the flags lives in
    /texk/xdvik/m4/xdvi-check-iconv.m4

It's this one in particular:

# _XDVI_ICONV_LIB
# ---------------
# Check for library containing iconv(), could be -liconv or -lrecode.
# Much like AC_SEARCH_LIBS([iconv], [iconv recode]),
# but needs to '#include <iconv.h>'.
m4_define([_XDVI_ICONV_LIB], [dnl
AC_CACHE_CHECK([for library containing iconv],
               [xdvi_cv_search_iconv], [dnl
xdvi_iconv_save_LDFLAGS=$LDFLAGS
xdvi_iconv_save_LIBS=$LIBS
LDFLAGS="$iconv_libpath $LDFLAGS"
AC_LANG_CONFTEST([AC_LANG_PROGRAM([[#include <stdlib.h>
#include <iconv.h>]],
                                  [[iconv_t cd = iconv_open("","");]])])
xdvi_cv_search_iconv=no
for xdvi_lib in "" -liconv -lrecode; do
  LIBS="$xdvi_lib $xdvi_iconv_save_LIBS"
  AC_LINK_IFELSE([],
                 [xdvi_cv_search_iconv=$xdvi_lib
                  break])
done
test "x$xdvi_cv_search_iconv" = x && xdvi_cv_search_iconv="none required"
LDFLAGS=$xdvi_iconv_save_LDFLAGS
LIBS=$xdvi_iconv_save_LIBS])
]) # _XDVI_ICONV_LIB


The result is
    configure:16097: checking for library containing iconv
    configure:16120: cc -o conftest -g -O2 conftest.c -lm >&5
    configure:16120: $? = 0
    configure:16131: result: none required

And in fact "cc test.c -o test" on

$ cat test.c
#include <stdlib.h>
#include <iconv.h>

int main()
{
iconv_t cd = iconv_open("", "");
return 0;
}

succeeds without the need to supply -liconv, yet the command to
compile xdvi doesn't work without -liconv.

Full log is here for example (it's somewhat long):
http://build.contextgarden.net/builders/texlive.freebsd-amd64.prg/builds/44/steps/shell/logs/stdio/text

Mojca


More information about the tlbuild mailing list