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

Privatize zlib + friends; build shared on win; bump to 1.55, build with protobuf 4.23 #243

Merged
merged 17 commits into from
May 24, 2023

Conversation

h-vetinari
Copy link
Member

@h-vetinari h-vetinari commented Sep 12, 2022

Follow-up to #213 / #236, cleaned up version of #237.

Also trying to switch to shared builds on windows.

Enabling the pkg-config tests on windows needs some more work in abseil, see #242

Closes #237
Closes #246
Closes #296

@conda-forge-linter
Copy link

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipe) and found it was in an excellent condition.

@h-vetinari
Copy link
Member Author

h-vetinari commented Sep 12, 2022

Preserving the log as azure will delete on push due to the very slow osx agent we caught

[1174/1200] Linking CXX shared library grpc.dll
FAILED: grpc.dll grpc.lib 
cmd.exe /C "cmd.exe /C "D:\bld\grpc-split_1662996274711\_build_env\Library\bin\cmake.exe -E __create_def D:\bld\grpc-split_1662996274711\work\build-cpp\CMakeFiles\grpc.dir\.\exports.def D:\bld\grpc-split_1662996274711\work\build-cpp\CMakeFiles\grpc.dir\.\exports.def.objs && cd D:\bld\grpc-split_1662996274711\work\build-cpp" && D:\bld\grpc-split_1662996274711\_build_env\Library\bin\cmake.exe -E vs_link_dll --intdir=CMakeFiles\grpc.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests  -- C:\PROGRA~2\MICROS~1\2019\ENTERP~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\grpc.rsp  /out:grpc.dll /implib:grpc.lib /pdb:grpc.pdb /dll /version:26.0 /machine:x64 /INCREMENTAL:NO  /DEF:CMakeFiles\grpc.dir\.\exports.def  && cd ."
LINK: command "C:\PROGRA~2\MICROS~1\2019\ENTERP~1\VC\Tools\MSVC\1429~1.301\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\grpc.rsp /out:grpc.dll /implib:grpc.lib /pdb:grpc.pdb /dll /version:26.0 /machine:x64 /INCREMENTAL:NO /DEF:CMakeFiles\grpc.dir\.\exports.def /MANIFEST /MANIFESTFILE:grpc.dll.manifest" failed (exit code 1120) with the following output:
   Creating library grpc.lib and object grpc.exp
alts_tsi_handshaker.cc.obj : error LNK2001: unresolved external symbol upb_alloc_global
transport_security_common_api.cc.obj : error LNK2001: unresolved external symbol upb_alloc_global
rls.cc.obj : error LNK2001: unresolved external symbol upb_alloc_global
xds_api.cc.obj : error LNK2001: unresolved external symbol upb_alloc_global
status_helper.cc.obj : error LNK2001: unresolved external symbol upb_alloc_global
alts_handshaker_client.cc.obj : error LNK2001: unresolved external symbol upb_alloc_global
backend_metric.cc.obj : error LNK2001: unresolved external symbol upb_alloc_global
health_check_client.cc.obj : error LNK2001: unresolved external symbol upb_alloc_global
grpclb.cc.obj : error LNK2001: unresolved external symbol upb_alloc_global
oob_backend_metric.cc.obj : error LNK2001: unresolved external symbol upb_alloc_global
alts_tsi_handshaker.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
completion_queue.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
init.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
lame_client.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
server.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
call.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
call_details.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
channel.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
channel_ping.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
slice_api.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
slice_buffer_api.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
byte_buffer.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
byte_buffer_reader.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
grpc_tls_certificate_provider.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
grpc_tls_certificate_verifier.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
grpc_tls_credentials_options.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
server_auth_filter.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
iam_credentials.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
jwt_credentials.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
jwt_verifier.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
plugin_credentials.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
api.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
security_context.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
credentials.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
google_default_credentials.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
iomgr.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
resolve_address_windows.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
timer_manager.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
sleep.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
channelz_registry.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
endpoint_pair_windows.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
executor.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
iocp_windows.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
chttp2_server.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
inproc_transport.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
xds_client.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
xds_server_config_fetcher.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
channel_connectivity.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
grpclb.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
subchannel.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
chttp2_connector.cc.obj : error LNK2001: unresolved external symbol "private: static struct std::atomic<bool> grpc_core::Fork::support_enabled_" (?support_enabled_@Fork@grpc_core@@0U?$atomic@_N@std@@A)
grpc.dll : fatal error LNK1120: 2 unresolved externals

ninja: build stopped: subcommand failed.

@h-vetinari
Copy link
Member Author

@isuruf

I managed to get rid of the linkage errors for upb_alloc_global, but for 1.48, there's a private static member that's eluding me (I'm starting with 1.48 directly with no intention to backport this change to 1.46/47, because I'd like to leave those versions stable now, and rather only do it for 1.48 and then see how the migration for that goes).

I tried a bunch of combinations of dllimport (based on the definition of ABSL_DLL, I would have expected we need dllexport while building, but this fails even harder), and marking either the member declaration (in .h), its definition (in .cc) or the whole class as dllimport, or even the member as public. But I struggle to find the right combination for this - my C++-foo is not the best, and certainly not when combined with the MSVC shenanigans.

If you have some insights on that, this would be much appreciated. 🙃

@h-vetinari
Copy link
Member Author

@isuruf
It's surprisingly tricky to google useful information on the the dllimport / export stuff (especially in conjunction with class members), so if the solution is obvious to you, I'd appreciate if you could share some pointers. :)

@h-vetinari
Copy link
Member Author

Thanks for the help!

Would you have anything against making the name a bit more homogeneous, i.e.
grpc_EXPORTS, GRPC_CONSUME_DLL -> gRPC_DLL_EXPORTS, gRPC_DLL_IMPORTS
resp.:

// Note: gRPC_DLL_EXPORTS is set by CMake when building the DLL
//       gRPC_DLL_IMPORTS is part of the interface for consumers of the DLL
#if defined(gRPC_DLL_EXPORTS)
#define GRPC_DLL __declspec(dllexport)
#elif defined(gRPC_DLL_IMPORTS)
#define GRPC_DLL __declspec(dllimport)
#else
#define GRPC_DLL
#endif // defined(gRPC_DLL_EXPORTS)

Also: fair warning that I'm going to rebase out my garbage commits.

@h-vetinari
Copy link
Member Author

On closer inspection, since I don't find grpc_EXPORTS specified anywhere I guess you're relying on CMake here - seems <target>_EXPORTS gets populated automatically...

@h-vetinari
Copy link
Member Author

I think it might be cleaner to override this default from DEFINE_SYMBOL

@h-vetinari
Copy link
Member Author

Or maybe not override it. In any case, <target_name>_IMPORTS seems to be unoccupied, so I'm also fine with closing the symmetry gap like that.

@h-vetinari
Copy link
Member Author

LINK : fatal error LNK1181: cannot open input file 'address_sorting.lib'

I think we're going to need set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) globally after all.

I had it in the bat script before.

@h-vetinari
Copy link
Member Author

This is so weird to me...

error LNK2001: unresolved external symbol upb_alloc_global

is back now that we're using the by-the-book setup, but it was not an issue when it had just been hardcoded to __declspec(dllimport). And that private static member is still missing...

PS. Link to CI run that just finished

@h-vetinari
Copy link
Member Author

Ah, just noticed that we're in a different lib here still...

[1167/1200] Linking CXX shared library grpc_unsecure.dll
FAILED: grpc_unsecure.dll grpc_unsecure.lib 

And grpc_unsecure does not depend on grpc itself (nor the other way around), so I think we'll have to go back to explicitly setting a common variable (like ABSL_BUILD_DLL resp what I had before).

@h-vetinari
Copy link
Member Author

I'm going to try what I had in mind here, but to be clear: I'm very grateful for your help and in no way do I want to be disrespectful by force-pushing over your changes. That's why I opened #246, so we can both iterate without sharing the same PR.

@h-vetinari
Copy link
Member Author

Well, the whole dance around grpc_core::Fork::support_enabled_ is a bit pointless on windows (no fork), which is also explicitly pointed out (though the only mention I found of this was in the python bindings)

@h-vetinari
Copy link
Member Author

@isuruf
Do you think we should still pursue this? I don't want to keep stalling versions indefinitely; now there's 1.50 out and I've been waiting for a resolution to the privatization thing before starting a new migration, but it seems that we should just move on with the current state (needing zlib at runtime) & retry again after 1.50?

At least I'm not confident I can shepherd this to completion, the windows symbol export stuff is just excruciating (I've also been really low on FOSS-time recently), and I'm out of ideas after we've now effectively copied the whole

#if defined(gRPC_DLL_EXPORTS)
#define GRPC_DLL __declspec(dllexport)
#elif defined(gRPC_DLL_IMPORTS)
#define GRPC_DLL __declspec(dllimport)
#else
#define GRPC_DLL
#endif // defined(gRPC_DLL_EXPORTS)

shebang, and it still not working.

@h-vetinari
Copy link
Member Author

Ping @isuruf, any further thoughts here?

Otherwise I think it's time to merge the PR for 1.49 and then start migrating 1.49 (skipping 1.48). We could use 1.50 to iterate on the privatization part.

