tvm
tvm copied to clipboard
[Bug] Build failed with `undefined references to 'std::__throw_bad_array_new_length()' follow`
Expected behavior
Build tvm-0.18.0 from source.
Actual behavior
Hi, I follow this document (https://tvm.apache.org/docs/install/from_source.html) to install tvm 0.18.0 from source.
Everything was fine until I ran the command:
cmake .. && cmake --build . --parallel $(nproc).
Here is the error I encountered:
/usr/bin/ld: /root/miniconda3/envs/tvm-build-venv/lib/libLLVMipo.a(SampleContextTracker.cpp.o):SampleContextTracker.cpp:(.text._ZN4llvm20SampleContextTracker17getBaseSamplesForENS_10sampleprof10FunctionIdEb+0x3c5): more undefined references to `std::__throw_bad_array_new_length()' follow
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/tvm.dir/build.make:2035: libtvm.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:205: CMakeFiles/tvm.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[100%] Built target tvm_allvisible
make: *** [Makefile:136: all] Error 2
Then, I searched for solutions on Github. This solution (https://github.com/mlc-ai/mlc-llm/issues/1683) worked.
The solution required me to execute conda deactivate tvm-build-venv to exit the conda environment with the build dependency.
In the base environment, I was able to successfully build tvm without encountering the same error.
I do not understand the role of the created build environment in this, at least during the installation of tvm-0.18.0.
Does the document (https://tvm.apache.org/docs/install/from_source.html) need to be updated again? Or if there are some issues that need fixing.
Thank you for your time and reply.
Environment
Ubuntu 20.04
cmake version 3.24.2
clang version 15.0.4
make version 4.2.1
gcc version 9.4.0
g++ version 9.4.0
Triage
Please refer to the list of label tags here to find the relevant tags and add them below in a bullet format (example below).
- backend: llvm
I encountered the same error
Figured out some more things about this. This error occurs when compiling with GCC version <= 10 because tvm_build_venv includes a version of libstdc++6 that was compiled with GCC version >= 11 which causes issues upon linking. More info here. So the options are to deactivate your environment when linking or use GCC >= 11
use find $CONDA_PREFIX/lib -name "libstdc*" to get "xxx/xxx/envs/tvm-build-venv/lib"
then cmake .. -DCMAKE_CXX_FLAGS="-L/xxx/xxx/envs/tvm-build-venv/lib" && cmake --build . --parallel $(nproc)