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

[openssl] openssl/1.1.1j Fails to build first time (once) when using cmake-conan with "cannot open input file 'apps\app_rand.obj'" #4740

Closed
Talkless opened this issue Mar 1, 2021 · 12 comments · Fixed by #5441
Labels
bug Something isn't working

Comments

@Talkless
Copy link
Contributor

Talkless commented Mar 1, 2021

Package and Environment Details (include every applicable attribute)

  • Package Name/Version: openssl/1.1.1j
  • Operating System+version: Windows 10
  • Compiler+version: Visual Studio 2017
  • Conan version: conan 1.32.1
  • Python version: Python 3.7.4

Steps to reproduce (Include if Applicable)

Let's say we have conan-bug directory, where inside we have:

profile.txt:

include(default)
[settings]
compiler="Visual Studio"
compiler.version=15
arch=x86
arch_build=x86

conanfile.txt:

[requires]
openssl/1.1.1j@

[options]
openssl:shared=True

[generators]
cmake_find_package
cmake_paths

CMakeLists.txt:

cmake_minimum_required(VERSION 3.16)

project(ConanBug)

list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake-conan-0.15")
include(conan)

add_executable(${PROJECT_NAME})

conan_cmake_run(
    BUILD missing
    BUILD_TYPE "${CMAKE_BUILD_TYPE}"
    CONANFILE conanfile.txt
    INSTALL_FOLDER "${PROJECT_SOURCE_DIR}/build"
    PROFILE "${PROJECT_SOURCE_DIR}/profile.txt"
    SETTINGS "build_type=${CMAKE_BUILD_TYPE}"
)
include(${PROJECT_SOURCE_DIR}/build/conan_paths.cmake)

cmake-conan-0.15 directory from:
https://github.com/conan-io/cmake-conan/releases/tag/v0.15

Now, in cmd.exe run:

conan.exe remove openssl --force
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat"
"C:\Program Files\CMake\bin\cmake.exe" -G Ninja -DCMAKE_BUILD_TYPE=Debug -B build .

Output with failure:
https://gist.github.com/Talkless/28fe39d2176e00b25d9987caef9009be (using gist as log conflicts with github formatting somehow).

Intrestingly, if I run same cmake command again (second time) - build succeeds (openssl is built)!

If I remove openssl package with conan.exe remove openssl --force and run cmake again, it also succeeds!

Now to actually reproduce build, I have to remove openssl package and build directory.

This issue is experienced only with openssl package so far.

@Talkless Talkless added the bug Something isn't working label Mar 1, 2021
@prince-chrismc
Copy link
Contributor

As an enterprise consumer, I strongly disagree with this comment... openssl/openssl#12563 (comment)

Most often this type of problem is the firewall/anti-virus.... You might want to try disabling those... check method 6 https://support.microsoft.com/en-us/topic/-windows-cannot-access-the-specified-device-path-or-file-error-when-you-try-to-install-update-or-start-a-program-or-file-46361133-47ed-6967-c13e-e75d3cc29657 it's a fairly well known problem

We've needed to disable the Windows Indexing Service on our build node, check this https://www.ghacks.net/2017/08/10/manage-windows-10-search-indexing/ how to

Both of these tend to open new/modified files which can prevent other processes from opening them... in this case the openssl build process.

@db4
Copy link
Contributor

db4 commented Apr 27, 2021

@prince-chrismc

Most often this type of problem is the firewall/anti-virus....

No. I have the same issue and can explain what's going on. Somehow openssl (conan?) configuration code detect cl.exe path as
C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x86/cl.exe. So when nmake is called it invokes the following command to create apps\app_rand.obj:

	C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x86/cl.exe  /Zi /Fdossl_static.pdb /MDd /Zl /Gs0 /GF /Gy -Zi -Ob0 -Od -MDd /W3 /wd4090 /nologo /Od /I "." /I "include" -D"L_ENDIAN" -D"OPENSSL_PIC" -D"OPENSSL_CPUID_OBJ" -D"OPENSSL_BN_ASM_PART_WORDS" -D"OPENSSL_IA32_SSE2" -D"OPENSSL_BN_ASM_MONT" -D"OPENSSL_BN_ASM_GF2m" -D"SHA1_ASM" -D"SHA256_ASM" -D"SHA512_ASM" -D"RC4_ASM" -D"MD5_ASM" -D"RMD160_ASM" -D"AESNI_ASM" -D"VPAES_ASM" -D"WHIRLPOOL_ASM" -D"GHASH_ASM" -D"ECP_NISTZ256_ASM" -D"POLY1305_ASM" -D"OPENSSLDIR=\"C:\\Users\\ContainerAdministrator\\.conan\\data\\openssl\\1.1.1h\\_\\_\\package\\b786e9ece960c3a76378ca4d5b0d0e922f4cedc1\\res\"" -D"ENGINESDIR=\"C:\\Users\\ContainerAdministrator\\.conan\\data\\openssl\\1.1.1h\\_\\_\\package\\b786e9ece960c3a76378ca4d5b0d0e922f4cedc1\\lib\\engines-1_1\"" -D"OPENSSL_SYS_WIN32" -D"WIN32_LEAN_AND_MEAN" -D"UNICODE" -D"_UNICODE" -D"_CRT_SECURE_NO_DEPRECATE" -D"_WINSOCK_DEPRECATED_NO_WARNINGS" -D"DEBUG" -D"_DEBUG" -I"C:/.conan/ceed98/1/include"  -c /Foapps\app_rand.obj "apps\app_rand.c"

Note C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x86/cl.exe with spaces without double quotes around. This fails SILENTLY with no app_rand.obj created. I've just verified it manually:

(conanbuildenv) C:\Users\ContainerAdministrator\.conan\data\openssl\1.1.1h\_\_\build\b786e9ece960c3a76378ca4d5b0d0e922f4cedc1\source_subfolder>nmake CC="C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x86/cl.exe" apps\app_rand.obj

Microsoft (R) Program Maintenance Utility Version 14.16.27045.0
Copyright (C) Microsoft Corporation.  All rights reserved.

        C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x86/cl.exe
 /Zi /Fdossl_static.pdb /MDd /Zl /Gs0 /GF /Gy -Zi -Ob0 -Od -MDd /W3 /wd4090 /nologo /Od /I "." /I "include" -D"L_ENDIAN" -D"OPENSSL_PIC" -D"OPENSSL_CPUID_OBJ" -D"OPENSSL_BN_ASM_PART_WORDS" -D"OPENSSL_IA32_SSE2" -D"OPENSSL_BN_ASM_MONT" -D"OPENSSL_BN_ASM_GF2m" -D"SHA1_ASM" -D"SHA256_ASM" -D"SHA512_ASM" -D"RC4_ASM" -D"MD5_ASM" -D"RMD160_ASM" -D"AESNI_ASM" -D"VPAES_ASM" -D"WHIRLPOOL_ASM" -D"GHASH_ASM" -D"ECP_NISTZ256_ASM" -D"POLY1305_ASM" -D"OPENSSLDIR=\"C:\\Users\\ContainerAdministrator\\.conan\\data\\openssl\\1.1.1h\\_\\_\\package\\b786e9ece960c3a76378ca4d5b0d0e922f4cedc1\\res\"" -D"ENGINESDIR=\"C:\\Users\\ContainerAdministrator\\.conan\\data\\openssl\\1.1.1h\\_\\_\\package\\b786e9ece960c3a76378ca4d5b0d0e922f4cedc1\\lib\\engines-1_1\"" -D"OPENSSL_SYS_WIN32" -D"WIN32_LEAN_AND_MEAN" -D"UNICODE" -D"_UNICODE" -D"_CRT_SECURE_NO_DEPRECATE" -D"_WINSOCK_DEPRECATED_NO_WARNINGS" -D"DEBUG" -D"_DEBUG" -I"C:/.conan/ceed98/1/include"  -c /Foapps\app_rand.obj "apps\app_rand.c"
        C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x86/cl.exe
 /Zi /Fdossl_static.pdb /MDd /Zl /Gs0 /GF /Gy -Zi -Ob0 -Od -MDd /W3 /wd4090 /nologo /Od /I "." /I "include" -D"L_ENDIAN" -D"OPENSSL_PIC" -D"OPENSSL_CPUID_OBJ" -D"OPENSSL_BN_ASM_PART_WORDS" -D"OPENSSL_IA32_SSE2" -D"OPENSSL_BN_ASM_MONT" -D"OPENSSL_BN_ASM_GF2m" -D"SHA1_ASM" -D"SHA256_ASM" -D"SHA512_ASM" -D"RC4_ASM" -D"MD5_ASM" -D"RMD160_ASM" -D"AESNI_ASM" -D"VPAES_ASM" -D"WHIRLPOOL_ASM" -D"GHASH_ASM" -D"ECP_NISTZ256_ASM" -D"POLY1305_ASM" -D"OPENSSLDIR=\"C:\\Users\\ContainerAdministrator\\.conan\\data\\openssl\\1.1.1h\\_\\_\\package\\b786e9ece960c3a76378ca4d5b0d0e922f4cedc1\\res\"" -D"ENGINESDIR=\"C:\\Users\\ContainerAdministrator\\.conan\\data\\openssl\\1.1.1h\\_\\_\\package\\b786e9ece960c3a76378ca4d5b0d0e922f4cedc1\\lib\\engines-1_1\"" -D"OPENSSL_SYS_WIN32" -D"WIN32_LEAN_AND_MEAN" -D"UNICODE" -D"_UNICODE" -D"_CRT_SECURE_NO_DEPRECATE" -D"_WINSOCK_DEPRECATED_NO_WARNINGS" -D"DEBUG" -D"_DEBUG" -I"C:/.conan/ceed98/1/include"  /Zs /showIncludes "apps\app_rand.c" 2>&1 > apps\app_rand.d

