tvm icon indicating copy to clipboard operation
tvm copied to clipboard

[Bug] 0.17.0 fails with GCC14 with: `error: control reaches end of non-void function [-Werror=return-type]`

Open ggardet opened this issue 1 year ago • 6 comments
trafficstars

0.17.0 fails with GCC14 (on openSSUE Tumbleweed) with: error: control reaches end of non-void function [-Werror=return-type]

Expected behavior

Build should succeed with GCC14.

Actual behavior

Build fails with:

[  247s] /home/abuild/rpmbuild/BUILD/tvm-0.17.0/src/meta_schedule/cost_model/../../support/base64.h: In member function ‘virtual size_t tvm::support::Base64OutStream::Read(void*, size_t)’:
[  247s] /home/abuild/rpmbuild/BUILD/tvm-0.17.0/src/meta_schedule/cost_model/../../support/base64.h:253:19: error: control reaches end of non-void function [-Werror=return-type]
[  247s]   253 |     LOG(FATAL) << "Base64OutStream do not support read";
[  247s]       |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[  247s] cc1plus: some warnings being treated as errors
[  247s] make[2]: *** [CMakeFiles/tvm_objs.dir/build.make:989: CMakeFiles/tvm_objs.dir/src/meta_schedule/cost_model/cost_model.cc.o] Error 1

Environment

openSUSE Tumbleweed TVM 0.17.0

Steps to reproduce

Try to build with GCC14.

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).

  • needs-triage

ggardet avatar Oct 10 '24 12:10 ggardet

If I add -Wno-error=return-type as workaround, I get the following errors:

[   50s] [  2%] Building CXX object CMakeFiles/tvm_runtime_objs.dir/src/runtime/disco/disco_worker.cc.o
[   50s] /usr/bin/c++ -DDMLC_USE_FOPEN64=0 -DDMLC_USE_LOGGING_LIBRARY="<tvm/runtime/logging.h>" -DNDEBUG -DNDEBUG=1 -DTVM_ENABLE_SPIRV=1 -DTVM_INDEX_DEFAULT_I64=1 -DTVM_LLVM_HAS_AARCH64_TARGET=1 -DTVM_LLVM_VERSION=140 -DTVM_THREADPOOL_USE_OPENMP=0 -DTVM_USE_LIBBACKTRACE=0 -DUSE_FALLBACK_STL_MAP=0 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/abuild/rpmbuild/BUILD/tvm-0.17.0/include -I/home/abuild/rpmbuild/BUILD/tvm-0.17.0/3rdparty/libcrc/include -isystem /usr/include/dlpack -isystem /usr/include/dmlc -isystem /usr/include/rang -isystem /home/abuild/rpmbuild/BUILD/tvm-0.17.0/3rdparty/compiler-rt -isystem /home/abuild/rpmbuild/BUILD/tvm-0.17.0/3rdparty/picojson -isystem /home/abuild/rpmbuild/BUILD/tvm-0.17.0/3rdparty/OpenCL-Headers -isystem /usr/include/spirv-tools -isystem /usr/include/spirv/unified1 -isystem /usr/include/openblas -std=c++17 -faligned-new -O2 -Wall -fPIC -mbranch-protection=standard -O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type  -g -Wno-error=return-type -O2 -g -DNDEBUG -ffile-prefix-map=..=/home/abuild/rpmbuild/BUILD/tvm-0.17.0 -MD -MT CMakeFiles/tvm_runtime_objs.dir/src/runtime/disco/disco_worker.cc.o -MF CMakeFiles/tvm_runtime_objs.dir/src/runtime/disco/disco_worker.cc.o.d -o CMakeFiles/tvm_runtime_objs.dir/src/runtime/disco/disco_worker.cc.o -c /home/abuild/rpmbuild/BUILD/tvm-0.17.0/src/runtime/disco/disco_worker.cc
[   50s] In file included from /home/abuild/rpmbuild/BUILD/tvm-0.17.0/src/runtime/disco/./protocol.h:35,
[   50s]                  from /home/abuild/rpmbuild/BUILD/tvm-0.17.0/src/runtime/disco/disco_worker.cc:26:
[   50s] /home/abuild/rpmbuild/BUILD/tvm-0.17.0/src/runtime/disco/./../../support/base64.h:209:10: error: conflicting return type specified for ‘virtual size_t tvm::support::Base64InStream::Write(const void*, size_t)’
[   50s]   209 |   size_t Write(const void* ptr, size_t size) final {
[   50s]       |          ^~~~~
[   50s] In file included from /home/abuild/rpmbuild/BUILD/tvm-0.17.0/include/tvm/runtime/module.h:29,
[   50s]                  from /home/abuild/rpmbuild/BUILD/tvm-0.17.0/include/tvm/runtime/disco/builtin.h:23,
[   50s]                  from /home/abuild/rpmbuild/BUILD/tvm-0.17.0/src/runtime/disco/disco_worker.cc:19:
[   50s] /usr/include/dmlc/io.h:44:16: note: overridden function is ‘virtual void dmlc::Stream::Write(const void*, size_t)’
[   50s]    44 |   virtual void Write(const void *ptr, size_t size) = 0;
[   50s]       |                ^~~~~
[   50s] /home/abuild/rpmbuild/BUILD/tvm-0.17.0/src/runtime/disco/./../../support/base64.h:232:10: error: conflicting return type specified for ‘virtual size_t tvm::support::Base64OutStream::Write(const void*, size_t)’
[   50s]   232 |   size_t Write(const void* ptr, size_t size) final {
[   50s]       |          ^~~~~
[   50s] /usr/include/dmlc/io.h:44:16: note: overridden function is ‘virtual void dmlc::Stream::Write(const void*, size_t)’
[   50s]    44 |   virtual void Write(const void *ptr, size_t size) = 0;
[   50s]       |                ^~~~~
[   50s] /home/abuild/rpmbuild/BUILD/tvm-0.17.0/src/runtime/disco/./../../support/base64.h: In member function ‘virtual size_t tvm::support::Base64OutStream::Read(void*, size_t)’:
[   50s] /home/abuild/rpmbuild/BUILD/tvm-0.17.0/src/runtime/disco/./../../support/base64.h:253:19: warning: control reaches end of non-void function [-Wreturn-type]
[   50s]   253 |     LOG(FATAL) << "Base64OutStream do not support read";
[   50s]       |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[   50s] make[2]: *** [CMakeFiles/tvm_runtime_objs.dir/build.make:191: CMakeFiles/tvm_runtime_objs.dir/src/runtime/disco/disco_worker.cc.o] Error 1
[   50s] make[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/tvm-0.17.0/build_cmake'
[   50s] make[2]: *** Waiting for unfinished jobs....

ggardet avatar Oct 10 '24 12:10 ggardet

Build works fine on my machine. Tested on OpenSUSE docker image.

# spawn openSUSE container
docker run -it --rm opensuse/tumbleweed:latest

# run the below commands inside the container
zypper install -y awk git cmake ninja gcc gcc-c++ llvm-devel clang
zypper install -y python3 python3-devel python3-pip
zypper install -y ncurses-devel libxml2-devel zlib-devel

python3 -m pip install --break-system-packages numpy decorator attrs pytest

git clone https://github.com/apache/tvm --branch v0.17.0 --recursive
cd tvm
cmake -E make_directory build
cmake -S . -G Ninja -B build \
          -DUSE_RPC=ON \
          -DUSE_GRAPH_RUNTIME=ON \
          -DUSE_LLVM=ON
cmake --build build
python3 -m pip install --break-system-packages ./python
python3 -c "import tvm; print(tvm.__version__)" # -> shows 0.17.0

mshr-h avatar Oct 17 '24 08:10 mshr-h

You need the C/CXX flags -Werror=return-type which is enabled in the openSUSE Tumbleweed build system.

ggardet avatar Oct 17 '24 11:10 ggardet

Ah, I think I understand what you're trying to do. You want to build TVM with openSUSE (default?) build system and eventually something like to provide TVM package for openSUSE?

mshr-h avatar Oct 17 '24 12:10 mshr-h

Ah, I think I understand what you're trying to do. You want to build TVM with openSUSE (default?) build system and eventually something like to provide TVM package for openSUSE?

Right, TVM 0.16.0 is already available in openSUSE as an RPM package, but update to 0.17.0 fails with errors above.

ggardet avatar Oct 17 '24 12:10 ggardet

Build worked fine with -Werror=return-type.

Repro:

# spawn openSUSE container
docker run -it --rm opensuse/tumbleweed:latest

# run the below commands inside the container
zypper install -y awk git cmake ninja gcc gcc-c++ llvm-devel clang python3 \
                  python3-devel python3-pip ncurses-devel libxml2-devel zlib-devel

python3 -m pip install --break-system-packages numpy decorator attrs pytest

git clone https://github.com/apache/tvm --branch v0.17.0 --recursive
cd tvm
cmake -E make_directory build
CC=gcc-14 CXX=g++-14 cmake -S . -G Ninja -B build \
                           -DCMAKE_C_FLAGS="-Werror=return-type" \
                           -DCMAKE_CXX_FLAGS="-Werror=return-type" \
                           -DUSE_RPC=ON -DUSE_GRAPH_RUNTIME=ON -DUSE_LLVM=ON
cmake --build build
python3 -m pip install --break-system-packages ./python
python3 -c "import tvm; print(tvm.__version__)" # -> shows 0.17.0

mshr-h avatar Oct 18 '24 07:10 mshr-h

To be more complete, here is the cmake commandline used for x86_64:

[   21s] + mkdir -p build_cmake
[   21s] + cd build_cmake
[   21s] + /usr/bin/cmake /home/abuild/rpmbuild/BUILD/tvm-0.17.0/. '-GUnix Makefiles' -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_INSTALL_BINDIR:PATH=bin -DCMAKE_INSTALL_SBINDIR:PATH=sbin -DCMAKE_INSTALL_LIBEXECDIR:PATH=libexec -DCMAKE_INSTALL_SYSCONFDIR:PATH=etc -DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=/var/lib -DCMAKE_INSTALL_LOCALSTATEDIR:PATH=var -DCMAKE_INSTALL_RUNSTATEDIR:PATH=run -DCMAKE_INSTALL_LIBDIR:PATH=lib64 -DCMAKE_INSTALL_INCLUDEDIR:PATH=include -DCMAKE_INSTALL_DATAROOTDIR:PATH=share -DCMAKE_INSTALL_DOCDIR:PATH=share/doc/packages/tvm -DCMAKE_INSTALL_MANDIR:PATH=share/man -DCMAKE_INSTALL_INFODIR:PATH=share/info -DINCLUDE_INSTALL_DIR:PATH=/usr/include -DLIB_INSTALL_DIR:PATH=/usr/lib64 -DSYSCONF_INSTALL_DIR:PATH=/etc -DSHARE_INSTALL_PREFIX:PATH=/usr/share -DCMAKE_BUILD_TYPE=RelWithDebInfo '-DCMAKE_C_FLAGS=-O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type  -g' '-DCMAKE_CXX_FLAGS=-O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type  -g' '-DCMAKE_Fortran_FLAGS=-O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type  -g' '-DCMAKE_EXE_LINKER_FLAGS= -Wl,--as-needed -Wl,--no-undefined -Wl,-z,now' '-DCMAKE_MODULE_LINKER_FLAGS= -Wl,--as-needed' '-DCMAKE_SHARED_LINKER_FLAGS= -Wl,--as-needed -Wl,--no-undefined -Wl,-z,now' -DLIB_SUFFIX=64 -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DBUILD_SHARED_LIBS:BOOL=ON -DBUILD_STATIC_LIBS:BOOL=OFF -DCMAKE_COLOR_MAKEFILE:BOOL=OFF -DCMAKE_INSTALL_DO_STRIP:BOOL=OFF -DCMAKE_MODULES_INSTALL_DIR=/usr/lib64/cmake/tvm -DDMLC_PATH=/usr/include/dmlc -DDLPACK_PATH=/usr/include/dlpack -DRANG_PATH=/usr/include/rang -DUSE_GRAPH_RUNTIME=ON -DUSE_LLVM=ON -DUSE_BLAS=openblas -DUSE_MKLDNN=ON -DUSE_OPENCL=ON -DUSE_OPENGL=ON -DUSE_OPENMP=ON -DUSE_RANDOM=ON -DUSE_RPC=ON -DUSE_RTTI=ON -DUSE_SORT=ON -DUSE_THREADS=ON -DUSE_VULKAN=ON -DUSE_LIBBACKTRACE=OFF -DUSE_ANTLR=/usr/share/java/antlr4/antlr4-runtime.jar -DINSTALL_DEV=ON

And for aarch64, we also have -mbranch-protection=standard

ggardet avatar Oct 22 '24 07:10 ggardet

I guess -DDMLC_PATH=/usr/include/dmlc is the problem. The dmlc API has changed in https://github.com/dmlc/dmlc-core/commit/3031e4a61a98f49f07a42cfdec6242340fb2fd8c and TVM adapted it in #16998 You're using the old dmlc version (maybe 0.3 according to https://packagehub.suse.com/packages/dmlc-core/) for TVM compilation because the dmlc team hasn't released the new version yet. https://github.com/dmlc/dmlc-core/issues/682

mshr-h avatar Oct 22 '24 12:10 mshr-h

Right. Updating dmlc-core fixed the build. Thanks!

ggardet avatar Oct 22 '24 15:10 ggardet