Skip to content

Commit

Permalink
Allow LTO for all build types.
Browse files Browse the repository at this point in the history
  • Loading branch information
levlam committed Sep 8, 2021
1 parent b8df633 commit c582ab0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Expand Up @@ -60,15 +60,15 @@ if (POLICY CMP0069)
# set_property(DIRECTORY PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) do not work?
string(REPLACE ";" " " CXX_FLAGS_IPO "${CMAKE_CXX_COMPILE_OPTIONS_IPO}")
message(STATUS "Use link time optimization CXX options: ${CXX_FLAGS_IPO}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CXX_FLAGS_IPO}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_FLAGS_IPO}")

string(REPLACE ";" " " C_FLAGS_IPO "${CMAKE_C_COMPILE_OPTIONS_IPO}")
message(STATUS "Use link time optimization C options: ${C_FLAGS_IPO}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${C_FLAGS_IPO}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_FLAGS_IPO}")

string(REPLACE ";" " " LINK_FLAGS_IPO "${CMAKE_CXX_LINK_OPTIONS_IPO}")
message(STATUS "Use link time optimization linker options: ${LINK_FLAGS_IPO}")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${LINK_FLAGS_IPO}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LINK_FLAGS_IPO}")
endif()
endif()
endif()
Expand Down

6 comments on commit c582ab0

@Sarisan
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build stucks and then gets killed due to this, LTO option doesn't change anything

@levlam
Copy link
Contributor Author

@levlam levlam commented on c582ab0 Sep 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LTO is disabled by default, so this is completely unrelated. Check that you have enough RAM for g++ for building.

@Sarisan
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use clang 12. Build failed 5 times before I reverted this commit.

@levlam
Copy link
Contributor Author

@levlam levlam commented on c582ab0 Sep 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you implicitly enabled LTO? Which build type are you using? Could you sent the command used to configure cmake build?

@Sarisan
Copy link

@Sarisan Sarisan commented on c582ab0 Sep 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CXXFLAGS="-stdlib=libc++" CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=.. ..

@levlam
Copy link
Contributor Author

@levlam levlam commented on c582ab0 Sep 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You didn't enable LTO, so. as I initially said, this commit is completely irrelevant.

Please sign in to comment.