Mbed-TLS / mbedtls

An open source, portable, easy to use, readable and flexible TLS library, and reference implementation of the PSA Cryptography API. Releases are on a varying cadence, typically around 3 - 6 months between releases.
https://www.trustedfirmware.org/projects/mbed-tls/
Other
5.58k stars 2.61k forks source link

Cmake build of development branch failed #8808

Closed PiotrBzdrega closed 9 months ago

PiotrBzdrega commented 9 months ago

Summary

Looks like some files are missing, I copied them from release v3.5.2 and everything was then fine.

Missing files:

System information

Mbed TLS version (number or commit id): development commit: c3d17cd Operating system and version: Windows10 22H2 (Build 19045.3930)

Steps to reproduce

C:\Users\piotr\source\repos>git clone https://github.com/Mbed-TLS/mbedtls.git mbedtls
Cloning into 'mbedtls'...
remote: Enumerating objects: 238770, done.
remote: Counting objects: 100% (3816/3816), done.
remote: Compressing objects: 100% (1467/1467), done.
remote: Total 238770 (delta 2726), reused 3014 (delta 2341), pack-reused 234954 eceiving objects: 100% (238770/238770), Receiving objects: 100% (238770/238770)
, 115.76 MiB | 2.03 MiB/s, done.
Resolving deltas: 100% (186125/186125), done.
Updating files: 100% (1714/1714), done.

C:\Users\piotr\source\repos>dir mbedtls
 Datenträger in Laufwerk C: ist Windows-SSD
 Volumeseriennummer: E8CC-2171

 Verzeichnis von C:\Users\piotr\source\repos\mbedtls

10.02.2024  23:07    <DIR>          .
10.02.2024  23:07    <DIR>          ..
10.02.2024  23:07               104 .gitattributes
10.02.2024  23:07    <DIR>          .github
10.02.2024  23:07             1.298 .gitignore
10.02.2024  23:07                46 .globalrc
10.02.2024  23:07                84 .mypy.ini
10.02.2024  23:07             2.765 .pylintrc
10.02.2024  23:07               957 .readthedocs.yaml
10.02.2024  23:07               738 .travis.yml
10.02.2024  23:07             6.610 .uncrustify.cfg
10.02.2024  23:07    <DIR>          3rdparty
10.02.2024  23:07             5.878 BRANCHES.md
10.02.2024  23:07               948 BUGS.md
10.02.2024  23:07           326.760 ChangeLog
10.02.2024  23:07    <DIR>          ChangeLog.d
10.02.2024  23:07    <DIR>          cmake
10.02.2024  23:07            18.520 CMakeLists.txt
10.02.2024  23:07    <DIR>          configs
10.02.2024  23:07             9.725 CONTRIBUTING.md
10.02.2024  23:07               114 DartConfiguration.tcl
10.02.2024  23:07             1.458 dco.txt
10.02.2024  23:07    <DIR>          docs
10.02.2024  23:07    <DIR>          doxygen
10.02.2024  23:07    <DIR>          include
10.02.2024  23:07    <DIR>          library
10.02.2024  23:07            30.405 LICENSE
10.02.2024  23:07             6.948 Makefile
10.02.2024  23:07    <DIR>          programs
10.02.2024  23:07            21.582 README.md
10.02.2024  23:07    <DIR>          scripts
10.02.2024  23:07             6.443 SECURITY.md
10.02.2024  23:07               696 SUPPORT.md
10.02.2024  23:07    <DIR>          tests
10.02.2024  23:07    <DIR>          visualc
              20 Datei(en),        442.079 Bytes
              15 Verzeichnis(se), 68.571.394.048 Bytes frei

C:\Users\piotr\source\repos>cd mbedtls

C:\Users\piotr\source\repos\mbedtls>mkdir build

C:\Users\piotr\source\repos\mbedtls>cd build

C:\Users\piotr\source\repos\mbedtls\build>cmake ..
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
-- The C compiler identification is MSVC 19.38.33134.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found Python3: C:/Users/piotr/AppData/Local/Programs/Python/Python310/python.exe (found version "3.10.0") found components: Interpreter
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
-- Configuring done (19.3s)
CMake Error at library/CMakeLists.txt:276 (add_library):
  Cannot find source file:

    error.c

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm
  .ccm .cxxm .c++m .h .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90
  .f95 .f03 .hip .ispc

CMake Error at library/CMakeLists.txt:292 (add_library):
  Cannot find source file:

    ssl_debug_helpers_generated.c

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm
  .ccm .cxxm .c++m .h .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90
  .f95 .f03 .hip .ispc

CMake Error at programs/ssl/CMakeLists.txt:39 (add_executable):
  Cannot find source file:

    C:/Users/piotr/source/repos/mbedtls/build/programs/test/query_config.c

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm
  .ccm .cxxm .c++m .h .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90
  .f95 .f03 .hip .ispc

CMake Error at programs/test/CMakeLists.txt:73 (add_executable):
  Cannot find source file:

    C:/Users/piotr/source/repos/mbedtls/build/programs/test/query_config.c

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm
  .ccm .cxxm .c++m .h .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90
  .f95 .f03 .hip .ispc

CMake Error at library/CMakeLists.txt:276 (add_library):
  No SOURCES given to target: mbedcrypto

CMake Error at library/CMakeLists.txt:292 (add_library):
  No SOURCES given to target: mbedtls

CMake Error at programs/ssl/CMakeLists.txt:39 (add_executable):
  No SOURCES given to target: ssl_client2

CMake Error at programs/ssl/CMakeLists.txt:39 (add_executable):
  No SOURCES given to target: ssl_server2

CMake Error at programs/test/CMakeLists.txt:73 (add_executable):
  No SOURCES given to target: query_compile_time_config

CMake Generate step failed.  Build files cannot be regenerated correctly.
davidhorstmann-arm commented 9 months ago

Hi,

Thanks for reporting!

In fact, this is a known issue. All of these files are generated by scripts which do not work on Windows. As you have discovered, the fix for this is to copy the generated files from a release.

PiotrBzdrega commented 9 months ago

Hi,

Thanks for reporting!

In fact, this is a known issue. All of these files are generated by scripts which do not work on Windows. As you have discovered, the fix for this is to copy the generated files from a release.

Thank you for feedback. I checked yet for Ubuntu 22.04.3 LTS and looks smooth. I had to only install additionally jsonschema and jinja2 to run those scripts, but except that like you mentioned it works.

jsonschema:

admin1@k21049859:/home/git$ git clone https://github.com/Mbed-TLS/mbedtls.git
Cloning into 'mbedtls'...
remote: Enumerating objects: 238817, done.
remote: Total 238817 (delta 0), reused 0 (delta 0), pack-reused 238817
Receiving objects: 100% (238817/238817), 114.39 MiB | 10.98 MiB/s, done.
Resolving deltas: 100% (186387/186387), done.
admin1@k21049859:/home/git$ cd mbedtls/
admin1@k21049859:/home/git/mbedtls$ mkdir build
admin1@k21049859:/home/git/mbedtls$ cd build/
admin1@k21049859:/home/git/mbedtls/build$ cmake --build .
[  0%] Building C object CMakeFiles/mbedtls_test.dir/tests/src/asn1_helpers.c.o
[  1%] Building C object CMakeFiles/mbedtls_test.dir/tests/src/bignum_helpers.c.o
[  1%] Building C object CMakeFiles/mbedtls_test.dir/tests/src/certs.c.o
[  1%] Building C object CMakeFiles/mbedtls_test.dir/tests/src/drivers/hash.c.o
[  1%] Building C object CMakeFiles/mbedtls_test.dir/tests/src/drivers/platform_builtin_keys.c.o
[  1%] Building C object CMakeFiles/mbedtls_test.dir/tests/src/drivers/test_driver_aead.c.o
[  1%] Building C object CMakeFiles/mbedtls_test.dir/tests/src/drivers/test_driver_asymmetric_encryption.c.o
[  1%] Building C object CMakeFiles/mbedtls_test.dir/tests/src/drivers/test_driver_cipher.c.o
[  2%] Building C object CMakeFiles/mbedtls_test.dir/tests/src/drivers/test_driver_key_agreement.c.o
[  2%] Building C object CMakeFiles/mbedtls_test.dir/tests/src/drivers/test_driver_key_management.c.o
[  2%] Building C object CMakeFiles/mbedtls_test.dir/tests/src/drivers/test_driver_mac.c.o
[  2%] Building C object CMakeFiles/mbedtls_test.dir/tests/src/drivers/test_driver_pake.c.o
[  2%] Building C object CMakeFiles/mbedtls_test.dir/tests/src/drivers/test_driver_signature.c.o
[  2%] Building C object CMakeFiles/mbedtls_test.dir/tests/src/fake_external_rng_for_test.c.o
[  2%] Building C object CMakeFiles/mbedtls_test.dir/tests/src/helpers.c.o
[  3%] Building C object CMakeFiles/mbedtls_test.dir/tests/src/psa_crypto_helpers.c.o
[  3%] Building C object CMakeFiles/mbedtls_test.dir/tests/src/psa_exercise_key.c.o
[  3%] Building C object CMakeFiles/mbedtls_test.dir/tests/src/random.c.o
[  3%] Building C object CMakeFiles/mbedtls_test.dir/tests/src/threading_helpers.c.o
[  3%] Built target mbedtls_test
[  3%] Building C object CMakeFiles/mbedtls_test_helpers.dir/tests/src/test_helpers/ssl_helpers.c.o
[  3%] Built target mbedtls_test_helpers
[  3%] Building C object 3rdparty/everest/CMakeFiles/everest.dir/library/everest.c.o
[  3%] Building C object 3rdparty/everest/CMakeFiles/everest.dir/library/x25519.c.o
[  4%] Building C object 3rdparty/everest/CMakeFiles/everest.dir/library/Hacl_Curve25519_joined.c.o
[  4%] Linking C static library libeverest.a
[  4%] Built target everest
[  4%] Building C object 3rdparty/p256-m/CMakeFiles/p256m.dir/p256-m_driver_entrypoints.c.o
[  4%] Building C object 3rdparty/p256-m/CMakeFiles/p256m.dir/p256-m/p256-m.c.o
[  4%] Linking C static library libp256m.a
[  4%] Built target p256m
[  5%] Generating version_features.c
[  5%] Generating error.c
[  5%] Generating psa_crypto_driver_wrappers.h, psa_crypto_driver_wrappers_no_static.c
Traceback (most recent call last):
  File "/home/git/mbedtls/library/../scripts/generate_driver_wrappers.py", line 18, in <module>
    import jsonschema
ModuleNotFoundError: No module named 'jsonschema'
gmake[2]: *** [library/CMakeFiles/mbedcrypto.dir/build.make:155: library/psa_crypto_driver_wrappers.h] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:957: library/CMakeFiles/mbedcrypto.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2

jinja2:

admin1@k21049859:/home/git/mbedtls/build$ cmake --build .
Consolidate compiler generated dependencies of target mbedtls_test
[  3%] Built target mbedtls_test
Consolidate compiler generated dependencies of target mbedtls_test_helpers
[  3%] Built target mbedtls_test_helpers
Consolidate compiler generated dependencies of target everest
[  4%] Built target everest
Consolidate compiler generated dependencies of target p256m
[  4%] Built target p256m
[  4%] Generating psa_crypto_driver_wrappers.h, psa_crypto_driver_wrappers_no_static.c
Traceback (most recent call last):
  File "/home/git/mbedtls/library/../scripts/generate_driver_wrappers.py", line 19, in <module>
    import jinja2
ModuleNotFoundError: No module named 'jinja2'
gmake[2]: *** [library/CMakeFiles/mbedcrypto.dir/build.make:155: library/psa_crypto_driver_wrappers.h] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:957: library/CMakeFiles/mbedcrypto.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2
tom-cosgrove-arm commented 9 months ago

Note that these files can be generated on Windows, by running

scripts\make_generated_files.bat

as documented in the README.md section Generated source files in the development branch.

The README file also mentions the Python requirements:

Python 3.8 and some Python packages, for some library source files, sample programs and test data. To install the necessary packages, run:

python3 -m pip install --user -r scripts/basic.requirements.txt