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

Update Makefile so LTO works on OSX #37356

Merged
merged 1 commit into from
Jan 25, 2020

Conversation

sayke
Copy link
Contributor

@sayke sayke commented Jan 24, 2020

Summary

SUMMARY: Build "Update Makefile so LTO works on OSX"

Purpose of change

Using the LTO flag on OSX would previously break the build (linking) process. The gold linker can only produce ELF binaries, not Mach, so it doesn't work on OSX. This minor tweak lets link-time optimization work when linking Mach binaries from clang.

I also added a commented-out line to let people easily build custom binaries for their hardware by uncommenting it:
# OTHERS += -march=native # Uncomment this to build an optimized binary for your machine only

Describe the solution

This uses -flto=full to use clang LTO instead of trying to use the gold linker via -fuse-ld=gold, thus enabling LTO on OSX.

Describe alternatives you've considered

I considering consolidating the ifdef LTO conditionals but I can see why someone would in principle
want to separate out the OPTLEVEL and LTOFLAGS stages.

Testing

I built it on OSX and it works.

Additional context

Current OSX binaries are basically unoptimized, because optimizations apparently break compatibility with OSX 10.11 and older versions. If we dropped compatibility for those old versions of OSX then user-facing performance would significantly increase.

The gold linker can only produce ELF binaries, not Mach, so it doesn't work on OSX. This lets link-time optimization work when linking Mach binaries from clang.
@ZhilkinSerg ZhilkinSerg added Code: Build Issues regarding different builds and build environments OS: macOS Issues related to macOS / OSX operating system labels Jan 25, 2020
@ZhilkinSerg ZhilkinSerg merged commit bb2b11c into CleverRaven:master Jan 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code: Build Issues regarding different builds and build environments OS: macOS Issues related to macOS / OSX operating system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants