RyzenAdj icon indicating copy to clipboard operation
RyzenAdj copied to clipboard

Allow disabling IPO/LTO in CMakeLists

Open ShadowApex opened this issue 1 year ago • 3 comments

I maintain Rust bindings to libryzenadj and encountered linking issues in Rust when CMAKE_INTERPROCEDURAL_OPTIMIZATION is set to TRUE. Could we update the CMakeLists to include a flag to disable IPO/LTO even if it is supported?

ShadowApex avatar Apr 10 '24 21:04 ShadowApex

I can just disable it. What was the problem btw

FlyGoat avatar Apr 11 '24 18:04 FlyGoat

In the linking step at the end of the Rust build, it fails to find the symbols.

Small snippet from attached log:

...
  = note: /usr/bin/ld: /home/william/Projects/PowerStation/target/debug/deps/liblibryzenadj-ec6b339ba685ce56.rlib(libryzenadj-ec6b339ba685ce56.1pc6pnmuzuak76qe.rcgu.o): in function `libryzenadj::RyzenAdj::new':
          /home/william/Projects/libryzenadj-rs/src/lib.rs:89: undefined reference to `init_ryzenadj'
          /usr/bin/ld: /home/william/Projects/libryzenadj-rs/src/lib.rs:94: undefined reference to `init_table'
          /usr/bin/ld: /home/william/Projects/PowerStation/target/debug/deps/liblibryzenadj-ec6b339ba685ce56.rlib(libryzenadj-ec6b339ba685ce56.1pc6pnmuzuak76qe.rcgu.o): in function `libryzenadj::RyzenAdj::get_fast_limit':
          /home/william/Projects/libryzenadj-rs/src/lib.rs:220: undefined reference to `get_fast_limit'
          /usr/bin/ld: /home/william/Projects/PowerStation/target/debug/deps/liblibryzenadj-ec6b339ba685ce56.rlib(libryzenadj-ec6b339ba685ce56.1pc6pnmuzuak76qe.rcgu.o): in function `libryzenadj::RyzenAdj::get_stapm_limit':
          /home/william/Projects/libryzenadj-rs/src/lib.rs:315: undefined reference to `get_stapm_limit'
...

lto-compile-failure.log

Disabling LTO fixes the issue.

ShadowApex avatar Apr 11 '24 21:04 ShadowApex

Do you rebuild ryzenadj in your setup? Looks like it. It feels like your build configuration doesn't know that these methods are exposed interface endpoints, because your build did maybe inline these, if disabling it did fix it.

But yes, I don't think INTERPROCEDURAL_OPTIMIZATION makes any difference at our already short call stacks, so it is a quick and easy fix on our side. Just wanted to remind you of a potential hidden secondary issue in your build setup.

Maybe we wait some days and let this question open before we do it in case somebody knows it better than us :)

Falcosc avatar Apr 11 '24 21:04 Falcosc