Skip to content

[feature] Add wholearchive#2602

Merged
nickclark2016 merged 1 commit intopremake:masterfrom
Jarod42:whole_archive
Mar 12, 2026
Merged

[feature] Add wholearchive#2602
nickclark2016 merged 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).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to have list of strings instead of an ON/OFF flags.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note:
Instead of

link { 'my_library' }
wholearchive { 'my_library' }

I also think about alternative API (similar to existing :static/:shared suffix syntax):

link { 'my_library:wholearchive' }

but it seems team's preferences go for the first syntax.


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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reworded to "Command linker to include all objects of given libraries."


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

@Jarod42 Jarod42 Jan 12, 2026

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to have granular support.
I follow the suggestion and use linker flags instead of getlinks functionality.

@Jarod42 Jarod42 force-pushed the whole_archive branch 2 times, most recently from 5da4ce3 to d238cd6 Compare February 22, 2026 13:27
@Jarod42 Jarod42 force-pushed the whole_archive branch 7 times, most recently from a8a5149 to d6c8540 Compare March 9, 2026 15:55
@Jarod42 Jarod42 marked this pull request as ready for review March 11, 2026 08:22
@Jarod42 Jarod42 marked this pull request as draft March 11, 2026 08:23
@Jarod42 Jarod42 marked this pull request as ready for review March 11, 2026 13:03
@Jarod42 Jarod42 requested a review from nickclark2016 March 11, 2026 13:04
| [vectorextensions](vectorextensions.md) | Enable hardware vector extensions |
| [vpaths](vpaths.md) | |
| [warnings](warnings.md) | |
| [wholearchive](wholearchive.md) | |
Copy link
Member

Choose a reason for hiding this comment

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

Out of scope of this PR, but I feel like I always forget to add things here. We should probably check to make sure all of the APIs are actually here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or remove it completely, as it doesn't bring more information that reference listing on the left panel.
I also note that for some pages, including Project-API, we lose the left panel.

Copy link
Member

@nickclark2016 nickclark2016 left a comment

Choose a reason for hiding this comment

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

Verified build in my local project and no issues readily presented.

@nickclark2016 nickclark2016 merged commit 540361d into premake:master Mar 12, 2026
107 of 108 checks passed
@Jarod42 Jarod42 deleted the whole_archive branch March 12, 2026 13:58
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