Skip to content

Python library fails to compile with gcc 14 #161

@Tomsod

Description

@Tomsod

GCC 14 adds the __type_pack_element builtin, but unlike with clang, it cannot be used in function signatures. tensorstore code will use this builtin if it exists, unfortunately including in said signatures. So, for instance, compiling v0.1.59 with gcc 14.1.1 will fail with this error:

ERROR: /home/tomsod/pkg/python-tensorstore/src/tensorstore-0.1.59/python/tensorstore/BUILD:884:20: Compiling python/tensorstore/cast.cc failed: (Exit 1): gcc failed: error executing command (from target //python/tensorstore:cast) 
  (cd /home/tomsod/.cache/bazel/_bazel_tomsod/2e8a30ae68d29622735d7834c8053860/sandbox/linux-sandbox/2872/execroot/tensorstore && \
  exec env - \
    PATH=/home/tomsod/.cache/bazelisk/downloads/bazelbuild/bazel-6.4.0-linux-x86_64/bin:/home/tomsod/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin \
    PWD=/proc/self/cwd \
  /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections '-std=c++14' -MD -MF bazel-out/k8-opt/bin/python/tensorstore/_objs/cast/cast.pic.d '-frandom-seed=bazel-out/k8-opt/bin/python/tensorstore/_objs/cast/cast.pic.o' -fPIC '-DPYBIND11_NAMESPACE=pybind11' '-DBAZEL_CURRENT_REPOSITORY=""' -iquote . -iquote bazel-out/k8-opt/bin -iquote external/com_github_nlohmann_json -iquote bazel-out/k8-opt/bin/external/com_github_nlohmann_json -iquote external/com_github_pybind_pybind11 -iquote bazel-out/k8-opt/bin/external/com_github_pybind_pybind11 -iquote external/local_config_python -iquote bazel-out/k8-opt/bin/external/local_config_python -iquote external/pypa_numpy -iquote bazel-out/k8-opt/bin/external/pypa_numpy -iquote external/com_google_absl -iquote bazel-out/k8-opt/bin/external/com_google_absl -iquote external/com_google_boringssl -iquote bazel-out/k8-opt/bin/external/com_google_boringssl -iquote external/com_google_riegeli -iquote bazel-out/k8-opt/bin/external/com_google_riegeli -iquote external/net_sourceforge_half -iquote bazel-out/k8-opt/bin/external/net_sourceforge_half -iquote external/com_google_re2 -iquote bazel-out/k8-opt/bin/external/com_google_re2 -Ibazel-out/k8-opt/bin/external/local_config_python/_virtual_includes/python_headers -Ibazel-out/k8-opt/bin/external/pypa_numpy/_virtual_includes/headers -Ibazel-out/k8-opt/bin/external/net_sourceforge_half/_virtual_includes/half -isystem external/com_github_nlohmann_json/include -isystem bazel-out/k8-opt/bin/external/com_github_nlohmann_json/include -isystem external/com_google_boringssl/src/include -isystem bazel-out/k8-opt/bin/external/com_google_boringssl/src/include '-fdiagnostics-color=always' -Wno-deprecated-declarations -Wno-sign-compare -Wno-unused-but-set-parameter -Wno-maybe-uninitialized -Wno-sequence-point -Wno-unknown-warning-option '-fvisibility=hidden' '-std=c++17' -fsized-deallocation -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c python/tensorstore/cast.cc -o bazel-out/k8-opt/bin/python/tensorstore/_objs/cast/cast.pic.o)
# Configuration: be1daf17721bf897cc460d9b48e54b347d1a384855b805400ec713560a9d01f6
# Execution platform: @local_config_platform//:host

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from ./tensorstore/box.h:33,
                 from ./tensorstore/array.h:38,
                 from ./python/tensorstore/array_type_caster.h:32,
                 from ./python/tensorstore/spec.h:28,
                 from python/tensorstore/cast.cc:21:
./tensorstore/internal/multi_vector.h: In instantiation of 'static tensorstore::span<tensorstore::internal::MultiVectorAccess<tensorstore::internal::MultiVectorStorageImpl<Extent, InlineSize, Ts> >::ElementType<I>, Extent> tensorstore::internal::MultiVectorAccess<tensorstore::internal::MultiVectorStorageImpl<Extent, InlineSize, Ts> >::get(StorageType*) [with long unsigned int I = 1; long int Extent = -1; long int InlineSize = 0; Ts = {long int, long int}]':
./tensorstore/internal/multi_vector.h:276:39: error: use of built-in trait '__type_pack_element<I, long int, long int>' in function signature; use library traits instead
  276 |   static span<ElementType<I>, Extent> get(StorageType* array) {
      |                                       ^~~
./tensorstore/internal/multi_vector.h: In instantiation of 'static tensorstore::span<tensorstore::internal::MultiVectorAccess<tensorstore::internal::MultiVectorStorageImpl<Extent, InlineSize, Ts> >::ElementType<I>, Extent> tensorstore::internal::MultiVectorAccess<tensorstore::internal::MultiVectorStorageImpl<Extent, InlineSize, Ts> >::get(StorageType*) [with long unsigned int I = 0; long int Extent = -1; long int InlineSize = 0; Ts = {long int, long int}]':
./tensorstore/internal/multi_vector.h:276:39: error: use of built-in trait '__type_pack_element<I, long int, long int>' in function signature; use library traits instead
In file included from ./tensorstore/box.h:34:
./tensorstore/internal/multi_vector_view.h: In instantiation of 'static tensorstore::span<tensorstore::internal::MultiVectorAccess<tensorstore::internal::MultiVectorViewStorage<Extent, Ts> >::ElementType<I>, Extent> tensorstore::internal::MultiVectorAccess<tensorstore::internal::MultiVectorViewStorage<Extent, Ts> >::get(const StorageType*) [with long unsigned int I = 1; long int Extent = -1; Ts = {long int, long int}]':
./tensorstore/internal/multi_vector_view.h:172:39: error: use of built-in trait '__type_pack_element<I, long int, long int>' in function signature; use library traits instead
  172 |   static span<ElementType<I>, Extent> get(const StorageType* array) noexcept {
      |                                       ^~~
./tensorstore/internal/multi_vector_view.h: In instantiation of 'static tensorstore::span<tensorstore::internal::MultiVectorAccess<tensorstore::internal::MultiVectorViewStorage<Extent, Ts> >::ElementType<I>, Extent> tensorstore::internal::MultiVectorAccess<tensorstore::internal::MultiVectorViewStorage<Extent, Ts> >::get(const StorageType*) [with long unsigned int I = 0; long int Extent = -1; Ts = {long int, long int}]':
./tensorstore/internal/multi_vector_view.h:172:39: error: use of built-in trait '__type_pack_element<I, long int, long int>' in function signature; use library traits instead
./tensorstore/internal/multi_vector_view.h: In instantiation of 'static tensorstore::span<tensorstore::internal::MultiVectorAccess<tensorstore::internal::MultiVectorViewStorage<Extent, Ts> >::ElementType<I>, Extent> tensorstore::internal::MultiVectorAccess<tensorstore::internal::MultiVectorViewStorage<Extent, Ts> >::get(const StorageType*) [with long unsigned int I = 1; long int Extent = -1; Ts = {const long int, const long int}]':
./tensorstore/internal/multi_vector_view.h:172:39: error: use of built-in trait '__type_pack_element<I, const long int, const long int>' in function signature; use library traits instead
./tensorstore/internal/multi_vector_view.h: In instantiation of 'static tensorstore::span<tensorstore::internal::MultiVectorAccess<tensorstore::internal::MultiVectorViewStorage<Extent, Ts> >::ElementType<I>, Extent> tensorstore::internal::MultiVectorAccess<tensorstore::internal::MultiVectorViewStorage<Extent, Ts> >::get(const StorageType*) [with long unsigned int I = 0; long int Extent = -1; Ts = {const long int, const long int}]':
./tensorstore/internal/multi_vector_view.h:172:39: error: use of built-in trait '__type_pack_element<I, const long int, const long int>' in function signature; use library traits instead
cc1plus: note: unrecognized command-line option '-Wno-unknown-warning-option' may have been intended to silence earlier diagnostics

As a quick workaround (not suggested as a fix!), it's possible to knock out this code:

#ifdef __has_builtin
#if __has_builtin(__type_pack_element)
#define TENSORSTORE_HAS_TYPE_PACK_ELEMENT
#endif
#endif

Then a substitute for the builtin will be used, which does compile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions