mapbox / mapbox/cpp

Docs on enabling LTO (-flto) with clang++

Open
#22 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
110
Forks
17
PR merge metrics
No merged PRs in 30d

Description

Getting Link Time optimization working takes certain combinations of modern tools and build settings. It would be great to have some general docs on this so that LTO is demystified and more commonly used.

Doc should cover:

### Linux details

- upgraded binutils gold (can be installed via mason)
- at least clang++ 3.9.1 via mason
- llvm-ar and llvm-ranlib on path (and set in environment `AR=/path/to/llvm-ar` `RANLIB=/path/to/llvm-ranlib`)
- `-flto` in the CXXFLAGS

### OS X details
- Apple built in compiler or clang++ via mason
- `-flto` in the CXXFLAGS and LDFLAGS

#### Troubleshooting:

This error indicates that the linker does not understand the LTO format. This will happen on linux if you've not installed binutils from mason.

```
file.o: file not recognized: File format not recognized
clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)
```

Refs https://github.com/mapbox/spatial-algorithms/pull/10

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the issue checklist and the referenced spatial-algorithms pull request. Verify the Linux and OS X toolchain requirements, flags, environment variables, and linker error guidance; the documentation is done when it covers each listed setup and troubleshooting detail.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
build-system, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.