Hello,
Mbed TLS includes some intermediate files that are generated by scripts,
but configuration- and platform-independent. One of these scripts needs
to compile and run a C program on the host. In principle, if you build
from a tagged release commit or from a release zip, those files should
not be rebuilt. Can you please share exactly how you obtained Mbed TLS
and how you build it? (Which build system, on what platform, etc.) There
may be a bug in how we prepare the files for the release, if those files
are getting rebuilt when they shouldn't.
Just in case, if the intermediate files are already present, but they're
getting rebuilt because they don't have newer timestamps than their
source, you can disable the regeneration. With the GNU makefiles, run
"make GEN_FILES=". With CMake, run "cmake -DGEN_FILES=0". This shouldn't
be needed though, since GEN_FILES defaults disabled in releases where
the intermediate files are already present, and defaults enabled outside
of releases since the intermediate files aren't in the source tree.
If you're in a situation where you do need to build the intermediate
files, set the HOSTCC environment variable to a native compiler. (This
is not a make or cmake variable.) For example:
env HOSTCC=cc make CC=myarch-cc CLFAGS="-mmyarch"
Best regards,
--
Gilles Peskine
Mbed TLS developer
On 20/02/2025 21:36, Francois Mace via mbed-tls wrote:
> Hello Everybody,
>
> I am trying to migrate my cross-compilation setup from version 2.28.9
> to version 3.6.2.
> I use a Makefile based approach for compilation.
> Everything seems to work fine up to the point where the compilation
> process reaches the test_suite data generation
>
> Gen suites/test_suite_psa_crypto_generate_key.generated.data
> suites/test_suite_psa_crypto_low_hash.generated.data
> suites/test_suite_psa_crypto_not_supported.generated.data
> suites/test_suite_psa_crypto_op_fail.generated.data
> suites/test_suite_psa_crypto_storage_format.current.data
> suites/test_suite_psa_crypto_storage_format.v0.data
>
> At that point it seems that the python based tools attempts to execute
> a temp executable (generated for my cross-compilation target ?) which
> fails.
> The traceback obtained is the following:
>
> Traceback (most recent call last):
> File "../framework/scripts/generate_psa_tests.py", line 849, in <module>
> test_data_generation.main(sys.argv[1:], __doc__, PSATestGenerator)
> File
> "/home/dev/test/mbed-TLS_3.6.2/framework/scripts/mbedtls_framework/test_data_generation.py",
> line 224, in main
> generator.generate_target(target)
> File "../framework/scripts/generate_psa_tests.py", line 845, in
> generate_target
> super().generate_target(name, self.info
http://self.info)
> File
> "/home/dev/test/mbed-TLS_3.6.2/framework/scripts/mbedtls_framework/test_data_generation.py",
> line 177, in generate_target
> self.write_test_data_file(name, test_cases)
> File
> "/home/dev/test/mbed-TLS_3.6.2/framework/scripts/mbedtls_framework/test_data_generation.py",
> line 164, in write_test_data_file
> test_case.write_data_file(filename, test_cases)
> File
> "/home/dev/test/mbed-TLS_3.6.2/framework/scripts/mbedtls_framework/test_case.py",
> line 88, in write_data_file
> for tc in test_cases:
> File "../framework/scripts/generate_psa_tests.py", line 694, in
> all_test_cases
> if key.location_value() != 0:
> File
> "/home/dev/test/mbed-TLS_3.6.2/framework/scripts/mbedtls_framework/psa_storage.py",
> line 186, in location_value
> return self.lifetime.value() >> 8
> File
> "/home/dev/test/mbed-TLS_3.6.2/framework/scripts/mbedtls_framework/psa_storage.py",
> line 89, in value
> self.update_cache()
> File
> "/home/dev/test/mbed-TLS_3.6.2/framework/scripts/mbedtls_framework/psa_storage.py",
> line 67, in update_cache
> include_path=includes) #type: List[str]
> File
> "/home/dev/test/mbed-TLS_3.6.2/framework/scripts/mbedtls_framework/c_build_helper.py",
> line 158, in get_c_expression_values
> output = subprocess.check_output([exe_name])
> File "/usr/lib/python3.7/subprocess.py", line 395, in check_output
> **kwargs).stdout
> File "/usr/lib/python3.7/subprocess.py", line 472, in run
> with Popen(*popenargs, **kwargs) as process:
> File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
> restore_signals, start_new_session)
> File "/usr/lib/python3.7/subprocess.py", line 1522, in _execute_child
> raise child_exception_type(errno_num, err_msg, err_filename)
> OSError: [Errno 8] Exec format error: '/tmp/tmp--m95sjmdw'
> make[2]: *** [Makefile:127: generated_psa_test_data] Error 1
> make[2] : on quitte le répertoire « /home/dev/test/mbed-TLS_3.6.2/tests »
> make[1]: *** [Makefile:35: tests] Error 2
> make[1] : on quitte le répertoire « /home/dev/test/mbed-TLS_3.6.2 »
> make: *** [test.make:152: all] Error 2
>
> Looking at the format of the generated tmp executable, it seems it is
> generated for my cross-compilation target, it therefore cannot be
> executed in my compilation environment.
>
> I would like to be able to generate the test and test data in order to
> be able to execute them on my compilation target, which is what I used
> to do with the previously integrated version of the library.
>
> Is there something I am missing in my compilation? am I missing a
> specific setup variable in my Makefile?
>
> Thanks for your feedback.
>
> Best regards,
>
> Francois
>