[skip ci] Drop ZIP_STATIC
hack
#15963
Closed
+0
−6
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.
Old versions of libzip didn't export the
ZIP_STATIC
macro, even if they had been built as static libraries. This hack in config.w32 is supposed to counteract that, since the macro is used in zip.h. However, PHP has no business in defining macros belonging to external libraries; instead the winlibs builds should have been fixed to set this macro in zip.h. Furthermore, as of libzip there is zipconf.h, where this macro is defined as appropriate, if libzip was build with the proper configuration options. Unfortunately, that has not been done so far, but assuming that new properly configured builds of libzip will be rolled out, we need to drop this hack to avoid conflicting macro definitions, since we define the macro to 1, but libzip only defines it (without further hackery).This falls in the category "things that should not have happened, and either we apply the painful fix now, or never". The fix is painful, because with the currently shipped winlib libzip builds, ext/zip can no longer be built on Windows (thus
[skip ci]
), while properly configured static builds of libzip (-DBUILD_SHARED_LIBS=OFF
) won't work without this fix (or additional hacks in zipconf.h). Now, the simple fix of using#cmakedefine01
instead of#cmakedefine
would work for static libzip builds (even with this patch), but not for shared builds of libzip.Besides that ext/zip should never have used this hack in the first place, the problem appears to be that CMake either uses
#define
/#undef
, or#define 1
/#define 0
, while ourAC_DEFINE
does not support#define
/#undef
at all.And this is even more painful, because pecl/zip also defines
ZIP_STATIC
for static libzip builds, and does not even allow to build against shared libzip. Considering this, it might be best to stick with the hack forever, and patch libzip respectively to suit ext/zip; and to back away from dreaming that PHP on Windows can ever be built against unpatched dependency libraries.Alternatives include to ignore the C4005 warning, not to build with
/WX
, to undefine the macro prior to the collsion, or to add support for#define
to ourAC_DEFINE
.cc @petk, @remicollet and @shivammathur