test for c++17 w/ c++14 stdlib

Apparently some of our stdlibs are not even quite c++11 compliant.

Bug: skia:9700
Change-Id: I842c2dd2eba55d576aa60b2b3a4734dbace00f6b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259074
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
diff --git a/infra/bots/assets/armhf_sysroot/VERSION b/infra/bots/assets/armhf_sysroot/VERSION
index e440e5c..c793025 100644
--- a/infra/bots/assets/armhf_sysroot/VERSION
+++ b/infra/bots/assets/armhf_sysroot/VERSION
@@ -1 +1 @@
-3
\ No newline at end of file
+7
\ No newline at end of file
diff --git a/infra/bots/assets/armhf_sysroot/create.py b/infra/bots/assets/armhf_sysroot/create.py
index 7be59fb..a0aa736 100755
--- a/infra/bots/assets/armhf_sysroot/create.py
+++ b/infra/bots/assets/armhf_sysroot/create.py
@@ -26,22 +26,21 @@
   raw_input()
   subprocess.check_call([
     "sudo","apt-get","install",
-    "libstdc++-4.8-dev-armhf-cross",
-    "libgcc-4.8-dev-armhf-cross",
+    "libstdc++-6-dev-armhf-cross",
+    "libgcc-6-dev-armhf-cross",
     "binutils-arm-linux-gnueabihf"
   ])
 
 
   shutil.copytree('/usr/arm-linux-gnueabihf', target_dir)
-  shutil.copytree('/usr/lib/gcc-cross/arm-linux-gnueabihf/4.8.4',
-    os.path.join(target_dir, 'gcc-cross'))
-  # copy_tree allows copying into a dir that exists
-  # We need to augment the toolchain with some lib*.so that help ld
-  # do its magic as well as some includes that may be useful.
-  dir_util.copy_tree('/usr/x86_64-linux-gnu/arm-linux-gnueabihf/lib',
-                     os.path.join(target_dir, 'lib'))
-  dir_util.copy_tree('/usr/x86_64-linux-gnu/arm-linux-gnueabihf/include',
-                     os.path.join(target_dir, 'include'))
+  shutil.copytree('/usr/lib/gcc-cross/arm-linux-gnueabihf/6',
+                  os.path.join(target_dir, 'gcc-cross'))
+
+  # Libs needed to link:
+  shutil.copy('/usr/lib/x86_64-linux-gnu/libbfd-2.28-armhf.so',
+              os.path.join(target_dir, 'lib'))
+  shutil.copy('/usr/lib/x86_64-linux-gnu/libopcodes-2.28-armhf.so',
+              os.path.join(target_dir, 'lib'))
 
   # The file paths in libpthread.so and libc.so start off as absolute file
   # paths (e.g. /usr/arm-linux-gnueabihf/lib/libpthread.so.0), which won't
diff --git a/infra/bots/recipe_modules/build/chromebook.py b/infra/bots/recipe_modules/build/chromebook.py
index baa2945..05091cc 100644
--- a/infra/bots/recipe_modules/build/chromebook.py
+++ b/infra/bots/recipe_modules/build/chromebook.py
@@ -31,9 +31,8 @@
       '--sysroot=%s' % sysroot_dir,
       '-I%s' % gl_dir.join('include'),
       '-I%s' % sysroot_dir.join('include'),
-      '-I%s' % sysroot_dir.join('include', 'c++', '4.8.4'),
-      '-I%s' % sysroot_dir.join('include', 'c++', '4.8.4',
-                                'arm-linux-gnueabihf'),
+      '-I%s' % sysroot_dir.join('include', 'c++', '6'),
+      '-I%s' % sysroot_dir.join('include', 'c++', '6', 'arm-linux-gnueabihf'),
       '-DMESA_EGL_NO_X11_HEADERS',
       '-U_GLIBCXX_DEBUG',
     ]
@@ -41,6 +40,7 @@
     extra_ldflags = [
       '--target=armv7a-linux-gnueabihf',
       '--sysroot=%s' % sysroot_dir,
+      '-static-libstdc++', '-static-libgcc',
       # use sysroot's ld which can properly link things.
       '-B%s' % sysroot_dir.join('bin'),
       # helps locate crt*.o
@@ -49,8 +49,6 @@
       '-L%s' % sysroot_dir.join('gcc-cross'),
       '-L%s' % sysroot_dir.join('lib'),
       '-L%s' % gl_dir.join('lib'),
-      # Explicitly do not use lld for cross compiling like this - I observed
-      # failures like "Unrecognized reloc 41" and couldn't find out why.
     ]
   else:
     gl_dir = api.vars.slave_dir.join('chromebook_x86_64_gles')
diff --git a/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-Clang-arm-Release-Chromebook_GLES.json b/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-Clang-arm-Release-Chromebook_GLES.json
index 616961f..d464cb5 100644
--- a/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-Clang-arm-Release-Chromebook_GLES.json
+++ b/infra/bots/recipe_modules/build/examples/full.expected/Build-Debian9-Clang-arm-Release-Chromebook_GLES.json
@@ -37,7 +37,7 @@
       "[START_DIR]/cache/work/skia/bin/gn",
       "gen",
       "[START_DIR]/cache/work/skia/out/Build-Debian9-Clang-arm-Release-Chromebook_GLES/Release",