(conanbuildenv) C:\Users\ContainerAdministrator\.conan\data\openssl\1.1.1h\_\_\build\b786e9ece960c3a76378ca4d5b0d0e922f4cedc1\source_subfolder>dir apps\*.obj
 Volume in drive C has no label.
 Volume Serial Number is DC8D-FFC1

Now the correct fix is needed :)

@prince-chrismc
Copy link
Contributor

I have the same issue and can explain what's going on

I love that!

We recently had a similar problem with boost. https://github.com/conan-io/conan-center-index/pull/5099/files,

If I make a PR would you be willing to test it to help confirm the fix? I don't have any problems locally so it's difficult for me to confirm.

@db4
Copy link
Contributor

db4 commented Apr 27, 2021

If I make a PR would you be willing to test it to help confirm the fix? I don't have any problems locally so it's difficult for me to confirm.

Sure. Thanks a lot in advance!

@prince-chrismc
Copy link
Contributor

For the original issue "it always works the second time", I'd stand by my first suggestion for OP... We have sadly seen this many times.


As for the path escape problem... I think I found the issue 🤔

❓ Are you specifying the compiler?

the following lines prepare the CC and CXX variables and pass them to perl/msys to apply in the build scripts.

cc = 'cc => "%s",' % cc if cc else ""
cxx = 'cxx => "%s",' % cxx if cxx else ""

Using a normal command prompt, I get

openssl/1.1.1j: Calling build()
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.7.7
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
openssl/1.1.1j: using target: VC-conan-Release-Windows-x86_64-Visual Studio-16 -> VC-WIN64A
openssl/1.1.1j: my %targets = (
    "VC-conan-Release-Windows-x86_64-Visual Studio-16" => {
        inherit_from => [ "VC-WIN64A" ],
        cflags => add("-O2 -Ob2 -MD"),
        cxxflags => add("-O2 -Ob2 -MD"),
        defines => add("NDEBUG"),
        includes => add("C:/.conan/9d4cd9/1/include"),
        lflags => add(""),
    },
);

Shortly after it happily compiles

Microsoft (R) Program Maintenance Utility Version 14.27.29112.0
Copyright (C) Microsoft Corporation.  All rights reserved.

        cl  /Zi /Fdossl_static.pdb /Gs0 /GF /Gy /MD -O2 -Ob2 -MD /W3 /wd4090 /nologo /O2 /I "." /I "include" -D"L_ENDIAN" -D"OPENSSL_PIC" -D"OPENSSL_CPUID_OBJ" -D"OPENSSL_IA32_SSE2" -D"OPENSSL_BN_ASM_MONT" -D"OPENSSL_BN_ASM_MONT5" -D"OPENSSL_BN_ASM_GF2m" -D"SHA1_ASM" -D"SHA256_ASM" -D"SHA512_ASM" -D"KECCAK1600_ASM" -D"RC4_ASM" -D"MD5_ASM" -D"AESNI_ASM" -D"VPAES_ASM" -D"GHASH_ASM" -D"ECP_NISTZ256_ASM" -D"X25519_ASM" -D"POLY1305_ASM" -D"OPENSSLDIR=\"C:\\Users\\Chris McArthur\\.conan\\data\\openssl\\1.1.1j\\_\\_\\package\\127af201a4cdf8111e2e08540525c245c9b3b99e\\res\"" -D"ENGINESDIR=\"C:\\Users\\Chris McArthur\\.conan\\data\\openssl\\1.1.1j\\_\\_\\package\\127af201a4cdf8111e2e08540525c245c9b3b99e\\lib\\engines-1_1\"" -D"OPENSSL_SYS_WIN32" -D"WIN32_LEAN_AND_MEAN" -D"UNICODE" -D"_UNICODE" -D"_CRT_SECURE_NO_DEPRECATE" -D"_WINSOCK_DEPRECATED_NO_WARNINGS" -D"OPENSSL_USE_APPLINK" -D"NDEBUG" -D"NDEBUG" -I"C:/.conan/9d4cd9/1/include"  -c /Foapps\app_rand.obj "apps\app_rand.c"

↪️ Notice it's using cl.exe directly from my path, so no funky path problems,

However with CC and CXX as follows

cc=C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx86/x86/cl.exe
cxx=C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx86/x86/cl.exe

OpenSSL build receives

openssl/1.1.1j: Calling build()
Conan:vcvars already set
openssl/1.1.1j: using target: VC-conan-Release-Windows-x86_64-Visual Studio-16 -> VC-WIN64A
openssl/1.1.1j: my %targets = (
    "VC-conan-Release-Windows-x86_64-Visual Studio-16" => {
        inherit_from => [ "VC-WIN64A" ],
        cflags => add("-O2 -Ob2 -MD"),
        cxxflags => add("-O2 -Ob2 -MD"),
        defines => add("NDEBUG"),
        includes => add("C:/.conan/9d4cd9/1/include"),
        lflags => add(""),
        cc => "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\Hostx86\x86\cl.exe",
        cxx => "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\Hostx86\x86\cl.exe",
    },
);

Than I can reproduce the original issues

C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx86/x86/cl.exe  /Zi /Fdossl_static.pdb /Gs0 /GF /Gy /MD -O2 -Ob2 -MD /W3 /wd4090 /nologo /O2 /I "." /I "include" -D"L_ENDIAN" -D"OPENSSL_PIC" -D"OPENSSL_CPUID_OBJ" -D"OPENSSL_IA32_SSE2" -D"OPENSSL_BN_ASM_MONT" -D"OPENSSL_BN_ASM_MONT5" -D"OPENSSL_BN_ASM_GF2m" -D"SHA1_ASM" -D"SHA256_ASM" -D"SHA512_ASM" -D"KECCAK1600_ASM" -D"RC4_ASM" -D"MD5_ASM" -D"AESNI_ASM" -D"VPAES_ASM" -D"GHASH_ASM" -D"ECP_NISTZ256_ASM" -D"X25519_ASM" -D"POLY1305_ASM" -D"OPENSSLDIR=\"C:\\Users\\Chris McArthur\\.conan\\data\\openssl\\1.1.1j\\_\\_\\package\\127af201a4cdf8111e2e08540525c245c9b3b99e\\res\"" -D"ENGINESDIR=\"C:\\Users\\Chris McArthur\\.conan\\data\\openssl\\1.1.1j\\_\\_\\package\\127af201a4cdf8111e2e08540525c245c9b3b99e\\lib\\engines-1_1\"" -D"OPENSSL_SYS_WIN32" -D"WIN32_LEAN_AND_MEAN" -D"UNICODE" -D"_UNICODE" -D"_CRT_SECURE_NO_DEPRECATE" -D"_WINSOCK_DEPRECATED_NO_WARNINGS" -D"OPENSSL_USE_APPLINK" -D"NDEBUG" -D"NDEBUG" -I"C:/.conan/9d4cd9/1/include"  -c /Foapps\app_rand.obj "apps\app_rand.c"

It does not print the app_rand.c as it should when it's successful.

Which is later followed by

LINK : fatal error LNK1181: cannot open input file 'apps\app_rand.obj'

As for fixing the problem, I'm at odds.

Adding " around the path gives

Bareword found where operator expected at (eval 13) line 13, near """C"
        (Missing operator before C?)

Failure!  build file wasn't produced.
Please read INSTALL and associated NOTES files.  You may also have to look over
your available compiler tool chain or change your configuration.

syntax error at (eval 13) line 13, near """C"
Unknown regexp modifier "/M" at (eval 13) line 13, at end of line
Unknown regexp modifier "/r" at (eval 13) line 13, at end of line
Unknown regexp modifier "/f" at (eval 13) line 13, at end of line
Unknown regexp modifier "/t" at (eval 13) line 13, at end of line
Unknown regexp modifier "/C" at (eval 13) line 13, at end of line
Unknown regexp modifier "/t" at (eval 13) line 13, at end of line
Unknown regexp modifier "/y" at (eval 13) line 13, at end of line
Unknown regexp modifier "/T" at (eval 13) line 13, at end of line
Unknown regexp modifier "/1" at (eval 13) line 13, at end of line
(eval 13) has too many errors.

And using \ does not help

        cc => "C:/Program\ Files\ (x86)/Microsoft\ Visual\ Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx86/x86/cl.exe",
        cxx => "C:/Program\ Files\ (x86)/Microsoft\ Visual\ Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx86/x86/cl.exe",

I still have the original issue 😑

To my knowledge thus far it seems to be a problem internal with the OpenSSL nmake in perl that is causing the problem.

@db4
Copy link
Contributor

db4 commented Apr 28, 2021

Are you specifying the compiler?

No. it's a CI job in a Docker container, involving conan.cmake and building missing conan packages from where. Simple conan install openssl/1.1.1h@ -s arch=x86 --build openssl in a clean container works as expected. OK, I'm trying to create a minimal test case that triggers the failure. It turns to be not that easy as I thought.

@prince-chrismc
Copy link
Contributor

It turns to be not that easy as I thought.

It'll be that much more rewarding when we fix it =D

@db4
Copy link
Contributor

db4 commented Apr 28, 2021

I was able to create a minimal (sort of) test case. Here it is:

CMakeLists.txt

cmake_minimum_required(VERSION 3.2)

project(build)

if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
  message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
  file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/v0.15/conan.cmake"
                "${CMAKE_BINARY_DIR}/conan.cmake")
endif()

include(${CMAKE_BINARY_DIR}/conan.cmake)

conan_check()
conan_cmake_run(
  BUILD_REQUIRES
    cmake/3.20.1
  REQUIRES
    openssl/1.1.1h
  SETTINGS
    cmake:arch=x86_64
    nasm:arch=x86_64
    strawberryperl:arch=x86_64
  BUILD openssl
)

Execute the following commands:

mkdir conan
echo [generators] > conan/conanfile.txt
conan install conan -if conan -g virtualbuildenv -s arch=x86
call conan\activate_build.bat
mkdir build
cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE="Debug" ..

When I run cmake for the first time, it detects C/C++ compilers and writes the settings into CMakeCache.txt:

-- The C compiler identification is MSVC 19.16.27045.0
-- The CXX compiler identification is MSVC 19.16.27045.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.2702
3/bin/Hostx64/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.2702
3/bin/Hostx64/x86/cl.exe -- works

when conan.cmake in the same process tries to build openssl package, these settings somehow affect its config:

openssl/1.1.1h: my %targets = (
    "VC-conan-Debug-Windows-x86-Visual Studio-15" => {
        inherit_from => [ "VC-WIN32" ],
        cflags => add("-Zi -Ob0 -Od -MDd"),
        cxxflags => add("-Zi -Ob0 -Od -MDd"),

        includes => add("C:/.conan/ceed98/1/include"),
        lflags => add(""),



        cc => "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x86/
cl.exe",
        cxx => "C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x86
/cl.exe",



    },
);

and openssl build fails. If I rerun cmake after that, C/C++ compiler settings are taken from CMakeCache.txt and do NOT affect openssl config while building:

openssl/1.1.1h: my %targets = (
    "VC-conan-Debug-Windows-x86-Visual Studio-15" => {
        inherit_from => [ "VC-WIN32" ],
        cflags => add("-Zi -Ob0 -Od -MDd"),
        cxxflags => add("-Zi -Ob0 -Od -MDd"),

        includes => add("C:/.conan/ceed98/1/include"),
        lflags => add(""),








    },
);

Why so? cmake sets some environment variables that affect perl? I have no idea...

@db4
Copy link
Contributor

db4 commented Apr 28, 2021

BTW, x86_64 build fails just the same way so the test case can be reduced to

cmake_minimum_required(VERSION 3.2)

project(build)

if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
  message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
  file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/v0.15/conan.cmake"
                "${CMAKE_BINARY_DIR}/conan.cmake")
endif()

include(${CMAKE_BINARY_DIR}/conan.cmake)

conan_cmake_run(
  BUILD_REQUIRES cmake/3.20.1
  REQUIRES openssl/1.1.1h
  BUILD openssl
)

and

mkdir conan
echo [generators] > conan/conanfile.txt
conan install conan -if conan -g virtualbuildenv
call conan\activate_build.bat
mkdir build
cd build
cmake -G Ninja ..

@db4
Copy link
Contributor

db4 commented Apr 28, 2021

cmake sets some environment variables?

Yes. When cmake initially determines C/C++ compilers, it sets CC/CXX environment variables to the full cl.exe path (forward slashes, no double quotes around) that affect openssl configuration.

@db4
Copy link
Contributor

db4 commented Apr 30, 2021

@prince-chrismc
The following seems to be is enough to resolve the issue:

--- a/recipes/openssl/1.x.x/conanfile.py
+++ b/recipes/openssl/1.x.x/conanfile.py
@@ -635,6 +635,10 @@ class OpenSSLConan(ConanFile):
             if self._use_nmake and self._full_version >= "1.1.0":
                 self._replace_runtime_in_file(os.path.join("Configurations", "10-main.conf"))

+            if tools.os_info.is_windows and not self._win_bash:
+                for v in ['CC', 'CXX', 'RC']:
+                    if v in os.environ and not '"' in os.environ[v]:
+                        os.environ[v] = '"' + os.environ[v].replace('/', '\\') + '"'
             self.run('{perl} ./Configure {args}'.format(perl=self._perl, args=args), win_bash=self._win_bash)

             self._patch_install_name()

If it's OK for you I can submit a PR.

@prince-chrismc
Copy link
Contributor

prince-chrismc commented May 1, 2021

Please! This way I can approve it right away =D

db4 added a commit to db4/conan-center-index that referenced this issue May 5, 2021
@db4 db4 mentioned this issue May 5, 2021
4 tasks
conan-center-bot pushed a commit that referenced this issue May 20, 2021
* openssl: closes #4740

* Avoid permanent environment modification
Croydon added a commit to bincrafters/conan-center-index that referenced this issue Sep 9, 2021
conan-center-bot pushed a commit that referenced this issue Sep 11, 2021
* openssl: create 3.x.x directory

* openssl/3.x.x: Update license to Apache-2.0

* openssl/3.x.x: Update reporting issues URL

* openssl/3.x.x: Add no_deprecated, no_legacy and no_fips options

