lf-lang / reactor-c

A reactor runtime written in C
Other
10 stars 23 forks source link

RTI build fails on arm 32-bit #447

Closed elgeeko1 closed 1 week ago

elgeeko1 commented 3 weeks ago

Platform: Raspberry Pi 4B OS: Ubuntu 22.04 32-bit LF branch: either v0.7.2 or master

Build commands:

git clone --branch v0.7.2 https://github.com/lf-lang/lingua-franca 
mkdir -p lingua-franca/core/src/main/resources/lib/c/reactor-c/core/federated/RTI/build
cd lingua-franca/core/src/main/resources/lib/c/reactor-c/core/federated/RTI/build
cmake -DAUTH=on ..
make

Expected output: happy build.

Observed output:

0.838 [  3%] Building C object CMakeFiles/lf-low-level-platform-impl.dir/lingua-franca/core/src/main/resources/lib/c/reactor-c/low_level_platform/impl/src/lf_unix_clock_support.c.o
1.406 [  6%] Building C object CMakeFiles/lf-low-level-platform-impl.dir/lingua-franca/core/src/main/resources/lib/c/reactor-c/low_level_platform/impl/src/lf_linux_support.c.o
2.046 [ 10%] Building C object CMakeFiles/lf-low-level-platform-impl.dir/lingua-franca/core/src/main/resources/lib/c/reactor-c/low_level_platform/impl/src/lf_atomic_gcc_clang.c.o
2.546 [ 13%] Building C object CMakeFiles/lf-low-level-platform-impl.dir/lingua-franca/core/src/main/resources/lib/c/reactor-c/low_level_platform/impl/src/lf_platform_util.c.o
3.047 [ 16%] Linking C static library liblf-low-level-platform-impl.a
3.381 [ 16%] Built target lf-low-level-platform-impl
3.636 [ 20%] Building C object CMakeFiles/lf-platform-impl.dir/lingua-franca/core/src/main/resources/lib/c/reactor-c/platform/impl/platform.c.o
4.135 [ 23%] Linking C static library liblf-platform-impl.a
4.476 [ 23%] Built target lf-platform-impl
4.730 [ 26%] Building C object CMakeFiles/lf-trace-impl.dir/lingua-franca/core/src/main/resources/lib/c/reactor-c/trace/impl/src/trace_impl.c.o
5.379 [ 30%] Linking C static library /lingua-franca/core/src/main/resources/lib/c/reactor-c/trace/impl/lib/lf-trace-impl.a
5.700 [ 30%] Built target lf-trace-impl
5.955 [ 33%] Building C object CMakeFiles/rti_lib.dir/rti_common.c.o
6.692 [ 36%] Building C object CMakeFiles/rti_lib.dir/rti_remote.c.o
7.799 [ 40%] Building C object CMakeFiles/rti_lib.dir/lingua-franca/core/src/main/resources/lib/c/reactor-c/core/tracepoint.c.o
8.419 [ 43%] Building C object CMakeFiles/rti_lib.dir/lingua-franca/core/src/main/resources/lib/c/reactor-c/core/utils/util.c.o
8.980 [ 46%] Building C object CMakeFiles/rti_lib.dir/lingua-franca/core/src/main/resources/lib/c/reactor-c/core/tag.c.o
9.660 [ 50%] Building C object CMakeFiles/rti_lib.dir/lingua-franca/core/src/main/resources/lib/c/reactor-c/core/clock.c.o
10.16 [ 53%] Building C object CMakeFiles/rti_lib.dir/lingua-franca/core/src/main/resources/lib/c/reactor-c/core/federated/network/net_util.c.o
10.98 [ 56%] Building C object CMakeFiles/rti_lib.dir/lingua-franca/core/src/main/resources/lib/c/reactor-c/core/utils/pqueue_base.c.o
11.62 [ 60%] Building C object CMakeFiles/rti_lib.dir/lingua-franca/core/src/main/resources/lib/c/reactor-c/core/utils/pqueue_tag.c.o
11.87 /lingua-franca/core/src/main/resources/lib/c/reactor-c/core/utils/pqueue_tag.c: In function 'pqueue_tag_get_priority':
11.88 /lingua-franca/core/src/main/resources/lib/c/reactor-c/core/utils/pqueue_tag.c:26:69: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
11.88    26 | static pqueue_pri_t pqueue_tag_get_priority(void* element) { return (pqueue_pri_t)element; }
11.88       |                                                                     ^
11.88 /lingua-franca/core/src/main/resources/lib/c/reactor-c/core/utils/pqueue_tag.c: In function 'pqueue_tag_compare':
11.88 /lingua-franca/core/src/main/resources/lib/c/reactor-c/core/utils/pqueue_tag.c:68:27: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
11.88    68 |   return (lf_tag_compare(((pqueue_tag_element_t*)priority1)->tag, ((pqueue_tag_element_t*)priority2)->tag));
11.88       |                           ^
11.88 /lingua-franca/core/src/main/resources/lib/c/reactor-c/core/utils/pqueue_tag.c:68:68: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
11.88    68 |   return (lf_tag_compare(((pqueue_tag_element_t*)priority1)->tag, ((pqueue_tag_element_t*)priority2)->tag));
11.88       |                                                                    ^
12.11 cc1: all warnings being treated as errors
12.11 make[2]: *** [CMakeFiles/rti_lib.dir/build.make:188: CMakeFiles/rti_lib.dir/lingua-franca/core/src/main/resources/lib/c/reactor-c/core/utils/pqueue_tag.c.o] Error 1
12.12 make[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/rti_lib.dir/all] Error 2
12.12 make: *** [Makefile:146: all] Error 2

The same build steps work for linux/amd64, linux/arm64, and linux/riscv64.

petervdonovan commented 3 weeks ago

This has more or less been a known issue -- the casts being done here do not really make sense. This actually should be OK because we are casting from a 32-bit pointer to a 64-bit integer, and we can just work around it by tweaking the error reporting settings in the C compiler, but I don't know why we wouldn't just fix this the right way (by storing pointers in the priority queue instead of integers).

edwardalee commented 1 week ago

I provided a solution in PR #450.