mbedtls icon indicating copy to clipboard operation
mbedtls copied to clipboard

MbedTLS 3.5.2 fails to build on RHEL 6.6 with gcc 4.4.7

Open Bhagyanidhi-Patil opened this issue 1 year ago • 5 comments

Summary

When I'm using to run MbedTLS 3.5.2 library on Linux system I'm hitting into the following issue : obj/GCC.Release.x64.hpsrvdll.crtdll/mbedtls/aes.o:aes.c:(.text+0x305): first defined here obj/GCC.Release.x64.hpsrvdll.crtdll/mbedtls/x509write_csr.o: In function mbedtls_put_unaligned_uint64': x509write_csr.c:(.text+0x117): multiple definition of mbedtls_put_unaligned_uint64' obj/GCC.Release.x64.hpsrvdll.crtdll/mbedtls/aes.o:aes.c:(.text+0x279): first defined here obj/GCC.Release.x64.hpsrvdll.crtdll/mbedtls/x509write_csr.o: In function mbedtls_get_unaligned_uint64': x509write_csr.c:(.text+0x11b): multiple definition of mbedtls_get_unaligned_uint64' obj/GCC.Release.x64.hpsrvdll.crtdll/mbedtls/aes.o:aes.c:(.text+0x27d): first defined here obj/GCC.Release.x64.hpsrvdll.crtdll/mbedtls/x509write_csr.o: In function mbedtls_xor': x509write_csr.c:(.text+0x11f): multiple definition of mbedtls_xor' obj/GCC.Release.x64.hpsrvdll.crtdll/mbedtls/aes.o:aes.c:(.text+0x281): first defined here obj/GCC.Release.x64.hpsrvdll.crtdll/mbedtls/x509write_csr.o: In function mbedtls_put_unaligned_uint32': x509write_csr.c:(.text+0x199): multiple definition of mbedtls_put_unaligned_uint32' obj/GCC.Release.x64.hpsrvdll.crtdll/mbedtls/aes.o:aes.c:(.text+0x2fb): first defined here obj/GCC.Release.x64.hpsrvdll.crtdll/mbedtls/x509write_csr.o: In function mbedtls_get_unaligned_uint32': x509write_csr.c:(.text+0x19c): multiple definition of mbedtls_get_unaligned_uint32' obj/GCC.Release.x64.hpsrvdll.crtdll/mbedtls/aes.o:aes.c:(.text+0x2fe): first defined here obj/GCC.Release.x64.hpsrvdll.crtdll/mbedtls/x509write_csr.o: In function mbedtls_put_unaligned_uint16': x509write_csr.c:(.text+0x19f): multiple definition of mbedtls_put_unaligned_uint16' obj/GCC.Release.x64.hpsrvdll.crtdll/mbedtls/aes.o:aes.c:(.text+0x301): first defined here obj/GCC.Release.x64.hpsrvdll.crtdll/mbedtls/x509write_csr.o: In function mbedtls_get_unaligned_uint16': x509write_csr.c:(.text+0x1a3): multiple definition of mbedtls_get_unaligned_uint16' obj/GCC.Release.x64.hpsrvdll.crtdll/mbedtls/aes.o:aes.c:(.text+0x305): first defined here

collect2: ld returned 1 exit status make[1]: *** [bin/libhpsrv-x64-1.so] Error 1 make[1]: Leaving directory `/root/Libhpsrv_352/libhpsrv' make: *** [dynamic-free] Error 2

System information

Mbed TLS version (number or commit id): 3.5.2 Operating system and version: Linux, rhel 6.6 Configuration (if not default, please attach mbedtls_config.h): Compiler and options (if you used a pre-built binary, please indicate how you obtained it): Additional environment information:

Expected behavior

Actual behavior

Steps to reproduce

Additional information

Bhagyanidhi-Patil avatar Feb 05 '24 09:02 Bhagyanidhi-Patil

Hello! Thanks for reporting the issue! Could I get more information on how to reproduce? What compiler/linker was used in producing this output? What versions?

tgonzalezorlandoarm avatar Feb 05 '24 15:02 tgonzalezorlandoarm

I'm building on Linux OS - Rhel 6.6 , gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-11)

Bhagyanidhi-Patil avatar Feb 07 '24 05:02 Bhagyanidhi-Patil

Could you share what configuration and compile-time options you are using? I don't have access to RHEL 6.6, but on Ubuntu 18.04 with gcc 4.4.7 installed I'm not able to compile, failing early with

gcc-4.4.7 $ make CC=gcc CFLAGS="-std=gnu99"
  CC    aes.c
  CC    aesni.c
  CC    aesce.c
  CC    aria.c
  CC    asn1parse.c
  CC    asn1write.c
  CC    base64.c
In file included from constant_time_internal.h:577,
                 from base64.c:16:
constant_time_impl.h:35: warning: expected [error|warning|ignored] after '#pragma GCC diagnostic'
constant_time_impl.h: In function 'mbedtls_ct_bool':
constant_time_impl.h:181: error: expected string literal before ')' token
constant_time_impl.h: In function 'mbedtls_ct_if':
constant_time_impl.h:262: error: expected string literal before ')' token
constant_time_impl.h: In function 'mbedtls_ct_uint_lt':
constant_time_impl.h:343: error: expected string literal before ')' token
constant_time_impl.h: At top level:
constant_time_impl.h:551: warning: expected [error|warning|ignored] after '#pragma GCC diagnostic'
Makefile:312: recipe for target 'base64.o' failed
make[1]: *** [base64.o] Error 1
Makefile:18: recipe for target 'lib' failed
make: *** [lib] Error 2

tom-cosgrove-arm avatar Feb 07 '24 12:02 tom-cosgrove-arm

Linux Flavor image gcc version image Compiler option image CPU information image

Bhagyanidhi-Patil avatar Feb 13 '24 06:02 Bhagyanidhi-Patil

Hello, I encuntered similar issue with "gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0" (when linking static mbedtls libraries) The issue happens because of usage of simple "inline" keyword (instead of "static inline") in mbedtls_put_unaligned_xxx, mbedtls_get_unaligned_xxx and mbedtls_xor methods, producing external definitions of said methods in the objects. The inlining behavior depends on compiler/c-flavor/options, but I believe "static inline" would be safest here for most of compilers.

pistegif avatar Feb 16 '24 07:02 pistegif

Could you please provide an update on this issue as it is essential for our project.

Bhagyanidhi-Patil avatar Feb 19 '24 06:02 Bhagyanidhi-Patil

Could you share what configuration and compile-time options you are using? I don't have access to RHEL 6.6, but on Ubuntu 18.04 with gcc 4.4.7 installed I'm not able to compile, failing early with

gcc-4.4.7 $ make CC=gcc CFLAGS="-std=gnu99"
  CC    aes.c
  CC    aesni.c
  CC    aesce.c
  CC    aria.c
  CC    asn1parse.c
  CC    asn1write.c
  CC    base64.c
In file included from constant_time_internal.h:577,
                 from base64.c:16:
constant_time_impl.h:35: warning: expected [error|warning|ignored] after '#pragma GCC diagnostic'
constant_time_impl.h: In function 'mbedtls_ct_bool':
constant_time_impl.h:181: error: expected string literal before ')' token
constant_time_impl.h: In function 'mbedtls_ct_if':
constant_time_impl.h:262: error: expected string literal before ')' token
constant_time_impl.h: In function 'mbedtls_ct_uint_lt':
constant_time_impl.h:343: error: expected string literal before ')' token
constant_time_impl.h: At top level:
constant_time_impl.h:551: warning: expected [error|warning|ignored] after '#pragma GCC diagnostic'
Makefile:312: recipe for target 'base64.o' failed
make[1]: *** [base64.o] Error 1
Makefile:18: recipe for target 'lib' failed
make: *** [lib] Error 2

Same error with old Xcode gcc, but only on Intel: https://github.com/Mbed-TLS/mbedtls/issues/8832#issue-2134933509 On PowerPC it builds with gcc-4.2

barracuda156 avatar Feb 19 '24 13:02 barracuda156

There have been a lot of changes in this area, most recently in PR #8719. Can you try again with development?

tom-cosgrove-arm avatar Feb 19 '24 13:02 tom-cosgrove-arm

There have been a lot of changes in this area, most recently in PR #8719. Can you try again with development?

I tried from development branch, it gives error. The psa_crypto_driver_wrappers.h file have been removed from dev branch but they included that as header in the psa_crypto.c file. So it is throwing error . image

Bhagyanidhi-Patil avatar Feb 22 '24 05:02 Bhagyanidhi-Patil

@Bhagyanidhi-Patil psa_crypto_driver_wrappers.h is a generated file. In releases we include them for convenience, but in development they must be built. This normally happens as part of make, but dependencies aren't exact, so you may need to do

make generated_files

tom-cosgrove-arm avatar Feb 22 '24 09:02 tom-cosgrove-arm

@Bhagyanidhi-Patil psa_crypto_driver_wrappers.h is a generated file. In releases we include them for convenience, but in development they must be built. This normally happens as part of make, but dependencies aren't exact, so you may need to do

make generated_files

We are not encountering the issue we faced in Mbedtls 3.5.1 and Mbedtls 3.5.2 in the development branch. Could you please provide and update on the release date of new version of Mbedtls?

Bhagyanidhi-Patil avatar Feb 28 '24 06:02 Bhagyanidhi-Patil

We are planning to release Mbed TLS 3.6 by the end of this quarter (end of March 2024). That will become our next LTS branch.

tom-cosgrove-arm avatar Feb 28 '24 14:02 tom-cosgrove-arm

We are blocked with this issue so is there any chance of releasing new version before the end of March 2024?

Bhagyanidhi-Patil avatar Feb 29 '24 09:02 Bhagyanidhi-Patil

Is there going be any beta release before the release of new version of the Mbedtls?

Bhagyanidhi-Patil avatar Mar 12 '24 10:03 Bhagyanidhi-Patil

We don't tend to do alpha or beta releases - the idea is that the development branch will become the new release, after any embargoed security fixes are merged

tom-cosgrove-arm avatar Mar 12 '24 11:03 tom-cosgrove-arm