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

undefined link errors on Windows #16844

Closed
avdv opened this issue May 14, 2024 · 8 comments · May be fixed by #20025
Closed

undefined link errors on Windows #16844

avdv opened this issue May 14, 2024 · 8 comments · May be fixed by #20025
Assignees
Labels
c++ inactive Denotes the issue/PR has not seen activity in the last 90 days. windows

Comments

@avdv
Copy link

avdv commented May 14, 2024

What version of protobuf and what language are you using?
Version: 26.1 / 27.0
Language: C++

What operating system (Linux, Windows, ...) and version?

Windows Server 2022 10.0.20348

What runtime / compiler are you using (e.g., python version or gcc version)

clang version 14.0.6
Target: x86_64-w64-windows-gnu
Thread model: posix

What did you do?
Steps to reproduce the behavior:

I am using Bazel (version 6.5.0) either using a workspace file or using a module (module version 26.0.bcr.1) and trying to build @com_google_protobuf//:protoc or @protobuf~26.0.bcr.1//:protoc respectively.

What did you expect to see

The build should succeed.

What did you see instead?

ERROR: C:/_bzl/minshlu6/external/com_google_protobuf/BUILD.bazel:225:10: Linking external/com_google_protobuf/protoc.exe [for tool] failed: (Exit 1): clang failed: error executing command (from target @com_google_protobuf//:protoc) 
  cd /d C:/_bzl/minshlu6/execroot/rules_haskell
  SET PATH=C:\Program Files\Git\usr\bin;C:\Program Files\Git\bin;C:\Windows;C:\Windows\System32;C:\Windows\System32\WindowsPowerShell\v1.0
    SET ***
    SET RUNFILES_MANIFEST_ONLY=1
  external\rules_haskell_ghc_windows_amd64\mingw\bin\clang -o bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/protoc.exe bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/libprotoc_lib.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/libcommand_line_interface.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/allowlists/liballowlists.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/libimporter.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/cpp/libcpp.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/csharp/libcsharp.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/csharp/libnames.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/java/libjava.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/java/libnames_internal.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/java/libjava_features_bootstrap.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/objectivec/libobjectivec.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/objectivec/libnames_internal.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/objectivec/libline_consumer.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/php/libphp.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/php/libnames.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/python/libpython.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/libversions.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/ruby/libruby.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/rust/librust.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/rust/libcrate_mapping.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/testing/libfile.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/rust/libmessage.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/rust/libenum.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/rust/liboneof.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/rust/libaccessors.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/rust/libhelpers.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/upb_generator/libmangle.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/rust/libnaming.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/rust/libcontext.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/rust/librelative_path.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/cpp/libnames_internal.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/libcode_generator.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/compiler/libretention.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/libprotobuf.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/libprotobuf_lite.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/io/libgzip_stream.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/zlib/libzlib.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/io/libtokenizer.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/third_party/utf8_range/libutf8_validity.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/third_party/utf8_range/libutf8_range.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/io/libprinter.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/io/libzero_copy_sink.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/io/libio.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/io/libio_win32.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/libarena.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/libarena_align.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/stubs/liblite.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src/google/protobuf/libport.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/container/libraw_hash_set.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/container/libhashtablez_sampler.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/log/internal/libcheck_op.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/log/internal/libconditions.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/log/internal/liblog_message.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/log/internal/libformat.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/log/internal/libnullguard.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/log/internal/libproto.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/debugging/libexamine_stack.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/log/internal/liblog_sink_set.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/log/liblog_sink.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/log/liblog_entry.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/status/libstatusor.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/status/libstatus.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/base/libstrerror.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/strings/libcord.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/strings/libcordz_info.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/strings/libcord_internal.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/strings/libcordz_functions.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/profiling/libexponential_biased.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/strings/libcordz_handle.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/crc/libcrc_cord_state.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/crc/libcrc32c.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/crc/libcrc_internal.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/crc/libcpu_detect.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/strings/libstr_format_internal.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/log/libinitialize.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/log/libglobals.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/hash/libhash.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/hash/libcity.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/hash/liblow_level_hash.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/types/libbad_variant_access.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/log/internal/libvlog_config.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/log/internal/libfnmatch.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/synchronization/libsynchronization.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/synchronization/libgraphcycles_internal.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/synchronization/libkernel_timeout_internal.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/debugging/libstacktrace.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/debugging/libsymbolize.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/debugging/libdebugging_internal.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/debugging/libdemangle_internal.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/base/libmalloc_internal.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/log/internal/libglobals.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/time/libtime.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/strings/libstrings.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/strings/libinternal.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/strings/libstring_view.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/base/libbase.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/base/libspinlock_wait.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/base/libthrow_delegate.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/numeric/libint128.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/time/internal/cctz/libtime_zone.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/time/internal/cctz/libcivil_time.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/types/libbad_optional_access.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/base/libraw_logging_internal.a bazel-out/x64_windows-opt-exec-2B5CBBC6/bin/external/com_google_absl/absl/base/liblog_severity.a -lpthread -lm -lpthread -lm -lpthread -lm -lpthread -lm -pthread -pthread -pthread -Wl,-S -lstdc++
# Configuration: 0b9902a8d78c28a893025c1bf3016058917f4c3cbd7fad5689dd81d8311894be
# Execution platform: @local_config_platform//:host
ld.lld: error: undefined symbol: __start_pb_defaults
>>> referenced by libprotobuf_lite.a(generated_message_util.o):(.refptr.__start_pb_defaults)

ld.lld: error: undefined symbol: __stop_pb_defaults
>>> referenced by libprotobuf_lite.a(generated_message_util.o):(.refptr.__stop_pb_defaults)

ld.lld: error: undefined symbol: __declspec(dllimport) SymSetOptions
>>> referenced by libsymbolize.a(symbolize.o):(absl::lts_20240116::InitializeSymbolizer(char const*))

ld.lld: error: undefined symbol: __declspec(dllimport) SymInitialize
>>> referenced by libsymbolize.a(symbolize.o):(absl::lts_20240116::InitializeSymbolizer(char const*))

ld.lld: error: undefined symbol: __declspec(dllimport) SymFromAddr
>>> referenced by libsymbolize.a(symbolize.o):(absl::lts_20240116::Symbolize(void const*, char*, int))
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment

@avdv avdv added the untriaged auto added to all issues by default when created. label May 14, 2024
@avdv
Copy link
Author

avdv commented Jun 25, 2024

This looks like -ldbghelp linker option is missing which is needed by abseil for its symbolizer.

\edit: Yes, adding -ldbghelp to the linkopts fixes the undefined symbol errors for SymSetOptions and SymInitialize.

But the __start_pb_defaults and __stop_pb_defaults symbols remain undefined. These are declared in src/google/protobuf/generated_messages.cc but only if PROTOBUF_DESCRIPTOR_WEAK_MESSAGES_ALLOWED is defined.

Is the __start / __stop mechanism supported on Windows with PE/COFF?

avdv added a commit to tweag/rules_haskell that referenced this issue Jun 26, 2024
avdv added a commit to tweag/rules_haskell that referenced this issue Jun 26, 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. 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 24, 2024
@avdv
Copy link
Author

avdv commented Sep 24, 2024

This is still a problem, it also happens with version 28.0.

@github-actions github-actions bot removed the inactive Denotes the issue/PR has not seen activity in the last 90 days. label Sep 25, 2024
@JasonLunn JasonLunn added c++ windows and removed untriaged auto added to all issues by default when created. labels Oct 3, 2024
@sbenzaquen
Copy link
Contributor

It seems the preprocessor checks we have are not taking into account this particular combination of clang+windows properly.
Would you be able to test a fix? I can't test on that configuration.

The proposed fix would be to modify PROTOBUF_DESCRIPTOR_WEAK_MESSAGES_ALLOWED in port_def.inc to add
&& !defined(_WIN32) to the predicate.

@avdv
Copy link
Author

avdv commented Oct 4, 2024

It seems the preprocessor checks we have are not taking into account this particular combination of clang+windows properly. Would you be able to test a fix? I can't test on that configuration.

The proposed fix would be to modify PROTOBUF_DESCRIPTOR_WEAK_MESSAGES_ALLOWED in port_def.inc to add && !defined(_WIN32) to the predicate.

Ha! You mean like this 😼 ?
tweag/rules_haskell@5cd6270#diff-65d611c8fe5c0eb76570cf39b77fc50a823a26f2755f64d0011cf980f59787b6R18-R25

That works indeed.

Copy link

github-actions bot commented Jan 2, 2025

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 Jan 2, 2025
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 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 github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 17, 2025
@avdv
Copy link
Author

avdv commented Jan 17, 2025

Still not fixed, please re-open. PR coming up....

@sbenzaquen PR is here: #20025 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ inactive Denotes the issue/PR has not seen activity in the last 90 days. windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants