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

zlib build failure when using bundled version #360

Open
carlosperate opened this issue Sep 6, 2023 · 1 comment · May be fixed by #388
Open

zlib build failure when using bundled version #360

carlosperate opened this issue Sep 6, 2023 · 1 comment · May be fixed by #388

Comments

@carlosperate
Copy link

Builds fine when libz-dev is installed in Ubuntu 22.04, but without it, it tries to use the local submodule sources and fails to find zlib.h.

$ cmake -B build -G Ninja -S . && cmake --build build
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
-- Checking for one of the modules 're2'
-- Checking for one of the modules 'capstone'
-- Checking for one of the modules 'protobuf'
-- System re2 not found, using bundled version
-- System capstone not found, using bundled version
-- System protobuf not found, using bundled version
-- System zlib not found, using bundled version
-- Setting build type to 'RelWithDebInfo' as none was specified.
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
CMake Deprecation Warning at third_party/capstone/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Warning (dev) at third_party/capstone/CMakeLists.txt:2 (project):
  Policy CMP0048 is not set: project() command manages VERSION variables.
  Run "cmake --help-policy CMP0048" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  The following variable(s) would be set to empty:

    PROJECT_VERSION
    PROJECT_VERSION_MAJOR
    PROJECT_VERSION_MINOR
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Deprecation Warning at third_party/capstone/CMakeLists.txt:18 (cmake_policy):
  The OLD behavior for policy CMP0048 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


Enabling CAPSTONE_ARM_SUPPORT
Enabling CAPSTONE_ARM64_SUPPORT
Enabling CAPSTONE_M68K_SUPPORT
Enabling CAPSTONE_MIPS_SUPPORT
Enabling CAPSTONE_PPC_SUPPORT
Enabling CAPSTONE_SPARC_SUPPORT
Enabling CAPSTONE_SYSZ_SUPPORT
Enabling CAPSTONE_XCORE_SUPPORT
Enabling CAPSTONE_X86_SUPPORT
Enabling CAPSTONE_TMS320C64X_SUPPORT
Enabling CAPSTONE_M680X_SUPPORT
Enabling CAPSTONE_EVM_SUPPORT
Enabling CAPSTONE_MOS65XX_SUPPORT
--
-- 3.9.1.0
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
-- Performing Test protobuf_HAVE_BUILTIN_ATOMICS
-- Performing Test protobuf_HAVE_BUILTIN_ATOMICS - Success
CMake Deprecation Warning at third_party/zlib/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Warning (dev) at third_party/zlib/CMakeLists.txt:4 (project):
  Policy CMP0048 is not set: project() command manages VERSION variables.
  Run "cmake --help-policy CMP0048" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  The following variable(s) would be set to empty:

    PROJECT_VERSION
    PROJECT_VERSION_MAJOR
    PROJECT_VERSION_MINOR
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - done
-- Looking for fseeko
-- Looking for fseeko - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Renaming
--     /bloaty/third_party/zlib/zconf.h
-- to 'zconf.h.included' because this file is included with zlib
-- but CMake generates it automatically in the build directory.
-- Performing Test SUPPORTS_COLOR_ALWAYS
-- Performing Test SUPPORTS_COLOR_ALWAYS - Success
-- Could NOT find Python (missing: Python_EXECUTABLE Interpreter)
-- Could NOT find Python (missing: Python_EXECUTABLE Interpreter)
-- Configuring done
-- Generating done
-- Build files have been written to: /bloaty/build
[96/375] Building CXX object third_party/protobuf/cmake/CMakeFiles/libprotobuf-lite.dir/__/src/google/protobuf/message_lite.cc.o
In file included from /usr/include/string.h:535,
                 from /bloaty/third_party/protobuf/src/google/protobuf/stubs/port.h:38,
                 from /bloaty/third_party/protobuf/src/google/protobuf/stubs/common.h:46,
                 from /bloaty/third_party/protobuf/src/google/protobuf/message_lite.h:45,
                 from /bloaty/third_party/protobuf/src/google/protobuf/message_lite.cc:36:
In function 'void* memcpy(void*, const void*, size_t)',
    inlined from 'google::protobuf::uint8* google::protobuf::io::EpsCopyOutputStream::WriteRaw(const void*, int, google::protobuf::uint8*)' at /bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:697:16,
    inlined from 'virtual google::protobuf::uint8* google::protobuf::internal::ImplicitWeakMessage::InternalSerializeWithCachedSizesToArray(google::protobuf::uint8*, google::protobuf::io::EpsCopyOutputStream*) const' at /bloaty/third_party/protobuf/src/google/protobuf/implicit_weak_message.h:87:28,
    inlined from 'bool google::protobuf::MessageLite::SerializePartialToZeroCopyStream(google::protobuf::io::ZeroCopyOutputStream*) const' at /bloaty/third_party/protobuf/src/google/protobuf/message_lite.cc:387:51:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:33: warning: 'void* __builtin___memcpy_chk(void*, const void*, long unsigned int, long unsigned int)' specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
   29 |   return __builtin___memcpy_chk (__dest, __src, __len,
      |          ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
   30 |                                  __glibc_objsize0 (__dest));
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~
[126/375] Building CXX object third_party/protobuf/cmake/CMakeFiles/libprotobuf.dir/__/src/google/protobuf/message_lite.cc.o
In file included from /usr/include/string.h:535,
                 from /bloaty/third_party/protobuf/src/google/protobuf/stubs/port.h:38,
                 from /bloaty/third_party/protobuf/src/google/protobuf/stubs/common.h:46,
                 from /bloaty/third_party/protobuf/src/google/protobuf/message_lite.h:45,
                 from /bloaty/third_party/protobuf/src/google/protobuf/message_lite.cc:36:
In function 'void* memcpy(void*, const void*, size_t)',
    inlined from 'google::protobuf::uint8* google::protobuf::io::EpsCopyOutputStream::WriteRaw(const void*, int, google::protobuf::uint8*)' at /bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:697:16,
    inlined from 'virtual google::protobuf::uint8* google::protobuf::internal::ImplicitWeakMessage::InternalSerializeWithCachedSizesToArray(google::protobuf::uint8*, google::protobuf::io::EpsCopyOutputStream*) const' at /bloaty/third_party/protobuf/src/google/protobuf/implicit_weak_message.h:87:28,
    inlined from 'bool google::protobuf::MessageLite::SerializePartialToZeroCopyStream(google::protobuf::io::ZeroCopyOutputStream*) const' at /bloaty/third_party/protobuf/src/google/protobuf/message_lite.cc:387:51:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:33: warning: 'void* __builtin___memcpy_chk(void*, const void*, long unsigned int, long unsigned int)' specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
   29 |   return __builtin___memcpy_chk (__dest, __src, __len,
      |          ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
   30 |                                  __glibc_objsize0 (__dest));
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~
[304/375] Building C object third_party/zlib/CMakeFiles/example.dir/test/example.o
FAILED: third_party/zlib/CMakeFiles/example.dir/test/example.o
/usr/bin/cc -DUSE_RE2 -D_LARGEFILE64_SOURCE=1 -D_LIBCXXABI_FUNC_VIS="" -I/bloaty/third_party/re2 -I/bloaty/third_party/capstone/include -I/bloaty/build/third_party/zlib -I/bloaty -isystem /bloaty/third_party/protobuf/src -O2 -g -DNDEBUG -MD -MT third_party/zlib/CMakeFiles/example.dir/test/example.o -MF third_party/zlib/CMakeFiles/example.dir/test/example.o.d -o third_party/zlib/CMakeFiles/example.dir/test/example.o -c /bloaty/third_party/zlib/test/example.c
/bloaty/third_party/zlib/test/example.c:8:10: fatal error: zlib.h: No such file or directory
    8 | #include "zlib.h"
      |          ^~~~~~~~
compilation terminated.
[305/375] Building C object third_party/zlib/CMakeFiles/minigzip.dir/test/minigzip.o
FAILED: third_party/zlib/CMakeFiles/minigzip.dir/test/minigzip.o
/usr/bin/cc -DUSE_RE2 -D_LARGEFILE64_SOURCE=1 -D_LIBCXXABI_FUNC_VIS="" -I/bloaty/third_party/re2 -I/bloaty/third_party/capstone/include -I/bloaty/build/third_party/zlib -I/bloaty -isystem /bloaty/third_party/protobuf/src -O2 -g -DNDEBUG -MD -MT third_party/zlib/CMakeFiles/minigzip.dir/test/minigzip.o -MF third_party/zlib/CMakeFiles/minigzip.dir/test/minigzip.o.d -o third_party/zlib/CMakeFiles/minigzip.dir/test/minigzip.o -c /bloaty/third_party/zlib/test/minigzip.c
/bloaty/third_party/zlib/test/minigzip.c:18:10: fatal error: zlib.h: No such file or directory
   18 | #include "zlib.h"
      |          ^~~~~~~~
compilation terminated.
[308/375] Linking CXX static library third_party/protobuf/cmake/libprotoc.a
ninja: build stopped: subcommand failed.

To replicate, the simplest method might be to use docker:

docker run --rm ubuntu:22.04 bash -c "apt-get update -qq && \
    apt-get install -y git build-essential cmake ninja-build && \
    git clone https://github.com/google/bloaty.git && \
    cd bloaty && \
    git submodule update --init --recursive && \
    cmake -B build -G Ninja -S . && \
    cmake --build build"

If libz-dev is added to the apt-get install line, it builds correctly using the system zlib.

@carlosperate carlosperate changed the title zlib build failure when using submodule source zlib build failure when using bundled version Sep 6, 2023
@dufferzafar
Copy link

I'm facing this as well, not sure what the reason is, since zlib is present in the third_party sources.

I even tried with disabling zlib in protobuf, just to see what would happen, and it failed to even compile zlib itself!

[258/375] Building C object third_party/zlib/CMakeFiles/minigzip.dir/test/minigzip.o
FAILED: third_party/zlib/CMakeFiles/minigzip.dir/test/minigzip.o
/dev/bin/x86_64-conda_cos6-linux-gnu-cc -DUSE_RE2 -D_LARGEFILE64_SOURCE=1 -D_LIBCXXABI_FUNC_VIS="" -I/dev/bloaty/re2 -I/dev/bloaty/capstone/include -I/dev/bloaty/build/third_party/zlib -I/dev/bloaty -isystem /dev/bloaty/protobuf/src -O2 -g -DNDEBUG -MD -MT third_party/zlib/CMakeFiles/minigzip.dir/test/minigzip.o -MF third_party/zlib/CMakeFiles/minigzip.dir/test/minigzip.o.d -o third_party/zlib/CMakeFiles/minigzip.dir/test/minigzip.o -c /dev/bloaty/zlib/test/minigzip.c
/dev/bloaty/zlib/test/minigzip.c:18:10: fatal error: zlib.h: No such file or directory
 #include "zlib.h"
          ^~~~~~~~
compilation terminated.
[259/375] Building C object third_party/zlib/CMakeFiles/example.dir/test/example.o
FAILED: third_party/zlib/CMakeFiles/example.dir/test/example.o
/dev/bin/x86_64-conda_cos6-linux-gnu-cc -DUSE_RE2 -D_LARGEFILE64_SOURCE=1 -D_LIBCXXABI_FUNC_VIS="" -I/dev/bloaty/re2 -I/dev/bloaty/capstone/include -I/dev/bloaty/build/third_party/zlib -I/dev/bloaty -isystem /dev/bloaty/protobuf/src -O2 -g -DNDEBUG -MD -MT third_party/zlib/CMakeFiles/example.dir/test/example.o -MF third_party/zlib/CMakeFiles/example.dir/test/example.o.d -o third_party/zlib/CMakeFiles/example.dir/test/example.o -c /dev/bloaty/zlib/test/example.c
/dev/bloaty/zlib/test/example.c:8:10: fatal error: zlib.h: No such file or directory
 #include "zlib.h"
          ^~~~~~~~
compilation terminated.
[275/375] Building CXX object third_party/protobuf/cmake/CMakeFiles/libprotoc.dir/__/src/google/protobuf/compiler/js/js_generator.cc.o
ninja: build stopped: subcommand failed

@peter23 peter23 linked a pull request Sep 12, 2024 that will close this issue
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 a pull request may close this issue.

2 participants