Closed bertulli closed 4 months ago
Can you pull the following submodule branch and see if this fixes you issue?
https://github.com/Azure/azure-uamqp-c/tree/ericwol/safemath_conflict
Hi, thanks. No, unfortunately it still gives error (I fetched and checked out the branch):
[ 38%] Building C object out/uamqp/CMakeFiles/uamqp.dir/src/session.c.o
In file included from /home/abertulli/two_lidars/azure-iot-sdk-c/uamqp/inc/azure_uamqp_c/session.h:7:0,
from /home/abertulli/two_lidars/azure-iot-sdk-c/uamqp/src/session.c:10:
/opt/box-root-fs/usr/include/stdint.h:266:0: error: "SIZE_MAX" redefined [-Werror]
# define SIZE_MAX (4294967295U)
In file included from /home/abertulli/two_lidars/azure-iot-sdk-c/uamqp/src/session.c:8:0:
/home/abertulli/two_lidars/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/safe_math.h:8:0: note: this is the location of the previous definition
#define SIZE_MAX ((size_t)((size_t)~(size_t)0))
cc1: all warnings being treated as errors
make[2]: *** [out/uamqp/CMakeFiles/uamqp.dir/build.make:384: out/uamqp/CMakeFiles/uamqp.dir/src/session.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:594: out/uamqp/CMakeFiles/uamqp.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
$ cd azure-iot-sdk-c/uamqp/
$ git status
On branch ericwol/safemath_conflict
Your branch is up to date with 'origin/ericwol/safemath_conflict'.
nothing to commit, working tree clean
$
I see. There was more files with the same issue. Please pull the new changes in the branch and try again.
It went way further this time (95%), but there's still an error:
[ 95%] Building C object out/serializer/CMakeFiles/serializer.dir/src/agenttypesystem.c.o
In file included from /home/abertulli/two_lidars/azure-iot-sdk-c/serializer/inc/agenttypesystem.h:15:0,
from /home/abertulli/two_lidars/azure-iot-sdk-c/serializer/src/agenttypesystem.c:8:
/opt/box-root-fs/usr/include/stdint.h:267:0: error: "SIZE_MAX" redefined [-Werror]
# define SIZE_MAX (4294967295U)
In file included from /home/abertulli/two_lidars/azure-iot-sdk-c/serializer/src/agenttypesystem.c:6:0:
/home/abertulli/two_lidars/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/safe_math.h:8:0: note: this is the location of the previous definition
#define SIZE_MAX ((size_t)((size_t)~(size_t)0))
cc1: all warnings being treated as errors
make[2]: *** [out/serializer/CMakeFiles/serializer.dir/build.make:76: out/serializer/CMakeFiles/serializer.dir/src/agenttypesystem.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1176: out/serializer/CMakeFiles/serializer.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
Please pull the following changes on the main repo https://github.com/Azure/azure-iot-sdk-c/tree/ericwol/safemath_conflict
Thanks, it appears to be working now! As a further comment, I'd add that a temporary workaround could be adding a guard in the standard C library stdint.h
:
/* Limit of `size_t' type. */
#ifndef SIZE_MAX // <----- HERE
# if __WORDSIZE == 64
# define SIZE_MAX (18446744073709551615UL)
# else
# ifdef __WORDSIZE32_SIZE_ULONG
# define SIZE_MAX (4294967295UL)
# else
# define SIZE_MAX (4294967295U)
# endif
# endif
#endif // <----- and HERE
It worked for me. Anyway, now it works with the standard headers, with the main repo at 033308b35 and the submodule uamqp
at Azure/azure-uamqp-c@ac5a7ec.
This issue can be closed for me, but I don't close it myself in case you would like to keep it open waiting to link it to a PR merging the fix into the main branch
Development Machine, OS, Compiler (and Other Relevant Toolchain Info) target system Debian stretch (armv7l) Cross Compiled on WSL Ubuntu 22.04 (x86-64) using GCC 6.3.0 built from source
Notice that the cross compiler works fine with other submodules / files / units
SDK Version
Release LTS_03_2024_Ref02 (commit 46996fca3601657a5a721dea66809d2372ae305c)
Protocol
MQTT
Describe the Bug
Hi, thanks for your work. Compiling the project on the target and the host system works fine, but when cross-compiling, I have an header conflict (see console logs and relevant file below). Notice that the cross compiler, that was built from source to match the Glibc version of the target, works fine with other projects not containing the Azure SDK.
MCVE Just compiling the Azure SDK is enough
Console Logs
Configuration output (cross compiling, some of the output is due to custom messages):
CMake Deprecation Warning at azure-iot-sdk-c/deps/umock-c/CMakeLists.txt:4 (cmake_minimum_required): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake.
Update the VERSION argument value or use a ... suffix to tell
CMake that the project does not need compatibility with older versions.
-- Looking for include file stdint.h -- Looking for include file stdint.h - found -- Looking for include file stdbool.h -- Looking for include file stdbool.h - found -- target architecture: ARM -- Performing Test CXX_FLAG_CXX11 -- Performing Test CXX_FLAG_CXX11 - Success -- Found OpenSSL: /opt/box-root-fs/usr/lib/arm-linux-gnueabihf/libcrypto.so (found version "1.0.2u") -- Found CURL: /opt/box-root-fs/usr/lib/arm-linux-gnueabihf/libcurl.so -- target architecture: ARM -- IoT Hub Architecture: ARM -- Configuring done -- Generating done -- Build files have been written to: /home/abertulli/two_lidars/build
$ make [ 0%] Building CXX object CMakeFiles/single_lidar_listener.dir/single_lidar.cpp.o In file included from /home/abertulli/two_lidars/single_lidar.cpp:12:0: /home/abertulli/two_lidars/include/dbg.h:39:76: note: #pragma message: WARNING: the 'dbg.h' header is included in your code base
pragma message("WARNING: the 'dbg.h' header is included in your code base")
[ 1%] Building C object CMakeFiles/single_lidar_listener.dir/sick_scan_xd_api_wrapper.c.o [ 1%] Linking CXX executable single_lidar_listener [ 1%] Built target single_lidar_listener [ 1%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/azure_base32.c.o [ 1%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/azure_base64.c.o [ 2%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/buffer.c.o [ 2%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/constbuffer_array.c.o [ 2%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/constbuffer_array_batcher.c.o [ 3%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/connection_string_parser.c.o [ 3%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/constbuffer.c.o [ 4%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/consolelogger.c.o [ 4%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/crt_abstractions.c.o [ 4%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/constmap.c.o [ 5%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/doublylinkedlist.c.o [ 5%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/gballoc.c.o [ 6%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/gbnetwork.c.o [ 6%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/gb_stdio.c.o [ 6%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/gb_time.c.o [ 7%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/hmac.c.o [ 7%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/hmacsha256.c.o [ 8%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/xio.c.o [ 8%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/singlylinkedlist.c.o [ 8%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/map.c.o [ 9%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/sastoken.c.o [ 9%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/sha1.c.o [ 10%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/sha224.c.o [ 10%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/sha384-512.c.o [ 10%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/strings.c.o [ 11%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/string_token.c.o [ 11%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/string_tokenizer.c.o [ 12%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/uuid.c.o [ 12%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/urlencode.c.o [ 12%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/usha.c.o [ 13%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/vector.c.o [ 13%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/xlogging.c.o [ 13%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/optionhandler.c.o [ 14%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/memory_data.c.o [ 14%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/adapters/agenttime.c.o [ 15%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/adapters/condition_pthreads.c.o [ 15%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/adapters/lock_pthreads.c.o [ 15%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/adapters/random_posix.c.o [ 16%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/adapters/platform_linux.c.o [ 16%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/adapters/socketio_berkeley.c.o [ 17%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/adapters/tickcounter_linux.c.o [ 17%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/adapters/threadapi_pthreads.c.o [ 17%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/adapters/uniqueid_linux.c.o [ 18%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/adapters/envvariable.c.o [ 18%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/dns_resolver_sync.c.o [ 19%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/adapters/linux_time.c.o [ 19%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/httpapiex.c.o [ 19%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/httpapiexsas.c.o [ 20%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/httpheaders.c.o [ 20%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/adapters/httpapi_curl.c.o [ 21%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/http_proxy_io.c.o [ 21%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/adapters/tlsio_openssl.c.o [ 21%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/adapters/x509_openssl.c.o [ 22%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/wsio.c.o [ 22%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/uws_client.c.o [ 23%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/uws_frame_encoder.c.o [ 23%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/utf8_checker.c.o [ 23%] Building C object out/c-utility/CMakeFiles/aziotsharedutil.dir/src/ws_url.c.o [ 24%] Linking C static library libaziotsharedutil.a [ 24%] Built target aziotsharedutil [ 25%] Building C object out/umqtt/CMakeFiles/umqtt.dir/src/mqtt_client.c.o [ 25%] Building C object out/umqtt/CMakeFiles/umqtt.dir/src/mqtt_codec.c.o [ 25%] Building C object out/umqtt/CMakeFiles/umqtt.dir/src/mqtt_message.c.o [ 26%] Linking C static library libumqtt.a [ 26%] Built target umqtt [ 27%] Building C object out/iothub_client/CMakeFiles/iothub_client_mqtt_ws_transport.dir/src/iothub_client_authorization.c.o [ 27%] Building C object out/iothub_client/CMakeFiles/iothub_client_mqtt_ws_transport.dir/src/iothub_client_retry_control.c.o [ 28%] Building C object out/iothub_client/CMakeFiles/iothub_client_mqtt_ws_transport.dir/src/iothub_transport_ll_private.c.o [ 28%] Building C object out/iothub_client/CMakeFiles/iothub_client_mqtt_ws_transport.dir/src/iothubtransport_mqtt_common.c.o [ 28%] Building C object out/iothub_client/CMakeFiles/iothub_client_mqtt_ws_transport.dir/src/iothubtransportmqtt_websockets.c.o [ 29%] Linking C static library libiothub_client_mqtt_ws_transport.a [ 29%] Built target iothub_client_mqtt_ws_transport [ 29%] Building C object out/deps/parson/CMakeFiles/parson.dir/parson.c.o [ 29%] Linking C static library libparson.a [ 29%] Built target parson [ 29%] Building C object out/uamqp/CMakeFiles/uamqp.dir/src/amqp_definitions.c.o [ 30%] Building C object out/uamqp/CMakeFiles/uamqp.dir/src/amqp_frame_codec.c.o [ 30%] Building C object out/uamqp/CMakeFiles/uamqp.dir/src/amqp_management.c.o [ 30%] Building C object out/uamqp/CMakeFiles/uamqp.dir/src/amqpvalue.c.o [ 31%] Building C object out/uamqp/CMakeFiles/uamqp.dir/src/amqpvalue_to_string.c.o [ 31%] Building C object out/uamqp/CMakeFiles/uamqp.dir/src/async_operation.c.o [ 32%] Building C object out/uamqp/CMakeFiles/uamqp.dir/src/cbs.c.o [ 32%] Building C object out/uamqp/CMakeFiles/uamqp.dir/src/connection.c.o [ 32%] Building C object out/uamqp/CMakeFiles/uamqp.dir/src/frame_codec.c.o [ 33%] Building C object out/uamqp/CMakeFiles/uamqp.dir/src/header_detect_io.c.o In file included from /home/abertulli/two_lidars/azure-iot-sdk-c/uamqp/inc/azure_uamqp_c/server_protocol_io.h:11:0, from /home/abertulli/two_lidars/azure-iot-sdk-c/uamqp/src/header_detect_io.c:13: /opt/box-root-fs/usr/include/stdint.h:266:0: error: "SIZE_MAX" redefined [-Werror]
define SIZE_MAX (4294967295U)
In file included from /home/abertulli/two_lidars/azure-iot-sdk-c/uamqp/src/header_detect_io.c:11:0: /home/abertulli/two_lidars/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/safe_math.h:8:0: note: this is the location of the previous definition
define SIZE_MAX ((size_t)((size_t)~(size_t)0))
cc1: all warnings being treated as errors make[2]: [out/uamqp/CMakeFiles/uamqp.dir/build.make:202: out/uamqp/CMakeFiles/uamqp.dir/src/header_detect_io.c.o] Error 1 make[1]: [CMakeFiles/Makefile2:594: out/uamqp/CMakeFiles/uamqp.dir/all] Error 2 make: *** [Makefile:136: all] Error 2
Investigating in the affected files, I see:
/opt/box-root-fs/usr/include/stdint.h
(/opt/box-root-fs
is the sysroot of the compiler, in which I copied the system libraries from the target system with rsync)~/two_lidars/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/safe_math.h
(~/two_lidars/
being my project):