Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#57774 closed defect (fixed)

texlive-bin @2018.47642_8 : error: Undefined symbols for architecture x86_64

Reported by: kencu (Ken) Owned by: drkp (Dan Ports)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)
Port: texlive-bin

Description (last modified by kencu (Ken))

On 10.7, 10.8, and I think likely all systems not configured to use libc++, we see:

libtool: link: /opt/local/bin/clang++-mp-5.0 -pipe -Os -std=c++11 -Wno-reserved-user-defined-literal -D_GLIBCXX_USE_CXX11_ABI=0 -stdlib=macports-libstdc++ -arch x86_64 -Wl,-headerpad_max_install_names -arch x86_64 -o .libs/xetex xetexdir/xetex-xetexextra.o synctexdir/xetex-synctex.o xetex-xetexini.o xetex-xetex0.o xetex-xetex-pool.o  -framework Cocoa libxetex.a -L/opt/local/lib /opt/local/lib/libharfbuzz-icu.dylib /opt/local/lib/libharfbuzz.dylib /opt/local/lib/libgraphite2.dylib -licui18n -licuuc -licudata -lpthread -lm /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_tex_texlive-bin/texlive-bin/work/texlive-source-2018.47642/libs/teckit/libTECkit.a /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_tex_texlive-bin/texlive-bin/work/texlive-source-2018.47642/libs/poppler/libpoppler.a /opt/local/lib/libpng16.dylib /opt/local/lib/libfreetype.dylib -lz libmd5.a lib/lib.a /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_tex_texlive-bin/texlive-bin/work/texlive-source-2018.47642/texk/kpathsea/.libs/libkpathsea.dylib -framework ApplicationServices
Undefined symbols for architecture x86_64:
  "XeTeXFontMgr::appendToList(std::__cxx11::list<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >*, char const*)", referenced from:
      XeTeXFontMgr_Mac::appendNameToList(__CTFont const*, std::__cxx11::list<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >*, __CFString const*) in libxetex.a(libxetex_a-XeTeXFontMgr_Mac.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

This looks to be occurring because we are trying to link in libgcc in ABI5 mode rather than ABI4 mode. In c++ files a flag is added automatically by the cxx11 PG to fix this, but this flag is not automatically added to the objective c++ flags (maybe should be?), so it errors out with an ABI mismatch.

The solution is to add that ABI-forcing flag to the ObjectiveC++ build flags:

if {[string match *clang* ${configure.cxx}]} {
    build.env-append        OBJCXXFLAGS="${configure.objcxxflags} [get_canonical_archflags objcxx] -D_GLIBCXX_USE_CXX11_ABI=0 -stdlib=${configure.cxx_stdlib}"
} else {
    build.env-append        OBJCXXFLAGS="${configure.objcxxflags} [get_canonical_archflags objcxx]"
}

and then the build succeeds:

$ port -v installed texlive-bin
The following ports are currently installed:
  texlive-bin @2018.47642_8+x11 (active) platform='darwin 11' archs='x86_64' date='2018-12-13T14:16:40-0800'

I don't think we should just add -D_GLIBCXX_USE_CXX11_ABI=0 to all builds. It's only useful when using libgcc. For our purposes, adding the flag if the configure.cxx_stdlib is not libc++ would probably be the right test...

Attachments (1)

texlive-bin-fail-10.8-macports-libsdcxx.log (5.2 MB) - added by kencu (Ken) 5 years ago.
log from failed build on 10.8

Change History (17)

comment:1 Changed 5 years ago by kencu (Ken)

Description: modified (diff)

comment:2 Changed 5 years ago by kencu (Ken)

OK. Those flags are already in the PG:

            configure.objcxxflags-delete -D_GLIBCXX_USE_CXX11_ABI=0
            configure.objcxxflags-append -D_GLIBCXX_USE_CXX11_ABI=0

so now I'm a touch confused. Why weren't they used in the build line...?

/opt/local/bin/clang++-mp-5.0 -DHAVE_CONFIG_H -I. -I./w2c  -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_tex_texlive-bin/texlive-bin/work/texlive-source-2018.47642/texk -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_tex_texlive-bin/texlive-bin/work/texlive-source-2018.47642/texk -I./xetexdir -I/opt/local/include  -I/opt/local/include/freetype2 -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_tex_texlive-bin/texlive-bin/work/texlive-source-2018.47642/libs/teckit/include -I/opt/local/include/harfbuzz -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include  -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_tex_texlive-bin/texlive-bin/work/texlive-source-2018.47642/libs/poppler/include -I/opt/local/include/libpng16  -I./libmd5 -DXETEX_MAC  -isystem/opt/local/include  -Os -stdlib=macports-libstdc++ -arch x86_64 -stdlib=macports-libstdc++ -std=c++11 -MT xetexdir/libxetex_a-XeTeXFontMgr_Mac.o -MD -MP -MF xetexdir/.deps/libxetex_a-XeTeXFontMgr_Mac.Tpo -c -o xetexdir/libxetex_a-XeTeXFontMgr_Mac.o `test -f 'xetexdir/XeTeXFontMgr_Mac.mm' || echo './'`xetexdir/XeTeXFontMgr_Mac.mm

When I add the flag manually to the Portfile, it does make it onto the build line (and then the build succeeds):

/opt/local/bin/clang++-mp-5.0 -DHAVE_CONFIG_H -I. -I./w2c  -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_tex_texlive-bin/texlive-bin/work/texlive-source-2018.47642/texk -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_tex_texlive-bin/texlive-bin/work/texlive-source-2018.47642/texk -I./xetexdir -I/opt/local/include  -I/opt/local/include/freetype2 -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_tex_texlive-bin/texlive-bin/work/texlive-source-2018.47642/libs/teckit/include -I/opt/local/include/harfbuzz -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include  -I/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_tex_texlive-bin/texlive-bin/work/texlive-source-2018.47642/libs/poppler/include -I/opt/local/include/libpng16  -I./libmd5 -DXETEX_MAC  -isystem/opt/local/include  -Os -stdlib=macports-libstdc++ -arch x86_64 -D_GLIBCXX_USE_CXX11_ABI=0 -stdlib=macports-libstdc++ -std=c++11 -MT xetexdir/libxetex_a-XeTeXFontMgr_Mac.o -MD -MP -MF xetexdir/.deps/libxetex_a-XeTeXFontMgr_Mac.Tpo -c -o xetexdir/libxetex_a-XeTeXFontMgr_Mac.o `test -f 'xetexdir/XeTeXFontMgr_Mac.mm' || echo './'`xetexdir/XeTeXFontMgr_Mac.mm
Last edited 5 years ago by kencu (Ken) (previous) (diff)

comment:3 Changed 5 years ago by kencu (Ken)

The OBJCXXFLAGS are not apparently seeing the -D_GLIBCXX_USE_CXX11_ABI=0 that is being added by the cxx11 PG, although the CXXFLAGS are seeing it:

configure: running /bin/sh ./configure --disable-option-checking '--prefix=/opt/local'  '--bindir=/opt/local/libexec/texlive/binaries' '--mandir=/opt/local/libexec/texlive/binaries' '--infodir=/opt/local/share/info' '--enable-shared' '--disable-multiplatform' '--disable-native-texlive-build' '--without-old-mac-fonts' '--with-banner-add=/MacPorts 2018.47642_8' '--with-system-freetype2' '--without-system-freetype' '--without-system-icu' '--with-system-cairo' '--with-system-gd' '--with-system-gmp' '--with-system-graphite2' '--with-system-harfbuzz' '--with-system-icu' '--with-system-libpaper' '--with-libpaper-includes=/opt/local/include' '--with-libpaper-libdir=/opt/local/lib' '--with-system-libpng' '--with-libpng-includes=/opt/local/include' '--with-libpng-libdir=/opt/local/lib' '--with-system-mpfr' '--with-system-ncurses' '--with-system-pixman' '--without-system-poppler' '--with-system-potrace' '--without-system-xpdf' '--with-system-zlib' '--with-system-zziplib' '--disable-biber' '--disable-etex' '--disable-detex' '--disable-dvi2tty' '--disable-dvipng' '--disable-dvisvgm' '--disable-lcdf-typetools' '--disable-ps2eps' '--disable-psutils' '--disable-t1utils' '--disable-texinfo' '--disable-xindy' '--enable-build-in-source-tree' 'ac_cv_prog_AWK=/usr/bin/awk' '--with-xdvi-x-toolkit=xaw' 'CC=/opt/local/bin/clang-mp-5.0' 'CFLAGS=-pipe -Os -arch x86_64' 'LDFLAGS=-Wl,-headerpad_max_install_names -arch x86_64' 'CPPFLAGS=-isystem/opt/local/include' 'CXX=/opt/local/bin/clang++-mp-5.0' 'CXXFLAGS=-pipe -Os -std=c++11 -Wno-reserved-user-defined-literal -D_GLIBCXX_USE_CXX11_ABI=0 -stdlib=macports-libstdc++ -arch x86_64' '--enable-largefile' '--disable-silent-rules' '--enable-cxx-runtime-hack=no' '--enable-libtool-hack=yes' '--enable-texlive-build' '--with-x' '--enable-autosp=yes' '--enable-axodraw2=yes' '--enable-devnag=yes' '--enable-lacheck=yes' '--enable-m-tx=yes' '--enable-pmx=yes' '--enable-texdoctk=yes' '--enable-tpic2pdftex=yes' '--enable-vlna=yes' '--with-clisp-runtime=system' '--enable-xpdfopen=yes' '--enable-web2c=yes' '--enable-afm2pl=yes' '--enable-bibtex-x=yes' '--enable-chktex=yes' '--enable-cjkutils=yes' '--enable-dtl=yes' '--enable-dvidvi=yes' '--enable-dviljk=yes' '--enable-dvipdfm-x=yes' '--enable-dvipos=yes' '--enable-dvipsk=yes' '--enable-gregorio=yes' '--enable-gsftopk=yes' '--enable-makeindexk=yes' '--enable-makejvf=yes' '--enable-mendexk=yes' '--enable-musixtnt=yes' '--enable-ps2pk=yes' '--enable-seetexk=yes' '--enable-tex4htk=yes' '--enable-ttf2pk2=yes' '--enable-ttfdump=yes' '--enable-upmendex=yes' '--enable-xdvik=yes' '--enable-texlive=yes' '--with-system-teckit=no' '--with-system-ptexenc=no' '--with-system-kpathsea=no' 'OBJCXX=/opt/local/bin/clang++-mp-5.0' 'OBJCXXFLAGS=-Os -stdlib=macports-libstdc++ -arch x86_64 -stdlib=macports-libstdc++' --cache-file=/dev/null --srcdir=.

Changed 5 years ago by kencu (Ken)

log from failed build on 10.8

comment:4 Changed 5 years ago by kencu (Ken)

Description: modified (diff)

comment:5 in reply to:  3 Changed 5 years ago by jmroot (Joshua Root)

Replying to kencu:

The OBJCXXFLAGS are not apparently seeing the -D_GLIBCXX_USE_CXX11_ABI=0 that is being added by the cxx11 PG, although the CXXFLAGS are seeing it:

The cxx11.add_dependencies callback in the portgroup is not executed until after the main body of the portfile has run, and that's where build.env is being set.

comment:6 Changed 5 years ago by kencu (Ken)

Right. I guess we could do one of these:

  1. duplicate the logic of the cxx11 1.1 PG in the Portfile (too inelegant)
  2. call the cxx11.add_dependencies function directly prior to setting the build.env
  3. change the cxx11 1.1 PG to set the flags when the portgroup is parsed (move the flag setting out of the callback proc(). Or just do it twice, once when parsed, and leave it in the callback proc(). No harm doing that, I think.

Option 3 would fix it for all ports, I think. Don't see any downside to it at this moment.

comment:7 Changed 5 years ago by mf2k (Frank Schima)

Cc: drkp removed
Owner: set to drkp
Status: newassigned

comment:8 Changed 5 years ago by kencu (Ken)

Cc: MarcusCalhoun-Lopez added

comment:9 Changed 5 years ago by kencu (Ken)

Marcus -- think we should modify the cxx11 1.1 PG as in 57774#comment:6 point 3 above?

comment:10 in reply to:  6 Changed 5 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)

Replying to kencu:

Right. I guess we could do one of these:

  1. duplicate the logic of the cxx11 1.1 PG in the Portfile (too inelegant)
  2. call the cxx11.add_dependencies function directly prior to setting the build.env
  3. change the cxx11 1.1 PG to set the flags when the portgroup is parsed (move the flag setting out of the callback proc(). Or just do it twice, once when parsed, and leave it in the callback proc(). No harm doing that, I think.

Option 3 would fix it for all ports, I think. Don't see any downside to it at this moment.

The problem with option 3 is that it would reintroduce #56280, which was fixed in 9a7f227d9761190cc531a7b3a41106b6ec976b13

comment:11 Changed 5 years ago by kencu (Ken)

Perhaps the cxx11 1.1 PG could append the -D_GLIBCXX_USE_CXX11_ABI=0 flag onto the OBJCXXFLAGS env var during it's callback proc as well?

Actually how do you append something to a current env variable without overwriting what is already set? I don't think I've done that yet...must be examples in the portfiles somewhere.

(BTW, it was these sorts of hiccups that led me to wonder two years ago if we should just build libgcc to default to GLIBCXX_USE_CXX11_ABI=0 on these systems, which is just a configure flag during the libgcc build.)

comment:12 Changed 5 years ago by kencu (Ken)

Something like this maybe, in the cxx11 1.1 PG callback proc?

configure.env-append      OBJCXXFLAGS =-D_GLIBCXX_USE_CXX11_ABI=0 $env(OBJCXXFLAGS)

I see some constructs like this in the portfiles, usually for PATH. I'll test that out.

Last edited 5 years ago by kencu (Ken) (previous) (diff)

comment:13 Changed 5 years ago by kencu (Ken)

none of that works. Looks like we're going for a fix in the Portfile on this one.

comment:15 Changed 5 years ago by ken-cunningham-webuse

Resolution: fixed
Status: assignedclosed

In 9988e1db726461786ea95e325b9e8ab5e34c9e4b/macports-ports (master):

texlive-bin: setup ABI for macports-libstdc++

closes: #57774

comment:16 Changed 5 years ago by kencu (Ken)

Hmm. I'm looking at the way the legacysupport PG calls the setup proc at both the beginning and end of the port processing....

Perhaps if did that with cxx11 PG also we wouldn't need to do these hacks in ports. Will have to test if everything else (like setting optflags) would still work...

Note: See TracTickets for help on using tickets.