conan-io / conan-center-index

Recipes for the ConanCenter repository
https://conan.io/center
MIT License
950 stars 1.74k forks source link

[package] libsodium/1.0.18: Build failing when using visual studio #14241

Closed calebkiage closed 1 year ago

calebkiage commented 1 year ago

Description

When I have multiple MSVC toolsets on Visual Studio 2022, building the library fails for some of the toolsets.

Tested toolsets: MSBuild 17.4 MSVC v140 - VS 2015 - pass MSBuild 17.4 MSVC v141 - VS 2017 - fail MSBuild 17.4 MSVC v142 - VS 2019 - fail MSBuild 17.4 MSVC v143 - VS 2022 - pass

This is a screenshot of the tools I have installed for visual studio image

Work around

I found a work around to fix the issue locally that I can open a PR for. The work around involves:

  1. Download a local copy of the recipe
  2. Update this code https://github.com/conan-io/conan-center-index/blob/b4ab46b1e95314d446c68e831e3a526b1770ed9a/recipes/libsodium/all/conanfile.py#L115 to this
    msbuild.build(sln_path, use_env=False, upgrade_project=upgrade_project, platforms={"x86": "Win32"}, build_type=build_type)
  3. Export the recipe
    conan export . libsodium/1.0.18@
  4. Run conan install

Package and Environment Details

Conan profile

[settings] os=Windows arch=x86_64

build_type=Release compiler=msvc compiler.cppstd=14 compiler.runtime=static compiler.version=191

[conf] tools.microsoft.msbuild:vs_version = 17

Steps to reproduce