* openssl/3.x.x: Delete patch for 1.1.1

* openssl/3.x.x: Update option from no_zlib to zlib

* openssl/3.x.x: Remove removed options no_md2 and no_rc5

* openssl/3.x.x.: no_rc4 is still a valid option

https://github.com/openssl/openssl/blob/1b495200436b57309ca958a7a72affaf75171c1a/INSTALL.md#no-algorithm

* openssl/3.x.x: Remove legacy target names

* openssl/3.x.x.: Remove more legacy conditions

* openssl/3.x.x: Fix zlib option name

* Revert "openssl/3.x.x: Update license to Apache-2.0"

This reverts commit 13852ab1da9678d3700440bee862561af7878b37.

* openssl/3.x.x: Actually update license to Apache-2.0

* openssl/3.x.x.: Remove all legacy version switches

* openssl/3.x.x: Use OpenSSL_version instead of legacy SSLeay_version

* openssl/3.x.x.: update test_package to never  use find_package()

Several reasons for this decision:

1) No matter the value of the paramter use_find_package CMake did always use a FindOpenSSL.cmake file

2) On my machine that meant that CMake used a FindOpenSSL.cmake file from my Python installation, which can't yet handle version 3.0.0 due to a regex error

3) Even when I addded the Conan cmake_find_package generator, it did not work (more cpp_info work needed, maybe?)

4) Even when 3) would be fixed, it would still always use the FindOpenSSL.cmake approach for some reason (I guess), so the entire use_find_package switch is pointless

* openssl/3.x.x.: Remove custom OpenSSLVersion object

* openssl/3.x.x.: Remove legacy target_prefix

* openssl/3.x.x.: Remove custom _cross_building method

Since tools.cross_building() has now a skip_x64_x86 flag

* openssl/3.x.x: Some formatting

* openssl/3.x.x: Remove old workaround for MinGW

This got fixed in the meantime via openssl/openssl@9694ebf

See also openssl/openssl#7653

* openssl/3.x.x: add no_engine option

* openssl/3.x.x: Add 3.0.0-alpha5

* openssl/3.x.x: Port #1782 from @syoliver - add components

* openssl/3.x.x: Fix license test

The LICENSE file got renamed to LICENSE.txt

* openssl/3.x.x: add old/ URLs as mirrors

* openssl/3.x.x: threat URLs explicit as strings

* openssl/3.x.x: add 3.0.0-alpha6

* openssl/3.x.x: the downloads have permament locations now

This seems to be the case for a while now, but not for all old versions we support in the recipe for the 1.x.x versions

It also does not seem to apply for pre-release versions, which rather  seem to get de-published

See also here: openssl/openssl#4469

* openssl: Update Conan conventions

Automatically created by bincrafters-conventions 0.26.0

* openssl/3.x.x: reorder methods

* openssl/3.x.x: add 3.0.0-alpha7

* openssl/3.x.x: test upstream PR 13225

openssl/openssl#13225

* openssl/3.x.x: update patch from upstream PR13225

* openssl/3.x.x: port #2944 Require installation of msys2 for MinGW builds

* openssl/3.x.x: port #3214 fix openssl/** build with shared and fPIC option for OS Neutrino

* openssl/3.x.x: add 3.0.0-alpha8

* openssl/3.x.x: remove fPIC when shared

Co-authored-by: Anonymous Maarten <[email protected]>

* openssl/3.x.x: add 3.0.0-alpha9

* openssl/3.x.x: use get_safe for fPIC

* openssl/3.x.x: don't use get_safe for zlib option

Co-authored-by: Anonymous Maarten <[email protected]>

* openssl/3.x.x: add 3.0.0-alpha10

* openssl/3.x.x: add openssl/3.0.0-alpha11

* openssl: Update Conan conventions

Automatically created by bincrafters-conventions 0.30.2

* openssl/3.x.x: add openssl/3.0.0

* openssl: Update Conan conventions

Automatically created by bincrafters-conventions 0.30.5

* openssl/3.x.x: modernize

Co-Authored-By: Anonymous Maarten <[email protected]>

