Skip to content

Fix #2904: add MUJOCO_ENABLE_LTO option to make LTO configurable#3374

Open
Ashutosh0x wants to merge 1 commit into
google-deepmind:mainfrom
Ashutosh0x:fix/issue-2904
Open

Fix #2904: add MUJOCO_ENABLE_LTO option to make LTO configurable#3374
Ashutosh0x wants to merge 1 commit into
google-deepmind:mainfrom
Ashutosh0x:fix/issue-2904

Conversation

@Ashutosh0x

Copy link
Copy Markdown
Contributor

Problem

CMAKE_INTERPROCEDURAL_OPTIMIZATION was set unconditionally for non-Debug builds whenever DEFINED was not set. There was no user-facing CMake option to disable LTO without resorting to undocumented internal variable manipulation.

An explicit -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF could also be silently overridden in certain CMake configurations, as discussed in the issue.

Fixes #2904.

Changes

cmake/MujocoOptions.cmake

  • Introduces a new MUJOCO_ENABLE_LTO option (default ON) that gives users a clean, documented way to disable LTO: -DMUJOCO_ENABLE_LTO=OFF.
  • The existing CMAKE_INTERPROCEDURAL_OPTIMIZATION logic is preserved inside the if(MUJOCO_ENABLE_LTO) guard, so the default behaviour (LTO on for non-Debug, off for Debug) is unchanged.
# Clean user-facing disable:
cmake -DMUJOCO_ENABLE_LTO=OFF ..

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

Successfully merging this pull request may close these issues.

LTO is forcefully enabled instead of by default in the build system

1 participant