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

Fix for arm64_32 (aka ILP32) on Clang #7808

Merged
merged 15 commits into from
Jun 27, 2023

Conversation

daverodgman
Copy link
Contributor

@daverodgman daverodgman commented Jun 20, 2023

Description

Possible fix for ILP32 compile issue described in #7787

Manually tested because I haven't been able to get clang or armclang to build the full library for ILP32.

PR checklist

Please tick as appropriate and edit the reasons (e.g.: "backport: not needed because this is a new feature")

  • changelog done
  • backport no, issue not present in 2.28
  • tests no, cannot build ILP32 in the CI - rely on manual testing and confirmation from reporter

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
@daverodgman
Copy link
Contributor Author

Possibly something like asm volatile ("ldr %w0, [%1]" : "=r" (r) : "p" (p) :); is better?

@paulocoutinhox
Copy link

Im getting this error:

/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/constant_time.c:84:19: error: invalid operand for instruction
    asm volatile ("ldr %w0, [%w1]" : "=r" (r) : "r" (p) :);
                  ^
<inline asm>:1:12: note: instantiated into assembly here
        ldr w10, [w10]
                  ^
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/constant_time.c:84:19: error: invalid operand for instruction
    asm volatile ("ldr %w0, [%w1]" : "=r" (r) : "r" (p) :);
                  ^
<inline asm>:1:12: note: instantiated into assembly here
        ldr w11, [w11]
                  ^
2 errors generated.

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
@daverodgman
Copy link
Contributor Author

@paulocoutinhox does the latest version help?

@daverodgman daverodgman added the needs-info An issue or PR which needs further info from the reporter / author label Jun 21, 2023
@gilles-peskine-arm
Copy link
Contributor

The latest version isn't working on arm64. I suspect we need three cases here (maybe 4 with thumb? Did we thoroughly test that module like we did with bn_mul?): arm/aarch32, aarch64, and arm64_32 with a different mixture of register sizes and C type sizes than the other two.

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
@daverodgman
Copy link
Contributor Author

Did we thoroughly test that module like we did with bn_mul?): arm/aarch32, aarch64, and arm64_32 with a different mixture of register sizes and C type sizes than the other two.

I've tested the existing code (via qemu) on thumb1, thumb2, arm and aarch64 (it hits the asm codepath and works correctly for all these cases). The only types it uses are a pointer to char, and uint32_t, so that should rule out misbehaviour with different C type sizes (except if the size of the pointer is not as expected, as we see here).

If the latest variant doesn't work, I'll simply disable the aarch64 asm for ILP32 (i.e., where SIZE_MAX == 0xffffffff).

@daverodgman
Copy link
Contributor Author

daverodgman commented Jun 21, 2023

We don't have a compiler in the CI that will build for watchos, but I've been able to test this approach locally with the following test program:

typedef unsigned int uint32_t;

 uint32_t ilp32_ok(volatile const unsigned char *ptr)
{
    uint32_t r;
    asm volatile ("ldr %w0, [%1]" : "=r" (r) : "p" (ptr) :);
    return r;
}

uint32_t aarch64_ok(volatile const unsigned char *ptr)
{
    uint32_t r;
    asm volatile ("ldr %w0, [%1]" : "=r" (r) : "r" (ptr) :);
    return r;
}

and then compile with

clang --target=arm64_32-apple-watchos4.0 -c test.c

The error is reproduced in the aarch64 version (error at line 13), but is fixed for the ILP32 version (no error at line 6):

test.c:13:53: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
    asm volatile ("ldr %w0, [%1]" : "=r" (r) : "r" (ptr) :);
                                                    ^
test.c:13:30: note: use constraint modifier "w"
    asm volatile ("ldr %w0, [%1]" : "=r" (r) : "r" (ptr) :);
                             ^~
                             %w1
