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

Compilation failure on 32-bit and 64-bit arm platforms with a recent clang #7787

Closed
paulocoutinhox opened this issue Jun 16, 2023 · 15 comments · Fixed by #7806
Closed

Compilation failure on 32-bit and 64-bit arm platforms with a recent clang #7787

paulocoutinhox opened this issue Jun 16, 2023 · 15 comments · Fixed by #7806
Labels
bug priority-medium Medium priority - this can be reviewed as time permits size-m Estimated task size: medium (~1w)

Comments

@paulocoutinhox
Copy link

Hi,

Can you add support for watchOS, tvOS and iOS?

Reference:
yasio/yasio#416 (comment)

Thanks.

@gilles-peskine-arm
Copy link
Contributor

The issue you link to is about the compiler and processor, not about the OS.

We recently fixed an issue where clang was picking up the wrong assembly code on some arm CPUs, can you please try the latest development branch?

If not, can you please let us know how to reproduce the problem: exact compiler command line, preferably one that doesn't require a “fancy” development kit and works on Linux.


We do not plan to add integration to the operating systems, i.e. platform support, TLS stack integration, build script, etc.

@gilles-peskine-arm gilles-peskine-arm changed the title Support for watchOS, tvOS and iOS Compilation failure in bn_mul.h with clang for Apple Watch CPU Jun 16, 2023
@gilles-peskine-arm
Copy link
Contributor

Oh, it failed with a different error? So is the bn_mul.h error that you encountered solved in the development branch then?

Is that in the same configuration with the same compiler? The errors in your latest links seem to be specific to a compile-time configuration (and perhaps 32-bit/64-bit), whereas the errors in your original report were about a combination of compiler and target CPU.

@paulocoutinhox
Copy link
Author

Is because they test in github action following their test suite using your development branch and im testing using a simple executable.

@paulocoutinhox
Copy link
Author

paulocoutinhox commented Jun 16, 2023

I have installed everything locally, including the mbedtls development branch and now get these errors:

iOS:

    /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.

watchOS:


