Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Got compiling errors when use arm gcc on Ubuntu 22 #52

Closed
JunhongMao opened this issue Aug 5, 2024 · 4 comments
Closed

Got compiling errors when use arm gcc on Ubuntu 22 #52

JunhongMao opened this issue Aug 5, 2024 · 4 comments

Comments

@JunhongMao
Copy link
Contributor

JunhongMao commented Aug 5, 2024

1 OS and environment.

$ lsb_release  -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.2 LTS
Release:        22.04
Codename:       jammy

$ sudo apt-get install gcc-arm-linux-gnueabi
$ sudo apt-get install gcc-arm-linux-gnueabihf


$ arm-linux-gnueabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabi/11/lto-wrapper
Target: arm-linux-gnueabi
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.4.0-1ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --with-system-zlib --enable-libphobos-checking=release --without-target-system-zlib --enable-multiarch --disable-sjlj-exceptions --with-specs='%{mfloat-abi=hard:-march=armv7-a -mcpu=generic-armv7-a -mfloat-abi=hard}' --with-arch=armv5t --with-float=soft --disable-werror --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabi --program-prefix=arm-linux-gnueabi- --includedir=/usr/arm-linux-gnueabi/include --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)


$ arm-linux-gnueabihf-gcc -v
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabihf/11/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.4.0-1ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --without-target-system-zlib --enable-multiarch --disable-sjlj-exceptions --with-arch=armv7-a+fp --with-float=hard --with-mode=thumb --disable-werror --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabihf --program-prefix=arm-linux-gnueabihf- --includedir=/usr/arm-linux-gnueabihf/include --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)

2 Upgrade Makefile by using arm-linux-gnueabi-gcc

$ git diff Makefile
diff --git a/Makefile b/Makefile
index 621b36c..359d401 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,6 @@

 PREFIX?=/usr/local
+export CC = arm-linux-gnueabi-gcc

 DESTDIR?=
 INSTALL = /usr/bin/install -c

3 Compile

$ git submodule update --init --recursive
$ make

handlersToJson.c: In function ‘toJsonSlotInfo’:
handlersToJson.c:176:48: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
  176 |     fprintf(ctx->outfile, "      \"slotId\": %lu,\n", info->slot_id);
      |                                              ~~^      ~~~~~~~~~~~~~
      |                                                |          |
      |                                                |          uint64_t {aka long long unsigned int}
      |                                                long unsigned int
      |                                              %llu
handlersToJson.c:177:50: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
  177 |     fprintf(ctx->outfile, "      \"slotSize\": %lu,\n", info->slot_size);
      |                                                ~~^      ~~~~~~~~~~~~~~~
      |                                                  |          |
      |                                                  |          uint64_t {aka long long unsigned int}
      |                                                  long unsigned int
      |                                                %llu
handlersToJson.c:178:58: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
  178 |     fprintf(ctx->outfile, "      \"slotSExpiresSize\": %lu\n", info->expires_slot_size);
      |                                                        ~~^     ~~~~~~~~~~~~~~~~~~~~~~~
      |                                                          |         |
      |                                                          |         uint64_t {aka long long unsigned int}
      |                                                          long unsigned int
      |                                                        %llu
handlersToJson.c: In function ‘toJsonModule’:
handlersToJson.c:356:87: error: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘size_t’ {aka ‘unsigned int’} [-Werror=format=]
  356 |     fprintf(ctx->outfile, "\"<Content of Module '%s'. Occupies a serialized size of %ld bytes>\"",
      |                                                                                     ~~^
      |                                                                                       |
      |                                                                                       long int
      |                                                                                     %d
  357 |             moduleName,
  358 |             serializedSize);
      |             ~~~~~~~~~~~~~~
      |             |
      |             size_t {aka unsigned int}
handlersToJson.c: In function ‘toJsonStreamItem’:
handlersToJson.c:535:57: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
  535 |         fprintf(ctx->outfile, "%c\n        { \"id\":\"%lu-%lu\", ",
      |                                                       ~~^
      |                                                         |
      |                                                         long unsigned int
      |                                                       %llu
  536 |                 (ctx->state == R2J_IN_STREAM_ENTRIES) ? ',' : ' ',
  537 |                 id->ms, id->seq );
      |                 ~~~~~~
      |                   |
      |                   uint64_t {aka long long unsigned int}
