Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6903109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:53:04+00:00 2026-05-27T07:53:04+00:00

When linking a shared library (or at least a Windows DLL), lots of optimizations

  • 0

When linking a shared library (or at least a Windows DLL), lots of optimizations are possible, and all functions and classes are thrown together and reorganized for optimal performance (or so I would think/hope).

Why are static libraries only a bag of objects? Wouldn’t it be better for the linker (both time and performance-wise) to have list of variables, functions, classes etc. that are contained within the object files, so when linking an executable or a shared object that uses this library can profit from an already performed optimization pass on interdependent things in the static library?

The static library creation would not take much longer (only a limited number of optimizations would be possible anyhow), but subsequent build steps using this library would be much faster/optimal.

PS: I’m mostly talking link-time-optimization here, but as all popular toolchains are proud to have this feature, I’m sure this question would pop up somehow? Please don’t answer this question with: that’s how it’s always been, and or compatibility nobody ever thought to change it. That’s not what I’m looking for…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:53:05+00:00Added an answer on May 27, 2026 at 7:53 am

    There is a conflict between link time code generation and pre-link optimizations.

    Assume from that library you call a function Foo only once with a fixed argument: Foo(12). LTCG now allows to reduce the Foo() implementation to that single case, invalidating all optimizations and call tree information you might previously have gathered.

    With that in mind only the information that Foo() does not call Bar() can carry over. I don’t see how that would significantly reduce link stage pressure, though.

    Ordering information is similarly subject to profiler-guided optimizations: which functions are hot spots that need to be grouped together can only be determined by the final binary.


    Generally it seems that optimization is moving towards the link stage, away from previous stages – and while the optimizations you suggest are feasible, it probably wouldn’t pay off when you weight it against the amount of scenarios where this could be used and the additional complexity in code (roughly proportional to number of bugs)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to import a shared object (without linking the program with it)
I want to create a shared library that uses functions from a 3rd-party static
I am working on creating and linking shared library (.so). While working with them,
I'm using shared library with explicit linking (loading shared lib with dlopen ) in
I have a shim library (shared, C++) which calls functions in another shared library
I'm having a linking problem. I need to link against a shared library libfoo.so
Linking a library with a project relative path in Visual studio 2008
I am successfully linking some of my code stored in a .jar-based library to
I was recently building a certain shared library (ELF) targeting x86-64 architecture, like this:
I am using a shared library. Which I am using it to cross compile

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.