Skip to content
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

Fix LTO warning by enabling parallel compilation #523

Merged
merged 1 commit into from
Dec 25, 2024

Conversation

eleanorLYJ
Copy link
Contributor

When using make, the following warning occurs:
lto-wrapper: warning: using serial compilation of 2 LTRANS jobs.

To resolve this and enable parallel compilation, -flto=auto is now used.

According to the GCC documentation:
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.

Copy link
Collaborator

@visitorckw visitorckw left a comment

Choose a reason for hiding this comment

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

Nit: Missing a period in the commit message. Otherwise, LGTM. Thanks!

@jserv jserv requested a review from ChinYikMing December 21, 2024 10:48
Copy link
Collaborator

@ChinYikMing ChinYikMing left a comment

Choose a reason for hiding this comment

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

The warning remains when using older version of gcc. @eleanorLYJ Can you check? (maybe provide some fallback mechanism for older gcc)

Note: I tried gcc-12 or above and the warning are gone.

Compiler:

gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Build log of make check:

  CC	build/map.o
  CC	build/utils.o
  CC	build/decode.o
  CC	build/io.o
  CC	build/syscall.o
  CC	build/emulate.o
  CC	build/riscv.o
  CC	build/elf.o
  CC	build/cache.o
  CC	build/mpool.o
  CC	build/main.o
  LD	build/rv32emu
lto-wrapper: warning: using serial compilation of 2 LTRANS jobs
[OK]
Checking SHA-1 of prebuilt binaries ... [OK]
Running hello.elf ... [OK]
Running puzzle ... [OK]
Running fcalc ... [OK]
Running pi ... [OK]

@jserv jserv added this to the release-2024.2 milestone Dec 22, 2024
Copy link
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

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

Always rebase the latest master branch when you submit pull requests.

@visitorckw
Copy link
Collaborator

The warning remains when using older version of gcc. @eleanorLYJ Can you check? (maybe provide some fallback mechanism for older gcc)

Note: I tried gcc-12 or above and the warning are gone.

Hmm, that's strange.
Is there a difference in the functionality of -flto=auto between gcc v11.4 and now?
Or does GCC v11.4 not even support the auto parameter?

@ChinYikMing
Copy link
Collaborator

ChinYikMing commented Dec 23, 2024

The warning remains when using older version of gcc. @eleanorLYJ Can you check? (maybe provide some fallback mechanism for older gcc)
Note: I tried gcc-12 or above and the warning are gone.

Hmm, that's strange. Is there a difference in the functionality of -flto=auto between gcc v11.4 and now? Or does GCC v11.4 not even support the auto parameter?

Found this at stackoverflow. The warning was introduced from v11.4 . Thus, I believe it might be specific to version 11.4 or later but below version 12.

Actually, flto=auto is supported in v11.4, and that's where the odd behavior originates.

I think we can mention this in the commit message and move on.

@ChinYikMing
Copy link
Collaborator

Don't use markdown syntax in the body of git commit messages since not every parser recognizes the format (I meant the gcc docs link here). Instead, always use plaintext. Thanks!

@jserv
Copy link
Contributor

jserv commented Dec 23, 2024

Don't use markdown syntax in the body of git commit messages since not every parser recognizes the format (I meant the gcc docs link here). Instead, always use plaintext. Thanks!

Change the following:

According to the GCC documentation:
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.

to

According to GCC optimization options [1], ...
[1] https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

When using make for builds, the following warning is observed:
lto-wrapper: warning: using serial compilation of 2 LTRANS jobs.

To address this, -flto=auto is now used.

According to GCC optimization options [1], 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.

While this patch does not fully suppress the warning in certain GCC
versions (11.4 or later but below 12), it improves build performance by
enabling parallel LTO compilation whenever possible.

[1] https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
Copy link
Collaborator

@ChinYikMing ChinYikMing left a comment

Choose a reason for hiding this comment

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

LGTM.

@jserv jserv merged commit f7fd15b into sysprog21:master Dec 25, 2024
8 checks passed
@jserv
Copy link
Contributor

jserv commented Dec 25, 2024

Thank @eleanorLYJ for contributing!

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.

4 participants