Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

add -Wno-error=implicit-fallthrough and -Wno-error=switch-default to CMAKE_CXX_FLAGS #729

Merged
merged 4 commits into from
Jun 5, 2018

Conversation

mxmilkiib
Copy link
Contributor

fixes half of #726

@morphis
Copy link
Member

morphis commented May 27, 2018

Ubuntu 16.04 doesn't like this as it seems

cc1plus: error: -Werror=implicit-fallthrough: no option -Wimplicit-fallthrough

Looks like we need to find another solution or make this conditional on the used GCC version.

@morphis
Copy link
Member

morphis commented May 28, 2018

Looks like -Wno-error=switch-default does what we want on 16.04. Does that work with newer GCC versions too?

@mxmilkiib
Copy link
Contributor Author

with GCC8 plus both -Wno-error=switch-default and -Wno-error=implicit-fallthrough, the build works.

@morphis
Copy link
Member

morphis commented May 30, 2018

@milkmiruku Are you going to update the PR with that?

@mxmilkiib mxmilkiib changed the title add -Wno-error=implicit-fallthrough to CMAKE_CXX_FLAGS add -Wno-error=implicit-fallthrough and -Wno-error=switch-default to CMAKE_CXX_FLAGS May 30, 2018
@daedroza
Copy link

daedroza commented Jun 1, 2018

@milkmiruku : Please remove -Wno-error=implicit-fallthrough first & then add -Wno-error=switch-default, since the switch-default works for both GCC versions.

@mxmilkiib
Copy link
Contributor Author

without both -Wno-error=switch-default and -Wno-error=implicit-fallthrough, the build fails.

on having just -Wno-error=switch-default, i get;

[ 35%] Building CXX object external/backtrace-cpp/CMakeFiles/backward_object.dir/backward.cpp.o
In file included from /home/milk/pkgs/anbox-git/src/anbox/external/backtrace-cpp/backward.cpp:26:
/home/milk/pkgs/anbox-git/src/anbox/external/backtrace-cpp/backward.hpp: In member function ‘void backward::StackTraceLinuxImplBase::load_thread_info()’:
/home/milk/pkgs/anbox-git/src/anbox/external/backtrace-cpp/backward.hpp:517:37: warning: use of old-style cast to ‘size_t’ {aka ‘long unsigned int’} [-Wold-style-cast]
   if (_thread_id == (size_t) getpid()) {
                                     ^
                     -----------------
                     static_cast<size_t> ( getpid())
/home/milk/pkgs/anbox-git/src/anbox/external/backtrace-cpp/backward.hpp: In static member function ‘static _Unwind_Reason_Code backward::details::Unwinder<F>::backtrace_trampoline(_Unwind_Context*, void*)’:
/home/milk/pkgs/anbox-git/src/anbox/external/backtrace-cpp/backward.hpp:576:22: warning: use of old-style cast to ‘class backward::details::Unwinder<F>*’ [-Wold-style-cast]
   return ((Unwinder*)self)->backtrace(ctx);
                      ^~~~
/home/milk/pkgs/anbox-git/src/anbox/external/backtrace-cpp/backward.hpp: In member function ‘_Unwind_Reason_Code backward::details::Unwinder<F>::backtrace(_Unwind_Context*)’:
/home/milk/pkgs/anbox-git/src/anbox/external/backtrace-cpp/backward.hpp:591:25: warning: use of old-style cast to ‘void*’ [-Wold-style-cast]
    (*_f)(_index, (void*)ip);
                         ^~
/home/milk/pkgs/anbox-git/src/anbox/external/backtrace-cpp/backward.hpp: In member function ‘backward::ResolvedTrace backward::TraceResolverLinuxImpl<backward::trace_resolver_tag::libdw>::resolve(backward::ResolvedTrace)’:
/home/milk/pkgs/anbox-git/src/anbox/external/backtrace-cpp/backward.hpp:1153:46: warning: use of old-style cast to ‘Dwarf_Addr’ {aka ‘long unsigned int’} [-Wold-style-cast]
   Dwarf_Addr trace_addr = (Dwarf_Addr) trace.addr;
                                              ^~~~
                           -----------------------
                           reinterpret_cast<Dwarf_Addr> ( trace.addr)
/home/milk/pkgs/anbox-git/src/anbox/external/backtrace-cpp/backward.hpp: In member function ‘void backward::TraceResolverLinuxImpl<backward::trace_resolver_tag::libdw>::inliners_search_cb::operator()(Dwarf_Die*)’:
/home/milk/pkgs/anbox-git/src/anbox/external/backtrace-cpp/backward.hpp:1312:11: warning: switch missing default case [-Wswitch-default]
    switch (dwarf_tag(die)) {
           ^
/home/milk/pkgs/anbox-git/src/anbox/external/backtrace-cpp/backward.hpp: In member function ‘void backward::Printer::print_source_loc(FILE*, const char*, const backward::ResolvedTrace::SourceLoc&, void*)’:
/home/milk/pkgs/anbox-git/src/anbox/external/backtrace-cpp/backward.hpp:1852:58: warning: use of old-style cast to ‘int’ [-Wold-style-cast]
     indent, source_loc.filename.c_str(), (int)source_loc.line,
                                                          ^~~~
                                          -----
                                          static_cast<int> (  )
/home/milk/pkgs/anbox-git/src/anbox/external/backtrace-cpp/backward.hpp: In constructor ‘backward::SignalHandling::SignalHandling(const std::vector<int>&)’:
/home/milk/pkgs/anbox-git/src/anbox/external/backtrace-cpp/backward.hpp:1908:48: warning: use of old-style cast to ‘char*’ [-Wold-style-cast]
   _stack_content.reset((char*)malloc(stack_size));
                                                ^
                        -------
                        static_cast<char*> (     )
/home/milk/pkgs/anbox-git/src/anbox/external/backtrace-cpp/backward.hpp: In static member function ‘static void backward::SignalHandling::sig_handler(int, siginfo_t*, void*)’:
/home/milk/pkgs/anbox-git/src/anbox/external/backtrace-cpp/backward.hpp:1944:36: warning: use of old-style cast to ‘ucontext_t*’ {aka ‘struct ucontext_t*’} [-Wold-style-cast]
   ucontext_t *uctx = (ucontext_t*) _ctx;
                                    ^~~~
                      -
                      static_cast<-
                                  > (   )
/home/milk/pkgs/anbox-git/src/anbox/external/backtrace-cpp/backward.hpp: In static member function ‘static Dwarf_Die* backward::TraceResolverLinuxImpl<backward::trace_resolver_tag::libdw>::find_fundie_by_pc(Dwarf_Die*, Dwarf_Addr, Dwarf_Die*)’:
/home/milk/pkgs/anbox-git/src/anbox/external/backtrace-cpp/backward.hpp:1391:6: error: this statement may fall through [-Werror=implicit-fallthrough=]
      if (die_has_pc(die, pc)) {
      ^~
/home/milk/pkgs/anbox-git/src/anbox/external/backtrace-cpp/backward.hpp:1394:5: note: here
     default:
     ^~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [external/backtrace-cpp/CMakeFiles/backward_object.dir/build.make:63: external/backtrace-cpp/CMakeFiles/backward_object.dir/backward.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1763: external/backtrace-cpp/CMakeFiles/backward_object.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
==> ERROR: A failure occurred in build().

though I can make the change to just -Wno-error=switch-default if the plan isn't to target GCC8 just yet, and recommend to the AUR PKGBUILD maintainer to patch in -Wno-error=implicit-fallthrough

@morphis
Copy link
Member

morphis commented Jun 4, 2018

though I can make the change to just -Wno-error=switch-default if the plan isn't to target GCC8 just yet, and recommend to the AUR PKGBUILD maintainer to patch in -Wno-error=implicit-fallthrough

The minimum required GCC version is what is shipped in Ubuntu 16.04. If you don't want to recommend the Arch maintainers to patch Anbox we can detect the GCC version in cmake and add the right flag depending on the version we find.

@mxmilkiib
Copy link
Contributor Author

I've removed -Wno-error=implicit-fallthrough. I'm not familiar with cmake so will leave the conditional aspect to someone else. anbox-git is the AUR entry (Arch User Repo, rather than official core/extra/community Arch maintainer packages). I'll leave a comment there reflecting the situation. Thanks folks for the assistance :)

@morphis
Copy link
Member

morphis commented Jun 5, 2018

@milkmiruku Thanks for all the work!

@HaoZeke
Copy link

HaoZeke commented Jun 11, 2018

Actually even with this the dkms modules fail to install on ArchLinux, by not finding ashmem..

@morphis
Copy link
Member

morphis commented Jun 11, 2018

@HaoZeke Actually that is a completely different thing. Please open a bug report with more details on the failing build of the kernel modules.

@rodneyrod
Copy link

I'm still getting this build failing with AUR on Manjaro. This is just the main package only and its dependencies, nothing else.

@ghost
Copy link

ghost commented Jun 12, 2018

As am I.
Kernel: 4.14.48-1-lts

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

Successfully merging this pull request may close these issues.

5 participants