1

I am just beginning to learn about link-time optimization, so I am not sure if this is a stupid question.

I am writing a library largely for use within our organization. There are a large number of classes, with both public and private functions, and a very small subset of the public functions are exported in the form of a Python module using Boost. All other functions, both public and private, are used within the library only. I tried using -flto -fuse-linker-plugin, and found a non-trivial improvement in performance. I am wondering if it is possible to convey to the optimizer that any function, except those exported to Python, maybe optimized, since the library will be used solely through the python module.

I'd appreciate any advice/suggestions.

1 Answer 1

1

You didn't state your platform, what I propose will work on ELF targets like Linux, Solaris, *BSD

You could play with symbols visibility, basically telling the compiler/linker to expose only methods/functions used to interface with python. Link: https://gcc.gnu.org/wiki/Visibility

Second proposal is to use gold linker, for me apps/shared libs compiled with gold linker are running a little bit (but a measurable bit) faster

UPDATE

Here is link to my question/discussion wrt gold vs BFD linker

Is binary linked with gold linker running faster?

Sign up to request clarification or add additional context in comments.

2 Comments

We're on Linux. Thanks for the answer, I'll explore this.
@user2308211 found link with my question wrt gold linker, please check update

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.