I'm using the entire LLVM toolchain v12.0.0 to build my packages. ghostscript-gpl fails with `ld.lld: error: undefined symbol: ...`. It works fine with GCC and Gold or BFD linker.
All undefined symbol errors are related to app-text/tesseract. Adding `--without-tesseract` to `src_configure()` fixes the problem and ghostscript-gpl builds without issue.
Here is one excerpt from the log file:
ld.lld: error: undefined symbol: std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::basic_stringstream()
>>> referenced by altorenderer.cpp
>>> ./obj/tesseract_api_altorenderer.o:(tesseract::TessBaseAPI::GetAltoText(tesseract::ETEXT_DESC*, int))
>>> referenced by baseapi.cpp
>>> referenced by hocrrenderer.cpp
>>> ./obj/tesseract_api_hocrrenderer.o:(tesseract::TessBaseAPI::GetHOCRText(tesseract::ETEXT_DESC*, int))
>>> referenced 9 more times
The full build.log and emerge —-info output is always needed. Could you provide that please?
Also, how about Clang with the normal GNU ld? ldd often exposes other issues unrelated to the compiler
Created attachment 700881 [details]
Output of `emerge --info`
Created attachment 700884 [details]
`build.log` with Clang + LLD and LTO enabled
Created attachment 700887 [details]
`build.log` with Clang + BFD without LTO
Sorry, in previous bug reports no one asked for `build.log` and the output of `emerge --info`. Now I included them.
The build process also fails when using Clang and BFD. Whether or not I enable LTO makes no difference.
app-text/tesseract is not installed and installing tesseract also did not fix the issue.
Adding `--without-tesseract' to EXTRA_ECONF solves it.
Note that app-text/ghostscript-gpl is bundling an own fork of tesseract since 9.53... so app-text/ghostscript-gpl does NOT use app-text/tesseract.
I personally do not care about Clang/LLVM/LLD at this point. Please report upstream and report back the link to their issue tracker. Also, patches are welcome.
In Arch's PKGBUILD - https://github.com/archlinux/svntogit-packages/blob/packages/ghostscript/trunk/PKGBUILD#L25
# *** remove after final decision ***
# new in 9.54.0:
# 1) inclusion of the tesseract/leptonica sources for OCR capabilities
# at the moment we do not support linking with tesseract/leptonica shared libraries.
# As is normal with such included libraries, deleting those directories and (re)running
# configure (on Unix like systems) will automatically build without the OCR functionality.
# increases package size ghostpcl 2.7->4.9MB | ghostscript 18->23MB | ghostxps 2,7->4.9MB
# https://www.ghostscript.com/doc/9.54.0/VectorDevices.htm#UseOCR -
# this doesn't seem to be worth to keep enabled until linking with shared libs is supported
rm -r tesseract leptonica
So, maybe just remove those directories as other internal copies ?
do you have libcxx enabled? probably caused by it linking against libstdc++ instead of libc++. the invocation has "-lstdc++"
This is an actual bug. ghostscript-gpl hard-codes -lstdc++ and -stdlib=stdc++ in the Makefile, so having USE="libcxx" for sys-devel/clang doesn't actually do anything for this particular package. ghostscript-gpl should honor this but it doesn't.
I added a package.env conf file for it with the following:
CFLAGS="-O2 -stdlib=libc++ -fPIC -fstack-protector-strong -fstack-clash-protection -fomit-frame-pointer -pipe -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
# ghostscript-gpl completely ignores CXXFLAGS
# -stdlib must actually be in CFLAGS
CXXFLAGS="-O2 -stdlib=libc++ -fPIC -fstack-protector-strong -fstack-clash-protection -fomit-frame-pointer -pipe -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -lc++ -fuse-ld=lld -Wl,-z,now -Wl,-z,relro -Wl,--strip-debug"
And the package built. The only relevant part for the bug is:
-stdlib=libc++ in CFLAGS
-lc++ in LDFLAGS.
Rest are all hardening flags, don't worry about that.