CompileC /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-watchos/Objects-normal/armv7k/ecp_curves.o /Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/ecp_curves.c normal armv7k 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 armv7k-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/armv7k -I/Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-watchos/DerivedSources/armv7k -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/armv7k/ecp_curves.d --serialize-diagnostics /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-watchos/Objects-normal/armv7k/ecp_curves.dia -c /Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/ecp_curves.c -o /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-watchos/Objects-normal/armv7k/ecp_curves.o
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/ecp_curves.c:5581:9: error: code will never be executed [-Werror,-Wunreachable-code]
        M[P224_WIDTH_MIN] &= ((mbedtls_mpi_uint)-1) >> (P224_UNUSED_BITS);
        ^
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/ecp_curves.c:5580:15: note: silence by adding parentheses to mark code as explicitly dead
    if (ciL > 4) {
              ^
              /* DISABLES CODE */ ( )
1 error 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.

Android:

OK

macOS without leetal cmake (https://github.com/leetal/ios-cmake):

OK

If you want that i test any branch with custom code to check if was solved, only post here that i can test now locally fast.

@tom-cosgrove-arm
Copy link
Contributor

The interesting one for me is mbedtls/library/ecp_curves.c:5581:9: error: code will never be executed [-Werror,-Wunreachable-code]

The code is

    if (ciL > 4) {
        M[P224_WIDTH_MIN] &= ((mbedtls_mpi_uint)-1) >> (P224_UNUSED_BITS);
    }

and so because ciL is 4, this is dead code. Annoyingly, some compilers won't be able to figure this out in the pre-processor, so it has to be a run-time check, but here's clang complaining that we're making a redundant run-time check!

@gilles-peskine-arm
Copy link
Contributor

ciL is derived from preprocessor symbols (MBEDTLS_HAVE_INTxx) so we should have used #ifdef MBEDTLS_HAVE_INT32 here, that one's clearly a coding mistake.

@paulocoutinhox Note that all the warnings in our latest post are harmless (the compiler's picky but the code's ok). If you disable -Werror you should be able to compile and run.

@gilles-peskine-arm gilles-peskine-arm changed the title Compilation failure in bn_mul.h with clang for Apple Watch CPU Compilation failure on 32-bit platform with a recent clang Jun 17, 2023
@paul-elliott-arm paul-elliott-arm linked a pull request Jun 20, 2023 that will close this issue
3 tasks
@gilles-peskine-arm
Copy link
Contributor

We've just merged a fix so that there are no compiler warnings with clang 15 in the default configuration with -Wall -Wextra or with the set of flags picked by cmake.

I'm reopening this issue because there are apparently more warnings in the LMS code which we haven't addressed.

@gilles-peskine-arm gilles-peskine-arm added bug size-s Estimated task size: small (~2d) priority-medium Medium priority - this can be reviewed as time permits labels Jun 20, 2023
@paulocoutinhox
Copy link
Author

Hi,

That warning was fixed, now have other:

CompileC /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-watchos/Objects-normal/arm64_32/constant_time.o /Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/constant_time.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/constant_time.d --serialize-diagnostics /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-watchos/Objects-normal/arm64_32/constant_time.dia -c /Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/constant_time.c -o /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-watchos/Objects-normal/arm64_32/constant_time.o
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/constant_time.c:82:53: error: value size does not match register size specified by the constraint and modifier [-Werror,-Wasm-operand-widths]
    asm volatile ("ldr %w0, [%1]" : "=r" (r) : "r" (p) :);
                                                    ^
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/constant_time.c:82:30: note: use constraint modifier "w"
    asm volatile ("ldr %w0, [%1]" : "=r" (r) : "r" (p) :);
                             ^~
                             %w1
1 error generated.

@gilles-peskine-arm gilles-peskine-arm changed the title Compilation failure on 32-bit platform with a recent clang Compilation failure on 32-bit and 64-bit arm platforms with a recent clang Jun 20, 2023
@gilles-peskine-arm gilles-peskine-arm added size-m Estimated task size: medium (~1w) and removed size-s Estimated task size: small (~2d) labels Jun 20, 2023
@gilles-peskine-arm
Copy link
Contributor

Oh, so that one is apparently a 64-bit platform, since line 82 in constant_time.c is guarded by defined(__aarch64__)?

Or maybe we're not doing the right thing for arm64_32-apple-watchos4.0 — I don't know exactly what arm64_32 entails: is that aarch64 instructions with 32-bit pointers?

It would help if the issue was focused on a single platform, rather than mixing many issues into one.

@paulocoutinhox
Copy link
Author

Hi,

About arm64_32 of apple watch:

The architecture "arm64_32" is a variant of the ARM architecture that combines elements of both 64-bit and 32-bit systems. It is designed to be backward compatible with 32-bit ARM code while also supporting 64-bit execution.

To clarify, the "arm64_32" architecture refers to the AArch32 execution state within a 64-bit ARM architecture (AArch64). In this execution state, the processor can execute both 32-bit and 64-bit instructions.

The term "arm64_32" might appear a bit confusing because it seems to imply that it is primarily a 32-bit architecture, but that is not the case. The architecture is fundamentally 64-bit but includes support for running 32-bit code.

In practical terms, this means that an "arm64_32" processor can execute both 32-bit and 64-bit applications. This compatibility is useful when transitioning from a 32-bit environment to a 64-bit one, as it allows for the continued use of existing 32-bit software without requiring immediate recompilation.

To summarize, "arm64_32" is a 64-bit architecture that includes support for executing 32-bit code, making it a hybrid architecture suitable for backward compatibility and transitioning from 32-bit to 64-bit systems.

I will add here some warnings using current version in development branch.

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.

watchOS error:

CompileC /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-watchos/Objects-normal/arm64_32/constant_time.o /Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/constant_time.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/constant_time.d --serialize-diagnostics /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-watchos/Objects-normal/arm64_32/constant_time.dia -c /Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/constant_time.c -o /Users/paulo/Developer/workspaces/cpp/cpp-http-test/build/build/mbedcrypto.build/Release-watchos/Objects-normal/arm64_32/constant_time.o
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/constant_time.c:82:53: error: value size does not match register size specified by the constraint and modifier [-Werror,-Wasm-operand-widths]
    asm volatile ("ldr %w0, [%1]" : "=r" (r) : "r" (p) :);
                                                    ^
/Users/paulo/Developer/workspaces/cpp/yasio/thirdparty/mbedtls/library/constant_time.c:82:30: note: use constraint modifier "w"
    asm volatile ("ldr %w0, [%1]" : "=r" (r) : "r" (p) :);
                             ^~
                             %w1
1 error generated.

@daverodgman
Copy link
Contributor

@paulocoutinhox please could you confirm if #7808 fixes this. Do you have any suggestions as to what the command line should look like in order to get clang to build ILP32 in order to test this? Thanks

@paulocoutinhox
Copy link
Author

Hi @daverodgman

I post the error on your PR.

@paulocoutinhox
Copy link
Author

Hi @daverodgman,

The watchOS bug was fixed.

But the iOS, macOS and tvOS problems with the warnings not. I need create a new issue?

@daverodgman
Copy link
Contributor

The conversion warnings are captured in #7813 , so I'm closing this issue. The conversion warnings doesn't seem to be a simple fix, so I recommend disabling -Wshorten-64-to-32 in order to build on the above platforms for now.

Thanks for your help in resolving the ILP32 issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug priority-medium Medium priority - this can be reviewed as time permits size-m Estimated task size: medium (~1w)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants