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

Prelink static libraries into an object file #3677

Merged
merged 1 commit into from Jun 10, 2020

Conversation

matthewbauer
Copy link
Member

@matthewbauer matthewbauer commented Jun 10, 2020

This combines the *.o into a big .o producing one translation unit.
This preserve our unused static initializers, as specified in the C++
standard:

If no variable or function is odr-used from a given translation
unit, the non-local variables defined in that translation unit may
never be initialized (this models the behavior of an on-demand
dynamic library).

Note that this is very similar to how the --whole-archive flag works.
One advantage of this approach is that users of the final .a library don’t have
to worry about specifying --whole-archive, or that we have unused
static initializers at all!

related to #2698 and #3511.

This combines the *.o into a big .o producing one translation unit.
This preserve our unused static initializers, as specified in the C++
standard:

  If no variable or function is odr-used from a given translation
  unit, the non-local variables defined in that translation unit may
  never be initialized (this models the behavior of an on-demand
  dynamic library).

Note that this is very similar to how the --whole-archive flag works.
One advantage of this is that users of the final .a library don’t have
to worry about specifying --whole-archive, or that we have unused
static initializers at all!
@Mic92
Copy link
Member

Mic92 commented Jun 10, 2020

That makes sense to me.

@domenkozar
Copy link
Member

Best if this came with release.nix changes to also build statically on CI :)

@edolstra edolstra merged commit dc719b9 into NixOS:master Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants