Open
Conversation
phdye
pushed a commit
to phdye-cygwin/abseil-cpp
that referenced
this pull request
Apr 7, 2026
Cygwin (POSIX on Windows/PE-COFF) was blocked by missing __CYGWIN__ guards in platform-detection lists throughout the codebase. Each omission caused a different failure mode: compile errors, silent data loss, ABI mismatches, or wrong runtime behavior. Library patches (8): - policy_checks.h: remove #error "Cygwin is not supported" - attributes.h: disable ABSL_ATTRIBUTE_WEAK (PE/COFF has no ELF weak symbols; they cause virtual dispatch table collapse) - config.h: add ABSL_HAVE_MMAP (Cygwin has working mmap) - low_level_alloc.h: Cygwin can allocate via mmap but lacks async-signal-safe allocation (same as Windows) - sysinfo.cc: reinterpret_cast for GetTID (pthread_t is a pointer on Cygwin; static_cast to int fails at compile time) - sysinfo.h: pid_t = uintptr_t on Cygwin (prevents truncation of 8-byte pthread_t to 4-byte int) - log/internal/config.h: Tid = uint64_t on Cygwin (log entries were truncating thread IDs from 8 bytes to 4, causing collisions) - raw_logging.cc: add __CYGWIN__ to ABSL_HAVE_POSIX_WRITE list (raw log output was silently discarded via no-op fallback) Test patches (2): - charconv_test.cc: disable strtod NaN payload comparison on Cygwin (unspecified IEEE 754 behavior differs from glibc) - stripping_test.cc: add __CYGWIN__ to /proc/self/exe guard (Cygwin provides /proc/self/exe like Linux) Build requirement: -DGTEST_HAS_PTHREAD=1 in CMAKE_CXX_FLAGS. googletest's auto-detection omits GTEST_OS_CYGWIN from its pthread platform list, causing a Mutex ABI mismatch between libgmock.a (real pthread_mutex_t) and test binaries (no-op Mutex). 5 of the original 8 library patches are from abseil/abseil-cpp PR abseil#2012 (Carlo Bramini). The remaining 3 library patches and both test patches are new. Test results: 218/218 pass (ctest --timeout 300).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch adds support for CYGWIN.
Hopefully, very few changes are needed.
absl/base/attributes.hTalking about shared libraries, CYGWIN shares the same behaviour of the traditional WIN32 binaries with DLLs.
So, exactly like MinGW, the compiler doesn't complain about the
weakattribute until it fails at the link step.Here, the solution is to avoid the
weakattribute, exactly like it has been already done for the existing MinGW support.absl/base/internal/low_level_alloc.hCYGWIN lacks support for low-level allocation of virtual memory, so here it follows again the same behaviour of WIN32.
absl/base/internal/sysinfo.ccabsl/base/internal/sysinfo.hOn CYGWIN, the function
GetTID()cannot be compiled becausepid_tand the return value ofpthread_self()are not compatible.pid_tis aninttype, so it's 32 bit on CYGWIN.pthread_self()returns apthread_twhich is an opaque object.And, on CYGWIN,
pthread_tis atypedefto a pointer.When compiling for x86_64, the size of the pointer is 64bit.
So, there is a mismatch because 32bit != 64bit.
Hopefully, it is already possible to support a different
pid_tintoabsl/base/internal/sysinfo.h, so I did the same thing that it has been done for_WIN32and I added it to be anuintptr_t, which is good for all conditions.However, into
absl/base/internal/sysinfo.cc, thestatic_castis not able to convert yet.It can work if
pthread_self()returns anint, but sincepthread_tis an opaque object and it must be assumed to be like that, here thereinterpret_castlooks a better solution.absl/base/policy_checks.hSince CYGWIN is supported after these changes, the lines for blocking the execution of the build process are not needed anymore and they have been removed from the code.
===
The library compiled fine in all conditions.
Tested build with both shared and static libraries.
Tested build with
ABSL_BUILD_MONOLITHIC_SHARED_LIBSto beONandOFF.Sadly, I have no chance to execute bazel or Docker inside CYGWIN for running the tests because they seem to be not supported.
However, the chance that everything is working fine looks very high because CYGWIN is using code that already existed.
A direct test has been done with direct use, when building gstreamer-1.0, since abseil-cpp is a dependency.
If you think that this may be enough or something more can be done, please let me know.
I hope that you will find this patch useful.
Sincerely.
Carlo Bramini.
===
Thank you for your contribution to Abseil!
Before submitting this PR, please be sure to read our contributing
guidelines.
If you are a Googler, please also note that it is required that you send us a
Piper CL instead of using the GitHub pull-request process. The code propagation
process will deliver the change to GitHub.