Skip to content

Eliminating compilation warnings when using lto in gcc12 and later versions#23991

Merged
asmorkalov merged 1 commit intoopencv:4.xfrom
buyuer:4.x
Jul 18, 2023
Merged

Eliminating compilation warnings when using lto in gcc12 and later versions#23991
asmorkalov merged 1 commit intoopencv:4.xfrom
buyuer:4.x

Conversation

@buyuer
Copy link
Copy Markdown
Contributor

@buyuer buyuer commented Jul 14, 2023

If use -flto in gcc12.1, then will be warning appear.

lto-wrapper: warning: using serial compilation of 57 LTRANS jobs
lto-wrapper: note: see the ‘-flto’ option documentation for more information

Reference:
https://stackoverflow.com/questions/72218980/gcc-v12-1-warning-about-serial-compilation
https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

Use -flto=auto to use GNU make’s job server, if available, or otherwise fall back to autodetection of the number of CPU threads present in your system.

gcc12 and later versions

use -flto=auto when use gcc12 or later

Signed-off-by: 不鱼儿 <36976072+buyuer@users.noreply.github.com>
@asmorkalov asmorkalov requested a review from mshabunin July 14, 2023 12:05
@asmorkalov asmorkalov added this to the 4.9.0 milestone Jul 14, 2023
@mshabunin
Copy link
Copy Markdown
Contributor

Does it work with Ninja generator?

@buyuer
Copy link
Copy Markdown
Contributor Author

buyuer commented Jul 17, 2023

yeah,I tested using ninja

@asmorkalov
Copy link
Copy Markdown
Contributor

I can confirm the issue and the fix works for me with Ubuntu 22.04 and GCC-12 (apt repo). Command line to build:

cmake -DCMAKE_C_COMPILER=gcc-12 -DCMAKE_CXX_COMPILER=g++-12 -DENABLE_LTO=ON ../opencv
make -j4 opencv_test_core

@asmorkalov asmorkalov requested review from asmorkalov and removed request for mshabunin July 18, 2023 13:25
Copy link
Copy Markdown
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

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

👍

@asmorkalov asmorkalov self-assigned this Jul 18, 2023
@asmorkalov asmorkalov merged commit 0519e05 into opencv:4.x Jul 18, 2023
@asmorkalov asmorkalov mentioned this pull request Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants