Skip to content

[feature] Add wholearchive#2602

Draft
Jarod42 wants to merge 1 commit intopremake:masterfrom
Jarod42:whole_archive
Draft

[feature] Add wholearchive#2602
Jarod42 wants to merge 1 commit intopremake:masterfrom
Jarod42:whole_archive

Conversation

@Jarod42
Copy link
Contributor

@Jarod42 Jarod42 commented Jan 12, 2026

What does this PR do?

Add wholearchive API which correspond to link option

How does this PR change Premake's behavior?

Add an API

Anything else we should know?

Tested with https://github.com/Jarod42/premake-sample-projects/tree/wholearchive/projects/wholearchive

Did you check all the boxes?

  • Focus on a single fix or feature; remove any unrelated formatting or code changes
  • Add unit tests showing fix or feature works; all tests pass
  • Mention any related issues (put closes #XXXX in comment to auto-close issue when PR is merged)
  • Follow our coding conventions
  • Minimize the number of commits
  • Align documentation to your changes

scope = "config",
kind = "string",
allowed = {
"Off",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's just on/off, it should be a boolean and not a string.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably have "Default" as well, because we should probably allow users to specify to use the default toolset/exporter behavior, rather than enforcing one behavior or another.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used linkgroups as model :-/

Ideally, I wanted libraries as well, but too lazy to do it, so currently an all or nothing.

Implementation would be more "On" or "Default" BTW :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not checked if we can have boolean or string (for individual library).


if cfg.wholearchive == p.ON then
-- Don't use "/WHOLEARCHIVE" as path.translate might be applied to result
links = table.translate(links, function (s) return "-WHOLEARCHIVE:" .. s end)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the path.translate issue something that you did indeed find to be a problem? Or is this pre-emptive?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I encounter it in visual.
Using - as workaround is rejected in commandline though (as ninja).
I think we have to specify 'shell' and translate path here.

@@ -0,0 +1,38 @@
Apply whole archive flag to linked libraries.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reword suggestion: Controls whether the linker should include all objects in the linked binary.


if cfg.wholearchive == p.ON then
-- Don't use "/WHOLEARCHIVE" as path.translate might be applied to result
links = table.translate(links, function (s) return "-WHOLEARCHIVE:" .. s end)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this should probably go into the linker flags, rather than the getlinks functionality. Also, I think the proper way to do this would be: link.exe foo.lib /WHOLEARCHIVE:foo.lib -- Following up on this, if we don't support granular whole archive, we can just have a single /WHOLEARCHIVE without specifying the individual libs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might try that.

if we don't support granular
I hope to add that support.

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.

2 participants