bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
23.16k stars 4.05k forks source link

The thin_lto feature is not enabled for MacOS #16269

Open mrkkrp opened 2 years ago

mrkkrp commented 2 years ago

Description of the bug:

In unix_cc_toolchain_config.bzl the thin_lto feature is in the config for Linux but not for MacOS. The result is that thin LTO cannot be used on MacOS with Bazel. AFAIU thin lto is supported on MacOS as well. Is this an oversight or there is a reason for exclusion of this feature on MacOS?

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

No response

Which operating system are you running Bazel on?

MacOS Monterey 12.5.1

What is the output of bazel info release?

release 5.1.1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

keith commented 2 years ago

I think this is just an oversight, FWIW as a short term workaround passing --copt=-flto=thin (and similar flags if you are building other languages) should "just work" (maybe you want --linkopt=-flto=thin as well)

mrkkrp commented 2 years ago

This was my first attempt. --copt=-flto=thin seems to add -flto=thin to the invocations of compile actions, however --linkopt=-flto=thin has no effect on the linking actions. Is this normal? Are these two flags really enough (there is quite a bit going on is that feature definition)?

keith commented 2 years ago

What failures do you see with that? Technically the linkopt might not matter since if the linker gets lto'd inputs it probably handles them regardless of the flags. I think if we were to add it to the crosstool we would have something that looked a bit more like https://github.com/bazelbuild/bazel/blob/fdcaaf4af3296bf544589810ad46b438bfe5e1fb/tools/cpp/unix_cc_toolchain_config.bzl?rgh-link-date=2022-09-13T18%3A20%3A59Z#L1136-L1197, but at least some flags like the linker plugin options are not available with ld64. I don't know the story behind the other flags, but I wouldn't be surprised if they were mostly nice, but not required, optimizations

github-actions[bot] commented 10 months ago

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

fhanau commented 9 months ago

@bazelbuild/triage