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 annotations for exporting generated functions from a Windows DLL #13726

Open
dawidcha opened this issue Aug 24, 2023 · 10 comments
Open

Add annotations for exporting generated functions from a Windows DLL #13726

dawidcha opened this issue Aug 24, 2023 · 10 comments

Comments

@dawidcha
Copy link

I'm currently engaged in some work with gRPC aiming at merging a PR which permits gRPC to be built as a dynamic library under Windows (i.e. a DLL). here. gRPC makes use of μpb and needs to expose symbols generated by it from a DLL. That requires that the functions marked as extern be annotated with '__declspec(dllexport)' when compiled and '__declspec(dllimport)' when consumed.

For the protoc compiler, this is achieved by prefixing the file output location on the command line with dllexport_decl=MY_EXPORT_MACRO, and then defining MY_EXPORT_MACRO as either __declspec(dllimport) or __declspec(dllexport); or empty string, as appropriate, but this feature doesn't appear to be available in μpb.

Can something similar be added?

@acozzette acozzette transferred this issue from protocolbuffers/upb Aug 29, 2023
Copy link

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 github-actions bot added the inactive Denotes the issue/PR has not seen activity in the last 90 days. label Nov 28, 2023
@h-vetinari
Copy link
Contributor

Not stale.

@github-actions github-actions bot removed the inactive Denotes the issue/PR has not seen activity in the last 90 days. label Nov 29, 2023
Copy link

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 github-actions bot added the inactive Denotes the issue/PR has not seen activity in the last 90 days. label Feb 27, 2024
@h-vetinari
Copy link
Contributor

This is not stale, and there's an on open PR for this as well, at least in the context of upb (for now): #14981

@github-actions github-actions bot removed the inactive Denotes the issue/PR has not seen activity in the last 90 days. label Feb 28, 2024
Copy link

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 github-actions bot added the inactive Denotes the issue/PR has not seen activity in the last 90 days. label May 28, 2024
@h-vetinari
Copy link
Contributor

Not stale, and has a new PR now too: #17079

@github-actions github-actions bot removed the inactive Denotes the issue/PR has not seen activity in the last 90 days. label Jun 8, 2024
copybara-service bot pushed a commit that referenced this issue Jun 10, 2024
…7079)

Picking up #14981 from @dawidcha after several months of radio silence.

Quoting the OP of that PR:
> I have been collaborating with the grpc developers to make it possible to build that library as a Windows DLL - a couple of PRs were already merged, more like [grpc/grpc#34345](grpc/grpc#34345) are pending.
>
> The grpc library incorporates some upb-generated, and upbdefs-generated code into grpc.dll, which is referenced by other code that consumes the library. Since this is now a DLL, that code doesn't know how to link to these generated symbols because they are not annotated with __declspec(dllimport).
>
> This PR aims to fix that by introducing a parameter 'dllexport_tag' to the upb and upbdefs plugins. That parameter should be a string e.g. MYAPP_DLL and when set, the extern symbols are annotated with a macro with that name. This can either be set externally to __declspec(dllimport) or, as is usual practice, when compiling code into a DLL, the macro <dllexport_tag>_EXPORT (i.e. MYAPP_DLL_EXPORT) is defined, and when consuming the DLL <dllexport_tag>_IMPORT is defined if neither are defined then the MYAPP_DLL macro becomes empty string which is what you want for building a static library.
>
> This is a continuation of #14230
>
> Fixes: #14255

Towards #13726
Closes #14981

Closes #17079

COPYBARA_INTEGRATE_REVIEW=#17079 from h-vetinari:add_dll_tags 523b92a
FUTURE_COPYBARA_INTEGRATE_REVIEW=#17079 from h-vetinari:add_dll_tags 523b92a
PiperOrigin-RevId: 641996346
copybara-service bot pushed a commit that referenced this issue Jun 10, 2024
…7079)

Picking up #14981 from @dawidcha after several months of radio silence.

Quoting the OP of that PR:
> I have been collaborating with the grpc developers to make it possible to build that library as a Windows DLL - a couple of PRs were already merged, more like [grpc/grpc#34345](grpc/grpc#34345) are pending.
>
> The grpc library incorporates some upb-generated, and upbdefs-generated code into grpc.dll, which is referenced by other code that consumes the library. Since this is now a DLL, that code doesn't know how to link to these generated symbols because they are not annotated with __declspec(dllimport).
>
> This PR aims to fix that by introducing a parameter 'dllexport_tag' to the upb and upbdefs plugins. That parameter should be a string e.g. MYAPP_DLL and when set, the extern symbols are annotated with a macro with that name. This can either be set externally to __declspec(dllimport) or, as is usual practice, when compiling code into a DLL, the macro <dllexport_tag>_EXPORT (i.e. MYAPP_DLL_EXPORT) is defined, and when consuming the DLL <dllexport_tag>_IMPORT is defined if neither are defined then the MYAPP_DLL macro becomes empty string which is what you want for building a static library.
>
> This is a continuation of #14230
>
> Fixes: #14255

Towards #13726
Closes #14981

Closes #17079

COPYBARA_INTEGRATE_REVIEW=#17079 from h-vetinari:add_dll_tags 523b92a
FUTURE_COPYBARA_INTEGRATE_REVIEW=#17079 from h-vetinari:add_dll_tags 523b92a
PiperOrigin-RevId: 641996346
copybara-service bot pushed a commit that referenced this issue Jun 10, 2024
…7079)

Picking up #14981 from @dawidcha after several months of radio silence.

Quoting the OP of that PR:
> I have been collaborating with the grpc developers to make it possible to build that library as a Windows DLL - a couple of PRs were already merged, more like [grpc/grpc#34345](grpc/grpc#34345) are pending.
>
> The grpc library incorporates some upb-generated, and upbdefs-generated code into grpc.dll, which is referenced by other code that consumes the library. Since this is now a DLL, that code doesn't know how to link to these generated symbols because they are not annotated with __declspec(dllimport).
>
> This PR aims to fix that by introducing a parameter 'dllexport_tag' to the upb and upbdefs plugins. That parameter should be a string e.g. MYAPP_DLL and when set, the extern symbols are annotated with a macro with that name. This can either be set externally to __declspec(dllimport) or, as is usual practice, when compiling code into a DLL, the macro <dllexport_tag>_EXPORT (i.e. MYAPP_DLL_EXPORT) is defined, and when consuming the DLL <dllexport_tag>_IMPORT is defined if neither are defined then the MYAPP_DLL macro becomes empty string which is what you want for building a static library.
>
> This is a continuation of #14230
>
> Fixes: #14255

Towards #13726
Closes #14981

Closes #17079

COPYBARA_INTEGRATE_REVIEW=#17079 from h-vetinari:add_dll_tags 523b92a
FUTURE_COPYBARA_INTEGRATE_REVIEW=#17079 from h-vetinari:add_dll_tags 523b92a
PiperOrigin-RevId: 641996346
copybara-service bot pushed a commit that referenced this issue Jun 10, 2024
…7079)

Picking up #14981 from @dawidcha after several months of radio silence.

Quoting the OP of that PR:
> I have been collaborating with the grpc developers to make it possible to build that library as a Windows DLL - a couple of PRs were already merged, more like [grpc/grpc#34345](grpc/grpc#34345) are pending.
>
> The grpc library incorporates some upb-generated, and upbdefs-generated code into grpc.dll, which is referenced by other code that consumes the library. Since this is now a DLL, that code doesn't know how to link to these generated symbols because they are not annotated with __declspec(dllimport).
>
> This PR aims to fix that by introducing a parameter 'dllexport_tag' to the upb and upbdefs plugins. That parameter should be a string e.g. MYAPP_DLL and when set, the extern symbols are annotated with a macro with that name. This can either be set externally to __declspec(dllimport) or, as is usual practice, when compiling code into a DLL, the macro <dllexport_tag>_EXPORT (i.e. MYAPP_DLL_EXPORT) is defined, and when consuming the DLL <dllexport_tag>_IMPORT is defined if neither are defined then the MYAPP_DLL macro becomes empty string which is what you want for building a static library.
>
> This is a continuation of #14230
>
> Fixes: #14255

Towards #13726
Closes #14981

Closes #17079

COPYBARA_INTEGRATE_REVIEW=#17079 from h-vetinari:add_dll_tags 523b92a
FUTURE_COPYBARA_INTEGRATE_REVIEW=#17079 from h-vetinari:add_dll_tags 523b92a
PiperOrigin-RevId: 641996346
copybara-service bot pushed a commit that referenced this issue Jun 10, 2024
…7079)

Picking up #14981 from @dawidcha after several months of radio silence.

Quoting the OP of that PR:
> I have been collaborating with the grpc developers to make it possible to build that library as a Windows DLL - a couple of PRs were already merged, more like [grpc/grpc#34345](grpc/grpc#34345) are pending.
>
> The grpc library incorporates some upb-generated, and upbdefs-generated code into grpc.dll, which is referenced by other code that consumes the library. Since this is now a DLL, that code doesn't know how to link to these generated symbols because they are not annotated with __declspec(dllimport).
>
> This PR aims to fix that by introducing a parameter 'dllexport_tag' to the upb and upbdefs plugins. That parameter should be a string e.g. MYAPP_DLL and when set, the extern symbols are annotated with a macro with that name. This can either be set externally to __declspec(dllimport) or, as is usual practice, when compiling code into a DLL, the macro <dllexport_tag>_EXPORT (i.e. MYAPP_DLL_EXPORT) is defined, and when consuming the DLL <dllexport_tag>_IMPORT is defined if neither are defined then the MYAPP_DLL macro becomes empty string which is what you want for building a static library.
>
> This is a continuation of #14230
>
> Fixes: #14255

Towards #13726
Closes #14981

Closes #17079

COPYBARA_INTEGRATE_REVIEW=#17079 from h-vetinari:add_dll_tags 523b92a
FUTURE_COPYBARA_INTEGRATE_REVIEW=#17079 from h-vetinari:add_dll_tags 523b92a
PiperOrigin-RevId: 641996346
copybara-service bot pushed a commit that referenced this issue Jun 11, 2024
…7079)

Picking up #14981 from @dawidcha after several months of radio silence.

Quoting the OP of that PR:
> I have been collaborating with the grpc developers to make it possible to build that library as a Windows DLL - a couple of PRs were already merged, more like [grpc/grpc#34345](grpc/grpc#34345) are pending.
>
> The grpc library incorporates some upb-generated, and upbdefs-generated code into grpc.dll, which is referenced by other code that consumes the library. Since this is now a DLL, that code doesn't know how to link to these generated symbols because they are not annotated with __declspec(dllimport).
>
> This PR aims to fix that by introducing a parameter 'dllexport_tag' to the upb and upbdefs plugins. That parameter should be a string e.g. MYAPP_DLL and when set, the extern symbols are annotated with a macro with that name. This can either be set externally to __declspec(dllimport) or, as is usual practice, when compiling code into a DLL, the macro <dllexport_tag>_EXPORT (i.e. MYAPP_DLL_EXPORT) is defined, and when consuming the DLL <dllexport_tag>_IMPORT is defined if neither are defined then the MYAPP_DLL macro becomes empty string which is what you want for building a static library.
>
> This is a continuation of #14230
>
> Fixes: #14255

Towards #13726
Closes #14981

Closes #17079

COPYBARA_INTEGRATE_REVIEW=#17079 from h-vetinari:add_dll_tags 34927b1
FUTURE_COPYBARA_INTEGRATE_REVIEW=#17079 from h-vetinari:add_dll_tags 34927b1
PiperOrigin-RevId: 642315126
copybara-service bot pushed a commit that referenced this issue Jun 12, 2024
…7079)

Picking up #14981 from @dawidcha after several months of radio silence.

Quoting the OP of that PR:
> I have been collaborating with the grpc developers to make it possible to build that library as a Windows DLL - a couple of PRs were already merged, more like [grpc/grpc#34345](grpc/grpc#34345) are pending.
>
> The grpc library incorporates some upb-generated, and upbdefs-generated code into grpc.dll, which is referenced by other code that consumes the library. Since this is now a DLL, that code doesn't know how to link to these generated symbols because they are not annotated with __declspec(dllimport).
>
> This PR aims to fix that by introducing a parameter 'dllexport_tag' to the upb and upbdefs plugins. That parameter should be a string e.g. MYAPP_DLL and when set, the extern symbols are annotated with a macro with that name. This can either be set externally to __declspec(dllimport) or, as is usual practice, when compiling code into a DLL, the macro <dllexport_tag>_EXPORT (i.e. MYAPP_DLL_EXPORT) is defined, and when consuming the DLL <dllexport_tag>_IMPORT is defined if neither are defined then the MYAPP_DLL macro becomes empty string which is what you want for building a static library.
>
> This is a continuation of #14230
>
> Fixes: #14255

Towards #13726
Closes #14981

Closes #17079

COPYBARA_INTEGRATE_REVIEW=#17079 from h-vetinari:add_dll_tags 34927b1
PiperOrigin-RevId: 642622258
TinyTinni pushed a commit to TinyTinni/protobuf that referenced this issue Jun 15, 2024
…otocolbuffers#17079)

Picking up protocolbuffers#14981 from @dawidcha after several months of radio silence.

Quoting the OP of that PR:
> I have been collaborating with the grpc developers to make it possible to build that library as a Windows DLL - a couple of PRs were already merged, more like [grpc/grpc#34345](grpc/grpc#34345) are pending.
>
> The grpc library incorporates some upb-generated, and upbdefs-generated code into grpc.dll, which is referenced by other code that consumes the library. Since this is now a DLL, that code doesn't know how to link to these generated symbols because they are not annotated with __declspec(dllimport).
>
> This PR aims to fix that by introducing a parameter 'dllexport_tag' to the upb and upbdefs plugins. That parameter should be a string e.g. MYAPP_DLL and when set, the extern symbols are annotated with a macro with that name. This can either be set externally to __declspec(dllimport) or, as is usual practice, when compiling code into a DLL, the macro <dllexport_tag>_EXPORT (i.e. MYAPP_DLL_EXPORT) is defined, and when consuming the DLL <dllexport_tag>_IMPORT is defined if neither are defined then the MYAPP_DLL macro becomes empty string which is what you want for building a static library.
>
> This is a continuation of protocolbuffers#14230
>
> Fixes: protocolbuffers#14255

Towards protocolbuffers#13726
Closes protocolbuffers#14981

Closes protocolbuffers#17079

COPYBARA_INTEGRATE_REVIEW=protocolbuffers#17079 from h-vetinari:add_dll_tags 34927b1
PiperOrigin-RevId: 642622258
deannagarcia pushed a commit to deannagarcia/protobuf that referenced this issue Jun 20, 2024
…otocolbuffers#17079)

Picking up protocolbuffers#14981 from @dawidcha after several months of radio silence.

Quoting the OP of that PR:
> I have been collaborating with the grpc developers to make it possible to build that library as a Windows DLL - a couple of PRs were already merged, more like [grpc/grpc#34345](grpc/grpc#34345) are pending.
>
> The grpc library incorporates some upb-generated, and upbdefs-generated code into grpc.dll, which is referenced by other code that consumes the library. Since this is now a DLL, that code doesn't know how to link to these generated symbols because they are not annotated with __declspec(dllimport).
>
> This PR aims to fix that by introducing a parameter 'dllexport_tag' to the upb and upbdefs plugins. That parameter should be a string e.g. MYAPP_DLL and when set, the extern symbols are annotated with a macro with that name. This can either be set externally to __declspec(dllimport) or, as is usual practice, when compiling code into a DLL, the macro <dllexport_tag>_EXPORT (i.e. MYAPP_DLL_EXPORT) is defined, and when consuming the DLL <dllexport_tag>_IMPORT is defined if neither are defined then the MYAPP_DLL macro becomes empty string which is what you want for building a static library.
>
> This is a continuation of protocolbuffers#14230
>
> Fixes: protocolbuffers#14255

Towards protocolbuffers#13726
Closes protocolbuffers#14981

Closes protocolbuffers#17079

COPYBARA_INTEGRATE_REVIEW=protocolbuffers#17079 from h-vetinari:add_dll_tags 34927b1
PiperOrigin-RevId: 642622258
Copy link

github-actions bot commented Sep 6, 2024

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. This issue will be closed and archived after 14 additional days without activity.

@github-actions github-actions bot added the inactive Denotes the issue/PR has not seen activity in the last 90 days. label Sep 6, 2024
@h-vetinari
Copy link
Contributor

Not stale

@github-actions github-actions bot removed the inactive Denotes the issue/PR has not seen activity in the last 90 days. label Sep 7, 2024
Copy link

github-actions bot commented Dec 6, 2024

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. This issue will be closed and archived after 14 additional days without activity.

@github-actions github-actions bot added the inactive Denotes the issue/PR has not seen activity in the last 90 days. label Dec 6, 2024
@h-vetinari
Copy link
Contributor

Not stale (c.f. also #19422)

@github-actions github-actions bot removed the inactive Denotes the issue/PR has not seen activity in the last 90 days. label Dec 7, 2024
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

No branches or pull requests

2 participants