handlersToJson.c:535:61: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 5 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
  535 |         fprintf(ctx->outfile, "%c\n        { \"id\":\"%lu-%lu\", ",
      |                                                           ~~^
      |                                                             |
      |                                                             long unsigned int
      |                                                           %llu
  536 |                 (ctx->state == R2J_IN_STREAM_ENTRIES) ? ',' : ' ',
  537 |                 id->ms, id->seq );
      |                         ~~~~~~~
      |                           |
      |                           uint64_t {aka long long unsigned int}
handlersToJson.c: In function ‘toJsonStreamMetadata’:
handlersToJson.c:573:52: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
  573 |     fprintf(ctx->outfile, "],\n      \"length\": %lu, ", meta->length);
      |                                                  ~~^     ~~~~~~~~~~~~
      |                                                    |         |
      |                                                    |         uint64_t {aka long long unsigned int}
      |                                                    long unsigned int
      |                                                  %llu
handlersToJson.c:574:56: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
  574 |     fprintf(ctx->outfile, "\n      \"entriesAdded\": %lu, ", meta->entriesAdded);
      |                                                      ~~^     ~~~~~~~~~~~~~~~~~~
      |                                                        |         |
      |                                                        |         uint64_t {aka long long unsigned int}
      |                                                        long unsigned int
      |                                                      %llu
handlersToJson.c:575:53: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
  575 |     fprintf(ctx->outfile, "\n      \"firstID\": \"%lu-%lu\", ", meta->firstID.ms, meta->firstID.seq);
      |                                                   ~~^           ~~~~~~~~~~~~~~~~
      |                                                     |                        |
      |                                                     long unsigned int        uint64_t {aka long long unsigned int}
      |                                                   %llu
handlersToJson.c:575:57: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
  575 |     fprintf(ctx->outfile, "\n      \"firstID\": \"%lu-%lu\", ", meta->firstID.ms, meta->firstID.seq);
      |                                                       ~~^                         ~~~~~~~~~~~~~~~~~
      |                                                         |                                      |
      |                                                         long unsigned int                      uint64_t {aka long long unsigned int}
      |                                                       %llu
handlersToJson.c:576:52: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
  576 |     fprintf(ctx->outfile, "\n      \"lastID\": \"%lu-%lu\", ", meta->lastID.ms, meta->lastID.seq);
      |                                                  ~~^           ~~~~~~~~~~~~~~~
      |                                                    |                       |
      |                                                    long unsigned int       uint64_t {aka long long unsigned int}
      |                                                  %llu
handlersToJson.c:576:56: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
  576 |     fprintf(ctx->outfile, "\n      \"lastID\": \"%lu-%lu\", ", meta->lastID.ms, meta->lastID.seq);
      |                                                      ~~^                        ~~~~~~~~~~~~~~~~
      |                                                        |                                    |
      |                                                        long unsigned int                    uint64_t {aka long long unsigned int}
      |                                                      %llu
handlersToJson.c:577:59: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
  577 |     fprintf(ctx->outfile, "\n      \"maxDelEntryID\": \"%lu-%lu\",", meta->maxDelEntryID.ms, meta->maxDelEntryID.seq);
      |                                                         ~~^          ~~~~~~~~~~~~~~~~~~~~~~
      |                                                           |                             |
      |                                                           long unsigned int             uint64_t {aka long long unsigned int}
      |                                                         %llu
handlersToJson.c:577:63: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
  577 |     fprintf(ctx->outfile, "\n      \"maxDelEntryID\": \"%lu-%lu\",", meta->maxDelEntryID.ms, meta->maxDelEntryID.seq);
      |                                                             ~~^                              ~~~~~~~~~~~~~~~~~~~~~~~
      |                                                               |                                                 |
      |                                                               long unsigned int                                 uint64_t {aka long long unsigned int}
      |                                                             %llu
handlersToJson.c: In function ‘toJsonStreamNewCGroup’:
handlersToJson.c:599:73: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 5 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
  599 |     fprintf(ctx->outfile, "%s        {\"name\": \"%s\", \"lastid\": \"%lu-%lu\", \"entriesRead\": %lu",
      |                                                                       ~~^
      |                                                                         |
      |                                                                         long unsigned int
      |                                                                       %llu
  600 |             prefix, grpName, meta->lastId.ms, meta->lastId.seq, meta->entriesRead);
      |                              ~~~~~~~~~~~~~~~
      |                                          |
      |                                          uint64_t {aka long long unsigned int}
handlersToJson.c:599:77: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
  599 |     fprintf(ctx->outfile, "%s        {\"name\": \"%s\", \"lastid\": \"%lu-%lu\", \"entriesRead\": %lu",
      |                                                                           ~~^
      |                                                                             |
      |                                                                             long unsigned int
      |                                                                           %llu
  600 |             prefix, grpName, meta->lastId.ms, meta->lastId.seq, meta->entriesRead);
      |                                               ~~~~~~~~~~~~~~~~
      |                                                           |
      |                                                           uint64_t {aka long long unsigned int}
handlersToJson.c:599:101: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 7 has type ‘int64_t’ {aka ‘long long int’} [-Werror=format=]
  599 |     fprintf(ctx->outfile, "%s        {\"name\": \"%s\", \"lastid\": \"%lu-%lu\", \"entriesRead\": %lu",
      |                                                                                                   ~~^
      |                                                                                                     |
      |                                                                                                     long unsigned int
      |                                                                                                   %llu
  600 |             prefix, grpName, meta->lastId.ms, meta->lastId.seq, meta->entriesRead);
      |                                                                 ~~~~~~~~~~~~~~~~~
      |                                                                     |
      |                                                                     int64_t {aka long long int}
handlersToJson.c: In function ‘toJsonStreamCGroupPendingEntry’:
handlersToJson.c:619:57: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
  619 |     fprintf(ctx->outfile, "%s\n           { \"sent\": %lu, \"id\":\"%lu-%lu\", \"count\": %lu }",
      |                                                       ~~^
      |                                                         |
      |                                                         long unsigned int
      |                                                       %llu
  620 |             prefix, pe->deliveryTime, pe->id.ms, pe->id.seq, pe->deliveryCount);
      |                     ~~~~~~~~~~~~~~~~
      |                       |
      |                       uint64_t {aka long long unsigned int}
handlersToJson.c:619:71: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 5 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
  619 |     fprintf(ctx->outfile, "%s\n           { \"sent\": %lu, \"id\":\"%lu-%lu\", \"count\": %lu }",
      |                                                                     ~~^
      |                                                                       |
      |                                                                       long unsigned int
      |                                                                     %llu
  620 |             prefix, pe->deliveryTime, pe->id.ms, pe->id.seq, pe->deliveryCount);
      |                                       ~~~~~~~~~
      |                                             |
      |                                             uint64_t {aka long long unsigned int}
handlersToJson.c:619:75: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
  619 |     fprintf(ctx->outfile, "%s\n           { \"sent\": %lu, \"id\":\"%lu-%lu\", \"count\": %lu }",
      |                                                                         ~~^
      |                                                                           |
      |                                                                           long unsigned int
      |                                                                         %llu
  620 |             prefix, pe->deliveryTime, pe->id.ms, pe->id.seq, pe->deliveryCount);
      |                                                  ~~~~~~~~~~
      |                                                        |
      |                                                        uint64_t {aka long long unsigned int}
handlersToJson.c:619:93: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 7 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
  619 |     fprintf(ctx->outfile, "%s\n           { \"sent\": %lu, \"id\":\"%lu-%lu\", \"count\": %lu }",
      |                                                                                           ~~^
      |                                                                                             |
      |                                                                                             long unsigned int
      |                                                                                           %llu
  620 |             prefix, pe->deliveryTime, pe->id.ms, pe->id.seq, pe->deliveryCount);
      |                                                              ~~~~~~~~~~~~~~~~~
      |                                                                |
      |                                                                uint64_t {aka long long unsigned int}
