Skip to contentSkip to conversation

openjdk-8-common: Fix warning evaluating CFLAGS

PATCH In review Ricardo Ribalda Delgado 1 participant 2 messages Sep 7, 2017 – Sep 26, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 openjdk-8-common: Fix warning evaluating CFLAGS

Code is (on my opinion) simpler, making use of the dumpversion flag, instead of calling the pre-processor via a pipe.

Flag has been tested on both clang gcc:

ricardo@neopili:~/curro/qt5022/build-qt5022-pyro/repo/java$ gcc-4.8 -dumpversion
4.8
ricardo@neopili:~/curro/qt5022/build-qt5022-pyro/repo/java$ gcc-4.9 -dumpversion
4.9.3
ricardo@neopili:~/curro/qt5022/build-qt5022-pyro/repo/java$ gcc-5 -dumpversion
5.4.1
ricardo@neopili:~/curro/qt5022/build-qt5022-pyro/repo/java$ gcc-6 -dumpversion
6.4.0
ricardo@neopili:~/curro/qt5022/build-qt5022-pyro/repo/java$ gcc-7 -dumpversion
7
ricardo@neopili:~/curro/qt5022/build-qt5022-pyro/repo/java$ clang-4.0 -dumpversion
4.2.1

Without this patch:

WARNING:
/home/ricardo/curro/qt5022/build-qt5022-pyro/repo/yocto/../java/recipes-core/openjdk/openjdk-8-native_102b14.bb:
Unable to export ${CXXFLAGS}: Failure expanding variable CXXFLAGS,
expression was -isystem/home/ricardo/curro/qt5022/build-qt5022-pyro/build/tmp/work/x86_64-linux/openjdk-8-native/102b14-r0/recipe-sysroot-native/usr/include -O2 -pipe -D_GLIBCXX_USE_CXX11_ABI=0 ${@version_specific_cflags(d)}
${@jdk_cpp_options(d)} which triggered exception IndexError: string
index out of range
WARNING:
/home/ricardo/curro/qt5022/build-qt5022-pyro/repo/yocto/../java/recipes-core/openjdk/openjdk-8-native_102b14.bb:
Unable to export ${CFLAGS}: Failure expanding variable CFLAGS,
expression was -isystem/home/ricardo/curro/qt5022/build-qt5022-pyro/build/tmp/work/x86_64-linux/openjdk-8-native/102b14-r0/recipe-sysroot-native/usr/include -O2 -pipe -Wno-error=deprecated-declarations
${@version_specific_cflags(d)} ${@jdk_cpp_options(d)} which triggered
exception IndexError: string index out of range

---
 recipes-core/openjdk/openjdk-8-common.inc | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
recipes-core/openjdk/openjdk-8-common.inc +3 -7
index 0c5c2c3e3d2f..83828e156fb6 100644
@@ -238,13 +238,9 @@ def version_specific_cflags(d):
     if bb.data.inherits_class('native', d):
         from subprocess import Popen, PIPE
 
-        cmd = d.expand('${CPP} -P -').split()
-        cc = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
-        # This check is GCC specific. Clang always returns 4. For Clang
-        # __clang_major__ and __clang_minor__ need to be checked. Ideally
-        # __GNUC_MINOR__ would be checked as well, but for this recipe
-        # GCC major is all we care about.
-        version = cc.communicate(b'__GNUC__')[0].decode('utf-8')[0]
+        cmd = d.expand('${CC} -dumpversion').split()
+        cc = Popen(cmd, stdout=PIPE, stderr=PIPE)
+        version = cc.communicate()[0].decode('utf-8')[0]
     else:
         # in the cross case, trust that GCCVERSION is correct. This won't
         # work if the native toolchain is Clang, but as of this writing that
Signature · 1 line
2.14.1
#1 lore raw

Ping?

Quoted 65 lines · Ricardo Ribalda Delgado

Code is (on my opinion) simpler, making use of the dumpversion flag, instead of calling the pre-processor via a pipe.

Flag has been tested on both clang gcc:

ricardo@neopili:~/curro/qt5022/build-qt5022-pyro/repo/java$ gcc-4.8 -dumpversion
4.8
ricardo@neopili:~/curro/qt5022/build-qt5022-pyro/repo/java$ gcc-4.9 -dumpversion
4.9.3
ricardo@neopili:~/curro/qt5022/build-qt5022-pyro/repo/java$ gcc-5 -dumpversion
5.4.1
ricardo@neopili:~/curro/qt5022/build-qt5022-pyro/repo/java$ gcc-6 -dumpversion
6.4.0
ricardo@neopili:~/curro/qt5022/build-qt5022-pyro/repo/java$ gcc-7 -dumpversion
7
ricardo@neopili:~/curro/qt5022/build-qt5022-pyro/repo/java$ clang-4.0 -dumpversion
4.2.1

Without this patch:

WARNING:
/home/ricardo/curro/qt5022/build-qt5022-pyro/repo/yocto/../java/recipes-core/openjdk/openjdk-8-native_102b14.bb:
Unable to export ${CXXFLAGS}: Failure expanding variable CXXFLAGS,
expression was -isystem/home/ricardo/curro/qt5022/build-qt5022-pyro/build/tmp/work/x86_64-linux/openjdk-8-native/102b14-r0/recipe-sysroot-native/usr/include -O2 -pipe -D_GLIBCXX_USE_CXX11_ABI=0 ${@version_specific_cflags(d)}
${@jdk_cpp_options(d)} which triggered exception IndexError: string
index out of range
WARNING:
/home/ricardo/curro/qt5022/build-qt5022-pyro/repo/yocto/../java/recipes-core/openjdk/openjdk-8-native_102b14.bb:
Unable to export ${CFLAGS}: Failure expanding variable CFLAGS,
expression was -isystem/home/ricardo/curro/qt5022/build-qt5022-pyro/build/tmp/work/x86_64-linux/openjdk-8-native/102b14-r0/recipe-sysroot-native/usr/include -O2 -pipe -Wno-error=deprecated-declarations
${@version_specific_cflags(d)} ${@jdk_cpp_options(d)} which triggered
exception IndexError: string index out of range

---
 recipes-core/openjdk/openjdk-8-common.inc | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
recipes-core/openjdk/openjdk-8-common.inc +3 -8
index 0c5c2c3e3d2f..83828e156fb6 100644
@@ -238,13 +238,9 @@ def version_specific_cflags(d):
     if bb.data.inherits_class('native', d):
         from subprocess import Popen, PIPE
 
-        cmd = d.expand('${CPP} -P -').split()
-        cc = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
-        # This check is GCC specific. Clang always returns 4. For Clang
-        # __clang_major__ and __clang_minor__ need to be checked. Ideally
-        # __GNUC_MINOR__ would be checked as well, but for this recipe
-        # GCC major is all we care about.
-        version = cc.communicate(b'__GNUC__')[0].decode('utf-8')[0]
+        cmd = d.expand('${CC} -dumpversion').split()
+        cc = Popen(cmd, stdout=PIPE, stderr=PIPE)
+        version = cc.communicate()[0].decode('utf-8')[0]
     else:
         # in the cross case, trust that GCCVERSION is correct. This won't
         # work if the native toolchain is Clang, but as of this writing that
--

2.14.1

Signature · 1 line
Ricardo Ribalda