Skip to content

Commit

Permalink
Posix_GCC: update compiler options (FreeRTOS#1227)
Browse files Browse the repository at this point in the history
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 <Florian.LaRoche@gmail.com>
  • Loading branch information
laroche committed Jun 10, 2024
1 parent 995a030 commit 5f85f43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions FreeRTOS/Demo/Posix_GCC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion FreeRTOS/Demo/Posix_GCC/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ void handle_sigint( int signal )
printf( "chdir into %s error is %d\n", BUILD, errno );
}

exit( 2 );
_exit( 2 );
}

/*-----------------------------------------------------------*/
Expand Down

0 comments on commit 5f85f43

Please sign in to comment.