_FORTIFY_SOURCE requires compiling with optimization (-O)
- Dominant language
- C
- Stars
- 51
- Forks
- 47
- PR merge metrics
- No merged PRs in 30d
Description
On a Fedora36 system, attempting to run the make command throws a large number of warnings such as the following:
```
[ 80%] Building CXX object CMakeFiles/camhal_static.dir/modules/ia_cipr/src/Command.cpp.o
In file included from /usr/include/c++/12/x86_64-redhat-linux/bits/os_defines.h:39,
from /usr/include/c++/12/x86_64-redhat-linux/bits/c++config.h:2892,
from /usr/include/c++/12/bits/stl_algobase.h:59,
from /usr/include/c++/12/vector:60,
from /root/stuff/ipu6-camera-hal/modules/ia_cipr/include/Command.h:19,
from /root/stuff/ipu6-camera-hal/modules/ia_cipr/src/Command.cpp:19:
/usr/include/features.h:412:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]
412 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O)
| ^~~~~~~
```
This patch makes the failures go away, but I don't understand whether there will be performance impact as a result of the change:
```
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a930feb..a79682f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -83,7 +83,7 @@ set (CMAKE_CXX_STANDARD 11)
add_compile_options(-Wall -Werror
-fstack-protector
-fPIE -fPIC
- -D_FORTIFY_SOURCE=2
+ -D_FORTIFY_SOURCE=0
-DDCHECK_ALWAYS_ON
-Wformat -Wformat-security
)
```
Contributor guide
Assessment
This issue has not been assessed yet.