Skip to content

Commit

Permalink
cmake/compiler/gcc: use -flto only for gcc >= 4.5.0
Browse files Browse the repository at this point in the history
Fixes commit 26c8776 ("buildsystem: Add an option to enable LTO")

Fixes the following error when compiling offsets.c

  xt-xcc ERROR parsing -fno-lto:  unknown flag

LTO options were introduced in gcc 4.5.0, compare:

https://gcc.gnu.org/onlinedocs/gcc-4.4.6/gcc/Option-Summary.html
https://gcc.gnu.org/onlinedocs/gcc-4.5.0/gcc/Option-Summary.html

Signed-off-by: Marc Herbert <[email protected]>
  • Loading branch information
marc-hb authored and henrikbrixandersen committed Feb 16, 2024
1 parent b5d4414 commit 16337e8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmake/compiler/gcc/compiler_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ endif()
set_compiler_property(PROPERTY optimization_speed -O2)
set_compiler_property(PROPERTY optimization_size -Os)

set_compiler_property(PROPERTY optimization_lto -flto)
set_compiler_property(PROPERTY prohibit_lto -fno-lto)
if(CMAKE_C_COMPILER_VERSION GREATER_EQUAL "4.5.0")
set_compiler_property(PROPERTY optimization_lto -flto)
set_compiler_property(PROPERTY prohibit_lto -fno-lto)
endif()

#######################################################
# This section covers flags related to warning levels #
Expand Down

0 comments on commit 16337e8

Please sign in to comment.