ARM-software / armnn

Arm NN ML Software. The code here is a read-only mirror of https://review.mlplatform.org/admin/repos/ml/armnn
https://developer.arm.com/products/processors/machine-learning/arm-nn
MIT License
1.17k stars 309 forks source link

Build-tool failure due to unaddressed -Werror=conversion #778

Closed robertbcalhoun closed 1 month ago

robertbcalhoun commented 3 months ago

Builds using Arm NN Build Tool fail as of 1f3eb73c6c4f03181f657650bde3ff2b9e6bfae8 due to unaddressed gcc warnings and use of -Werror flag.

Build environments:

Commands tested:

The warnings are mostly in test execution code and are not indicative of real problems. Example:

330.8 /home/arm-user/source/armnn/tests/ExecuteNetwork/ArmNNExecutor.cpp:293:37: error: conversion from ‘size_t’ {aka ‘long unsigned int’} to ‘unsigned int’ may change value [-Werror=conversion]
330.8   293 |             PrintOutputTensors(out, iteration);
330.8       |                                     ^~~~~~~~~

Workaround:

disable error=conversion e.g.

diff --git a/build-tool/scripts/build-armnn.sh b/build-tool/scripts/build-armnn.sh
index b399a5aa6..da6a86034 100755
--- a/build-tool/scripts/build-armnn.sh
+++ b/build-tool/scripts/build-armnn.sh
@@ -138,6 +138,8 @@ build_armnn()
       if [ "$os_darwin" -eq 1 ]; then
         linker_cmake_args="-DCMAKE_SHARED_LINKER_FLAGS='-framework CoreFoundation -framework Foundation'"
         warn_flags="-DCMAKE_CXX_FLAGS='-Wno-error=deprecated-declarations'"
+      else
+        warn_flags="-DCMAKE_CXX_FLAGS='-Wno-error=conversion'"
       fi
       ;;
     "android64")

Truncated error log attached.

build-tool-fail-Werror.txt

Colm-in-Arm commented 2 months ago

Thank you Robert.

We have not tested the build-tool on Ubuntu 22.04. Can you confirm that it was the default gcc compiler version, 11.2.0-1 please.

Colm.

robertbcalhoun commented 2 months ago

I'm using Ubuntu 22.04 to run docker, not compile the software. The software is compiled inside the container, using the cross-compiler specified by your docker container in install-packaages.sh:

# Install cross compile toolchains if host is x86_64
  if [ "$HOST_ARCH" == "x86_64" ]; then
    apt-get update && apt-get install -y --no-install-recommends  \
        crossbuild-essential-arm64
  fi

As of today, the version of gcc used to cross-compile armnn inside the container is:

arm-user@dd63b47dc028:~$ /usr/bin/aarch64-linux-gnu-g++ --version
aarch64-linux-gnu-g++ (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Adding explicit casts to tests/ExecuteNetwork/ArmNNExecutor.cpp fixes the warnings. After that I could build the software successfully. I'll make a pull request.

-Rob

Colm-in-Arm commented 2 months ago

Hello Robert,

Would you mind creating a patch on mlplatform.org rather than the pull request please. If you'd rather not I can create it for you with your permission.

Colm.

Colm-in-Arm commented 1 month ago

This has since been fixed by: https://review.mlplatform.org/c/ml/armnn/+/12251