1 warning generated.

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
@daverodgman daverodgman added needs-review Every commit must be reviewed by at least two team members, priority-high High priority - will be reviewed soon size-xs Estimated task size: extra small (a few hours at most) labels Jun 21, 2023
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
@@ -79,7 +80,12 @@ static inline uint32_t mbedtls_get_unaligned_volatile_uint32(volatile const unsi
#if defined(__arm__) || defined(__thumb__) || defined(__thumb2__)
asm volatile ("ldr %0, [%1]" : "=r" (r) : "r" (p) :);
#elif defined(__aarch64__)
#if (SIZE_MAX == 0xffffffff)
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm Jun 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how SIZE_MAX matters here. Is it a proxy for the size of a pointer? If so, this needs at the very least a comment to explain. And it's wrong for targets with 64-bit pointers but 32-bit size_t, which is possible in theory but I don't know if any actually exist on arm. But then why not use UINTPTR_MAX? It doesn't actually have to match sizeof(unsigned char *), but I think it's less likely to diverge if the choice is 32-bit vs 64-bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think UINTPTR_WIDTH is in C99 (although we only care about GNUC compilers here so maybe that's OK). UINTPTR_MAX could work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WIDTH/MAX: yes, I realized immediately after posting.

Also a minor thing: these two lines should be #elif.

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me except that since this is fixing a build error (not just a warning) I think this requires a changelog entry. Never mind I was looking at the wrong tab.


This makes sense to me and I have verified that the following works on Linux with official Clang-15 packages from llvm.org:

  1. Patch out some header inclusions because I don't have suitable headers.
    diff --git a/library/alignment.h b/library/alignment.h
    index 41823485ad..acae9f618a 100644
    --- a/library/alignment.h
    +++ b/library/alignment.h
    @@ -24,8 +24,9 @@
     #define MBEDTLS_LIBRARY_ALIGNMENT_H
     
     #include <stdint.h>
    -#include <string.h>
    -#include <stdlib.h>
    +//#include <string.h>
    +//#include <stdlib.h>
    +void *memcpy(void *, const void *, unsigned long);
     
     /*
      * Define MBEDTLS_EFFICIENT_UNALIGNED_ACCESS for architectures where unaligned memory
    diff --git a/library/constant_time.c b/library/constant_time.c
    index f7da39f8e1..a0063e8996 100644
    --- a/library/constant_time.c
    +++ b/library/constant_time.c
    @@ -45,7 +45,7 @@
     #include "constant_time_invasive.h"
     #endif
     
    -#include <string.h>
    +//#include <string.h>
     #if defined(MBEDTLS_USE_PSA_CRYPTO)
     #define PSA_TO_MBEDTLS_ERR(status) PSA_TO_MBEDTLS_ERR_LIST(status,    \
                                                                psa_to_ssl_errors,              \
    
  2. Configure out the bits that need more stdlib:
    scripts/config.py crypto
    scripts/config.py unset MBEDTLS_RSA_C
    scripts/config.py unset MBEDTLS_HAVE_TIME_DATE
    scripts/config.py unset MBEDTLS_HAVE_TIME
    
  3. Build:
    clang-15 -I include -I library -target arm64_32-apple-watchos4.0 -Wall -Wextra -Werror -Os -c library/constant_time.c
    clang-15 -I include -I library -target arm64_32-apple-watchos4.0 -Wall -Wextra -Werror -O3 -c library/constant_time.c
    clang-15 -I include -I library -target arm64_32-apple-watchos4.0 -Wall -Wextra -Werror -S library/constant_time.c
    

I looked at the unoptimized assembly and it seems sensible to me (but I'm not an expert). It assumes that unaligned access is ok, which is already the case for the existing arm and aarch64 variants, so that's fine.

Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except maybe the changelog entry needs minor tweaks.

@@ -0,0 +1,4 @@
Bugfix
* Fix a compile failure in the constant_time module when building
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, not worth updating just for that:

Suggested change
* Fix a compile failure in the constant_time module when building
* Fix a compilation failure in the constant_time module when building

@@ -0,0 +1,4 @@
Bugfix
* Fix a compile failure in the constant_time module when building
for watchos (i.e. for Aarch64 ILP32). Reported by Paulo Coutinho
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, perhaps updating just for that: watchos is not really material here, what's material is arm64_32. Suggested wording: “when building for arm64_32, e.g. for watchOS”.

@daverodgman
Copy link
Contributor Author

It assumes that unaligned access is ok

That's not an assumption - it's gated by MBEDTLS_EFFICIENT_UNALIGNED_ACCESS which is in turn derived from __ARM_FEATURE_UNALIGNED, which the compiler sets when unaligned access is safe.

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
library/common.h Outdated
@@ -181,7 +181,7 @@ inline void mbedtls_xor(unsigned char *r, const unsigned char *a, const unsigned
#define MBEDTLS_ASM_AARCH64_PTR_CONSTRAINT "p"
#elif UINTPTR_MAX == 0xfffffffffffffffful
/* Normal case (64-bit pointers): use "r" as the constraint for pointer operands to asm */
#define MBEDTLS_ASM_AARCH64_PTR_CONSTRAINT "r"
#define MBEDTLS_ASM_AARCH64_PTR_CONSTRAINT "p"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that locally (as before, commenting out the inclusion of string.h) and both work:

aarch64-linux-gnu-gcc -I include -I library -Wall -Wextra -Werror -S library/constant_time.c
clang-15 -I include -I library -target aarch64 -Wall -Wextra -Werror -S library/constant_time.c

I don't know what the problem is in the Travis build.

@daverodgman
Copy link
Contributor Author

According to godbolt ( https://gcc.godbolt.org/z/sWooPKd1n ), clang trunk recognises 'p' but does not recognise '+p'. According to docs & local testing, armclang does not recognise 'p' at all.

So I think we need the option to use 'r' for armclang. I am not sure what we can do for clang ILP32, other than turn off the bn_mul.h asm. I'm assuming that it really does need to update the pointer value - will check this.

@daverodgman
Copy link
Contributor Author

Those two operands do not need to be written to, so I've moved them into the inputs section and avoided the need to use '+p'.

'p' probably is the preferred option for this kind of parameter, with an exception for armclang, but it feels safer to make the minimal change (i.e., only use 'p' for ILP32 where it seems needed).

As it stands it won't build on armclang for ILP32 (it will try to use the 'p' constraint which armclang doesn't recognise), but I don't know if this is even a supported target for armclang.

@paulocoutinhox
Copy link

The latest commit work for me when compile for watchOS.

For tvOS:

/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/lms.c:392:56: error: implicit conversion loses integer precision: 'unsigned long' to 'unsigned int' [-Werror,-Wshorten-64-to-32]
        MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) + q_leaf_identifier,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/lms.c:395:67: error: implicit conversion loses integer precision: 'unsigned long' to 'unsigned int' [-Werror,-Wshorten-64-to-32]
    curr_node_id = MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) +
                 ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
2 errors generated.

For macOS:

CompileC /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release/Objects-normal/x86_64/lms.o /Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/lms.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler (in target 'mbedcrypto' from project 'test')
    cd /Users/paulo/Developer/workspaces/cpp/cpp-http-test
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c -ivfsstatcache /var/folders/0j/1vzxlz_d135_p0gs5jjc428c0000gn/C/com.apple.DeveloperTools/14.3.1-14E300c/Xcode/SDKStatCaches.noindex/macosx13.3-22E245-.sdkstatcache -target x86_64-apple-macos11.0 -fmessage-length\=245 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -fcolor-diagnostics -Wno-trigraphs -fpascal-strings -O2 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-implicit-fallthrough -DCMAKE_INTDIR\=\"Release\" -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Wno-sign-conversion -Wno-infinite-recursion -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-semicolon-before-method-body -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/Release/include -I/Users/paulo/Developer/workspaces/cpp/yasio -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/_deps/yasio-build -I/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/include -I/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release/DerivedSources-normal/x86_64 -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release/DerivedSources/x86_64 -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release/DerivedSources -F/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/Release -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow -Wvla -Wformat\=2 -Wno-format-nonliteral -Werror -Wmissing-declarations -Wmissing-prototypes -Wdocumentation -Wno-documentation-deprecated-sync -Wunreachable-code -std\=c99 -MMD -MT dependencies -MF /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release/Objects-normal/x86_64/lms.d --serialize-diagnostics /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release/Objects-normal/x86_64/lms.dia -c /Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/lms.c -o /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release/Objects-normal/x86_64/lms.o
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/lms.c:392:56: error: implicit conversion loses integer precision: 'unsigned long' to 'unsigned int' [-Werror,-Wshorten-64-to-32]
        MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) + q_leaf_identifier,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/lms.c:395:67: error: implicit conversion loses integer precision: 'unsigned long' to 'unsigned int' [-Werror,-Wshorten-64-to-32]
    curr_node_id = MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) +
                 ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
2 errors generated.

@daverodgman
Copy link
Contributor Author

Those two operands do not need to be written to, so I've moved them into the inputs section and avoided the need to use '+p'.

This is not correct - they are updated so they need to be outputs.

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
@daverodgman
Copy link
Contributor Author

Casting to uintptr_t and using +r seems to work, but it's a bit of an awkward way to do it.

@daverodgman daverodgman removed the needs-ci Needs to pass CI tests label Jun 22, 2023
Co-authored-by: Tom Cosgrove <tom.cosgrove@arm.com>
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
Copy link
Contributor

@tom-cosgrove-arm tom-cosgrove-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tom-cosgrove-arm
Copy link
Contributor

@paulocoutinhox Would you mind checking that the latest version works for you?

@paulocoutinhox
Copy link

paulocoutinhox commented Jun 24, 2023 via email

@paulocoutinhox
Copy link

Hi,

Im testing now the latest commit and get this error:

watchOS


CompileC /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-watchos/Objects-normal/arm64_32/bignum_core.o /Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bignum_core.c normal arm64_32 c com.apple.compilers.llvm.clang.1_0.compiler (in target 'mbedcrypto' from project 'test')
    cd /Users/paulo/Developer/workspaces/cpp/cpp-http-test
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c -ivfsstatcache /var/folders/0j/1vzxlz_d135_p0gs5jjc428c0000gn/C/com.apple.DeveloperTools/14.3.1-14E300c/Xcode/SDKStatCaches.noindex/watchos9.4-20T248-.sdkstatcache -target arm64_32-apple-watchos4.0 -fmessage-length\=245 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -fcolor-diagnostics -Wno-trigraphs -fpascal-strings -O2 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wno-shorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-implicit-fallthrough -DCMAKE_INTDIR\=\"Release-watchos\" -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS9.4.sdk -fstrict-aliasing -Wdeprecated-declarations -Wno-sign-conversion -Wno-infinite-recursion -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-semicolon-before-method-body -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/Release/include -I/Users/paulo/Developer/workspaces/cpp/yasio -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/_deps/yasio-build -I/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/include -I/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-watchos/DerivedSources-normal/arm64_32 -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-watchos/DerivedSources/arm64_32 -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-watchos/DerivedSources -F/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/Release -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow -Wvla -Wformat\=2 -Wno-format-nonliteral -Werror -Wmissing-declarations -Wmissing-prototypes -Wdocumentation -Wno-documentation-deprecated-sync -Wunreachable-code -std\=c99 -MMD -MT dependencies -MF /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-watchos/Objects-normal/arm64_32/bignum_core.d --serialize-diagnostics /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-watchos/Objects-normal/arm64_32/bignum_core.dia -c /Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bignum_core.c -o /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-watchos/Objects-normal/arm64_32/bignum_core.o
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bignum_core.c:481:13: error: value size does not match register size specified by the constraint and modifier [-Werror,-Wasm-operand-widths]
            MULADDC_X8_STOP
            ^
In file included from /Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bignum_core.c:33:
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bn_mul.h:1098:25: note: expanded from macro 'MULADDC_X8_STOP'
#define MULADDC_X8_STOP MULADDC_X4_STOP
                        ^
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bn_mul.h:1092:25: note: expanded from macro 'MULADDC_X4_STOP'
#define MULADDC_X4_STOP MULADDC_X2_STOP
                        ^
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bn_mul.h:1086:25: note: expanded from macro 'MULADDC_X2_STOP'
#define MULADDC_X2_STOP MULADDC_X1_STOP
                        ^
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bn_mul.h:272:18: note: expanded from macro 'MULADDC_X1_STOP'
           "+r" (muladdc_s),                                            \
                 ^
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bignum_core.c:480:9: note: use constraint modifier "w"
        MULADDC_X8_CORE
        ^
In file included from /Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bignum_core.c:33:
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bn_mul.h:1099:25: note: expanded from macro 'MULADDC_X8_CORE'
#define MULADDC_X8_CORE MULADDC_X4_CORE MULADDC_X4_CORE
                        ^
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bn_mul.h:1093:25: note: expanded from macro 'MULADDC_X4_CORE'
#define MULADDC_X4_CORE MULADDC_X2_CORE MULADDC_X2_CORE
                        ^
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bn_mul.h:1087:25: note: expanded from macro 'MULADDC_X2_CORE'
#define MULADDC_X2_CORE MULADDC_X1_CORE MULADDC_X1_CORE
                        ^
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bn_mul.h:259:19: note: expanded from macro 'MULADDC_X1_CORE'
        "ldr x4, [%2], #8   \n\t"   \
                  ^
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bignum_core.c:481:13: error: value size does not match register size specified by the constraint and modifier [-Werror,-Wasm-operand-widths]
            MULADDC_X8_STOP
            ^
In file included from /Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bignum_core.c:33:
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bn_mul.h:1098:25: note: expanded from macro 'MULADDC_X8_STOP'
#define MULADDC_X8_STOP MULADDC_X4_STOP
                        ^
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bn_mul.h:1092:25: note: expanded from macro 'MULADDC_X4_STOP'
#define MULADDC_X4_STOP MULADDC_X2_STOP
                        ^
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bn_mul.h:1086:25: note: expanded from macro 'MULADDC_X2_STOP'
#define MULADDC_X2_STOP MULADDC_X1_STOP
                        ^
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bn_mul.h:271:18: note: expanded from macro 'MULADDC_X1_STOP'
           "+r" (muladdc_d),                                            \
                 ^
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bignum_core.c:480:9: note: use constraint modifier "w"
        MULADDC_X8_CORE
        ^
In file included from /Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bignum_core.c:33:
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bn_mul.h:1099:25: note: expanded from macro 'MULADDC_X8_CORE'
#define MULADDC_X8_CORE MULADDC_X4_CORE MULADDC_X4_CORE
                        ^
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bn_mul.h:1093:25: note: expanded from macro 'MULADDC_X4_CORE'
#define MULADDC_X4_CORE MULADDC_X2_CORE MULADDC_X2_CORE
                        ^
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bn_mul.h:1087:25: note: expanded from macro 'MULADDC_X2_CORE'
#define MULADDC_X2_CORE MULADDC_X1_CORE MULADDC_X1_CORE
                        ^
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bn_mul.h:260:19: note: expanded from macro 'MULADDC_X1_CORE'
        "ldr x5, [%1]       \n\t"   \
                  ^
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/bignum_core.c:481:13: error: value size does not match register size specified by the constraint and modifier [-Werror,-Wasm-operand-widths]
            MULADDC_X8_STOP
            ^
