Open trivialkettle opened 2 weeks ago
I would attribute it to be a bug in the compiler. It's just unable to compile a legit line of code of appending data to the end of std::vector
.
...
inlined from ‘cc_mqttsn_gateway_app::GatewaySession::doBrokerConnect()::<lambda(const uint8_t*, std::size_t)>’ at xxx/cc.mqttsn.libs/gateway/app/gateway/GatewaySession.cpp:112:36,
...
The only thing I can recommend here is to try to build without treating warnings as errors, i.e. pass -DCC_MQTTSN_WARN_AS_ERR=OFF
to your cmake invocation.
I didn't come around to upgrade my development system to Ubuntu-24.04, still using 22.04. I'll try to reproduce the problem on github actions ubuntu-24.04 runner and see if I can do anything to workaround the problem.
The ubuntu-24.04 runner on github actions uses gcc v14.0.1 and compiles fine. Looks like the image hasn't been updated for a while. I guess it will have to wait until I upgrade my development PC to 24.04 and reproduce the issue in my environment.
I could reproduce the issue using the gcc-14.2, gcc-14.1 and gcc-13 docker image:
# clone repository and cd into then:
docker run -it --rm -v $(pwd):/src gcc:14.2
apt-get update && apt-get install --yes cmake libboost-all-dev
cd src
BUILD_DIR=./build ./script/prepare_externals.sh
cd build/
cmake .. -DCMAKE_BUILD_TYPE=Release -DCC_MQTTSN_CLIENT_DEFAULT_LIB=OFF -DCMAKE_PREFIX_PATH=$(pwd)/externals/comms/build/install\;$(pwd)/externals/cc.mqttsn.generated/build/install\;$(pwd)/externals/cc.mqtt311.generated/build/install
cmake --build . --config Release --target install
I also tested with ubuntu-24.
My Dockerfile:
FROM curlimages/curl:latest AS download
ARG MQTTSN_GW_VERSION=2.0.3
ARG LINK=https://github.com/commschamp/cc.mqttsn.libs/archive/refs/tags
RUN echo $(PWD)
RUN curl -L ${LINK}/v${MQTTSN_GW_VERSION}.tar.gz -o /tmp/mqttsn.tar.gz \
&& mkdir /tmp/mqttsn/ \
&& tar -zxf /tmp/mqttsn.tar.gz -C /tmp/mqttsn --strip-components=1
FROM ubuntu:24.04 AS build
RUN set -eux; \
apt-get update; \
apt-get install --yes --no-install-recommends \
make \
ca-certificates \
cmake \
gcc-14 \
g++-14 \
git \
libboost-all-dev \
; \
rm -rf /var/lib/apt/lists/*
COPY --from=download /tmp/mqttsn/ ./mqttsn/
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 50; \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 50
RUN cd mqttsn/ \
&& mkdir build \
&& BUILD_DIR=./build ./script/prepare_externals.sh \
&& cd build \
&& cmake .. -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=20 \
-DCC_MQTTSN_CLIENT_DEFAULT_LIB=OFF \
-DCC_MQTTSN_WARN_AS_ERR=OFF \
-DCMAKE_PREFIX_PATH=$(pwd)/externals/comms/build/install\;$(pwd)/externals/cc.mqttsn.generated/build/install\;$(pwd)/externals/cc.mqtt311.generated/build/install \
&& cmake --build /mqttsn/build/ --target cc_mqttsn_gateway_app -- -j4
There are even some warnings related to builtin_memcmp
:
#12 23.41 In file included from /usr/include/c++/14/list:62,
#12 23.41 from /mqttsn/gateway/lib/src/session_op/Encapsulate.h:11,
#12 23.41 from /mqttsn/gateway/lib/src/session_op/Encapsulate.cpp:8:
#12 23.41 In function 'constexpr decltype (__comp((* __first1), (* __first2))) std::lexicographical_compare_three_way(_InputIter1, _InputIter1, _InputIter2, _InputIter2, _Comp) [with _InputIter1 = __gnu_cxx::__normal_iterator<const unsigned char*, vector<unsigned char> >; _InputIter2 = __gnu_cxx::__normal_iterator<const unsigned char*, vector<unsigned char> >; _Comp = __detail::_Synth3way]',
#12 23.41 inlined from 'constexpr std::__detail::__synth3way_t<_T1> std::operator<=>(const vector<_Tp, _Alloc>&, const vector<_Tp, _Alloc>&) [with _Tp = unsigned char; _Alloc = allocator<unsigned char>]' at /usr/include/c++/14/bits/stl_vector.h:2071:52,
#12 23.41 inlined from 'constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = std::vector<unsigned char>]' at /usr/include/c++/14/bits/stl_function.h:405:20,
#12 23.41 inlined from 'std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos(const key_type&) [with _Key = std::vector<unsigned char>; _Val = std::pair<const std::vector<unsigned char>, std::unique_ptr<cc_mqttsn_gateway::Session> >; _KeyOfValue = std::_Select1st<std::pair<const std::vector<unsigned char>, std::unique_ptr<cc_mqttsn_gateway::Session> > >; _Compare = std::less<std::vector<unsigned char> >; _Alloc = std::allocator<std::pair<const std::vector<unsigned char>, std::unique_ptr<cc_mqttsn_gateway::Session> > >]' at /usr/include/c++/14/bits/stl_tree.h:2114:35:
#12 23.41 /usr/include/c++/14/bits/stl_algobase.h:1874:39: warning: 'int __builtin_memcmp(const void*, const void*, long unsigned int)' specified bound [9223372036854775808, 18446744073709551615] exceeds maximum object size 9223372036854775807 [-Wstringop-overread]
#12 23.41 1874 | = __builtin_memcmp(&*__first1, &*__first2, __blen) <=> 0;
#12 23.41 | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
And the __builtin_memmove
warning shwn above.
I'm planning to upgrade my development system to 24.04 over the next weekend and will take closer look at it. However, I think the "fix" is going to be to suppress the pesky warning. The gcc bug tracking seems to have similar issues to periodically pop-up, like this one. As a temporary option, please pass -DCC_MQTTSN_WARN_AS_ERR=OFF
to your CMake configuration.
Hi, I tried to compile the version 2 code and ran into the following build error:
When I built the target it worked though.