<@U0A71G31CDV> I am unable to build format-lib wit...
# questions-and-troubleshooting
c
@Rocky I am unable to build format-lib with command ./build.sh --format-lib --enable-shared-data -j4 GEtting this error at 93% [ 93%] Building CXX object src/exprs/CMakeFiles/Exprs.dir/binary_predicate.cpp.o In file included from /opt/gcc-toolset-14/include/c++/14.3.0/memory:78, from /root/starrocks/be/src/pch/starrocks_pch.h:29, from /root/starrocks/be/build_Release_format-lib/src/exprs/CMakeFiles/Exprs.dir/cmake_pch.hxx:5, from <command-line>: /opt/gcc-toolset-14/include/c++/14.3.0/bits/unique_ptr.h: In instantiation of ‘void std:default delete&lt; Tp&gt;:operator()(_Tp*) const [with _Tp = starrocks:JavaUDAFUniqueContext]’ /opt/gcc-toolset-14/include/c++/14.3.0/bits/unique_ptr.h39917: required from ‘std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = starrocks::JavaUDAFUniqueContext; _Dp = std:default delete&lt;starrocks:JavaUDAFUniqueContext>]’ 399 | get_deleter()(std::move(__ptr)); | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /root/starrocks/be/src/exprs/function_context.cpp801: required from here 80 | FunctionContext::FunctionContext() = default; | ^~~~~~~~~~~~~~~ /opt/gcc-toolset-14/include/c++/14.3.0/bits/unique_ptr.h9123: error: invalid application of ‘sizeof’ to incomplete type ‘starrocks::JavaUDAFUniqueContext’ 91 | static_assert(sizeof(_Tp)>0, | ^~~~~~~~~~~ make[2]: * [src/exprs/CMakeFiles/Exprs.dir/build.make400 src/exprs/CMakeFiles/Exprs.dir/function_context.cpp.o] Error 1 make[2]: * Waiting for unfinished jobs.... In file included from /usr/include/x86_64-linux-gnu/bits/types/stack_t.h:23, from /usr/include/signal.h:313, from /usr/include/x86_64-linux-gnu/sys/param.h:28, from /var/local/thirdparty/installed/include/thrift/protocol/TProtocol.h:105, from /var/local/thirdparty/installed/include/thrift/TBase.h:24, from /root/starrocks/be/src/gen_cpp/build/gen_cpp/Types_types.h:14, from /root/starrocks/be/src/util/hash_util.hpp:50, from /root/starrocks/be/src/runtime/decimalv2_value.h:47, from /root/starrocks/be/src/column/column_visitor.h:19, from /root/starrocks/be/src/column/column.h:21, from /root/starrocks/be/src/exprs/function_context.h:25, from /root/starrocks/be/src/exprs/expr_context.h:42, from /root/starrocks/be/src/exprs/expr.h:44, from /root/starrocks/be/src/exprs/arrow_function_call.h:20, from /root/starrocks/be/src/exprs/arrow_function_call.cpp15 /root/starrocks/be/src/runtime/current_thread.h: In static member function ‘static constexpr std::size_t starrocks:CurrentThread:query_id_offset()’: /root/starrocks/be/src/runtime/current_thread.h28865: warning: ‘offsetof’ within non-standard-layout type ‘starrocks::CurrentThread’ is conditionally-supported [-Winvalid-offsetof] 288 | static constexpr size_t query_id_offset() { return offsetof(CurrentThread, _query_id); } | ^ /root/starrocks/be/src/runtime/current_thread.h: In static member function ‘static constexpr std::size_t starrocks:CurrentThread:module_type_offset()’: /root/starrocks/be/src/runtime/current_thread.h28968: warning: ‘offsetof’ within non-standard-layout type ‘starrocks::CurrentThread’ is conditionally-supported [-Winvalid-offsetof] 289 | static constexpr size_t module_type_offset() { return offsetof(CurrentThread, _module_type); } | ^ In file included from /usr/include/x86_64-linux-gnu/bits/types/stack_t.h:23, from /usr/include/signal.h:313, from /usr/include/x86_64-linux-gnu/sys/param.h:28, from /var/local/thirdparty/installed/include/thrift/protocol/TProtocol.h:105, from /var/local/thirdparty/installed/include/thrift/TBase.h:24, from /root/starrocks/be/src/gen_cpp/build/gen_cpp/Types_types.h:14, from /root/starrocks/be/src/util/hash_util.hpp:50, from /root/starrocks/be/src/runtime/decimalv2_value.h:47, from /root/starrocks/be/src/column/column_visitor.h:19, from /root/starrocks/be/src/column/column.h:21, from /root/starrocks/be/src/column/array_column.h:19, from /root/starrocks/be/src/exprs/array_functions.tpp:17, from /root/starrocks/be/src/exprs/array_functions.h:17, from /root/starrocks/be/src/exprs/array_functions.cpp15 /root/starrocks/be/src/runtime/current_thread.h: In static member function ‘static constexpr std::size_t starrocks:CurrentThread:query_id_offset()’: /root/starrocks/be/src/runtime/current_thread.h28865: warning: ‘offsetof’ within non-standard-layout type ‘starrocks::CurrentThread’ is conditionally-supported [-Winvalid-offsetof] 288 | static constexpr size_t query_id_offset() { return offsetof(CurrentThread, _query_id); } | ^ /root/starrocks/be/src/runtime/current_thread.h: In static member function ‘static constexpr std::size_t starrocks:CurrentThread:module_type_offset()’: /root/starrocks/be/src/runtime/current_thread.h28968: warning: ‘offsetof’ within non-standard-layout type ‘starrocks::CurrentThread’ is conditionally-supported [-Winvalid-offsetof] 289 | static constexpr size_t module_type_offset() { return offsetof(CurrentThread, _module_type); } | ^ make[1]: * [CMakeFiles/Makefile21137 src/exprs/CMakeFiles/Exprs.dir/all] Error 2 make: * [Makefile156 all] Error 2 Please help
r
The error you are encountering is a classic C++ "incomplete type" issue, made more prominent by the strictness of GCC 14. It occurs because the
FunctionContext
class now contains a
std::unique_ptr
to
starrocks::JavaUDAFUniqueContext
, but the compiler cannot find the full definition of that type when trying to generate the default constructor or destructor. Root Cause In
be/src/exprs/function_context.cpp
, the constructor (and likely the destructor) is defined as
= default;
.
Copy code
cpp
FunctionContext::FunctionContext() = default; // Line 80
When using
std::unique_ptr<T>
, the compiler must have the full definition of
T
(not just a forward declaration) to instantiate the default deleter, which calls
sizeof(T)
. This is likely surfacing now because: 1. GCC 14 is significantly stricter regarding template instantiations and incomplete types compared to the GCC 10/11 versions typically used for StarRocks builds. 2. The
--format-lib
flag builds a limited subset of the StarRocks codebase. It appears the header defining
JavaUDAFUniqueContext
is missing from the
format-lib
include path or is not included in
function_context.cpp
. Suggested Fixes 1. Add the missing include Locate the header file that defines
JavaUDAFUniqueContext
(usually
be/src/exprs/java_udaf_context.h
or similar) and include it in
be/src/exprs/function_context.cpp
.
Copy code
cpp
// In be/src/exprs/function_context.cpp
#include "exprs/java_udaf_context.h"  // Add this line
2. Ensure non-defaulted Destructor in .cpp If the destructor is defaulted in the header file (
function_context.h
), move its definition to the
.cpp
file. This ensures the compiler only looks for the full definition of
JavaUDAFUniqueContext
inside the implementation file where the header is included. 3. Review Build Flags The combination of
--format-lib
and
--enable-shared-data
is uncommon. *
--format-lib
is intended for building the standalone columnar format library (often for external connectors). *
--enable-shared-data
enables Cloud-Native (shared-storage) features. If you do not specifically need Cloud-Native features in your format library, try building without `--enable-shared-data`:
Copy code
bash
./build.sh --format-lib -j4
Recommendation for GCC 14 StarRocks' official build environment currently uses GCC 11 or Clang. GCC 14 may introduce other "conditionally-supported" warnings (like the
offsetof
warning you see in
current_thread.h
) that can be treated as errors if
-Werror
is enabled. If possible, use the official StarRocks build docker image to ensure compatibility. If the issue persists after adding the include, it may be a bug in the recent
main
branch where Java UDF components were added to
FunctionContext
without proper guards for the
format-lib
target. You should report this on the StarRocks GitHub Issues. References • administration/management/FE_configuration.md • administration/management/BE_configuration.md • deployment/shared_data/s3.md • deployment/shared_data/minio.md
c
@Rocky But I am using
dev-env-ubuntu:4.1.3
to build from tag 4.1.3... Should I be using another dev-env-ubuntu?
r
The build error you're seeing is a compilation issue specifically triggered by the strictness of GCC 14 (which appears to be the default in your
dev-env-ubuntu:4.1.3
image) and a missing header dependency in the StarRocks source code. 1. Why it's happening The error
invalid application of 'sizeof' to incomplete type 'starrocks::JavaUDAFUniqueContext'
happens because the class
FunctionContext
uses a
std::unique_ptr<JavaUDAFUniqueContext>
. In the file
be/src/exprs/function_context.cpp
, the constructor or destructor is "defaulted" (using
= default;
). When using
std::unique_ptr
, the compiler must have the full definition of the managed type (not just a forward declaration) at the point where the destructor or constructor is defined, because it needs to know how to delete the object. GCC 14 is much more aggressive about checking this than the older GCC 11/12 versions. 2. How to fix it You need to manually add the missing include to the implementation file so the compiler can see the full definition of
JavaUDAFUniqueContext
. 1. Open the file:
be/src/exprs/function_context.cpp
. 2. Add the following include at the top with the other includes:
Copy code
cpp
    #include "exprs/java_udaf_context.h"
(Note: If that specific path doesn't exist, search for the file defining
class JavaUDAFUniqueContext
in
be/src/exprs/
and include that.)
3. Re-run your build command. 3. About the Build Environment You are using
dev-env-ubuntu:4.1.3
to build tag
4.1.3
, which is the correct match. However, StarRocks recently moved to a newer toolchain (including GCC 14) for the 4.x series. This transition often uncovers "incomplete type" bugs like this one that were hidden in older compilers. 4. Build Flag Recommendation You are using both
--format-lib
and
--enable-shared-data
. *
--format-lib
is meant for building a standalone columnar library for external use (like the StarRocks Spark/Flink connectors). *
--enable-shared-data
is for the cloud-native "Lake" architecture. Unless you are specifically developing a connector that needs to read StarRocks' shared-data (lake) storage format directly, you usually don't need both. If the header fix above doesn't work or leads to more errors, try building with just the flag you absolutely need:
Copy code
bash
./build.sh --format-lib -j4
# OR
./build.sh --be --enable-shared-data -j4
Summary: The image is likely correct, but the code in tag 4.1.3 has a minor header omission that GCC 14 caught. Adding the
#include
for the Java UDAF context in
function_context.cpp
should resolve the "incomplete type" error.
c
@Rocky - Should I use any older dev-env-ubuntu?
r
While matching the
dev-env-ubuntu
tag to your StarRocks version is generally the correct approach, the 4.1.3 image has transitioned to GCC 14, which is significantly stricter than previous versions. The error you are seeing is a known side effect of this transition, specifically affecting builds where certain headers aren't explicitly included. Should you use an older
dev-env-ubuntu
?
Generally, no. Moving to a significantly older image (like
3.x
) might cause other issues because StarRocks 4.1 introduces dependencies (like newer versions of Thrift or specific C++20 features) that the older toolchains in 3.x images may not support. However, if you want to avoid editing the source code and just need a working build, you can try: *
starrocks/dev-env-ubuntu:3.5-latest
: This is a very stable build environment that uses GCC 11. Many 4.x components still compile fine with GCC 11, though you might run into issues with the absolute latest 4.1-specific features. *
starrocks/dev-env-ubuntu:4.0.x
: If there is a 4.0.14 or similar tag, it likely uses a slightly older toolset (GCC 12 or 13) that may not trigger the "incomplete type" error. Why the code fix is better The "incomplete type" error is essentially a small bug in the StarRocks source code for the
--format-lib
build path. GCC 14 flags it, while GCC 11 allowed it to slide. By simply adding the missing header, you can continue using the modern, intended toolchain. To fix the code in your current environment: 1. Open
be/src/exprs/function_context.cpp
. 2. Add this line near the top:
Copy code
cpp
    #include "exprs/java_udaf_context.h"
3. Re-run your build command. A note on your build flags The combination of
--format-lib
and
--enable-shared-data
is quite rare. *
--format-lib
is typically used to build the standalone library for external connectors (like Spark/Flink). *
--enable-shared-data
is for the Cloud-Native/Lakehouse architecture. If you are only trying to build the backend (BE) for a normal StarRocks cluster, you should use:
Copy code
bash
./build.sh --be --enable-shared-data -j4
If you specifically need the format-lib but don't need Cloud-Native support inside that library, removing
--enable-shared-data
may also bypass the problematic code path. Summary: Stick with the 4.1.3 environment but apply the
#include
fix. If you absolutely cannot modify the code, try
starrocks/dev-env-ubuntu:3.5-latest
as a fallback.
k
format lib code might be broken, you can build with the latest dev-env image and fix.whatever needed and open a PR for the project.