-      "--args=cc=\"[START_DIR]/clang_linux/bin/clang\" cxx=\"[START_DIR]/clang_linux/bin/clang++\" extra_asmflags=[\"--target=armv7a-linux-gnueabihf\", \"--sysroot=[START_DIR]/armhf_sysroot\", \"-march=armv7-a\", \"-mfpu=neon\", \"-mthumb\"] extra_cflags=[\"--target=armv7a-linux-gnueabihf\", \"--sysroot=[START_DIR]/armhf_sysroot\", \"-I[START_DIR]/chromebook_arm_gles/include\", \"-I[START_DIR]/armhf_sysroot/include\", \"-I[START_DIR]/armhf_sysroot/include/c++/4.8.4\", \"-I[START_DIR]/armhf_sysroot/include/c++/4.8.4/arm-linux-gnueabihf\", \"-DMESA_EGL_NO_X11_HEADERS\", \"-U_GLIBCXX_DEBUG\", \"-DDUMMY_clang_linux_version=42\"] extra_ldflags=[\"--target=armv7a-linux-gnueabihf\", \"--sysroot=[START_DIR]/armhf_sysroot\", \"-B[START_DIR]/armhf_sysroot/bin\", \"-B[START_DIR]/armhf_sysroot/gcc-cross\", \"-L[START_DIR]/armhf_sysroot/gcc-cross\", \"-L[START_DIR]/armhf_sysroot/lib\", \"-L[START_DIR]/chromebook_arm_gles/lib\"] is_debug=false skia_use_egl=true skia_use_fontconfig=false skia_use_system_freetype2=false target_cpu=\"arm\" werror=true"
+      "--args=cc=\"[START_DIR]/clang_linux/bin/clang\" cxx=\"[START_DIR]/clang_linux/bin/clang++\" extra_asmflags=[\"--target=armv7a-linux-gnueabihf\", \"--sysroot=[START_DIR]/armhf_sysroot\", \"-march=armv7-a\", \"-mfpu=neon\", \"-mthumb\"] extra_cflags=[\"--target=armv7a-linux-gnueabihf\", \"--sysroot=[START_DIR]/armhf_sysroot\", \"-I[START_DIR]/chromebook_arm_gles/include\", \"-I[START_DIR]/armhf_sysroot/include\", \"-I[START_DIR]/armhf_sysroot/include/c++/6\", \"-I[START_DIR]/armhf_sysroot/include/c++/6/arm-linux-gnueabihf\", \"-DMESA_EGL_NO_X11_HEADERS\", \"-U_GLIBCXX_DEBUG\", \"-DDUMMY_clang_linux_version=42\"] extra_ldflags=[\"--target=armv7a-linux-gnueabihf\", \"--sysroot=[START_DIR]/armhf_sysroot\", \"-static-libstdc++\", \"-static-libgcc\", \"-B[START_DIR]/armhf_sysroot/bin\", \"-B[START_DIR]/armhf_sysroot/gcc-cross\", \"-L[START_DIR]/armhf_sysroot/gcc-cross\", \"-L[START_DIR]/armhf_sysroot/lib\", \"-L[START_DIR]/chromebook_arm_gles/lib\"] is_debug=false skia_use_egl=true skia_use_fontconfig=false skia_use_system_freetype2=false target_cpu=\"arm\" werror=true"
     ],
     "cwd": "[START_DIR]/cache/work/skia",
     "env": {
diff --git a/infra/bots/tasks.json b/infra/bots/tasks.json
index 5c69bfa..15ff748 100755
--- a/infra/bots/tasks.json
+++ b/infra/bots/tasks.json
@@ -4031,7 +4031,7 @@
         {
           "name": "skia/bots/armhf_sysroot",
           "path": "armhf_sysroot",
-          "version": "version:3"
+          "version": "version:7"
         },
         {
           "name": "skia/bots/chromebook_arm_gles",
@@ -4529,7 +4529,7 @@
         {
           "name": "skia/bots/armhf_sysroot",
           "path": "armhf_sysroot",
-          "version": "version:3"
+          "version": "version:7"
         },
         {
           "name": "skia/bots/chromebook_arm_gles",
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 9dd0f16..26a30d1 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -54,8 +54,9 @@
 #define RETURN_ON_NULL(ptr)     do { if (nullptr == (ptr)) return; } while (0)
 #define RETURN_ON_FALSE(pred)   do { if (!(pred)) return; } while (0)
 
-// This is a test: static_assert with no message is a c++17 feature.
-static_assert(true);
+// This is a test: static_assert with no message is a c++17 feature,
+// and std::max() is constexpr only since the c++14 stdlib.
+static_assert(std::max(3,4) == 4);
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////