Skip to content
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

_FORTIFY_SOURCE requires compiling with optimization (-O) #19

Open
netllama opened this issue Jul 25, 2022 · 3 comments
Open

_FORTIFY_SOURCE requires compiling with optimization (-O) #19

netllama opened this issue Jul 25, 2022 · 3 comments

Comments

@netllama
Copy link

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
                     )
@hao-yao
Copy link
Contributor

hao-yao commented Feb 14, 2023

@netllama Did you build with -DCMAKE_BUILD_TYPE=Release? It sets compiler option -O2 which is needed by D_FORTIFY_SOURCE=2.

@netllama
Copy link
Author

@hao-yao i ran make with no other options or variables.

@cbarbu
Copy link

cbarbu commented Aug 22, 2023

Same error here. Adding
-DCMAKE_BUILD_TYPE=Release
in build.sh, function build_hal_adaptor() {

so that cmake call looks like

command cmake -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR/install ../

Allowed to compile smoothly build_hal_adaptor

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

No branches or pull requests

3 participants