@isuruf
Copy link
Member

isuruf commented Oct 22, 2022

You need to do

set_target_properties(upb PROPERTIES DEFINE_SYMBOL "gRPC_DLL_EXPORTS")

around https://github.com/grpc/grpc/blob/v1.48.1/CMakeLists.txt#L4215

@h-vetinari
Copy link
Member Author

OK I'll try, thanks a lot! What do you think we should do about grpc_core::Fork::support_enabled_?

Unconditionally set it to False on windows?

@h-vetinari
Copy link
Member Author

upb_alloc_global still missing even with the DEFINE_SYMBOL in place; grpc_core::Fork::support_enabled_ unchanged of course.

@h-vetinari
Copy link
Member Author

I had a commit with the rename lined up (even though the interaction is not clear to me), but was waiting for CI to finish (I don't like how azure deletes logs of interrupted runs; makes going back to previous logs much harder).

In any case, I pushed your changes to #246. Like I asked above, please use that one if you want to iterate.

@h-vetinari
Copy link
Member Author

Not sure if this rabbit hole ever ends... Despite doing the same for some more missing symbols now (even disambiguating further), I still run into:

server_cc.cc.obj : error LNK2001: unresolved external symbol "private: static class grpc_core::ExecCtx * grpc_core::ExecCtx::exec_ctx_" (?exec_ctx_@ExecCtx@grpc_core@@0PEAV12@EA)
client_callback.cc.obj : error LNK2001: unresolved external symbol "private: static class grpc_core::ExecCtx * grpc_core::ExecCtx::exec_ctx_" (?exec_ctx_@ExecCtx@grpc_core@@0PEAV12@EA)
alarm.cc.obj : error LNK2001: unresolved external symbol "private: static class grpc_core::ExecCtx * grpc_core::ExecCtx::exec_ctx_" (?exec_ctx_@ExecCtx@grpc_core@@0PEAV12@EA)
channel_arguments.cc.obj : error LNK2001: unresolved external symbol "private: static class grpc_core::ExecCtx * grpc_core::ExecCtx::exec_ctx_" (?exec_ctx_@ExecCtx@grpc_core@@0PEAV12@EA)
server_callback.cc.obj : error LNK2001: unresolved external symbol "private: static class grpc_core::ExecCtx * grpc_core::ExecCtx::exec_ctx_" (?exec_ctx_@ExecCtx@grpc_core@@0PEAV12@EA)
alarm.cc.obj : error LNK2019: unresolved external symbol "private: static class grpc_core::ApplicationCallbackExecCtx * grpc_core::ApplicationCallbackExecCtx::callback_exec_ctx_" (?callback_exec_ctx_@ApplicationCallbackExecCtx@grpc_core@@0PEAV12@EA) referenced in function "public: __cdecl grpc_core::ApplicationCallbackExecCtx::ApplicationCallbackExecCtx(void)" (??0ApplicationCallbackExecCtx@grpc_core@@QEAA@XZ)
default_health_check_service.cc.obj : error LNK2019: unresolved external symbol grpc_health_v1_HealthCheckRequest_msginit referenced in function "private: static bool __cdecl grpc::DefaultHealthCheckService::HealthCheckServiceImpl::DecodeRequest(class grpc::ByteBuffer const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?DecodeRequest@HealthCheckServiceImpl@DefaultHealthCheckService@grpc@@CA_NAEBVByteBuffer@3@PEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
default_health_check_service.cc.obj : error LNK2019: unresolved external symbol grpc_health_v1_HealthCheckResponse_msginit referenced in function "private: static bool __cdecl grpc::DefaultHealthCheckService::HealthCheckServiceImpl::EncodeResponse(enum grpc::DefaultHealthCheckService::ServingStatus,class grpc::ByteBuffer *)" (?EncodeResponse@HealthCheckServiceImpl@DefaultHealthCheckService@grpc@@CA_NW4ServingStatus@23@PEAVByteBuffer@3@@Z)
call_metric_recorder.cc.obj : error LNK2019: unresolved external symbol xds_data_orca_v3_OrcaLoadReport_msginit referenced in function "private: class std::optional<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > __cdecl grpc::experimental::CallMetricRecorder::CreateSerializedReport(void)" (?CreateSerializedReport@CallMetricRecorder@experimental@grpc@@AEAA?AV?$optional@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@std@@XZ)

grpc++_unsecure.dll : fatal error LNK1120: 5 unresolved externals

@h-vetinari h-vetinari changed the title Privatize zlib + friends; build shared on windows Privatize zlib + friends; build shared on win; bump to 1.55, build with protobuf 4.23 May 24, 2023
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.

None yet

4 participants