[clang] [compiler-rt] [lldb] [llvm] [Support] Remove terminfo dependency (PR #92865)
Aaron Siddhartha Mondal via cfe-commits
cfe-commits at lists.llvm.org
Mon May 27 09:03:03 PDT 2024
aaronmondal wrote:
@gulfemsavrun The file `terminal.c` that is causing this linker error is not in LLVM but in `libedit`. The configure step doesn't find `libedit`:
```
Not searching for unused variables given on the command line.
-- Could NOT find LibEdit (missing: LibEdit_INCLUDE_DIRS LibEdit_LIBRARIES)
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
-- Could NOT find zstd (missing: zstd_LIBRARY zstd_INCLUDE_DIR)
-- Could NOT find LibXml2 (missing: LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR)
-- Could NOT find CURL (missing: CURL_LIBRARY CURL_INCLUDE_DIR)
...
-- Could NOT find LibEdit (missing: LibEdit_INCLUDE_DIRS LibEdit_LIBRARIES)
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
-- Could NOT find zstd (missing: zstd_LIBRARY zstd_INCLUDE_DIR)
-- Could NOT find LibXml2 (missing: LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR)
-- Could NOT find CURL (missing: CURL_LIBRARY CURL_INCLUDE_DIR)
...
-- Building with -fPIC
-- LLVM host triple: x86_64-unknown-linux-gnu
-- LLVM default target triple: x86_64-unknown-linux-gnu
-- Using libunwind testing configuration: /b/s/w/ir/x/w/llvm-llvm-project/libunwind/test/configs/llvm-libunwind-static.cfg.in
-- Failed to locate sphinx-build executable (missing: SPHINX_EXECUTABLE)
-- Using libc++abi testing configuration: /b/s/w/ir/x/w/llvm-llvm-project/libcxxabi/test/configs/llvm-libc++abi-static.cfg.in
-- Using libc++ testing configuration: /b/s/w/ir/x/w/llvm-llvm-project/libcxx/test/configs/llvm-libc++-static.cfg.in
-- Could NOT find LibEdit (missing: LibEdit_INCLUDE_DIRS LibEdit_LIBRARIES)
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
-- Could NOT find zstd (missing: zstd_LIBRARY zstd_INCLUDE_DIR)
-- Could NOT find LibXml2 (missing: LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR)
```
My guess is that some other mechanism is adding `libedit` into this build with an explicit `-ledit` flag instead of using `pkgconfig`. This causing the `/usr/lib64/pkgconfig/libedit.pc` (or similar) file to be ignored. That file should contain a line like `Libs.private: -ltinfo` if it's a `libedit` that was configured to depend on `tinfo`.
```
FAILED: unittests/LineEditor/LineEditorTests
: && /b/s/w/ir/x/w/cipd/bin/clang++ --sysroot=/b/s/w/ir/x/w/cipd/linux -stdlib=libc++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -ffat-lto-objects -ffile-prefix-map=/b/s/w/ir/x/w/llvm_build=../llvm-llvm-project -ffile-prefix-map=/b/s/w/ir/x/w/llvm-llvm-project/= -no-canonical-prefixes -O3 -DNDEBUG -static-libstdc++ -stdlib=libc++ -static-libstdc++ -fuse-ld=lld -Wl,--color-diagnostics -ffat-lto-objects -Wl,--gc-sections unittests/LineEditor/CMakeFiles/LineEditorTests.dir/LineEditor.cpp.o -o unittests/LineEditor/LineEditorTests lib/libLLVMLineEditor.a lib/libLLVMSupport.a lib/libLLVMSupport.a -lpthread lib/libllvm_gtest_main.a lib/libllvm_gtest.a -lpthread /b/s/w/ir/x/w/libedit_install/lib/libedit.a lib/libLLVMSupport.a -lrt -ldl -lpthread -lm /b/s/w/ir/x/w/zlib_install_target/lib/libz.a /b/s/w/ir/x/w/zstd_install/lib/libzstd.a -pthread lib/libLLVMDemangle.a -lpthread && :
ld.lld: error: undefined symbol: tgetent
>>> referenced by terminal.c
>>> terminal.o:(terminal_set) in archive /b/s/w/ir/x/w/libedit_install/lib/libedit.a
ld.lld: error: undefined symbol: tgetflag
>>> referenced by terminal.c
>>> terminal.o:(terminal_set) in archive /b/s/w/ir/x/w/libedit_install/lib/libedit.a
>>> referenced by terminal.c
>>> terminal.o:(terminal_set) in archive /b/s/w/ir/x/w/libedit_install/lib/libedit.a
>>> referenced by terminal.c
>>> terminal.o:(terminal_set) in archive /b/s/w/ir/x/w/libedit_install/lib/libedit.a
>>> referenced 3 more times
ld.lld: error: undefined symbol: tgetnum
>>> referenced by terminal.c
>>> terminal.o:(terminal_set) in archive /b/s/w/ir/x/w/libedit_install/lib/libedit.a
>>> referenced by terminal.c
>>> terminal.o:(terminal_set) in archive /b/s/w/ir/x/w/libedit_install/lib/libedit.a
ld.lld: error: undefined symbol: tgetstr
>>> referenced by terminal.c
>>> terminal.o:(terminal_set) in archive /b/s/w/ir/x/w/libedit_install/lib/libedit.a
>>> referenced by terminal.c
>>> terminal.o:(terminal_echotc) in archive /b/s/w/ir/x/w/libedit_install/lib/libedit.a
ld.lld: error: undefined symbol: tputs
>>> referenced by terminal.c
>>> terminal.o:(terminal_move_to_line) in archive /b/s/w/ir/x/w/libedit_install/lib/libedit.a
>>> referenced by terminal.c
>>> terminal.o:(terminal_move_to_line) in archive /b/s/w/ir/x/w/libedit_install/lib/libedit.a
>>> referenced by terminal.c
>>> terminal.o:(terminal_move_to_char) in archive /b/s/w/ir/x/w/libedit_install/lib/libedit.a
>>> referenced 16 more times
ld.lld: error: undefined symbol: tgoto
>>> referenced by terminal.c
>>> terminal.o:(terminal_move_to_line) in archive /b/s/w/ir/x/w/libedit_install/lib/libedit.a
>>> referenced by terminal.c
>>> terminal.o:(terminal_move_to_char) in archive /b/s/w/ir/x/w/libedit_install/lib/libedit.a
>>> referenced by terminal.c
>>> terminal.o:(terminal_move_to_char) in archive /b/s/w/ir/x/w/libedit_install/lib/libedit.a
>>> referenced 5 more times
```
If this setup doesn't make use of `pkgconfig` the way to fix this would be to either use a `libedit` that doesn't depend on `tinfo`, or to add `tinfo` as a dependency to the `libedit_install` target. In both cases this would be configuration outside of the LLVM build graph.
The previous `tinfo` dependency in LLVM hid this misconfiguration and happened to satisfy the `libedit` setup by chance.
https://github.com/llvm/llvm-project/pull/92865
More information about the cfe-commits
mailing list