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

Compiler Error w/ GCC 8.1 on RHEL-latest #4741

Closed
victorstewart opened this issue May 15, 2018 · 12 comments
Closed

Compiler Error w/ GCC 8.1 on RHEL-latest #4741

victorstewart opened this issue May 15, 2018 · 12 comments

Comments

@victorstewart
Copy link

victorstewart commented May 15, 2018

Let me know if you need any further info.

-- The C compiler identification is GNU 8.1.0
-- The CXX compiler identification is GNU 8.1.0
-- Check for working C compiler: /usr/local/bin/gcc
-- Check for working C compiler: /usr/local/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/local/bin/c++
-- Check for working CXX compiler: /usr/local/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /root/libraries/flatbuffers-1.9.0
Scanning dependencies of target flatbuffers
[  2%] Building CXX object CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o
In file included from /root/libraries/flatbuffers-1.9.0/include/flatbuffers/flexbuffers.h:24,
                 from /root/libraries/flatbuffers-1.9.0/include/flatbuffers/idl.h:26,
                 from /root/libraries/flatbuffers-1.9.0/include/flatbuffers/code_generators.h:22,
                 from /root/libraries/flatbuffers-1.9.0/src/code_generators.cpp:17:
/root/libraries/flatbuffers-1.9.0/include/flatbuffers/util.h: In function 'int flatbuffers::FromUTF8(const char**)':
/root/libraries/flatbuffers-1.9.0/include/flatbuffers/util.h:324:45: error: type qualifiers ignored on cast result type [-Werror=ignored-qualifiers]
   if ((static_cast<const unsigned char>(**in) << len) & 0x80) return -1;  // Bit after leading 1's must be 0.
                                             ^
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/flatbuffers.dir/src/code_generators.cpp.o] Error 1
make[1]: *** [CMakeFiles/flatbuffers.dir/all] Error 2
make: *** [all] Error 2
@victorstewart
Copy link
Author

when I clone the git repository, everything is good! Just the last release doesn't include the const tweaks.

@aardappel
Copy link
Collaborator

Yes, sounds like this was already fixed. So far we've never backported fixes to releases (I don't think we'd have the bandwidth), and just relied on people using master instead.

@glensc
Copy link

glensc commented Sep 10, 2018

#4698 fixes this.

glensc added a commit to pld-linux/flatbuffers that referenced this issue Sep 10, 2018
@geraldstanje
Copy link

geraldstanje commented May 7, 2019

FROM golang:1.12.4-alpine3.9

ARG FB_VERSION="v1.9.0"

RUN apk update && apk upgrade \
    && apk add curl ca-certificates git build-base cmake bash docker \
    && git clone --branch ${FB_VERSION} --depth 1 https://github.com/google/flatbuffers.git /opt/flatbuffers \
    && go get -u github.com/jstemmer/go-junit-report github.com/jteeuwen/go-bindata/... \
                 github.com/mailru/easyjson/... github.com/golang/dep/cmd/dep \
    && rm -rf /var/cache/apk/*

WORKDIR /opt/flatbuffers

RUN cmake -G  "Unix Makefiles" \
    && make \
    && ./flattests \
    && make install \
    && cp flatc /bin/
(17/51) Installing gcc (8.3.0-r0)
...

[  2%] Building CXX object CMakeFiles/flatc.dir/src/code_generators.cpp.o
In file included from /opt/flatbuffers/include/flatbuffers/flexbuffers.h:24,
                 from /opt/flatbuffers/include/flatbuffers/idl.h:26,
                 from /opt/flatbuffers/include/flatbuffers/code_generators.h:22,
                 from /opt/flatbuffers/src/code_generators.cpp:17:
/opt/flatbuffers/include/flatbuffers/util.h: In function 'int flatbuffers::FromUTF8(const char**)':
/opt/flatbuffers/include/flatbuffers/util.h:324:45: error: type qualifiers ignored on cast result type [-Werror=ignored-qualifiers]
   if ((static_cast<const unsigned char>(**in) << len) & 0x80) return -1;  // Bit after leading 1's must be 0.
                                             ^
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/flatc.dir/build.make:63: CMakeFiles/flatc.dir/src/code_generators.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/flatc.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

i see same error with gcc 8.3. how to fix it?

@vglavnyy
Copy link
Contributor

vglavnyy commented May 8, 2019

Fast workaround: remove const qualifier. This qualifier is ignored by the compiler.
if ((static_cast<unsigned char>(**in) << len) & 0x80) return -1;

@vglavnyy
Copy link
Contributor

vglavnyy commented May 8, 2019

Can't reproduce this error.
Ubuntu 18.04, GCC 8.3.0, have added -Werror=ignored-qualifiers to CMAKE_CXX_FLAGS.

inline int FromUTF8(const char **in) {
int len = 0;
// Count leading 1 bits.
for (int mask = 0x80; mask >= 0x04; mask >>= 1) {
if (**in & mask) {
len++;
} else {
break;
}
}
if ((static_cast<unsigned char>(**in) << len) & 0x80)
return -1; // Bit after leading 1's must be 0.
if (!len) return *(*in)++;
// UTF-8 encoded values with a length are between 2 and 4 bytes.

You are using an old version of Flatbuffers.

@geraldstanje
Copy link

geraldstanje commented May 8, 2019

@vglavnyy you cannot reproduce it? try using: golang:1.12.4-alpine3.9 + dont add: -Werror=ignored-qualifiers !?

can you reproduce it with this docker file?

FROM golang:1.12.4-alpine3.9

ARG FB_VERSION="v1.9.0"

RUN apk update && apk upgrade \
    && apk add curl ca-certificates git build-base cmake bash docker \
    && git clone --branch ${FB_VERSION} --depth 1 https://github.com/google/flatbuffers.git /opt/flatbuffers \
    && rm -rf /var/cache/apk/*

WORKDIR /opt/flatbuffers

RUN cmake -G  "Unix Makefiles" \
    && make \
    && ./flattests \
    && make install \
    && cp flatc /bin/

is flatbuffer 1.10 backwards compatible with 1.9?

i also see some errors when i use flatbuffer 1.11:

In file included from /opt/flatbuffers/include/flatbuffers/flexbuffers.h:24,
                 from /opt/flatbuffers/include/flatbuffers/idl.h:26,
                 from /opt/flatbuffers/include/flatbuffers/code_generators.h:22,
                 from /opt/flatbuffers/src/code_generators.cpp:17:
/opt/flatbuffers/include/flatbuffers/util.h: In function 'void flatbuffers::strtoval_impl(int64_t*, const char*, char**, int)':
/opt/flatbuffers/include/flatbuffers/util.h:228:38: error: 'strtoll_l' was not declared in this scope
     #define __strtoll_impl(s, pe, b) strtoll_l(s, pe, b, ClassicLocale::Get())
                                      ^~~~~~~~~
/opt/flatbuffers/include/flatbuffers/util.h:246:12: note: in expansion of macro '__strtoll_impl'
     *val = __strtoll_impl(str, endptr, base);
            ^~~~~~~~~~~~~~
/opt/flatbuffers/include/flatbuffers/util.h:228:38: note: suggested alternative: 'strcoll_l'
     #define __strtoll_impl(s, pe, b) strtoll_l(s, pe, b, ClassicLocale::Get())
                                      ^~~~~~~~~
/opt/flatbuffers/include/flatbuffers/util.h:246:12: note: in expansion of macro '__strtoll_impl'
     *val = __strtoll_impl(str, endptr, base);
            ^~~~~~~~~~~~~~
/opt/flatbuffers/include/flatbuffers/util.h: In function 'void flatbuffers::strtoval_impl(uint64_t*, const char*, char**, int)':
/opt/flatbuffers/include/flatbuffers/util.h:227:39: error: 'strtoull_l' was not declared in this scope
     #define __strtoull_impl(s, pe, b) strtoull_l(s, pe, b, ClassicLocale::Get())
                                       ^~~~~~~~~~
/opt/flatbuffers/include/flatbuffers/util.h:251:10: note: in expansion of macro '__strtoull_impl'
   *val = __strtoull_impl(str, endptr, base);
          ^~~~~~~~~~~~~~~
/opt/flatbuffers/include/flatbuffers/util.h:227:39: note: suggested alternative: 'strcoll_l'
     #define __strtoull_impl(s, pe, b) strtoull_l(s, pe, b, ClassicLocale::Get())
                                       ^~~~~~~~~~
/opt/flatbuffers/include/flatbuffers/util.h:251:10: note: in expansion of macro '__strtoull_impl'
   *val = __strtoull_impl(str, endptr, base);
          ^~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/flatc.dir/build.make:63: CMakeFiles/flatc.dir/src/code_generators.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/flatc.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

@vglavnyy
Copy link
Contributor

vglavnyy commented May 8, 2019

I have tested with 1.11.00.
The unnecessary const qualifier was removed by #4698 (86153fd, release tag 1.10.0).

is flatbuffer 1.10 backwards compatible with 1.9?

Yes, should be compatible.

i also see some errors when i use flatbuffer 1.11:

How to reproduce this?
Looks line FLATBUFFERS_LOCALE_INDEPENDENT is defined and greater than zero.
There is only one definition point for this PPD:

# Auto-detect locale-narrow 'strtod_l' function.
if(NOT DEFINED FLATBUFFERS_LOCALE_INDEPENDENT)
if(MSVC)
check_cxx_symbol_exists(_strtof_l stdlib.h FLATBUFFERS_LOCALE_INDEPENDENT)
else()
check_cxx_symbol_exists(strtof_l stdlib.h FLATBUFFERS_LOCALE_INDEPENDENT)
endif()
endif()
add_definitions(-DFLATBUFFERS_LOCALE_INDEPENDENT=$<BOOL:${FLATBUFFERS_LOCALE_INDEPENDENT}>)

It is assumed that if stdlib has strtof_l then strtoull_l has too.
What version of stdlib you are using with GCC 8.3.0?
Can you attach cmake output log?

Workaround:
Add -DFLATBUFFERS_LOCALE_INDEPENDENT=0 to cmake command line arguments to disable this PPD.

@geraldstanje
Copy link

geraldstanje commented May 8, 2019

For 1.11 you can reproduce it using, are you able to run the docker file?

FROM golang:1.12.4-alpine3.9

ARG FB_VERSION="v1.11.0"

RUN apk update && apk upgrade \
    && apk add curl ca-certificates git build-base cmake bash docker \
    && git clone --branch ${FB_VERSION} --depth 1 https://github.com/google/flatbuffers.git /opt/flatbuffers \
    && rm -rf /var/cache/apk/*

WORKDIR /opt/flatbuffers

RUN cmake -G  "Unix Makefiles" \
    && make \
    && ./flattests \
    && make install \
    && cp flatc /bin/

... as you see it will run: Installing gcc (8.3.0-r0)

@vglavnyy
Copy link
Contributor

vglavnyy commented May 8, 2019

Ok, I will check today.
I have gcc-8 (Ubuntu 8.3.0-6ubuntu1~18.04) 8.3.0, all passed without errors.
Another test with gcc 8.3 (https://godbolt.org/z/0_WuRh)

@vglavnyy
Copy link
Contributor

vglavnyy commented May 8, 2019

This docker image does not have glibc package.
Thank you for the report.

Workaround:

RUN cmake .. -G  "Unix Makefiles" -DFLATBUFFERS_LOCALE_INDEPENDENT=0 \
    && make \
    && ./flattests \
    && make install \
    && cp flatc /bin/

@geraldstanje
Copy link

geraldstanje commented May 8, 2019

@vglavnyy thank u! is it safe to upgrade from flatbuffer 1.9 to 1.10 or 1.11? do you guys support backwards compability?

the workaround seems not to work?

FROM golang:1.12.4-alpine3.9

ARG FB_VERSION="v1.9.0"

RUN apk update && apk upgrade \
    && apk add curl ca-certificates git build-base cmake bash docker \
    && git clone --branch ${FB_VERSION} --depth 1 https://github.com/google/flatbuffers.git /opt/flatbuffers \
    && rm -rf /var/cache/apk/*

WORKDIR /opt/flatbuffers

RUN cmake -G  "Unix Makefiles" -DFLATBUFFERS_LOCALE_INDEPENDENT=0 \
    && make \
    && ./flattests \
    && make install \
    && cp flatc /bin/
Step 5/8 : RUN cmake -G  "Unix Makefiles" -DFLATBUFFERS_LOCALE_INDEPENDENT=0     && make     && ./flattests     && make install     && cp flatc /bin/
 ---> Running in 071443e69fd3
-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is GNU 8.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    FLATBUFFERS_LOCALE_INDEPENDENT


-- Build files have been written to: /opt/flatbuffers
Scanning dependencies of target flatc
[  2%] Building CXX object CMakeFiles/flatc.dir/src/code_generators.cpp.o
In file included from /opt/flatbuffers/include/flatbuffers/flexbuffers.h:24,
                 from /opt/flatbuffers/include/flatbuffers/idl.h:26,
                 from /opt/flatbuffers/include/flatbuffers/code_generators.h:22,
                 from /opt/flatbuffers/src/code_generators.cpp:17:
/opt/flatbuffers/include/flatbuffers/util.h: In function 'int flatbuffers::FromUTF8(const char**)':
/opt/flatbuffers/include/flatbuffers/util.h:324:45: error: type qualifiers ignored on cast result type [-Werror=ignored-qualifiers]
   if ((static_cast<const unsigned char>(**in) << len) & 0x80) return -1;  // Bit after leading 1's must be 0.
                                             ^
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/flatc.dir/build.make:63: CMakeFiles/flatc.dir/src/code_generators.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/flatc.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

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

5 participants