Skip to content

[Bug]: examples/cpp/executor linking failure #7181

Description

@WilliamTambellini

System Info

TRTLLM: today's main commit 81fd468
TRT: 10.11
cuda: 12.9
GCC: 11.3
OS: rocky8.10

Who can help?

@tongyuantongyu

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

1 cd cpp/build && cmake -DUSE_CXX11_ABI=OFF ..
2 make
3 cd ../../examples/cpp/executor/build
4 cmake ..
5 make

Expected behavior

Build success

actual behavior

Linking failure:

[ 10%] Building CXX object CMakeFiles/executorExampleBasic.dir/executorExampleBasic.cpp.o                                                                                       
g++ -DENABLE_BF16 -DENABLE_FP8 -Iexamples/cpp/executor/../../../cpp/include 
-isystem /usr/local/cuda-12/include -Wall -pthread -lstdc++ -DENABLE_MULTI_DEVICE=0  -O3 
-std=gnu++17 
-D_GLIBCXX_USE_CXX11_ABI=1 
-MD -MT  CMakeFiles/executorExampleBasic.dir/executorExampleBasic.cpp.o 
-MF CMakeFiles/executorExampleBasic.dir/executorExampleBasic.cpp.o.d 
-o CMakeFiles/executorExampleBasic.dir/executorExampleBasic.cpp.o -c 
/local/wtambellini/TensorRT-LLM/examples/cpp/executor/executorExampleBasic.cpp         

[ 20%] Linking CXX executable executorExampleBasic                                                                                                                              
cmake -E cmake_link_script CMakeFiles/executorExampleBasic.dir/link.txt --verbose=1                           
g++ -Wall -pthread -lstdc++ -DENABLE_MULTI_DEVICE=0  -O3 CMakeFiles/executorExampleBasic.dir/executorExampleBasic.cpp.o -o executorExampleBasic  libnvinfer_plugin_tensorrt_llm.so libtensorrt_llm.so /usr/lib64/libcuda.so /usr/local/cuda-12.9/targets/x86_64-linux/lib/libcudart_static.a -lpthread -ldl /usr/lib64/librt.so /usr/lib64/libnvidia-ml.so
                                 
CMakeFiles/executorExampleBasic.dir/executorExampleBasic.cpp.o: In function `main':                                                                                             
executorExampleBasic.cpp:(.text.startup+0x375): undefined reference to 
`tensorrt_llm::executor::Executor::Executor(std::filesystem::__cxx11::path const&, 
tensorrt_llm::executor::ModelType, tensorrt_llm::executor::ExecutorConfig const&)'                                                                                                                    
...

See that _GLIBCXX_USE_CXX11_ABI has been set to 1

additional notes

It s because the example executor cmake script tries to auto guess if cxx11ABI was on in libtensorrt_llm.so:

COMMAND bash -c "nm -f posix -D ${TRTLLM_LIB_PATH} | grep __cxx11"

Despite building without cxx11 ABI, my libtensorrt_llm.so still has a small dozen of 'cxx11' keywords in some symbols:

$ nm -f posix -D cpp/Release/tensorrt_llm/libtensorrt_llm.so | grep __cxx11                                  
_ZN12tensorrt_llm6common14printArrayInfoI13__nv_bfloat16EEvPKT_mNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb W 00000000045005e0 0000000000000d88
...

When I force set USE_CXX11_ABI=0, the examples link fine.

Proposal:
I propose to just add a cmake option to examples/cpp/executor/CMakeLists.txt in order for the user to let the script autodetects USE_CXX11_ABI or not.
Example:

option(AUTODETECT_USE_CXX11_ABI ON)
if(${AUTODETECT_USE_CXX11_ABI})
 execute_process(
   COMMAND bash -c "nm -f posix -D ${TRTLLM_LIB_PATH} | grep __cxx11"
  RESULT_VARIABLE GLIB_CXX11_FOUND
  OUTPUT_QUIET)
if(GLIB_CXX11_FOUND EQUAL 0)
  set(USE_CXX11_ABI 1)
else()
  set(USE_CXX11_ABI 0)
endif()
endif()

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and checked the documentation and examples for answers to frequently asked questions.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Infra<NV>automated tests, build checks, github actions, system stability & efficiency.InstallationSetting up and building TRTLLM: compilation, pip install, dependencies, env config, CMake.InvestigatingTesting<NV>Continuous integration, build system, and testing infrastructure issuesbugSomething isn't workingtriagedIssue has been triaged by maintainers

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions