-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fix protobuf compilation under MSYS2 #22766
base: master
Are you sure you want to change the base?
Conversation
Building protobuf on MSYS2 fails on the line 100. Apparently the conan detection of `is_msvc` and `is_clang_cl` is flawed. Work around this by guarding the statement.
🤖 Beep Boop! This pull request is making changes to 'recipes/protobuf//'. 👋 @Hopobcn you might be interested. 😉 |
Conan v1 pipeline ✔️All green in build 1 (
Conan v2 pipeline ❌
The v2 pipeline failed. Please, review the errors and note this is required for pull requests to be merged. In case this recipe is still not ported to Conan 2.x, please, ping See details:Failure in build 1 (
Note: To save resources, CI tries to finish as soon as an error is found. For this reason you might find that not all the references have been launched or not all the configurations for a given reference. Also, take into account that we cannot guarantee the order of execution as it depends on CI workload and workers availability. |
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.
LGTM. Thank you for your hotfix!
The Conan blog post related to Clang usage in Windows points out that runtime is not needed when consuming Clang via MSYS2: https://blog.conan.io/2022/10/13/Different-flavors-Clang-compiler-Windows.html. Having this information, we can understand your profile should not contain compiler.runtime
configured as well, which is expected.
I installed Clang 16 via MSYS2 on my Windows machine to investigate your case. I tried to a profile that looks like the one pointed out in the blog post. So, locally, I can reproduce your error:
conan create all --version=3.21.12 -pr msys2-clang
======== Exporting recipe to the cache ========
protobuf/3.21.12: Exporting package recipe: C:\Users\uilia\Development\conan\conan-center-index\recipes\protobuf\all\conanfile.py
protobuf/3.21.12: exports: File 'conandata.yml' found. Exporting it...
protobuf/3.21.12: Calling export_sources()
protobuf/3.21.12: Copied 1 '.yml' file: conandata.yml
protobuf/3.21.12: Copied 1 '.py' file: conanfile.py
protobuf/3.21.12: Copied 1 '.patch' file: protobuf-3.21.12-upstream-macos-macros.patch
protobuf/3.21.12: Copied 1 '.cmake' file: protobuf-conan-protoc-target.cmake
protobuf/3.21.12: Exported to cache folder: C:\Users\uilia\.conan2\p\protofc076c5c7bf36\e
protobuf/3.21.12: Exported: protobuf/3.21.12#3bab1b51cf5ecbf4681845540c280683 (2025-01-21 17:14:53 UTC)
======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=clang
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=16
os=Windows
[tool_requires]
*: cmake/3.30.1, ninja/1.12.1
[conf]
tools.build:compiler_executables={'c': 'C:/msys64/mingw64/bin/clang.exe', 'cpp': 'C:/msys64/mingw64/bin/clang++.exe'}
tools.build:verbosity=verbose
tools.cmake.cmaketoolchain:generator=Ninja
tools.compilation:verbosity=verbose
[buildenv]
PATH+=(path)C:/msys64/mingw64/bin
[runenv]
PATH+=(path)C:/msys64/mingw64/bin
Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=17
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=193
os=Windows
[tool_requires]
*: cmake/3.30.1
[conf]
tools.build:verbosity=verbose
tools.cmake.cmaketoolchain:generator=Ninja
tools.compilation:verbosity=verbose
======== Computing dependency graph ========
Graph root
cli
Requirements
protobuf/3.21.12#3bab1b51cf5ecbf4681845540c280683 - Cache
zlib/1.3.1#99d6f9ea0a1dd63d973392c24ce0aa9b - Cache
Build requirements
cmake/3.30.1#6d832cf2d46f6ec969ca5ed5b41f91eb - Cache
ninja/1.12.1#fd583651bf0c6a901943495d49878803 - Cache
Resolved version ranges
zlib/[>=1.2.11 <2]: zlib/1.3.1
======== Computing necessary packages ========
protobuf/3.21.12: Forced build from source
Requirements
protobuf/3.21.12#3bab1b51cf5ecbf4681845540c280683:81690af62a61097f6d097f66401b7b384dc1339a - Build
zlib/1.3.1#99d6f9ea0a1dd63d973392c24ce0aa9b:115cadc47ac9101765393979a1604d740e2183e8#58cbeab265d78d3ae06a6f28708ac7da - Cache
Build requirements
cmake/3.30.1#6d832cf2d46f6ec969ca5ed5b41f91eb:522dcea5982a3f8a5b624c16477e47195da2f84f#e4039405f7640830990126c02c0c9959 - Cache
ninja/1.12.1#fd583651bf0c6a901943495d49878803:723257509aee8a72faf021920c2874abc738e029#360592e21b5a6812030b65cbdd1c4a8d - Cache
======== Installing packages ========
cmake/3.30.1: Already installed! (1 of 4)
cmake/3.30.1: Appending PATH environment variable: C:\Users\uilia\.conan2\p\cmake3081ce9d742b2\p\bin
cmake/3.30.1: Appending PATH environment variable: C:\Users\uilia\.conan2\p\cmake3081ce9d742b2\p\bin
ninja/1.12.1: Already installed! (2 of 4)
zlib/1.3.1: Already installed! (3 of 4)
-------- Installing package protobuf/3.21.12 (4 of 4) --------
protobuf/3.21.12: Building from source
protobuf/3.21.12: Package protobuf/3.21.12:81690af62a61097f6d097f66401b7b384dc1339a
protobuf/3.21.12: Copying sources to build folder
protobuf/3.21.12: Building your package in C:\Users\uilia\.conan2\p\b\proto897ab39b0b186\b
protobuf/3.21.12: Calling generate()
protobuf/3.21.12: Generators folder: C:\Users\uilia\.conan2\p\b\proto897ab39b0b186\b\build\Release\generators
ERROR: protobuf/3.21.12: Error in generate() method, line 145
tc.cache_variables["protobuf_MSVC_STATIC_RUNTIME"] = "MT" in runtime
TypeError: argument of type 'NoneType' is not iterable
Then, after applying your patch, I can build Protobuf with success (I reduced the log due comment size limit):
conan create all --version=3.21.12 -pr msys2-clang
======== Exporting recipe to the cache ========
protobuf/3.21.12: Exporting package recipe: C:\Users\uilia\Development\conan\conan-center-index\recipes\protobuf\all\conanfile.py
protobuf/3.21.12: exports: File 'conandata.yml' found. Exporting it...
protobuf/3.21.12: Calling export_sources()
protobuf/3.21.12: Copied 1 '.yml' file: conandata.yml
protobuf/3.21.12: Copied 1 '.py' file: conanfile.py
protobuf/3.21.12: Copied 1 '.patch' file: protobuf-3.21.12-upstream-macos-macros.patch
protobuf/3.21.12: Copied 1 '.cmake' file: protobuf-conan-protoc-target.cmake
protobuf/3.21.12: Exported to cache folder: C:\Users\uilia\.conan2\p\proto5f106ea547151\e
protobuf/3.21.12: Exported: protobuf/3.21.12#c98dee2f019002ff185fe594dfaac105 (2025-01-21 17:16:39 UTC)
======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=clang
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=16
os=Windows
[tool_requires]
*: cmake/3.30.1, ninja/1.12.1
[conf]
tools.build:compiler_executables={'c': 'C:/msys64/mingw64/bin/clang.exe', 'cpp': 'C:/msys64/mingw64/bin/clang++.exe'}
tools.build:verbosity=verbose
tools.cmake.cmaketoolchain:generator=Ninja
tools.compilation:verbosity=verbose
[buildenv]
PATH+=(path)C:/msys64/mingw64/bin
[runenv]
PATH+=(path)C:/msys64/mingw64/bin
Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=17
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=193
os=Windows
[tool_requires]
*: cmake/3.30.1
[conf]
tools.build:verbosity=verbose
tools.cmake.cmaketoolchain:generator=Ninja
tools.compilation:verbosity=verbose
======== Computing dependency graph ========
Graph root
cli
Requirements
protobuf/3.21.12#c98dee2f019002ff185fe594dfaac105 - Cache
zlib/1.3.1#99d6f9ea0a1dd63d973392c24ce0aa9b - Cache
Build requirements
cmake/3.30.1#6d832cf2d46f6ec969ca5ed5b41f91eb - Cache
ninja/1.12.1#fd583651bf0c6a901943495d49878803 - Cache
Resolved version ranges
zlib/[>=1.2.11 <2]: zlib/1.3.1
======== Computing necessary packages ========
protobuf/3.21.12: Forced build from source
Requirements
protobuf/3.21.12#c98dee2f019002ff185fe594dfaac105:81690af62a61097f6d097f66401b7b384dc1339a - Build
zlib/1.3.1#99d6f9ea0a1dd63d973392c24ce0aa9b:115cadc47ac9101765393979a1604d740e2183e8#58cbeab265d78d3ae06a6f28708ac7da - Cache
Build requirements
cmake/3.30.1#6d832cf2d46f6ec969ca5ed5b41f91eb:522dcea5982a3f8a5b624c16477e47195da2f84f#e4039405f7640830990126c02c0c9959 - Cache
ninja/1.12.1#fd583651bf0c6a901943495d49878803:723257509aee8a72faf021920c2874abc738e029#360592e21b5a6812030b65cbdd1c4a8d - Cache
======== Installing packages ========
cmake/3.30.1: Already installed! (1 of 4)
cmake/3.30.1: Appending PATH environment variable: C:\Users\uilia\.conan2\p\cmake3081ce9d742b2\p\bin
cmake/3.30.1: Appending PATH environment variable: C:\Users\uilia\.conan2\p\cmake3081ce9d742b2\p\bin
ninja/1.12.1: Already installed! (2 of 4)
zlib/1.3.1: Already installed! (3 of 4)
protobuf/3.21.12: Calling source() in C:\Users\uilia\.conan2\p\proto5f106ea547151\s\src
protobuf/3.21.12: Source https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.21.12.tar.gz retrieved from local download cache
protobuf/3.21.12: Unzipping v3.21.12.tar.gz to .
-------- Installing package protobuf/3.21.12 (4 of 4) --------
protobuf/3.21.12: Building from source
protobuf/3.21.12: Package protobuf/3.21.12:81690af62a61097f6d097f66401b7b384dc1339a
protobuf/3.21.12: Copying sources to build folder
protobuf/3.21.12: Building your package in C:\Users\uilia\.conan2\p\b\protod4996dba5ecf7\b
protobuf/3.21.12: Calling generate()
protobuf/3.21.12: Generators folder: C:\Users\uilia\.conan2\p\b\protod4996dba5ecf7\b\build\Release\generators
protobuf/3.21.12: CMakeToolchain generated: conan_toolchain.cmake
protobuf/3.21.12: CMakeToolchain generated: C:\Users\uilia\.conan2\p\b\protod4996dba5ecf7\b\build\Release\generators\CMakePresets.json
protobuf/3.21.12: CMakeToolchain generated: C:\Users\uilia\.conan2\p\b\protod4996dba5ecf7\b\src\CMakeUserPresets.json
protobuf/3.21.12: CMakeDeps necessary find_package() and targets for your CMakeLists.txt
find_package(ZLIB)
target_link_libraries(... ZLIB::ZLIB)
protobuf/3.21.12: Generating aggregated env files
protobuf/3.21.12: Generated aggregated env files: ['conanbuild.bat', 'conanrun.bat']
protobuf/3.21.12: Calling build()
protobuf/3.21.12: Apply patch (bugfix): Handle case where macOS SDK macros may conflict with protobuf message types
protobuf/3.21.12: Running CMake.configure()
protobuf/3.21.12: RUN: cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="C:/Users/uilia/.conan2/p/b/protod4996dba5ecf7/p" -DCMAKE_INSTALL_CMAKEDIR="lib/cmake/protobuf" -Dprotobuf_WITH_ZLIB="ON" -Dprotobuf_BUILD_TESTS="OFF" -Dprotobuf_BUILD_PROTOC_BINARIES="ON" -Dprotobuf_BUILD_LIBPROTOC="ON" -Dprotobuf_DISABLE_RTTI="OFF" -Dprotobuf_BUILD_LIBUPB="None" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "C:/Users/uilia/.conan2/p/b/protod4996dba5ecf7/b/src" --loglevel=VERBOSE
-- Using Conan toolchain: C:/Users/uilia/.conan2/p/b/protod4996dba5ecf7/b/build/Release/generators/conan_toolchain.cmake
-- Conan toolchain: Defining architecture flag: -m64
-- Conan toolchain: Defining libcxx as C++ flags: -stdlib=libstdc++
-- Conan toolchain: C++ Standard 17 with extensions ON
-- Conan toolchain: Setting BUILD_SHARED_LIBS = OFF
-- The C compiler identification is Clang 16.0.5
-- The CXX compiler identification is Clang 16.0.5
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/msys64/mingw64/bin/clang.exe - 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: C:/msys64/mingw64/bin/clang++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Warning: Standard CMAKE_CXX_STANDARD value defined in conan_toolchain.cmake to 17 has been modified to 11 by C:/Users/uilia/.conan2/p/b/protod4996dba5ecf7/b/src/CMakeLists.txt
--
-- 3.21.12.0
-- Performing Test protobuf_HAVE_LD_VERSION_SCRIPT
-- Performing Test protobuf_HAVE_LD_VERSION_SCRIPT - Success
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Conan: Target declared 'ZLIB::ZLIB'
-- Conan: Library z found C:/Users/uilia/.conan2/p/b/zlibf8670f7b6d906/p/lib/libz.a
-- Conan: Found: C:/Users/uilia/.conan2/p/b/zlibf8670f7b6d906/p/lib/libz.a
-- Performing Test protobuf_HAVE_BUILTIN_ATOMICS
-- Performing Test protobuf_HAVE_BUILTIN_ATOMICS - Success
-- Configuring done (2.4s)
-- Generating done (0.1s)
CMake Warning:
Manually-specified variables were not used by the project:
protobuf_BUILD_LIBUPB
-- Build files have been written to: C:/Users/uilia/.conan2/p/b/protod4996dba5ecf7/b/build/Release
protobuf/3.21.12: Running CMake.build()
protobuf/3.21.12: RUN: cmake --build "C:\Users\uilia\.conan2\p\b\protod4996dba5ecf7\b\build\Release" --verbose -- -j12
Change Dir: 'C:/Users/uilia/.conan2/p/b/protod4996dba5ecf7/b/build/Release'
Run Build Command(s): C:/Users/uilia/.conan2/p/ninjad9a44352249a5/p/bin/ninja.exe -v -j12
[1/204] C:\msys64\mingw64\bin\clang++.exe -DGOOGLE_PROTOBUF_CMAKE_BUILD -DHAVE_ZLIB -IC:/Users/uilia/.conan2/p/b/protod4996dba5ecf7/b/build/Release -IC:/Users/uilia/.conan2/p/b/protod4996dba5ecf7/b/src/src -isystem C:/Users/uilia/.conan2/p/b/zlibf8670f7b6d906/p/include -m64 -stdlib=libstdc++ -O3 -DNDEBUG -std=c++11 -MD -MT CMakeFiles/libprotobuf.dir/src/google/protobuf/arenaz_sampler.cc.obj -MF CMakeFiles\libprotobuf.dir\src\google\protobuf\arenaz_sampler.cc.obj.d -o CMakeFiles/libprotobuf.dir/src/google/protobuf/arenaz_sampler.cc.obj -c C:/Users/uilia/.conan2/p/b/protod4996dba5ecf7/b/src/src/google/protobuf/arenaz_sampler.cc
...
[204/204] C:\WINDOWS\system32\cmd.exe /C "cd . && C:\Users\uilia\.conan2\p\cmake3081ce9d742b2\p\bin\cmake.exe -E rm -f libprotobuf-lite.a && C:\msys64\mingw64\bin\llvm-ar.exe qc libprotobuf-lite.a CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/any_lite.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/arena.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/arenastring.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/arenaz_sampler.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/extension_set.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/generated_enum_util.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/generated_message_tctable_lite.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/generated_message_util.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/implicit_weak_message.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/inlined_string_field.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/io/coded_stream.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/io/io_win32.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/io/strtod.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/io/zero_copy_stream.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/io/zero_copy_stream_impl.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/io/zero_copy_stream_impl_lite.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/map.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/message_lite.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/parse_context.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/repeated_field.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/repeated_ptr_field.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/stubs/bytestream.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/stubs/common.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/stubs/int128.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/stubs/status.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/stubs/statusor.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/stubs/stringpiece.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/stubs/stringprintf.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/stubs/structurally_valid.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/stubs/strutil.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/stubs/time.cc.obj CMakeFiles/libprotobuf-lite.dir/src/google/protobuf/wire_format_lite.cc.obj && C:\msys64\mingw64\bin\llvm-ranlib.exe libprotobuf-lite.a && cd ."
protobuf/3.21.12: Package '81690af62a61097f6d097f66401b7b384dc1339a' built
protobuf/3.21.12: Build folder C:\Users\uilia\.conan2\p\b\protod4996dba5ecf7\b\build\Release
protobuf/3.21.12: Generating the package
protobuf/3.21.12: Packaging in folder C:\Users\uilia\.conan2\p\b\protod4996dba5ecf7\p
protobuf/3.21.12: Calling package()
protobuf/3.21.12: Running CMake.install()
protobuf/3.21.12: RUN: cmake --install "C:\Users\uilia\.conan2\p\b\protod4996dba5ecf7\b\build\Release" --prefix "C:/Users/uilia/.conan2/p/b/protod4996dba5ecf7/p" --verbose
-- Install configuration: "Release"
-- Installing: C:/Users/uilia/.conan2/p/b/protod4996dba5ecf7/p/lib/libprotobuf-lite.a
...
protobuf/3.21.12: package(): Packaged 1 '.exe' file: protoc.exe
protobuf/3.21.12: package(): Packaged 116 '.h' files
protobuf/3.21.12: package(): Packaged 12 '.proto' files
protobuf/3.21.12: package(): Packaged 2 '.inc' files: port_def.inc, port_undef.inc
protobuf/3.21.12: package(): Packaged 2 '.a' files: libprotobuf.a, libprotoc.a
protobuf/3.21.12: package(): Packaged 4 '.cmake' files: protobuf-conan-protoc-target.cmake, protobuf-generate.cmake, protobuf-module.cmake, protobuf-options.cmake
protobuf/3.21.12: package(): Packaged 1 file: LICENSE
protobuf/3.21.12: Created package revision 6ff52cf0c1b4c9e2ca64b4efaead155c
protobuf/3.21.12: Package '81690af62a61097f6d097f66401b7b384dc1339a' created
protobuf/3.21.12: Full package reference: protobuf/3.21.12#c98dee2f019002ff185fe594dfaac105:81690af62a61097f6d097f66401b7b384dc1339a#6ff52cf0c1b4c9e2ca64b4efaead155c
protobuf/3.21.12: Package folder C:\Users\uilia\.conan2\p\b\protod4996dba5ecf7\p
…netheril96-patch-1-22766-cii-command
Building protobuf on MSYS2 fails on the line 100. Apparently the conan detection of
is_msvc
andis_clang_cl
is flawed. Work around this by guarding the statement.Specify library name and version: protobuf/3.21.12