From 5f85f43c39bcb99f7e4a6068fe155dcfcbc1af6f Mon Sep 17 00:00:00 2001 From: Florian La Roche Date: Mon, 10 Jun 2024 08:02:23 +0200 Subject: [PATCH] Posix_GCC: update compiler options (#1227) Posix_GCC: update compiler options 1. Add to CFLAGS - add -O0 optimization for debug builds. - add -O3 optimization for release builds. 2. Update signal handler `handle_sigint()` to use `_exit()` instead of `exit()`. Normal exit() is not allowed within a signal handler. Signed-off-by: Florian La Roche --- FreeRTOS/Demo/Posix_GCC/CMakeLists.txt | 5 +++++ FreeRTOS/Demo/Posix_GCC/main.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt b/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt index 199de7508b5..6131634b6c0 100644 --- a/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt +++ b/FreeRTOS/Demo/Posix_GCC/CMakeLists.txt @@ -4,6 +4,8 @@ project( posix_demo ) add_compile_options( -D_WINDOWS_ ) +add_compile_options( -Wall -Wextra -Wpedantic ) + if( TRACE_ON_ENTER ) add_compile_options( -DTRACE_ON_ENTER=1 ) else() @@ -33,6 +35,9 @@ else() set( CMAKE_BUILD_TYPE "debug" ) endif() +set(CMAKE_CXX_FLAGS_RELEASE "-O3") +set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3") + if( SANITIZE_ADDRESS ) add_compile_options( -fsanitize=address -fsanitize=alignment ) endif() diff --git a/FreeRTOS/Demo/Posix_GCC/main.c b/FreeRTOS/Demo/Posix_GCC/main.c index bf69bf280c0..f5773de512e 100644 --- a/FreeRTOS/Demo/Posix_GCC/main.c +++ b/FreeRTOS/Demo/Posix_GCC/main.c @@ -455,7 +455,7 @@ void handle_sigint( int signal ) printf( "chdir into %s error is %d\n", BUILD, errno ); } - exit( 2 ); + _exit( 2 ); } /*-----------------------------------------------------------*/