[...]
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

tvOS:

CompileC /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-appletvos/Objects-normal/arm64/lms.o /Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/lms.c normal arm64 c com.apple.compilers.llvm.clang.1_0.compiler (in target 'mbedcrypto' from project 'test')
    cd /Users/paulo/Developer/workspaces/cpp/cpp-http-test
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c -ivfsstatcache /var/folders/0j/1vzxlz_d135_p0gs5jjc428c0000gn/C/com.apple.DeveloperTools/14.3.1-14E300c/Xcode/SDKStatCaches.noindex/appletvos16.4-20L489-.sdkstatcache -target arm64-apple-tvos11.0 -fmessage-length\=245 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -fcolor-diagnostics -Wno-trigraphs -fpascal-strings -O2 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-implicit-fallthrough -DCMAKE_INTDIR\=\"Release-appletvos\" -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS16.4.sdk -fstrict-aliasing -Wdeprecated-declarations -Wno-sign-conversion -Wno-infinite-recursion -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-semicolon-before-method-body -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/Release/include -I/Users/paulo/Developer/workspaces/cpp/yasio -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/_deps/yasio-build -I/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/include -I/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-appletvos/DerivedSources-normal/arm64 -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-appletvos/DerivedSources/arm64 -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-appletvos/DerivedSources -F/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/Release -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow -Wvla -Wformat\=2 -Wno-format-nonliteral -Werror -Wmissing-declarations -Wmissing-prototypes -Wdocumentation -Wno-documentation-deprecated-sync -Wunreachable-code -std\=c99 -MMD -MT dependencies -MF /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-appletvos/Objects-normal/arm64/lms.d --serialize-diagnostics /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-appletvos/Objects-normal/arm64/lms.dia -c /Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/lms.c -o /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-appletvos/Objects-normal/arm64/lms.o
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/lms.c:392:56: error: implicit conversion loses integer precision: 'unsigned long' to 'unsigned int' [-Werror,-Wshorten-64-to-32]
        MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) + q_leaf_identifier,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/lms.c:395:67: error: implicit conversion loses integer precision: 'unsigned long' to 'unsigned int' [-Werror,-Wshorten-64-to-32]
    curr_node_id = MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) +
                 ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
2 errors generated.

macOS:

CompileC /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release/Objects-normal/x86_64/lms.o /Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/lms.c normal x86_64 c com.apple.compilers.llvm.clang.1_0.compiler (in target 'mbedcrypto' from project 'test')
    cd /Users/paulo/Developer/workspaces/cpp/cpp-http-test
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c -ivfsstatcache /var/folders/0j/1vzxlz_d135_p0gs5jjc428c0000gn/C/com.apple.DeveloperTools/14.3.1-14E300c/Xcode/SDKStatCaches.noindex/macosx13.3-22E245-.sdkstatcache -target x86_64-apple-macos11.0 -fmessage-length\=245 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -fcolor-diagnostics -Wno-trigraphs -fpascal-strings -O2 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-implicit-fallthrough -DCMAKE_INTDIR\=\"Release\" -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Wno-sign-conversion -Wno-infinite-recursion -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-semicolon-before-method-body -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/Release/include -I/Users/paulo/Developer/workspaces/cpp/yasio -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/_deps/yasio-build -I/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/include -I/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release/DerivedSources-normal/x86_64 -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release/DerivedSources/x86_64 -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release/DerivedSources -F/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/Release -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow -Wvla -Wformat\=2 -Wno-format-nonliteral -Werror -Wmissing-declarations -Wmissing-prototypes -Wdocumentation -Wno-documentation-deprecated-sync -Wunreachable-code -std\=c99 -MMD -MT dependencies -MF /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release/Objects-normal/x86_64/lms.d --serialize-diagnostics /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release/Objects-normal/x86_64/lms.dia -c /Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/lms.c -o /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release/Objects-normal/x86_64/lms.o
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/lms.c:392:56: error: implicit conversion loses integer precision: 'unsigned long' to 'unsigned int' [-Werror,-Wshorten-64-to-32]
        MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) + q_leaf_identifier,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/lms.c:395:67: error: implicit conversion loses integer precision: 'unsigned long' to 'unsigned int' [-Werror,-Wshorten-64-to-32]
    curr_node_id = MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) +
                 ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
2 errors generated.

iOS:

CompileC /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-iphoneos/Objects-normal/arm64/lms.o /Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/lms.c normal arm64 c com.apple.compilers.llvm.clang.1_0.compiler (in target 'mbedcrypto' from project 'test')
    cd /Users/paulo/Developer/workspaces/cpp/cpp-http-test
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c -ivfsstatcache /var/folders/0j/1vzxlz_d135_p0gs5jjc428c0000gn/C/com.apple.DeveloperTools/14.3.1-14E300c/Xcode/SDKStatCaches.noindex/iphoneos16.4-20E238-.sdkstatcache -target arm64-apple-ios11.0 -fmessage-length\=245 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -fcolor-diagnostics -Wno-trigraphs -fpascal-strings -O2 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-implicit-fallthrough -DCMAKE_INTDIR\=\"Release-iphoneos\" -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.4.sdk -fstrict-aliasing -Wdeprecated-declarations -Wno-sign-conversion -Wno-infinite-recursion -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-semicolon-before-method-body -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/Release/include -I/Users/paulo/Developer/workspaces/cpp/yasio -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/_deps/yasio-build -I/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/include -I/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-iphoneos/DerivedSources-normal/arm64 -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-iphoneos/DerivedSources/arm64 -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-iphoneos/DerivedSources -F/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/Release -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow -Wvla -Wformat\=2 -Wno-format-nonliteral -Werror -Wmissing-declarations -Wmissing-prototypes -Wdocumentation -Wno-documentation-deprecated-sync -Wunreachable-code -std\=c99 -MMD -MT dependencies -MF /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-iphoneos/Objects-normal/arm64/lms.d --serialize-diagnostics /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-iphoneos/Objects-normal/arm64/lms.dia -c /Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/lms.c -o /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-iphoneos/Objects-normal/arm64/lms.o
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/lms.c:392:56: error: implicit conversion loses integer precision: 'unsigned long' to 'unsigned int' [-Werror,-Wshorten-64-to-32]
        MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) + q_leaf_identifier,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/lms.c:395:67: error: implicit conversion loses integer precision: 'unsigned long' to 'unsigned int' [-Werror,-Wshorten-64-to-32]
    curr_node_id = MERKLE_TREE_INTERNAL_NODE_AM(ctx->params.type) +
                 ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
2 errors generated.

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
@daverodgman
Copy link
Contributor Author

@paulocoutinhox please let us know if the latest update addresses the error: value size does not match register size specified by the constraint and modifier [-Werror,-Wasm-operand-widths] issue.

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
@paulocoutinhox
Copy link

Hi,

watchOS:

** BUILD SUCCEEDED **

Thanks

@daverodgman daverodgman removed the needs-info An issue or PR which needs further info from the reporter / author label Jun 27, 2023
Copy link
Member

@paul-elliott-arm paul-elliott-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@tom-cosgrove-arm tom-cosgrove-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tom-cosgrove-arm tom-cosgrove-arm added approved Design and code approved - may be waiting for CI or backports and removed needs-review Every commit must be reviewed by at least two team members, labels Jun 27, 2023
@daverodgman daverodgman merged commit 9f4fd28 into Mbed-TLS:development Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Design and code approved - may be waiting for CI or backports bug component-platform Portability layer and build scripts priority-high High priority - will be reviewed soon size-xs Estimated task size: extra small (a few hours at most)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants