google-deepmind / google-deepmind/mujoco
LTO is forcefully enabled instead of by default in the build system
- Dominant language
- C++
- Stars
- 15.2k
- Forks
- 1.8k
- Avg merge
- 10d 16h
- Merged PRs (30d)
- 25
Description
### Intro
Hi!
I am a student (in a few days researcher) at University of Ljubljana, I use MuJoCo for my research on RL.
### My setup
MuJoCo 3.3.7. Other info is irrelevant.
### What's happening? What did you expect?
A few CMake files contain forceful set of the CMake variable `CMAKE_INTERPROCEDURAL_OPTIMIZATION` (LTO).
- https://github.com/google-deepmind/mujoco/blob/36bed9a9da8cbd42a8dddd8ab3d586a51abedd7d/cmake/MujocoOptions.cmake#L107-L109
- https://github.com/google-deepmind/mujoco/blob/36bed9a9da8cbd42a8dddd8ab3d586a51abedd7d/sample/cmake/SampleOptions.cmake#L107-L109
- https://github.com/google-deepmind/mujoco/blob/36bed9a9da8cbd42a8dddd8ab3d586a51abedd7d/simulate/cmake/SimulateOptions.cmake#L107-L109
This causes problems whenever the compiled (static) libraries may be used with a different linker, which is now the case for the Rust language on the default Linux target (they switched to rust-lld).
As a result of the forceful enable, the compiled library files contain additional information that is only compatible with the same linker. See the following issue: https://github.com/rust-lang/rust/issues/146952.
Based on the commit message that added the forceful enable of LTO, the plan was to enable it by default, not permanently.
Several CI files also contain commands where this is explicitly disabled (https://github.com/google-deepmind/mujoco/blob/36bed9a9da8cbd42a8dddd8ab3d586a51abedd7d/.github/workflows/build.yml#L178), but as the result of the given lines inside CMake option files, nothing changes.
### Steps for reproduction
1. Compile with `CMAKE_INTERPROCEDURAL_OPTIMIZATION` disabled from the console
2. CMAKE_INTERPROCEDURAL_OPTIMIZATION (LTO) is still enabled
### Minimal model for reproduction
Irrelevant
### Code required for reproduction
Irrelevant
### Confirmations
- [x] I searched the [latest documentation](https://mujoco.readthedocs.io/en/latest/overview.html) thoroughly before posting.
- [x] I searched previous [Issues](https://github.com/google-deepmind/mujoco/issues) and [Discussions](https://github.com/google-deepmind/mujoco/discussions), I am certain this has not been raised before.
Contributor guide
Assessment
This issue has not been assessed yet.