-
-
Notifications
You must be signed in to change notification settings - Fork 849
Improve cmake lto config #6333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Improve cmake lto config #6333
Conversation
@@ -946,6 +946,10 @@ function _get_configs(package, configs, opt) | |||
_get_configs_for_generic(package, configs, opt) | |||
end | |||
|
|||
if not opt._configs_str:find("CMAKE_INTERPROCEDURAL_OPTIMIZATION", 1, true) then | |||
table.insert(configs, "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=" .. (package:config("lto") and "ON" or "OFF")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
既然已经直接打 lto flags 进去了,为啥还要这个?跟现有打的 lto flags 冲突么?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有些库会探测是否有这个选项,如果没有就开启 lto。比如 clang ci 链接还是用的 gnu ld,就链接失败了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
目前直接设置了 lto flags ,thin lto/full lto ,我不确定 CMAKE_INTERPROCEDURAL_OPTIMIZATION 用的是哪个,如果不一致,应该会有冲突问题。
不建议两个同时设置,如果设置了 CMAKE_INTERPROCEDURAL_OPTIMIZATION,那就不要再直接传递 lto flags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那这个选项只传 off 就好了,lto flags 只让 xmake 传递。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有些库会探测是否有这个选项,如果没有就开启 lto。比如 clang ci 链接还是用的 gnu ld,就链接失败了
只传 off 不就又有这个问题了么。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 直接硬编码
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
的,只能手动 patch (msvc runtime 同理 - 有检测代码。只传 off 就是解决这种。
if(NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
endif()
@@ -946,6 +946,10 @@ function _get_configs(package, configs, opt) | |||
_get_configs_for_generic(package, configs, opt) | |||
end | |||
|
|||
if not opt._configs_str:find("CMAKE_INTERPROCEDURAL_OPTIMIZATION", 1, true) then | |||
table.insert(configs, "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这怎么看着有点 hack, 依赖特定包中对 CMAKE_INTERPROCEDURAL_OPTIMIZATION defined 的判断。
确定所有包和 cmake 内部都是defined 这种形式来判断?永远不会出现 if(NOT CMAKE_INTERPROCEDURAL_OPTIMIZATION)
?
if(NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
endif()
在没这个上下文背景下,单看这个 patch ,字面上跟 lto flags 设置状态,很不搭。
要么开头加点注释详细说明下情况,否则我怕 过上一阵子,就看不懂了
No description provided.