[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cross compilation with openssl > 1.0.2


On 5/19/21 1:39 PM, Andrey Strunin wrote:
Hi,

Actually I just built the whole library (before even reading your message). I did it with nasty hack of disabling the whole libcrypto-compat.c with `#if 0`.

I think there is some problem with detection OPENSSL version when cross compiling (in my logs I saw that it detected 1.0.2k. It looks like it found a host library...)

UPD:
Just added this line to my toolchain cmake file and removed `#if 0` hack from libcrypto-compat.c:
SET(OPENSSL_VERSION 3.0.0)

Everything builds great.

Thanks,
Andrey

ср, 19 мая 2021 г. в 13:25, Anderson Sasaki <ansasaki@xxxxxxxxxx <mailto:ansasaki@xxxxxxxxxx>>:



    On Wed, May 19, 2021 at 11:26 AM Andrey Strunin
    <acrapmonster@xxxxxxxxx <mailto:acrapmonster@xxxxxxxxx>> wrote:

        Thank you for the response,

        I am using my own cmake toolchain file that sets compiler and
        sysroot. It worked great when it was openssl 1.0.2 in sysroot.

        Here is the content of my toolchain.cmake file:

        #CMAKE Toolchain file for PowerPC
        # this one is important
        SET(CMAKE_SYSTEM_NAME Linux)
        #this one not so much
        SET(CMAKE_SYSTEM_VERSION 1)

        # specify the cross compiler
        SET(CMAKE_C_COMPILER
        /localhome/new_sdk/gnss_tcc-glibc_cgl/x86-linux2/ppc_e500v2-target-linux-gnu-gcc)
        SET(CMAKE_CXX_COMPILER
        /localhome/new_sdk/gnss_tcc-glibc_cgl/x86-linux2/ppc_e500v2-target-linux-gnu-g++)

        # where is the target environment
        SET(CMAKE_FIND_ROOT_PATH
         /localhome/new_sdk/gnss_tcc-glibc_cgl/sysroot)

        # Local plaform dependent toolchain outputs
        SET(CMAKE_LOCAL_BASE_ROOT_PATH
         /localhome/new_sdk/gnss_tcc-glibc_cgl/sysroot)

        # search for programs in the build host directories
        SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
        # for libraries and headers in the target directories
        SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
        SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

        Here is the output with openssl related errors:
        https://pastebin.com/raw/NrMXi5M8
        <https://pastebin.com/raw/NrMXi5M8>

        I should have clarified the version of libssh I am using. It's
        the latest 0.9.5. However, I have the same build issue (maybe
        with slightly different errors, but still related to openssl)
        with older versions (such as 0.8.9).

        Thanks,
        Andrey


    Hello,

    After checking the log you linked, I suspect cmake failed to
    detect the OpenSSL version and included libcrypto-compat.c into
    the sources. In my machine (Fedora 33), I see this line when
    running cmake to generate the configuration:

    -- Found OpenSSL: /usr/lib64/libcrypto.so (found suitable version
    "1.1.1k", minimum required is "1.0.1")

    Please check if cmake found the dynamic library you expected.
    Maybe you will have to tweak the places where cmake searches for
    libraries in your custom environment.

    In my machine, the "OPENSSL_FOUND" and "OPENSSL_VERSION" are set
    by the cmake module "FindOpenSSL.cmake" which is located at
    /usr/share/cmake/Modules.

    Regards,
    Anderson

It would be useful to debug the issue further to provide a proper solutions also for cross-compiling. We just use normal find_package():

https://gitlab.com/libssh/libssh-mirror/-/blob/master/CMakeLists.txt#L61

It would be worth checking what it does for openssl and if there is something to adjust for cross-compiling. In Fedora, I have /usr/share/cmake/Modules/FindOpenSSL.cmake, which handles this. First, make sure it is up-to-date. From my fast read-through, I would consider using OPENSSL_ROOT_DIR pointing to the place where your openssl is installed.

Regards,

--
Jakub Jelen
Senior Software Engineer
Crypto Team, Security Engineering
Red Hat, Inc.


References:
Cross compilation with openssl > 1.0.2Andrey Strunin <acrapmonster@xxxxxxxxx>
Re: Cross compilation with openssl > 1.0.2Jakub Jelen <jjelen@xxxxxxxxxx>
Re: Cross compilation with openssl > 1.0.2Andrey Strunin <acrapmonster@xxxxxxxxx>
Re: Cross compilation with openssl > 1.0.2Anderson Sasaki <ansasaki@xxxxxxxxxx>
Re: Cross compilation with openssl > 1.0.2Andrey Strunin <acrapmonster@xxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org