0

If gcc get called with link time optimization (-flto) enabled and I am using one of the following keyword/attribute:

__attribute__((always_inline)) void foo(int i);
inline void bar(int i);

Does this keyword/attribute affect the behavior of the link-time optimization (If the compiler is not able to do the inlineing)?

Does the link-time optimization prefer inlineing of these function over functions without this keyword/attribute.

The question is if it makes a difference for the linker-phase processing not the compiler.

user3666197
  • 1
  • 6
  • 50
  • 92
AlphaBeta
  • 320
  • 1
  • 4
  • 13

1 Answers1

2

Based on a previous answer found here: what “inline __attribute__((always_inline))” means in the function?

__attribute__((always_inline))

makes the compiler try to inline it even if it's disabled in the preferences, and

inline

tells the compiler to try really hard to inline the function.

Community
  • 1
  • 1
Jorj
  • 56
  • 5
  • 1
    The OP question is how it affects link-time and not so much the compile time – Soren Aug 15 '15 at 10:13
  • The answer there just points to read the documentation thoroughly, which is what I'd recommend in this case as well. You should probably have flagged the question as duplicate of what you found. Though you gave some more information as is given by the linked answer +1 for that. – πάντα ῥεῖ Aug 15 '15 at 10:15
  • When I click 'flag' the closest option to duplicate is "in need of moderator intervention". Is that what I should do in the future? – Jorj Aug 15 '15 at 10:20
  • Edited the question. I want to know how the LTO (linker) handle these keywords, not the compiler. – AlphaBeta Aug 15 '15 at 10:40
  • Apparently the linker does the automatic in-lining, so by shifting that process to the compiler phase, you make the linking phase faster. Probably doesn't actually make the overall process any faster, though. – Jorj Aug 15 '15 at 11:16