-
Notifications
You must be signed in to change notification settings - Fork 118
Windows compatibility changes for C++ code. #1967
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
base: develop
Are you sure you want to change the base?
Conversation
e092665
to
7290027
Compare
Reviewers: please provide a detailed review, especially focusing on code paths that were not just forked between Posix/Windows but were rewritten to be portable. The intent was that these should be NFC, but the original code had numerous bugs which I could spot (and expect were corner cases that were not being exercised), and I made judgment calls to fix them vs preserve broken behavior. |
tensilelite/Tensile/Source/lib/include/Tensile/Serialization/PlaceholderLibrary.hpp
Show resolved
Hide resolved
Rename incorrect find/replace ABC_dims back to abc.
bfe0a59
to
84b36f2
Compare
PTAL - Rebased and fixed a couple of minor issues on the Posix side (dladdr call needed a cast, and some missed |
} | ||
return pathstr; | ||
#else | ||
return std::string(realpath("/proc/self/exe", 0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If realpath cannot resolve /proc/self/exe then a nullptr is returned, which would cause undefined behaviour here when constructing the std::string. However, I understand this is an edge case and I'm not too familiar with /proc/self/exe. Is this guaranteed to be defined on all Posix-compliant systems?
@stellaraccident I am rebooting tests because there was a spurious docker failure. I am going to approve now because tests are otherwise passing. |
Includes findings/fixes from #1864.
Fixes all portability issues that resulted in compilation errors in C++ code. There are still warnings and some possible functional issues which need more work, but this is a first step we should commit. This patch was written/tested in a combined tree that is capable of building on Windows, and we need to verify that any rewritten paths do not regress Posix. With this and new CMake patches, the project compiles on Windows. It has some linkage issues on the tests which need further investigation (we have another branch with some of these findings/workarounds).
Several additional changes from the above:
#ifdef _WIN32
when the branches could be expressed in a portable manner.Explanations for some changes:
s/ABC/ABC_dims/
:ABC
is used as a bareword in Windows headers.s/WIN32/_WIN32/
:_WIN32
is the modern/correct way to detect if compiling on Windows. It is defined in all cases whereasWIN32
is only defined in some situations.ssize_t
is non-standard. In the place it is used, did the usual typedef from theSSIZE_T
type that windows provides in its headers.portable_uniform_int_distribution
template specializations instead of direct use ofstd::uniform_int_distribution
enables compilation on standards compliant C++ standard libs, which do not include char specializations (includes MSVC but also some others).DL_LIB
ways to include-ldl
on Posix. That is whatCMAKE_DL_LIBS
is for.libgen.h
withstd::filesystem
equivalents. We should not allowlibgen.h
in new code.u_int16_t
is not a real/standard type. Useuint16_t
.