Fix conditions mismatch for gc-sections with lld #115964
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Judging by the changes made in 410aa0a, gc-sections optimization should be enabled:
lld
newer than 12Both conditions are checked when adding linker arguments, but only the latter condition is checked when writing the linker script. This PR adds the missing conditions.
Relevant code
runtime/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
Lines 319 to 323 in 410aa0a
runtime/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets
Lines 338 to 341 in 410aa0a
Reproduction steps
This discrepancy is not observable in standard use cases. However, overriding the relevant properties will result in a vague error message unrelated to the actual issue.
Predictably, setting the
_LinkerVersion
property next will causesections.ld
file to be written but left unused: