-
Notifications
You must be signed in to change notification settings - Fork 31
Add -D_FORTIFY_SOURCE=2 for fixing hardening-check #149
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
Conversation
Required security compiler’s flags:
Linker flags:
Any recent GLIBC and stdlibc++ would work, I thought. |
-Wall -Wextra -Winit-self -Wuninitialized -Wmissing-declarations \ | ||
-fdiagnostics-color=auto -O3 \ | ||
") | ||
set(SDL_FLAGS "-fstack-protector -fstack-protector-all -fpic -fPIC -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -fno-strict-overflow -fno-delete-null-pointer-checks") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we reformat the flags like this to make them readable. Also do we not need -O3
?
set(CMAKE_C_FLAGS " \
${CMAKE_C_FLAGS} \
-Wall \
-Wextra \
-Winit-self \
-Wuninitialized \
-Wmissing-declarations \
-fdiagnostics-color=auto -O3 \
")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qstd=c++17")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb3 -DDEBUG ")
elseif(UNIX)
set(SDL_FLAGS " \
-fstack-protector \
-fstack-protector-all \
-fpic \
-fPIC \
-D_FORTIFY_SOURCE=2 \
-Wformat \
-Wformat-security \
-fno-strict-overflow \
-fno-delete-null-pointer-checks \
"
)
set(CMAKE_C_FLAGS " \
${CMAKE_C_FLAGS} \
${SDL_FLAGS} \
-Wall \
-Wextra \
-Winit-self \
-Wuninitialized \
-Wmissing-declarations \
-fdiagnostics-color=auto \
-O3 \
"
)
set(CMAKE_C_FLAGS_DEBUG " \
${CMAKE_C_FLAGS_DEBUG} \
${SDL_FLAGS} \
-Wall \
-Wextra \
-Winit-self \
-Wuninitialized \
-Wmissing-declarations \
-fdiagnostics-color=auto \
-O0 \
-ggdb3 \
-DDEBUG \
"
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This style of formatting makes a lot spaces in commands. You can see all calls to compilers if use make -j4 VERBOSE=1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There will be a lot of spaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would propose to use add_compile_options()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, Then never mind.
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb3 -DDEBUG ") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -fsycl") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SDL_FLAGS} -std=c++17 -fsycl") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-O3
needs to be added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-O3 is part of CMAKE_CXX_FLAGS_RELEASE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course.
See https://wiki.debian.org/HardeningWalkthrough#Testing_your_packages_after_conversion