* openssl/3.x.x: modernize

Co-Authored-By: Anonymous Maarten <[email protected]>

* openssl/3.x.x: replace os.rename -> tools.rename

* opeensl/3.x.x.: nit

Co-authored-by: Anonymous Maarten <[email protected]>

* openssl/3.x.x: readd old versions to config.yml

Co-Authored-By: Anonymous Maarten <[email protected]>

* openssl/3.x.x: remove platform import

Co-authored-by: Anonymous Maarten <[email protected]>

* openssl/3.x.x: fix typo in option name

* openssl/3.x.x: more tools modernizations

* openssl/3.x.x: use textwrap

Co-authored-by: Anonymous Maarten <[email protected]>

* openssl/3.x.x: remove MD5 and SHA1 from test_package

* openssl/3.x.x: use self.options.get_safe()

* openssl: add openssl.pc + fix libdir

* openssl: convert test to pure C source

* openssl: use spaces in test source

* openssl/3.x.x: remove SSL_library_init from test_package

* openssl: run openssl binary in test package

* openssl: digest.c only needs crypto library

* openssl: remove unused definitions for cmake

* openssl: enable fPIC when not enabled + use zlib's shared option correctly

* openssl: don't echo args (there is log.print_run_commands) + don't add shared/zlib multiple times

* openssl: tools.XCRun only acceps Settings object

* openssl: use self.settings.os

* openssl: reformatting + be the first to use f-strings + functools.lru_cache

* openssl: ./Configure --help does not print any targets.

* openssl: fix critical typo

* openssl: fix sneaky usage of tools.os_info in build_requirements

* openssl/3.x.x: remove patch for macOS shared

Co-Authored-By: Bowb <[email protected]>

* openssl/3.x.x: port #4460 remove explicit apple deployment target flag

Co-Authored-By: SSE4 <[email protected]>

* openssl/3.x.x: port #4597 provide official variables in cmake_find_package

Co-Authored-By: SpaceIm <[email protected]>

* openssl/3.x.x: port #4698 fix rt dependency for SUSE11

Co-Authored-By: Alexey Klimkin <[email protected]>

* openssl/3.x.x: port #4772 fix builddirs and add vars module to cmake_find_package only

Co-Authored-By: SpaceIm <[email protected]>

* openssl/3.x.x: port #5441 closes #4740

Co-Authored-By: Dmitry Bely <[email protected]>

* openssl/3.x.x: port #3998 add libatomic in build dependency for Neutrino OS

Co-Authored-By: Arenoros <[email protected]>

* openssl/3.x.x: port #6337 OpenSSL on Windows: multi-profile support

Co-Authored-By: Stefan Floeren <[email protected]>

* openssl/3.x.x: port #6588 Add macOS ARM target

Co-Authored-By: gmeeker <[email protected]>

* openssl/3.x.x: port #6884 Build openssl for emscripten

Co-Authored-By: Volodymyr B. <[email protected]>

* openssl: reformatting fixes

* openssl: make method property + remove unused import

* openssl: reverse sort openssl's config.yml

* openssl: only run openssl when not cross building

* openssl: port options of openssl 1.1.1

* openssl: fix MSVC install + remove options unsupported by openssl 3 + openssl exe is only available when building with no_stio=False

* force push

Signed-off-by: Uilian Ries <[email protected]>

* openssl: add missing options + various reformatting

Co-authored-by: bincrafters-user <[email protected]>
Co-authored-by: Anonymous Maarten <[email protected]>
Co-authored-by: Anonymous Maarten <[email protected]>
Co-authored-by: Bowb <[email protected]>
Co-authored-by: SSE4 <[email protected]>
Co-authored-by: SpaceIm <[email protected]>
Co-authored-by: Alexey Klimkin <[email protected]>
Co-authored-by: Dmitry Bely <[email protected]>
Co-authored-by: Arenoros <[email protected]>
Co-authored-by: Stefan Floeren <[email protected]>
Co-authored-by: gmeeker <[email protected]>
Co-authored-by: Volodymyr B. <[email protected]>
Co-authored-by: Uilian Ries <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants