pytorch 2.1.2+dfsg-4 FTBFS with llvm 18

Bug #2067720 reported by Benjamin Drung
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pytorch (Ubuntu)
Fix Released
Undecided
Sergio Durigan Junior

Bug Description

pytorch 2.1.2+dfsg-4 fails to build from source with llvm 18:

```
[957/1892] /usr/bin/c++ -DAT_PER_OPERATOR_HEADERS -DCAFFE2_BUILD_MAIN_LIB -DFMT_HEADER_ONLY=1 -DHAVE_MALLOC_USABLE_SIZE=1 -DHAVE_MMAP=1 -DHAVE_SHM_OPEN=1 -DHAVE_SHM_UNLINK=1 -DMINIZ_DISABLE_ZIP_READER_CRC32_CHECKS -DONNXIFI_ENABLE_EXT=1 -DONNX_ML=1 -DONNX_NAMESPACE=onnx -DTORCH_ENABLE_LLVM -DUSE_C10D_GLOO -DUSE_DISTRIBUTED -DUSE_EXTERNAL_MZCRC -DUSE_RPC -DUSE_TENSORPIPE -D_FILE_OFFSET_BITS=64 -Dtorch_cpu_EXPORTS -I/<<PKGBUILDDIR>>/build/aten/src -I/<<PKGBUILDDIR>>/aten/src -I/<<PKGBUILDDIR>>/build -I/<<PKGBUILDDIR>> -I/<<PKGBUILDDIR>>/cmake/../third_party/benchmark/include -I/usr/lib/llvm-18/include -I/<<PKGBUILDDIR>>/debian/foxi -I/<<PKGBUILDDIR>>/build/debian/foxi -I/<<PKGBUILDDIR>>/torch/csrc/api -I/<<PKGBUILDDIR>>/torch/csrc/api/include -I/<<PKGBUILDDIR>>/caffe2/aten/src/TH -I/<<PKGBUILDDIR>>/build/caffe2/aten/src/TH -I/<<PKGBUILDDIR>>/build/caffe2/aten/src -I/<<PKGBUILDDIR>>/build/caffe2/../aten/src -I/<<PKGBUILDDIR>>/torch/csrc -I/<<PKGBUILDDIR>>/third_party/miniz-2.1.0 -I/<<PKGBUILDDIR>>/debian/kineto/libkineto/include -I/<<PKGBUILDDIR>>/debian/kineto/libkineto/src -I/<<PKGBUILDDIR>>/aten/src/ATen/.. -I/<<PKGBUILDDIR>>/c10/.. -I/<<PKGBUILDDIR>>/aten/src/ATen/native/quantized/cpu/qnnpack/include -I/<<PKGBUILDDIR>>/aten/src/ATen/native/quantized/cpu/qnnpack/src -I/<<PKGBUILDDIR>>/aten/src/ATen/native/quantized/cpu/qnnpack/deps/clog/include -I/<<PKGBUILDDIR>>/third_party/flatbuffers/include -isystem /<<PKGBUILDDIR>>/build/third_party/gloo -isystem /<<PKGBUILDDIR>>/cmake/../third_party/gloo -isystem /<<PKGBUILDDIR>>/cmake/../third_party/googletest/googlemock/include -isystem /<<PKGBUILDDIR>>/cmake/../third_party/googletest/googletest/include -isystem /usr/include/opencv4 -isystem /usr/include/eigen3 -isystem /<<PKGBUILDDIR>>/caffe2 -Wdate-time -D_FORTIFY_SOURCE=3 -g -O2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -fdebug-prefix-map=/<<PKGBUILDDIR>>=/usr/src/pytorch-2.1.2+dfsg-4 -gsplit-dwarf -Wno-dangling-reference -I/usr -D_GLIBCXX_USE_CXX11_ABI=1 -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -DUSE_KINETO -DLIBKINETO_NOCUPTI -DLIBKINETO_NOROCTRACER -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -O2 -fPIC -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Werror=range-loop-construct -Werror=bool-operation -Wnarrowing -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=old-style-cast -Wno-invalid-partial-specialization -Wno-unused-private-field -Wno-aligned-allocation-unavailable -Wno-missing-braces -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-stringop-overflow -DHAVE_AVX512_CPU_DEFINITION -DHAVE_AVX2_CPU_DEFINITION -O2 -g -DNDEBUG -std=gnu++17 -fPIC -DCAFFE2_USE_GLOO -DTH_HAVE_THREAD -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-missing-field-initializers -Wno-unknown-pragmas -Wno-type-limits -Wno-array-bounds -Wno-strict-overflow -Wno-strict-aliasing -Wno-missing-braces -Wno-maybe-uninitialized -fvisibility=hidden -O2 -fopenmp -Wno-init-list-lifetime -MD -MT caffe2/CMakeFiles/torch_cpu.dir/__/torch/csrc/jit/tensorexpr/llvm_codegen.cpp.o -MF caffe2/CMakeFiles/torch_cpu.dir/__/torch/csrc/jit/tensorexpr/llvm_codegen.cpp.o.d -o caffe2/CMakeFiles/torch_cpu.dir/__/torch/csrc/jit/tensorexpr/llvm_codegen.cpp.o -c /<<PKGBUILDDIR>>/torch/csrc/jit/tensorexpr/llvm_codegen.cpp
FAILED: caffe2/CMakeFiles/torch_cpu.dir/__/torch/csrc/jit/tensorexpr/llvm_codegen.cpp.o
/usr/bin/c++ -DAT_PER_OPERATOR_HEADERS -DCAFFE2_BUILD_MAIN_LIB -DFMT_HEADER_ONLY=1 -DHAVE_MALLOC_USABLE_SIZE=1 -DHAVE_MMAP=1 -DHAVE_SHM_OPEN=1 -DHAVE_SHM_UNLINK=1 -DMINIZ_DISABLE_ZIP_READER_CRC32_CHECKS -DONNXIFI_ENABLE_EXT=1 -DONNX_ML=1 -DONNX_NAMESPACE=onnx -DTORCH_ENABLE_LLVM -DUSE_C10D_GLOO -DUSE_DISTRIBUTED -DUSE_EXTERNAL_MZCRC -DUSE_RPC -DUSE_TENSORPIPE -D_FILE_OFFSET_BITS=64 -Dtorch_cpu_EXPORTS -I/<<PKGBUILDDIR>>/build/aten/src -I/<<PKGBUILDDIR>>/aten/src -I/<<PKGBUILDDIR>>/build -I/<<PKGBUILDDIR>> -I/<<PKGBUILDDIR>>/cmake/../third_party/benchmark/include -I/usr/lib/llvm-18/include -I/<<PKGBUILDDIR>>/debian/foxi -I/<<PKGBUILDDIR>>/build/debian/foxi -I/<<PKGBUILDDIR>>/torch/csrc/api -I/<<PKGBUILDDIR>>/torch/csrc/api/include -I/<<PKGBUILDDIR>>/caffe2/aten/src/TH -I/<<PKGBUILDDIR>>/build/caffe2/aten/src/TH -I/<<PKGBUILDDIR>>/build/caffe2/aten/src -I/<<PKGBUILDDIR>>/build/caffe2/../aten/src -I/<<PKGBUILDDIR>>/torch/csrc -I/<<PKGBUILDDIR>>/third_party/miniz-2.1.0 -I/<<PKGBUILDDIR>>/debian/kineto/libkineto/include -I/<<PKGBUILDDIR>>/debian/kineto/libkineto/src -I/<<PKGBUILDDIR>>/aten/src/ATen/.. -I/<<PKGBUILDDIR>>/c10/.. -I/<<PKGBUILDDIR>>/aten/src/ATen/native/quantized/cpu/qnnpack/include -I/<<PKGBUILDDIR>>/aten/src/ATen/native/quantized/cpu/qnnpack/src -I/<<PKGBUILDDIR>>/aten/src/ATen/native/quantized/cpu/qnnpack/deps/clog/include -I/<<PKGBUILDDIR>>/third_party/flatbuffers/include -isystem /<<PKGBUILDDIR>>/build/third_party/gloo -isystem /<<PKGBUILDDIR>>/cmake/../third_party/gloo -isystem /<<PKGBUILDDIR>>/cmake/../third_party/googletest/googlemock/include -isystem /<<PKGBUILDDIR>>/cmake/../third_party/googletest/googletest/include -isystem /usr/include/opencv4 -isystem /usr/include/eigen3 -isystem /<<PKGBUILDDIR>>/caffe2 -Wdate-time -D_FORTIFY_SOURCE=3 -g -O2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -fdebug-prefix-map=/<<PKGBUILDDIR>>=/usr/src/pytorch-2.1.2+dfsg-4 -gsplit-dwarf -Wno-dangling-reference -I/usr -D_GLIBCXX_USE_CXX11_ABI=1 -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -DUSE_KINETO -DLIBKINETO_NOCUPTI -DLIBKINETO_NOROCTRACER -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -O2 -fPIC -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Werror=range-loop-construct -Werror=bool-operation -Wnarrowing -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=old-style-cast -Wno-invalid-partial-specialization -Wno-unused-private-field -Wno-aligned-allocation-unavailable -Wno-missing-braces -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-stringop-overflow -DHAVE_AVX512_CPU_DEFINITION -DHAVE_AVX2_CPU_DEFINITION -O2 -g -DNDEBUG -std=gnu++17 -fPIC -DCAFFE2_USE_GLOO -DTH_HAVE_THREAD -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-missing-field-initializers -Wno-unknown-pragmas -Wno-type-limits -Wno-array-bounds -Wno-strict-overflow -Wno-strict-aliasing -Wno-missing-braces -Wno-maybe-uninitialized -fvisibility=hidden -O2 -fopenmp -Wno-init-list-lifetime -MD -MT caffe2/CMakeFiles/torch_cpu.dir/__/torch/csrc/jit/tensorexpr/llvm_codegen.cpp.o -MF caffe2/CMakeFiles/torch_cpu.dir/__/torch/csrc/jit/tensorexpr/llvm_codegen.cpp.o.d -o caffe2/CMakeFiles/torch_cpu.dir/__/torch/csrc/jit/tensorexpr/llvm_codegen.cpp.o -c /<<PKGBUILDDIR>>/torch/csrc/jit/tensorexpr/llvm_codegen.cpp
/<<PKGBUILDDIR>>/torch/csrc/jit/tensorexpr/llvm_codegen.cpp:37:10: fatal error: llvm/Support/Host.h: No such file or directory
   37 | #include <llvm/Support/Host.h>
      | ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
```

Full log: https://launchpadlibrarian.net/732495262/buildlog_ubuntu-oracular-amd64.pytorch_2.1.2+dfsg-4_BUILDING.txt.gz

llvm-dev pulls in llvm 18 and /usr/include/llvm-$version/llvm/Support/Host.h is gone in that llvm version.

Revision history for this message
Benjamin Drung (bdrung) wrote :

Looking at the upstream git repository, I found a fix for llvm >= 18: https://github.com/pytorch/pytorch/pull/115652

Revision history for this message
Benjamin Drung (bdrung) wrote :
Download full text (11.3 KiB)

That commit is not enough. The build fails then with:

```
/usr/bin/c++ -DAT_PER_OPERATOR_HEADERS -DCAFFE2_BUILD_MAIN_LIB -DFMT_HEADER_ONLY=1 -DHAVE_MALLOC_USABLE_SIZE=1 -DHAVE_MMAP=1 -DHAVE_SHM_OPEN=1 -DHAVE_SHM_UNLINK=1 -DMINIZ_DISABLE_ZIP_READER_CRC32_CHECKS -DONNXIFI_ENABLE_EXT=1 -DONNX_ML=1 -DONNX_NAMESPACE=onnx -DTORCH_ENABLE_LLVM -DUSE_C10D_GLOO -DUSE_DISTRIBUTED -DUSE_EXTERNAL_MZCRC -DUSE_RPC -DUSE_TENSORPIPE -D_FILE_OFFSET_BITS=64 -Dtorch_cpu_EXPORTS -I/<<PKGBUILDDIR>>/build/aten/src -I/<<PKGBUILDDIR>>/aten/src -I/<<PKGBUILDDIR>>/build -I/<<PKGBUILDDIR>> -I/<<PKGBUILDDIR>>/cmake/../third_party/benchmark/include -I/usr/lib/llvm-18/include -I/<<PKGBUILDDIR>>/debian/foxi -I/<<PKGBUILDDIR>>/build/debian/foxi -I/<<PKGBUILDDIR>>/torch/csrc/api -I/<<PKGBUILDDIR>>/torch/csrc/api/include -I/<<PKGBUILDDIR>>/caffe2/aten/src/TH -I/<<PKGBUILDDIR>>/build/caffe2/aten/src/TH -I/<<PKGBUILDDIR>>/build/caffe2/aten/src -I/<<PKGBUILDDIR>>/build/caffe2/../aten/src -I/<<PKGBUILDDIR>>/torch/csrc -I/<<PKGBUILDDIR>>/third_party/miniz-2.1.0 -I/<<PKGBUILDDIR>>/debian/kineto/libkineto/include -I/<<PKGBUILDDIR>>/debian/kineto/libkineto/src -I/<<PKGBUILDDIR>>/aten/src/ATen/.. -I/<<PKGBUILDDIR>>/c10/.. -I/<<PKGBUILDDIR>>/aten/src/ATen/native/quantized/cpu/qnnpack/include -I/<<PKGBUILDDIR>>/aten/src/ATen/native/quantized/cpu/qnnpack/src -I/<<PKGBUILDDIR>>/aten/src/ATen/native/quantized/cpu/qnnpack/deps/clog/include -I/<<PKGBUILDDIR>>/third_party/flatbuffers/include -isystem /<<PKGBUILDDIR>>/build/third_party/gloo -isystem /<<PKGBUILDDIR>>/cmake/../third_party/gloo -isystem /<<PKGBUILDDIR>>/cmake/../third_party/googletest/googlemock/include -isystem /<<PKGBUILDDIR>>/cmake/../third_party/googletest/googletest/include -isystem /usr/include/opencv4 -isystem /usr/include/eigen3 -isystem /<<PKGBUILDDIR>>/caffe2 -Wdate-time -D_FORTIFY_SOURCE=3 -g -O2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -fdebug-prefix-map=/<<PKGBUILDDIR>>=/usr/src/pytorch-2.1.2+dfsg-4ubuntu1 -gsplit-dwarf -Wno-dangling-reference -I/usr -D_GLIBCXX_USE_CXX11_ABI=1 -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -DUSE_KINETO -DLIBKINETO_NOCUPTI -DLIBKINETO_NOROCTRACER -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -O2 -fPIC -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Werror=range-loop-construct -Werror=bool-operation -Wnarrowing -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=old-style-cast -Wno-invalid-partial-specialization -Wno-unused-private-field -Wno-aligned-allocation-unavailable -Wno-missing-braces -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-stringop-overflow -DHAVE_AVX512_CPU_DEFINITION -DHAVE_AVX2_CPU_DEFINITION -O2 -g -DNDEBUG -std=gnu++17 -fPIC -DCAFFE2_USE_GLOO -DTH_HAVE_THR...

Revision history for this message
Athos Ribeiro (athos-ribeiro) wrote :
Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

I may have found the right set of patches to backport. I'm doing a PPA build now to confirm, and will upload if everything goes OK.

Changed in pytorch (Ubuntu):
assignee: nobody → Sergio Durigan Junior (sergiodj)
status: New → Triaged
Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Package uploaded.

Changed in pytorch (Ubuntu):
status: Triaged → In Progress
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package pytorch - 2.1.2+dfsg-4ubuntu1

---------------
pytorch (2.1.2+dfsg-4ubuntu1) oracular; urgency=medium

  * Fix FTBFS with LLVM 18. (LP: #2067720)
    - d/p/0011-Update-caffe2-with-LLVM-18-API-change-109408.patch:
    - d/p/0012-Fix-build-for-llvm-18-115652.patch:
    - d/p/0013-Update-for-an-API-change-in-LLVM-18.-117086.patch:
    - d/p/0014-Replaced-getInt8PtrTy-with-getUnqual-113455.patch:
    - d/p/0015-Update-apis-incompatible-with-llvm-versions-in-codeg.patch:
    - d/p/0016-Revert-upstream-commit-32643bc9266271ebf3b935573189e.patch:
      Backport patches from upstream to fix the issue.

 -- Sergio Durigan Junior <email address hidden> Mon, 10 Jun 2024 14:38:33 -0400

Changed in pytorch (Ubuntu):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.