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

Add @hidden UDA #3855

Merged
merged 1 commit into from
Oct 23, 2021
Merged

Add @hidden UDA #3855

merged 1 commit into from
Oct 23, 2021

Conversation

kinke
Copy link
Member

@kinke kinke commented Oct 20, 2021

To hide a symbol in the sense of making it DSO-local. An export visibility is stronger and overrides the UDA.

On non-Windows and non-Mac, also newly hide symbols (without export) with linkonce_odr etc. linkage. The Mac linker warns about hidden linkonce_odr symbols, e.g.:

ld: warning: direct access in function '__D3std6format5write__T14formattedWriteTSQBm5stdio4File17LockingTextWriterTaTSQCx9container5array__T5ArrayTiZQjZQDlFKQCzMxAaQBvZk' from file '{{RESULTS_DIR}}/runnable/ldc_github_1033_0.o' to global weak symbol '__D44TypeInfo_S3std5array__T8AppenderTAyaZQo4Data6__initZ' from file '/Users/runner/work/1/build/lib/libphobos2-ldc.a(array.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.

@kinke
Copy link
Member Author

kinke commented Oct 21, 2021

Ah wait, the Apple linker probably warns about a conflict between a public weak_odr TypeInfo symbol in regularly-compiled Phobos and a newly hidden linkonce_odr duplicate in an object file compiled with -linkonce-templates. That would make some sense to me. (dmd-testsuite debug was green, dmd-testsuite release with -linkonce-templates had failures.)

@kinke kinke force-pushed the hidden branch 2 times, most recently from 3a6054b to 0d517f2 Compare October 21, 2021 10:45
To hide a symbol in the sense of making it DSO-local. An `export`
visibility is stronger and overrides the UDA.

On non-Windows, also newly hide symbols (without `export`) with
linkonce_odr etc. linkage.
@JohanEngelen
Copy link
Member

It'll be useful for other use cases anywhere, nice.

@kinke
Copy link
Member Author

kinke commented Oct 22, 2021

Yeah, more power for power users. :)

Wrt. export overriding the UDA, that's motivated by the visibility being downgradable via public or whatever, whereas you cannot remove the UDA from a single declaration in an @hidden scope.

@kinke kinke merged commit 4fcbd69 into ldc-developers:master Oct 23, 2021
@kinke kinke deleted the hidden branch October 23, 2021 15:50
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