mirror of https://github.com/aristocratos/btop.git
Use _FORTIFY_SOURCE=3 and put it behind a build flag
This commit is contained in:
parent
36842a3bcc
commit
19c6099c7c
|
@ -41,6 +41,7 @@ option(BTOP_LTO "Enable LTO" ON)
|
||||||
option(BTOP_USE_MOLD "Use mold to link btop" OFF)
|
option(BTOP_USE_MOLD "Use mold to link btop" OFF)
|
||||||
option(BTOP_PEDANTIC "Enable a bunch of additional warnings" OFF)
|
option(BTOP_PEDANTIC "Enable a bunch of additional warnings" OFF)
|
||||||
option(BTOP_WERROR "Compile with warnings as errors" OFF)
|
option(BTOP_WERROR "Compile with warnings as errors" OFF)
|
||||||
|
option(BTOP_FORTIFY "Detect buffer overflows with _FORTIFY_SOURCE=3" ON)
|
||||||
option(BTOP_GPU "Enable GPU support" ON)
|
option(BTOP_GPU "Enable GPU support" ON)
|
||||||
cmake_dependent_option(BTOP_RSMI_STATIC "Link statically to ROCm SMI" OFF "BTOP_GPU" OFF)
|
cmake_dependent_option(BTOP_RSMI_STATIC "Link statically to ROCm SMI" OFF "BTOP_GPU" OFF)
|
||||||
|
|
||||||
|
@ -112,7 +113,7 @@ target_compile_definitions(btop PRIVATE
|
||||||
_FILE_OFFSET_BITS=64
|
_FILE_OFFSET_BITS=64
|
||||||
$<$<CONFIG:Debug>:_GLIBCXX_ASSERTIONS _LIBCPP_ENABLE_ASSERTIONS=1>
|
$<$<CONFIG:Debug>:_GLIBCXX_ASSERTIONS _LIBCPP_ENABLE_ASSERTIONS=1>
|
||||||
# Only has an effect with optimizations enabled
|
# Only has an effect with optimizations enabled
|
||||||
$<$<NOT:$<CONFIG:Debug>>:_FORTIFY_SOURCE=2>
|
$<$<AND:$<NOT:$<CONFIG:Debug>>,$<BOOL:${BTOP_FORTIFY}>>:_FORTIFY_SOURCE=3>
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(btop SYSTEM PRIVATE include)
|
target_include_directories(btop SYSTEM PRIVATE include)
|
||||||
|
|
7
Makefile
7
Makefile
|
@ -50,6 +50,11 @@ ifeq ($(GPU_SUPPORT),true)
|
||||||
override ADDFLAGS += -DGPU_SUPPORT
|
override ADDFLAGS += -DGPU_SUPPORT
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
FORTIFY_SOURCE ?= true
|
||||||
|
ifeq ($(FORTIFY_SOURCE),true)
|
||||||
|
override ADDFLAGS += -D_FORTIFY_SOURCE=3
|
||||||
|
endif
|
||||||
|
|
||||||
#? Compiler and Linker
|
#? Compiler and Linker
|
||||||
ifeq ($(shell $(CXX) --version | grep clang >/dev/null 2>&1; echo $$?),0)
|
ifeq ($(shell $(CXX) --version | grep clang >/dev/null 2>&1; echo $$?),0)
|
||||||
override CXX_IS_CLANG := true
|
override CXX_IS_CLANG := true
|
||||||
|
@ -174,7 +179,7 @@ override GOODFLAGS := $(foreach flag,$(TESTFLAGS),$(strip $(shell echo "int main
|
||||||
override REQFLAGS := -std=c++20
|
override REQFLAGS := -std=c++20
|
||||||
WARNFLAGS := -Wall -Wextra -pedantic
|
WARNFLAGS := -Wall -Wextra -pedantic
|
||||||
OPTFLAGS := -O2 -ftree-vectorize -flto=$(LTO)
|
OPTFLAGS := -O2 -ftree-vectorize -flto=$(LTO)
|
||||||
LDCXXFLAGS := -pthread -D_FORTIFY_SOURCE=2 -D_GLIBCXX_ASSERTIONS -D_FILE_OFFSET_BITS=64 $(GOODFLAGS) $(ADDFLAGS)
|
LDCXXFLAGS := -pthread -D_GLIBCXX_ASSERTIONS -D_FILE_OFFSET_BITS=64 $(GOODFLAGS) $(ADDFLAGS)
|
||||||
override CXXFLAGS += $(REQFLAGS) $(LDCXXFLAGS) $(OPTFLAGS) $(WARNFLAGS)
|
override CXXFLAGS += $(REQFLAGS) $(LDCXXFLAGS) $(OPTFLAGS) $(WARNFLAGS)
|
||||||
override LDFLAGS += $(LDCXXFLAGS) $(OPTFLAGS) $(WARNFLAGS)
|
override LDFLAGS += $(LDCXXFLAGS) $(OPTFLAGS) $(WARNFLAGS)
|
||||||
INC := $(foreach incdir,$(INCDIRS),-isystem $(incdir)) -I$(SRCDIR)
|
INC := $(foreach incdir,$(INCDIRS),-isystem $(incdir)) -I$(SRCDIR)
|
||||||
|
|
|
@ -405,6 +405,7 @@ Also needs a UTF8 locale and a font that covers:
|
||||||
| `STRIP=true` | To force stripping of debug symbols (adds `-s` linker flag) |
|
| `STRIP=true` | To force stripping of debug symbols (adds `-s` linker flag) |
|
||||||
| `DEBUG=true` | Sets OPTFLAGS to `-O0 -g` and enables more verbose debug logging |
|
| `DEBUG=true` | Sets OPTFLAGS to `-O0 -g` and enables more verbose debug logging |
|
||||||
| `ARCH=<architecture>` | To manually set the target architecture |
|
| `ARCH=<architecture>` | To manually set the target architecture |
|
||||||
|
| `FORTIFY_SOURCE=false` | Disable fortification with `_FORTIFY_SOURCE=3` |
|
||||||
| `GPU_SUPPORT=<true\|false>` | Enable/disable GPU support (Enabled by default on X86_64 Linux) |
|
| `GPU_SUPPORT=<true\|false>` | Enable/disable GPU support (Enabled by default on X86_64 Linux) |
|
||||||
| `RSMI_STATIC=true` | To statically link the ROCm SMI library used for querying AMDGPU |
|
| `RSMI_STATIC=true` | To statically link the ROCm SMI library used for querying AMDGPU |
|
||||||
| `ADDFLAGS=<flags>` | For appending flags to both compiler and linker |
|
| `ADDFLAGS=<flags>` | For appending flags to both compiler and linker |
|
||||||
|
@ -503,6 +504,7 @@ Also needs a UTF8 locale and a font that covers:
|
||||||
| `-DBTOP_USE_MOLD=<ON\|OFF>` | Use mold to link btop (OFF by default) |
|
| `-DBTOP_USE_MOLD=<ON\|OFF>` | Use mold to link btop (OFF by default) |
|
||||||
| `-DBTOP_PEDANTIC=<ON\|OFF>` | Compile with additional warnings (OFF by default) |
|
| `-DBTOP_PEDANTIC=<ON\|OFF>` | Compile with additional warnings (OFF by default) |
|
||||||
| `-DBTOP_WERROR=<ON\|OFF>` | Compile with warnings as errors (OFF by default) |
|
| `-DBTOP_WERROR=<ON\|OFF>` | Compile with warnings as errors (OFF by default) |
|
||||||
|
| `-DBTOP_FORTIFY=<ON\|OFF>` | Detect buffer overflows with `_FORTIFY_SOURCE=3` (ON by default) |
|
||||||
| `-DBTOP_GPU=<ON\|OFF>` | Enable GPU support (ON by default) |
|
| `-DBTOP_GPU=<ON\|OFF>` | Enable GPU support (ON by default) |
|
||||||
| `-DBTOP_RSMI_STATIC=<ON\|OFF>` | Build and link the ROCm SMI library statically (OFF by default) |
|
| `-DBTOP_RSMI_STATIC=<ON\|OFF>` | Build and link the ROCm SMI library statically (OFF by default) |
|
||||||
| `-DCMAKE_INSTALL_PREFIX=<path>` | The installation prefix ('/usr/local' by default) |
|
| `-DCMAKE_INSTALL_PREFIX=<path>` | The installation prefix ('/usr/local' by default) |
|
||||||
|
@ -576,6 +578,7 @@ Also needs a UTF8 locale and a font that covers:
|
||||||
| `STRIP=true` | To force stripping of debug symbols (adds `-s` linker flag) |
|
| `STRIP=true` | To force stripping of debug symbols (adds `-s` linker flag) |
|
||||||
| `DEBUG=true` | Sets OPTFLAGS to `-O0 -g` and enables more verbose debug logging |
|
| `DEBUG=true` | Sets OPTFLAGS to `-O0 -g` and enables more verbose debug logging |
|
||||||
| `ARCH=<architecture>` | To manually set the target architecture |
|
| `ARCH=<architecture>` | To manually set the target architecture |
|
||||||
|
| `FORTIFY_SOURCE=false` | Disable fortification with `_FORTIFY_SOURCE=3` |
|
||||||
| `ADDFLAGS=<flags>` | For appending flags to both compiler and linker |
|
| `ADDFLAGS=<flags>` | For appending flags to both compiler and linker |
|
||||||
| `CXX=<compiler>` | Manualy set which compiler to use |
|
| `CXX=<compiler>` | Manualy set which compiler to use |
|
||||||
|
|
||||||
|
@ -674,6 +677,7 @@ Also needs a UTF8 locale and a font that covers:
|
||||||
| `-DBTOP_USE_MOLD=<ON\|OFF>` | Use mold to link btop (OFF by default) |
|
| `-DBTOP_USE_MOLD=<ON\|OFF>` | Use mold to link btop (OFF by default) |
|
||||||
| `-DBTOP_PEDANTIC=<ON\|OFF>` | Compile with additional warnings (OFF by default) |
|
| `-DBTOP_PEDANTIC=<ON\|OFF>` | Compile with additional warnings (OFF by default) |
|
||||||
| `-DBTOP_WERROR=<ON\|OFF>` | Compile with warnings as errors (OFF by default) |
|
| `-DBTOP_WERROR=<ON\|OFF>` | Compile with warnings as errors (OFF by default) |
|
||||||
|
| `-DBTOP_FORTIFY=<ON\|OFF>` | Detect buffer overflows with `_FORTIFY_SOURCE=3` (ON by default) |
|
||||||
| `-DCMAKE_INSTALL_PREFIX=<path>` | The installation prefix ('/usr/local' by default) |
|
| `-DCMAKE_INSTALL_PREFIX=<path>` | The installation prefix ('/usr/local' by default) |
|
||||||
|
|
||||||
To force any specific compiler, run `CXX=<compiler> cmake -B build -G Ninja`
|
To force any specific compiler, run `CXX=<compiler> cmake -B build -G Ninja`
|
||||||
|
@ -742,6 +746,7 @@ Also needs a UTF8 locale and a font that covers:
|
||||||
| `STRIP=true` | To force stripping of debug symbols (adds `-s` linker flag) |
|
| `STRIP=true` | To force stripping of debug symbols (adds `-s` linker flag) |
|
||||||
| `DEBUG=true` | Sets OPTFLAGS to `-O0 -g` and enables more verbose debug logging |
|
| `DEBUG=true` | Sets OPTFLAGS to `-O0 -g` and enables more verbose debug logging |
|
||||||
| `ARCH=<architecture>` | To manually set the target architecture |
|
| `ARCH=<architecture>` | To manually set the target architecture |
|
||||||
|
| `FORTIFY_SOURCE=false` | Disable fortification with `_FORTIFY_SOURCE=3` |
|
||||||
| `ADDFLAGS=<flags>` | For appending flags to both compiler and linker |
|
| `ADDFLAGS=<flags>` | For appending flags to both compiler and linker |
|
||||||
| `CXX=<compiler>` | Manualy set which compiler to use |
|
| `CXX=<compiler>` | Manualy set which compiler to use |
|
||||||
|
|
||||||
|
@ -851,6 +856,7 @@ Also needs a UTF8 locale and a font that covers:
|
||||||
| `-DBTOP_USE_MOLD=<ON\|OFF>` | Use mold to link btop (OFF by default) |
|
| `-DBTOP_USE_MOLD=<ON\|OFF>` | Use mold to link btop (OFF by default) |
|
||||||
| `-DBTOP_PEDANTIC=<ON\|OFF>` | Compile with additional warnings (OFF by default) |
|
| `-DBTOP_PEDANTIC=<ON\|OFF>` | Compile with additional warnings (OFF by default) |
|
||||||
| `-DBTOP_WERROR=<ON\|OFF>` | Compile with warnings as errors (OFF by default) |
|
| `-DBTOP_WERROR=<ON\|OFF>` | Compile with warnings as errors (OFF by default) |
|
||||||
|
| `-DBTOP_FORTIFY=<ON\|OFF>` | Detect buffer overflows with `_FORTIFY_SOURCE=3` (ON by default) |
|
||||||
| `-DCMAKE_INSTALL_PREFIX=<path>` | The installation prefix ('/usr/local' by default) |
|
| `-DCMAKE_INSTALL_PREFIX=<path>` | The installation prefix ('/usr/local' by default) |
|
||||||
|
|
||||||
_**Note:** Static linking does not work with GCC._
|
_**Note:** Static linking does not work with GCC._
|
||||||
|
@ -921,6 +927,7 @@ Also needs a UTF8 locale and a font that covers:
|
||||||
| `STRIP=true` | To force stripping of debug symbols (adds `-s` linker flag) |
|
| `STRIP=true` | To force stripping of debug symbols (adds `-s` linker flag) |
|
||||||
| `DEBUG=true` | Sets OPTFLAGS to `-O0 -g` and enables more verbose debug logging |
|
| `DEBUG=true` | Sets OPTFLAGS to `-O0 -g` and enables more verbose debug logging |
|
||||||
| `ARCH=<architecture>` | To manually set the target architecture |
|
| `ARCH=<architecture>` | To manually set the target architecture |
|
||||||
|
| `FORTIFY_SOURCE=false` | Disable fortification with `_FORTIFY_SOURCE=3` |
|
||||||
| `ADDFLAGS=<flags>` | For appending flags to both compiler and linker |
|
| `ADDFLAGS=<flags>` | For appending flags to both compiler and linker |
|
||||||
| `CXX=<compiler>` | Manualy set which compiler to use |
|
| `CXX=<compiler>` | Manualy set which compiler to use |
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue