Compiler warning about potential signed overflow being treated as an error

40 views
Skip to first unread message

Jacob Bundgaard

unread,
May 29, 2016, 6:34:51 PM5/29/16
to Dartino Discuss
I'm trying to figure out what the minimum requirements are to build the Dartino SDK for the STM Discovery board, but I get a compiler warning aborting the build when building on a clean Ubuntu VM. I've posted my setup procedure at the bottom.

For AMD64 and IA32 builds, I get a warning from GCC about a potential signed overflow, which, due to the -Werror option, is treated like an error and aborts the build. See below for the complete error message.

I can build just fine by disabling treatment of the warning as an error with the -Wno-error=strict-overflow argument in out/Release??/obj/src/double_conversion.ninja and the same file in out/Release??/obj.host/src/



ninja: Entering directory `out/ReleaseX64'
[88/347] CXX obj/third_party/double-conversion/src/double_conversion.bignum.o
FAILED: obj/third_party/double-conversion/src/double_conversion.bignum.o
../../tools/cxx_wrapper.py -MMD -MF obj/third_party/double-conversion/src/double_conversion.bignum.o.d -DDARTINO_ENABLE_LIVE_CODING -DDARTINO_ENABLE_DEBUGGING -DDARTINO_ENABLE_FFI -DDARTINO_ENABLE_NATIVE_PROCESSES -DDARTINO_ENABLE_PRINT_INTERCEPTORS -DDARTINO_TARGET_OS_LINUX -DDARTINO_TARGET_OS_POSIX -DNDEBUG -DDARTINO64 -DDARTINO_TARGET_X64 -I../../.. -O3 -fomit-frame-pointer -fno-strict-aliasing -fPIC -Wall -Wextra -Wno-unused-parameter -Wno-format -Wno-comment -Wno-non-virtual-dtor -Werror -std=c++11 -fdata-sections -ffunction-sections -fvisibility=hidden -Wno-invalid-offsetof -fno-rtti -fno-exceptions  -c ../../third_party/double-conversion/src/bignum.cc -o obj/third_party/double-conversion/src/double_conversion.bignum.o
../../third_party/double-conversion/src/bignum.cc: In member function ‘void double_conversion::Bignum::AssignDecimalString(double_conversion::Vector<const char>)’:
../../third_party/double-conversion/src/bignum.cc:102:6: error: assuming signed overflow does not occur when assuming that (X + c) < X is always false [-Werror=strict-overflow]
 void Bignum::AssignDecimalString(Vector<const char> value) {
      ^
cc1plus: all warnings being treated as errors
[89/347] CXX obj.host/third_party/doub...version/src/double_conversion.bignum.o
FAILED: obj.host/third_party/double-conversion/src/double_conversion.bignum.o
../../tools/cxx_wrapper.py -MMD -MF obj.host/third_party/double-conversion/src/double_conversion.bignum.o.d -DDARTINO_ENABLE_LIVE_CODING -DDARTINO_ENABLE_DEBUGGING -DDARTINO_ENABLE_FFI -DDARTINO_ENABLE_NATIVE_PROCESSES -DDARTINO_ENABLE_PRINT_INTERCEPTORS -DDARTINO_TARGET_OS_LINUX -DDARTINO_TARGET_OS_POSIX -DNDEBUG -DDARTINO64 -DDARTINO_TARGET_X64 -I../../.. -O3 -fomit-frame-pointer -fno-strict-aliasing -fPIC -Wall -Wextra -Wno-unused-parameter -Wno-format -Wno-comment -Wno-non-virtual-dtor -Werror -std=c++11 -fdata-sections -ffunction-sections -fvisibility=hidden -Wno-invalid-offsetof -fno-rtti -fno-exceptions  -c ../../third_party/double-conversion/src/bignum.cc -o obj.host/third_party/double-conversion/src/double_conversion.bignum.o
../../third_party/double-conversion/src/bignum.cc: In member function ‘void double_conversion::Bignum::AssignDecimalString(double_conversion::Vector<const char>)’:
../../third_party/double-conversion/src/bignum.cc:102:6: error: assuming signed overflow does not occur when assuming that (X + c) < X is always false [-Werror=strict-overflow]
 void Bignum::AssignDecimalString(Vector<const char> value) {
      ^
cc1plus: all warnings being treated as errors
ninja: build stopped: subcommand failed.



Steps to setup a Dartino SDK development environment for the STM Discovery:

  • Spin up a new virtual machine
  • Install Ubuntu 16.04 Desktop (64-bit)
  • Install Git
    • sudo apt install git
  • Install depot_tools and add it to the PATH
  • Get the Dartino source
    • mkdir dartino-repo
    • cd dartino-repo
    • fetch dartino
    • cd sdk
  • Install g++-multilib to allow 32-bit compiling on a 64-bit architecture
    • sudo apt install g++-multilib
  • Build Dartino host and client binaries
    •  + ../../depot_tools/ninja -C out/ReleaseX64
    •  + ../../depot_tools/ninja -C out/ReleaseIA32
    •  + ../../depot_tools/ninja -C out/ReleaseSTM

P.S. g++-multilib should be added as a prerequisite at the Building wiki page.

Rico Wind

unread,
May 30, 2016, 2:50:29 AM5/30/16
to Jacob Bundgaard, Florian Loitsch, Dartino Discuss
+floitsch
This is probably because your GCC is more recent than what the dartino team is on (we are on Trusty). 
Florian can speak to if this is relevant or not, but for now something like this should work in the gyp files:
diff --git a/src/double_conversion.gyp b/src/double_conversion.gyp
index e24b942..3c52fa6 100644
--- a/src/double_conversion.gyp
+++ b/src/double_conversion.gyp
@@ -17,6 +17,13 @@
           'standalone_static_library': 1,
       }]],
       'toolsets': ['target', 'host'],
+      'conditions': [
+        ['OS=="linux"', {
+          'cflags': [
+            '-Wno-strict-overflow',
+          ],
+        }],
+      ],
       'sources': [
         '../third_party/double-conversion/src/bignum-dtoa.cc',
         '../third_party/double-conversion/src/bignum-dtoa.h',

Cheers,
Rico

--
You received this message because you are subscribed to the Google Groups "Dartino Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dartino-discu...@googlegroups.com.
To post to this group, send email to dartino...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dartino-discuss/a10b1b6e-00aa-45f4-8673-52879e167cd0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rico Wind

unread,
May 30, 2016, 2:56:07 AM5/30/16
to Jacob Bundgaard, Florian Loitsch, Dartino Discuss

Søren Gjesse

unread,
May 30, 2016, 3:00:38 AM5/30/16
to Rico Wind, Jacob Bundgaard, Florian Loitsch, Dartino Discuss
Thanks for looking into this Rico. I will roll the dependency.

Regards,
Søren

---
Søren Gjesse
Software Engineer, Google Denmark
CVR nr. 28 86 69 84


Søren Gjesse

unread,
May 30, 2016, 3:32:42 AM5/30/16
to Rico Wind, Jacob Bundgaard, Florian Loitsch, Dartino Discuss
Jacob, can you tell me what GCC version you are using? Last week I rolled the toolchain we use for cross-compiling to GCC 5.3.1, and that did not trigger this warning (https://github.com/dartino/sdk/commit/d60513dc8dd08c1ad69f685989d66afb30b33995).

I have a roll of third_party/double_conversion in https://codereview.chromium.org/2019983002/.

Regards,
Søren

Jacob Bundgaard

unread,
May 30, 2016, 4:21:52 AM5/30/16
to Dartino Discuss
Thanks for the quick response.

I'm using the gcc that's included with the Ubuntu 16.04 (Xenial) image and is the latest in the Ubuntu repo: gcc (Ubuntu 5.3.1-14ubuntu2) 5.3.1 20160413

The upstream patch fixes the problem.
Reply all
Reply to author
Forward
0 new messages