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

Platform compatibility with MinGW and HPE NonStop #99

Merged
merged 4 commits into from
Sep 5, 2024

Conversation

pks-t
Copy link
Member

@pks-t pks-t commented Sep 5, 2024

Fix a couple of platform compatibility issues with MinGW and HPE NonStop. These patches are required by Git to make the clar work for all currently tested platforms.

The HPE NonStop changes have been picked from #96, removing the other changes to make the CFLAGS overridable. The Windows fixes have been picked from the downstream patch series in Git.

The patches were originally by @rsbeckerca and @dscho. I have noted authorship via Original-patch-by trailers, but am happy to attribute full authorship of the commits if preferred by the authors.

The NonStop platform does not have `mkdtemp()` available, which we rely
on in `build_sandbox_path()`. Fix this issue by using `mktemp()` and
`mkdir()` instead on this platform.

Original-patch-by: Randall S. Becker <[email protected]>
Signed-off-by: Patrick Steinhardt <[email protected]>
When using mingw-w64 to compile the code, and using `_stat()`, it is
necessary to use `struct _stat`, too, and not `struct stat` (as the
latter is incompatible with the "dashed" version because it is limited
to 32-bit time types for backwards compatibility).

Original-patch-by: Johannes Schindelin <[email protected]>
Signed-off-by: Patrick Steinhardt <[email protected]>
When CLAR_FIXTURE_PATH is unset, the `fs_copy()` function seems not to
be used. But it is declared as `static`, and GCC does not like that,
complaining that it should not be declared/defined to begin with.

We could mark this function as (potentially) unused by following the
`MAYBE_UNUSED` pattern from Git's `git-compat-util.h`. However, this is
a GCC-only construct that is not understood by Visual C. Besides, `clar`
does not use that pattern at all.

Instead, let's use the `((void)SYMBOL);` pattern that `clar` already
uses elsewhere; This avoids the compile error by sorta kinda make the
function used after a fashion.

Note: GCC 14.x (which Git for Windows' SDK already uses) is able to
figure out that this function is unused even though there are recursive
calls between `fs_copy()` and `fs_copydir_helper()`; Earlier GCC
versions do not detect that, and therefore the issue has been hidden
from the regular Linux CI builds (where GCC 14.x is not yet used). That
is the reason why this change is only made in the Windows-specific
portion of `t/unit-tests/clar/clar/fs.h`.

Original-patch-by: Johannes Schindelin <[email protected]>
Signed-off-by: Patrick Steinhardt <[email protected]>
The `shellapi.h` header was included as of
clar-test@136e763211aa, to have
`SHFileOperation()` declared so that it could be called.

However, clar-test@5ce31b69b525 removed
that call, and therefore that `#include <shellapi.h>` is unnecessary.

It is also unwanted in Git because this project uses a subset of Git for
Windows' SDK in its CI builds that (for bandwidth reasons) excludes tons
of header files, including `shellapi.h`.

So let's remove it.

Note: Since the `windows.h` header would include `shellapi.h` anyway, we
also define `WIN32_LEAN_AND_MEAN` to avoid this and similar other
unnecessary includes before including `windows.h`.

Original-patch-by: Johannes Schindelin <[email protected]>
Signed-off-by: Patrick Steinhardt <[email protected]>
@pks-t
Copy link
Member Author

pks-t commented Sep 5, 2024

Note that I'm wiring up support for Win32 CI in #100, which surfaces some of the Windows issues here.

@ethomson ethomson merged commit 614d38d into clar-test:main Sep 5, 2024
2 checks passed
@ethomson
Copy link
Member

ethomson commented Sep 5, 2024

Thanks!

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.

3 participants