aristocratos / btop

A monitor of resources
Apache License 2.0
21.37k stars 655 forks source link

[REQUEST] Explain more thoroughly on how to compile btop with GCC 10 #786

Open akamayu-ouo opened 9 months ago

akamayu-ouo commented 9 months ago

Is your feature request related to a problem? Please describe.

I tried to build btop with make on an Ubuntu 20.04 machine with g++ 10.5.0 and got errors about missing header <source_location> in btop_tools.hpp.

$ make CXX=g++-10 GPU_SUPPORT=false
...
In file included from src/btop_input.cpp:29:
src/btop_tools.hpp:40:10: fatal error: source_location: No such file or directory
   40 | #include <source_location>
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:379: obj/btop_input.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from src/btop.cpp:49:
src/btop_tools.hpp:40:10: fatal error: source_location: No such file or directory
   40 | #include <source_location>
      |          ^~~~~~~~~~~~~~~~~
...

It was confusing since make asked for gcc 10.1.0 when I used some older version of gcc, so I expected gcc 10.5.0 would be sufficient.

$ make CXX=g++-9 GPU_SUPPORT=false
Makefile:89: *** ERROR: Compiler too old. (Requires Clang 16.0.0, GCC 10.1.0).  Stop.

It turned out that support for <source_location> was added in gcc 11 1, so to compile btop with gcc 10, I had to add OPTFLAGS=-DNDEBUG to avoid the header being included. (Not sure if the flag is intended for this, but it works.)

Describe the solution you'd like

Add descriptions in README on how to disable <source_location> when compiling with gcc 10 or bump the minimal support version of gcc to 11.

imwints commented 9 months ago

It was confusing since make asked for gcc 10.1.0 when I used some older version of gcc, so I expected gcc 10.5.0 would be sufficient.

The commit introducing <source_location> happened pretty recent so I guess no one thought about testing and updating the build requirements.

GCC 10 never had proper C++ 20 support and was probably only supported since it was the most recent version of GCC when btop started. Might be time to drop it altogether if we want to use more C++ 20 features like <source_location> and <semaphore>.

The other solution would be to add some ugly macro stuff to replace functionality which increases maintenance. So I'm all for dropping GCC 10.

By the way -DNDEBUG is not a 'feature' so I wouldn't give instructions how to disable it.

akamayu-ouo commented 9 months ago

GCC 10 never had proper C++ 20 support and was probably only supported since it was the most recent version of GCC when btop started. Might be time to drop it altogether if we want to use more C++ 20 features like <source_location> and <semaphore>.

The other solution would be to add some ugly macro stuff to replace functionality which increases maintenance. So I'm all for dropping GCC 10.

The alternative is not so attractive. I think dropping GCC 10 is a good call.