protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Disabling protobuf's TLS callbacks on Windows

Open Ou7law007 opened this issue 2 years ago • 2 comments

Platform: Windows Version: protobuf:x64-static-windows=3.21.4 (vcpkg)

Protobuf is generating TLS callbacks.

Just by including any .cc files (generated by protobuf) in the project, protobuf causes the final executable to have TLS callbacks present inside of it.

1- What's the purpose of these TLS callbacks? 2- How would one disable this behavior?

option optimize_for does not change anything about this.

Ou7law007 avatar Oct 25 '22 12:10 Ou7law007

Assuming "TLS" means "thread local storage", protobuf uses thread locals for some concurrency optimizations. Assuming you mean "transport layer security", I am quite stumped.

fowles avatar Oct 25 '22 19:10 fowles

transport layer security

I've never heard of transport layer security callbacks before 😅

Is it possible to omit these "concurrency optimizations" and manage them myself?

The compiler flag /Zc:threadSafeInit- (with the hyphen) allows for exactly this.

I'm not sure how to apply it for an external library such as protobuf or even better, if this was probably a built-in option?

Please don't tell me "compiling protobuf myself is the only option" because it was so painful and didn't even work in the end.

I also tried using vcpkg's triplets as follows:

set(VCPKG_CXX_FLAGS "/Zc:threadSafeInit-") set(VCPKG_CXX_FLAGS_DEBUG "/Zc:threadSafeInit-") set(VCPKG_CXX_FLAGS_RELEASE "/Zc:threadSafeInit-") set(VCPKG_C_FLAGS "/Zc:threadSafeInit-") set(VCPKG_C_FLAGS_DEBUG "/Zc:threadSafeInit-") set(VCPKG_C_FLAGS_RELEASE "/Zc:threadSafeInit-")

The TLS callbacks were still present.

Is protobuf maybe using some other external libraries that are using TLS callbacks? Isn't there a recursive way or some built in feature? I've been struggling with this for a while now.

Ou7law007 avatar Oct 25 '22 21:10 Ou7law007

@Ou7law007 did you by any chance happen to find a solution for this?

omry99 avatar Aug 24 '23 20:08 omry99

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

github-actions[bot] avatar Dec 30 '23 10:12 github-actions[bot]

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.

This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.

github-actions[bot] avatar Jan 16 '24 10:01 github-actions[bot]