conan install . --build libsodium/* --profile:host ./.conan/profiles/win-x64/win-x64-host --profile:build ./.conan/profiles/win-x64/win-x64-host --settings:build build_type=Release --settings:host build_type=Release --settings:host compiler.runtime=dynamic

Logs

Click to expand log ``` Configuration (profile_host): [settings] arch=x86_64 build_type=Release compiler=msvc compiler.cppstd=14 compiler.runtime=dynamic compiler.runtime_type=Release compiler.version=191 os=Windows [options] [build_requires] [env] [conf] tools.microsoft.msbuild:vs_version=17 tools.microsoft.msbuild:verbosity=Normal Configuration (profile_build): [settings] arch=x86_64 build_type=Release compiler=msvc compiler.cppstd=14 compiler.runtime=static compiler.runtime_type=Release compiler.version=191 os=Windows [options] [build_requires] [env] [conf] tools.microsoft.msbuild:vs_version=17 tools.microsoft.msbuild:verbosity=Normal catch2/3.1.0: Main binary package '16041e00ee7792b16701a7a92918452f6b5a519b' missing. Using compatible package '6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7' fmt/9.1.0: Main binary package '3da0313181279a1d9c8fe73b0cc5c53165ce845c' missing. Using compatible package '8270b003766febceb5d9d24a7b7c6ee95f6a94d7' libsodium/1.0.18: Forced build from source spdlog/1.11.0: Main binary package 'c75fefb15e33a09eff126ebe14e057073ae7b5b6' missing. Using compatible package '304e089472614b68b915bef54bff3f1159403980' zeromq/4.3.4: Main binary package 'dde1239d1a1912a68c95b6edfcffc533c1e72cef' missing. Using compatible package '92105e8fc16d129eb40755d7d2152c4855f68c46' conanfile.py: Installing package Requirements asio/1.24.0 from 'conancenter' - Cache boost/1.80.0 from 'conancenter' - Cache catch2/3.1.0 from 'conancenter' - Cache cppzmq/4.9.0 from 'conancenter' - Cache cxxopts/3.0.0 from 'conancenter' - Cache fmt/9.1.0 from 'conancenter' - Cache libsodium/1.0.18 from 'conancenter' - Cache spdlog/1.11.0 from 'conancenter' - Cache zeromq/4.3.4 from 'conancenter' - Cache Packages asio/1.24.0:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Cache boost/1.80.0:524ea35a8120baabdde02483add58d81bf541327 - Cache catch2/3.1.0:6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7 - Cache cppzmq/4.9.0:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Cache cxxopts/3.0.0:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Cache fmt/9.1.0:8270b003766febceb5d9d24a7b7c6ee95f6a94d7 - Cache libsodium/1.0.18:7b29bd067fdfb16abfe9ea2a31df29d4e11ef2b2 - Build spdlog/1.11.0:304e089472614b68b915bef54bff3f1159403980 - Cache zeromq/4.3.4:92105e8fc16d129eb40755d7d2152c4855f68c46 - Cache Installing (downloading, building) binaries... asio/1.24.0: Already installed! boost/1.80.0: Already installed! catch2/3.1.0: Already installed! cxxopts/3.0.0: Already installed! fmt/9.1.0: Already installed! Downloading conan_sources.tgz completed [0.58k] Decompressing conan_sources.tgz completed [0.00k] libsodium/1.0.18: Configuring sources in C:\dev\.conan\0d8924\1 Downloading libsodium-1.0.18.tar.gz completed [1874.82k] libsodium/1.0.18: Copying sources to build folder libsodium/1.0.18: Building your package in C:\dev\.conan\30b2f9\1 libsodium/1.0.18: Generator txt created conanbuildinfo.txt libsodium/1.0.18: Aggregating env generators libsodium/1.0.18: Calling build() libsodium/1.0.18: Found Visual Studio 17 libsodium/1.0.18: Skipped sln project upgrade ********************************************************************** ** Visual Studio 2022 Developer Command Prompt v17.4.1 ** Copyright (c) 2022 Microsoft Corporation ********************************************************************** [vcvarsall.bat] Environment initialized for: 'x64' MSBuild version 17.4.0+18d5aef85 for .NET Framework C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\Microsoft.Cpp.Redirect.15.targets(69,5): error MSB8052: MSVC Toolset Version '14.34.31933' is not compatible with 'v141' Platform Toolset. Please ei ther change Platform Toolset to v143 or MSVC Toolset Version (VCToolsVersion property) to the version with the format '14.1*.*'. To use default MSVC Toolset Version for a given Platform Toolset don't set VCToolsVersion property. [ C:\dev\.conan\30b2f9\1\source_subfolder\builds\msvc\vs2017\libsodium\libsodium.vcxproj] libsodium/1.0.18: libsodium/1.0.18: ERROR: Package '7b29bd067fdfb16abfe9ea2a31df29d4e11ef2b2' build failed libsodium/1.0.18: WARN: Build folder C:\dev\.conan\30b2f9\1 ERROR: libsodium/1.0.18: Error in build() method, line 143 self._build_msvc() while calling '_build_msvc', line 115 msbuild.build(sln_path, upgrade_project=upgrade_project, platforms={"x86": "Win32"}, build_type=build_type) ConanException: Error 1 while executing set "VSCMD_START_DIR=%CD%" && call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC/Auxiliary/Build/vcvarsall.bat" amd64 && msbuild "C:\dev\.conan\30b2f9\1\source_subfolder\builds\msvc\vs2017\libsodium.sln" /p:Configuration="StaticRelease" /p:UseEnv=true /p:Platform="x64" /m:8 /verbosity:minimal /p:ForceImportBeforeCppTargets="C:\dev\.conan\30b2f9\1\conan_build.props" ```
TobiSchluter commented 1 year ago

It fails with VS2022 over here like so:

libsodium/1.0.18: WARN: Build folder is dirty, removing it: C:\.conan\5488b6\1
libsodium/1.0.18: Copying sources to build folder
libsodium/1.0.18: Building your package in C:\.conan\5488b6\1
libsodium/1.0.18: Generator cmake created conanbuildinfo.cmake
libsodium/1.0.18: Aggregating env generators
libsodium/1.0.18: Calling build()
libsodium/1.0.18: libsodium/1.0.18: ERROR: Package '0b05059ca636ddfa23e6dc44613da1b6a0c20b36' build failed

libsodium/1.0.18: WARN: Build folder C:\.conan\5488b6\1
ERROR: libsodium/1.0.18: Invalid configuration: Unsupported msvc version: 17
calebkiage commented 1 year ago

I've just tried it here and it works for me. It updates the toolset from v142 to v143 and builds fine.

Click to expand log ```log conan install . --build libsodium/* --profile:host ./.conan/profiles/default/host --profile:build ./.conan/profiles/default/build --settings:build build_type=Release --settings:host build_type=Release --settings:host compiler.runtime=dynamic -of build Configuration (profile_host): [settings] arch=x86_64 arch_build=x86_64 build_type=Release compiler=msvc compiler.cppstd=14 compiler.runtime=dynamic compiler.runtime_type=Release compiler.version=193 os=Windows os_build=Windows [options] [build_requires] [env] [conf] tools.microsoft.msbuild:vs_version=17 Configuration (profile_build): [settings] arch=x86_64 arch_build=x86_64 build_type=Release compiler=msvc compiler.cppstd=14 compiler.runtime_type=Release compiler.version=193 os=Windows os_build=Windows [options] [build_requires] [env] [conf] tools.microsoft.msbuild:vs_version=17 libsodium/1.0.18: Forced build from source conanfile.py: Installing package Requirements fmt/9.1.0 from 'conancenter' - Cache libsodium/1.0.18 from 'conancenter' - Cache Packages fmt/9.1.0:9cbe2f0bb0b0a104c0ffa3dc04c8481cd5a78730 - Cache libsodium/1.0.18:26b825dd7f1d26c95c3362d416bad89147b212a8 - Build Installing (downloading, building) binaries... fmt/9.1.0: Already installed! libsodium/1.0.18: Copying sources to build folder libsodium/1.0.18: Building your package in C:\dev\.conan\fdb54c\1 libsodium/1.0.18: Generator txt created conanbuildinfo.txt libsodium/1.0.18: Aggregating env generators libsodium/1.0.18: Calling build() libsodium/1.0.18: Found Visual Studio 17 ********************************************************************** ** Visual Studio 2022 Developer Command Prompt v17.4.1 ** Copyright (c) 2022 Microsoft Corporation ********************************************************************** [vcvarsall.bat] Environment initialized for: 'x64' Microsoft Visual Studio 2022 Version 17.4.1. Copyright (C) Microsoft Corp. All rights reserved. Upgrading project 'libsodium'... Configuration 'ReleaseLTCG|x64': changing Platform Toolset to 'v143' (was 'v142'). Configuration 'ReleaseLTCG|Win32': changing Platform Toolset to 'v143' (was 'v142'). Configuration 'DebugLTCG|Win32': changing Platform Toolset to 'v143' (was 'v142'). Configuration 'DebugLTCG|x64': changing Platform Toolset to 'v143' (was 'v142'). Configuration 'ReleaseDLL|x64': changing Platform Toolset to 'v143' (was 'v142'). Configuration 'ReleaseLIB|x64': changing Platform Toolset to 'v143' (was 'v142'). Configuration 'ReleaseDLL|Win32': changing Platform Toolset to 'v143' (was 'v142'). Configuration 'ReleaseLIB|Win32': changing Platform Toolset to 'v143' (was 'v142'). Configuration 'DebugLIB|Win32': changing Platform Toolset to 'v143' (was 'v142'). Configuration 'DebugDLL|Win32': changing Platform Toolset to 'v143' (was 'v142'). Configuration 'DebugLIB|x64': changing Platform Toolset to 'v143' (was 'v142'). Configuration 'DebugDLL|x64': changing Platform Toolset to 'v143' (was 'v142'). MSBuild version 17.4.0+18d5aef85 for .NET Framework ConfigurationType : StaticLibrary Configuration : ReleaseLIB PlatformToolset : v143 TargetPath : C:\dev\.conan\fdb54c\1\source_subfolder\builds\msvc\vs2019\libsodium\..\..\..\..\bin\x64\Release\v143\static\libsodium.lib Will copy C:\dev\.conan\fdb54c\1\source_subfolder\builds\msvc\vs2019\libsodium\..\..\version.h -> C:\dev\.conan\fdb54c\1\source_subfolder\builds\msvc\vs2019\libsodium\..\..\..\..\sr c\libsodium\include\sodium\version.h Option-amd64asm : 1 file(s) copied. cl : command line warning D9002: ignoring unknown option '-dynamic' [C:\dev\.conan\fdb54c\1\source_subfolder\builds\msvc\vs2019\libsodium\libsodium.vcxproj] cl : command line warning D9002: ignoring unknown option '-dynamic' [C:\dev\.conan\fdb54c\1\source_subfolder\builds\msvc\vs2019\libsodium\libsodium.vcxproj] cl : command line warning D9002: ignoring unknown option '-dynamic' [C:\dev\.conan\fdb54c\1\source_subfolder\builds\msvc\vs2019\libsodium\libsodium.vcxproj] crypto_generichash.c generichash_blake2.c cl : command line warning D9002: ignoring unknown option '-dynamic' [C:\dev\.conan\fdb54c\1\source_subfolder\builds\msvc\vs2019\libsodium\libsodium.vcxproj] cl : command line warning D9002: ignoring unknown option '-dynamic' [C:\dev\.conan\fdb54c\1\source_subfolder\builds\msvc\vs2019\libsodium\libsodium.vcxproj] blake2b-compress-ref.c blake2b-compress-ssse3.c cl : command line warning D9002: ignoring unknown option '-dynamic' [C:\dev\.conan\fdb54c\1\source_subfolder\builds\msvc\vs2019\libsodium\libsodium.vcxproj] blake2b-compress-avx2.c cl : command line warning D9002: ignoring unknown option '-dynamic' [C:\dev\.conan\fdb54c\1\source_subfolder\builds\msvc\vs2019\libsodium\libsodium.vcxproj] cl : command line warning D9002: ignoring unknown option '-dynamic' [C:\dev\.conan\fdb54c\1\source_subfolder\builds\msvc\vs2019\libsodium\libsodium.vcxproj] cl : command line warning D9002: ignoring unknown option '-dynamic' [C:\dev\.conan\fdb54c\1\source_subfolder\builds\msvc\vs2019\libsodium\libsodium.vcxproj] blake2b-compress-sse41.c generichash_blake2b.c blake2b-ref.c crypto_kx.c crypto_sign.c sign_ed25519.c obsolete.c sign.c keypair.c open.c crypto_secretbox.c crypto_secretbox_easy.c secretbox_xsalsa20poly1305.c secretbox_xchacha20poly1305.c crypto_pwhash.c blake2b-long.c argon2-core.c argon2-fill-block-avx512f.c argon2-fill-block-ref.c argon2-fill-block-ssse3.c pwhash_argon2i.c pwhash_argon2id.c argon2.c argon2-fill-block-avx2.c argon2-encoding.c scrypt_platform.c crypto_scrypt-common.c pwhash_scryptsalsa208sha256.c pbkdf2-sha256.c pwhash_scryptsalsa208sha256_nosse.c pwhash_scryptsalsa208sha256_sse.c verify.c crypto_auth.c C:\dev\.conan\fdb54c\1\source_subfolder\src\libsodium\crypto_verify\sodium\verify.c(68,52): warning C4197: 'volatile const unsigned char *volatile ': top-level volatile in cast is ign ored [C:\dev\.conan\fdb54c\1\source_subfolder\builds\msvc\vs2019\libsodium\libsodium.vcxproj] C:\dev\.conan\fdb54c\1\source_subfolder\src\libsodium\crypto_verify\sodium\verify.c(70,52): warning C4197: 'volatile const unsigned char *volatile ': top-level volatile in cast is ign ored [C:\dev\.conan\fdb54c\1\source_subfolder\builds\msvc\vs2019\libsodium\libsodium.vcxproj] auth_hmacsha512.c auth_hmacsha512256.c auth_hmacsha256.c crypto_kdf.c kdf_blake2b.c crypto_shorthash.c shorthash_siphash24.c shorthash_siphashx24.c shorthash_siphashx24_ref.c shorthash_siphash24_ref.c crypto_scalarmult.c scalarmult_ristretto255_ref10.c scalarmult_ed25519_ref10.c scalarmult_curve25519.c curve25519_sandy2x.c fe_frombytes_sandy2x.c fe51_invert.c x25519_ref10.c crypto_onetimeauth.c onetimeauth_poly1305.c poly1305_donna.c poly1305_sse2.c randombytes.c randombytes_sysrandom.c randombytes_internal_random.c crypto_hash.c hash_sha512.c hash_sha512_cp.c hash_sha256.c hash_sha256_cp.c aead_xchacha20poly1305.c aead_aes256gcm_aesni.c aead_chacha20poly1305.c secretstream_xchacha20poly1305.c core_salsa_ref.c core_hchacha20.c core_hsalsa20.c core_hsalsa20_ref2.c core_ed25519.c core_ristretto255.c ed25519_ref10.c libsodium.vcxproj -> C:\dev\.conan\fdb54c\1\source_subfolder\builds\msvc\vs2019\libsodium\..\..\..\..\bin\x64\Release\v143\static\libsodium.lib libsodium/1.0.18: Package '26b825dd7f1d26c95c3362d416bad89147b212a8' built libsodium/1.0.18: Build folder C:\dev\.conan\fdb54c\1 libsodium/1.0.18: Generated conaninfo.txt libsodium/1.0.18: Generated conanbuildinfo.txt libsodium/1.0.18: Generating the package libsodium/1.0.18: Package folder C:\dev\.conan\b179af\1 libsodium/1.0.18: Calling package() libsodium/1.0.18 package(): Packaged 63 '.h' files libsodium/1.0.18 package(): Packaged 1 '.lib' file: libsodium.lib libsodium/1.0.18 package(): Packaged 1 file: LICENSE libsodium/1.0.18: Package '26b825dd7f1d26c95c3362d416bad89147b212a8' created libsodium/1.0.18: Created package revision 757d4b17194ad5a2d557fc601274aae9 conanfile.py: Generator 'CMakeToolchain' calling 'generate()' conanfile.py: Preset 'default' added to CMakePresets.json. Invoke it manually using 'cmake --preset default' conanfile.py: If your CMake version is not compatible with CMakePresets (<3.19) call cmake like: 'cmake -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE=C:\Users\calebmagiya\Documents\projects\practice\cpp\conan-cmake-toolchain\conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW' conanfile.py: Generator txt created conanbuildinfo.txt conanfile.py: Generator 'CMakeDeps' calling 'generate()' conanfile.py: Aggregating env generators conanfile.py: Generated conaninfo.txt conanfile.py: Generated graphinfo ```
calebkiage commented 1 year ago

This issue seems to have been fixed by using the new MSBuild from package conan.tools.microsoft