handlersToJson.c: In function ‘toJsonStreamConsumerPendingEntry’:
handlersToJson.c:662:59: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
  662 |     fprintf(ctx->outfile, "%s\n               {\"id\":\"%lu-%lu\"}", prefix, streamId->ms, streamId->seq);
      |                                                         ~~^                  ~~~~~~~~~~~~
      |                                                           |                          |
      |                                                           long unsigned int          uint64_t {aka long long unsigned int}
      |                                                         %llu
handlersToJson.c:662:63: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 5 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
  662 |     fprintf(ctx->outfile, "%s\n               {\"id\":\"%lu-%lu\"}", prefix, streamId->ms, streamId->seq);
      |                                                             ~~^                            ~~~~~~~~~~~~~
      |                                                               |                                    |
      |                                                               long unsigned int                    uint64_t {aka long long unsigned int}
      |                                                             %llu
cc1: all warnings being treated as errors
make[1]: *** [Makefile:51: handlersToJson.o] Error 1
make[1]: Leaving directory '~/rdb/librdb/src/ext'
make: *** [Makefile:29: all] Error 2

4 Update the Makefile by arm-linux-gnueabihf-gcc

$ git diff
diff --git a/Makefile b/Makefile
index 621b36c..ee2849a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-
+export CC=arm-linux-gnueabihf-gcc
 PREFIX?=/usr/local

 DESTDIR?=

5 Compile

$ make
make[1]: Entering directory 'librdb/src/lib'
arm-linux-gnueabihf-gcc -fPIC -fPIC -O3 -std=c99 -fstack-protector-all -Wstack-protector -Wall -Wextra -pedantic -Werror -fvisibility=hidden -DNDEBUG=1 -c parser.c -o parser.o -g3
parser.c: In function ‘elementModule’:
parser.c:2181:71: error: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
 2181 |                             "elementModule() : Invalid when opcode: %ld.", when_opcode);
      |                                                                     ~~^    ~~~~~~~~~~~
      |                                                                       |    |
      |                                                                       |    uint64_t {aka long long unsigned int}
      |                                                                       long int
      |                                                                     %lld
cc1: all warnings being treated as errors
make[1]: *** [Makefile:52: parser.o] Error 1

@JunhongMao JunhongMao changed the title Got compiling erros when use arm-linux-gnueabi-gcc on Ubuntu 22 Got compiling errors when use arm-linux-gnueabi-gcc on Ubuntu 22 Aug 5, 2024
@JunhongMao
Copy link
Contributor Author

I'm glad to fix this issue. Please assign it to me.

@moticless
Copy link
Collaborator

Hi @JunhongMao, thank you for your willingness to help! Feel free to open a PR whenever you're ready. I'm curious about what changes we can make to the CI to catch this next time. Thanks!

@JunhongMao
Copy link
Contributor Author

Hi @moticless , no problem. I will. I guess the CI can catch this when building with the environment below:

export CC = arm-linux-gnueabi-gcc

JunhongMao added a commit to JunhongMao/librdb that referenced this issue Aug 15, 2024
JunhongMao added a commit to JunhongMao/librdb that referenced this issue Aug 15, 2024
JunhongMao added a commit to JunhongMao/librdb that referenced this issue Aug 15, 2024
JunhongMao added a commit to JunhongMao/librdb that referenced this issue Aug 15, 2024
@JunhongMao JunhongMao changed the title Got compiling errors when use arm-linux-gnueabi-gcc on Ubuntu 22 Got compiling errors when use arm gcc on Ubuntu 22 Aug 15, 2024
JunhongMao added a commit to JunhongMao/librdb that referenced this issue Aug 15, 2024
JunhongMao added a commit to JunhongMao/librdb that referenced this issue Aug 15, 2024
JunhongMao added a commit to JunhongMao/librdb that referenced this issue Aug 16, 2024
@moticless
Copy link
Collaborator

This issue has been resolved by PR #54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants