Skip to contentSkip to conversation

java-bootstrapping: Do not rely on hardcoded paths

PATCH Superseded Erkka Kääriä 2 participants 4 messages Apr 22, 2016 – Apr 28, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 java-bootstrapping: Do not rely on hardcoded paths

Various paths to files are hardcoded in either helper scripts or the resulting binaries (like path to Java class libraries). While this works well when using the files on the build machine, things start breaking down when the sstate gets shared between multiple workers in CI, as the paths between workers can differ.

Instead of using these hardcoded paths, form the paths at runtime and pass them as parameters when required.

---
 ...cacao-1.6.1-do-not-rely-on-absolute-paths.patch | 38 ++++++++++++++++++++++
 recipes-core/cacao/cacao-initial-native_0.98.bb    |  1 +
 recipes-core/cacao/cacao_1.6.1.bb                  | 22 +++----------
 ...cacao-0.9.8-do-not-rely-on-absolute-paths.patch | 31 ++++++++++++++++++
 recipes-core/ecj/ecj-bootstrap-native.bb           |  8 ++++-
 recipes-core/ecj/ecj-initial-native.bb             |  9 ++++-
 6 files changed, 90 insertions(+), 19 deletions(-)
 create mode 100644 recipes-core/cacao/cacao-1.6.1/cacao-1.6.1-do-not-rely-on-absolute-paths.patch
 create mode 100644 recipes-core/cacao/files/cacao-0.9.8-do-not-rely-on-absolute-paths.patch
recipes-core/cacao/cacao-1.6.1/cacao-1.6.1-do-not-rely-on-absolute-paths.patch new file +38 -0
new file mode 100644
index 0000000..11d6bca
@@ -0,0 +1,38 @@
+java.in: Do not use hardcode paths
+
+Cacao uses hardcoded paths to various files, if these paths are not
+provided. This causes issues when sharing sstate with otherwise
+identical workers, if build time paths are not identical.
+
+Signed-off-by: Erkka Kääriä <[email protected]>
+---
+ cacao-1.6.1/src/scripts/java.in | 16 ++++++++++++++--
+ 1 file changed, 14 insertions(+), 2 deletions(-)
+
+diff --git cacao-1.6.1/src/scripts/java.in cacao-1.6.1/src/scripts/java.in
+index 0790f02..2118de7 100644
+--- cacao-1.6.1/src/scripts/java.in
++++ cacao-1.6.1/src/scripts/java.in
+@@ -22,5 +22,17 @@
+ ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ ## 02110-1301, USA.
+
+-IFS=""
+-exec $(dirname ${0})/cacao ${1+"$@"}
++SH_DIR=`dirname "$0"`
++CURRENT_DIR=`cd "${SH_DIR}" && pwd`
++
++# if this shell script is invoked through symlink, we get invalid paths. As getting the real path to this file is
++# very painful using only /bin/sh, python is used instead.
++PYTHON_STR="import os; print os.path.dirname(os.path.realpath(os.readlink(\"${CURRENT_DIR}/java\"))) if os.path.islink(\"${CURRENT_DIR}/java\") else \"${CURRENT_DIR}\""
++REAL_DIR=`python -c "${PYTHON_STR}"`
++
++PARENT_DIR=`dirname ${REAL_DIR}`
++
++export BOOTCLASSPATH="${PARENT_DIR}/share/cacao/vm.zip:${PARENT_DIR}/share/classpath/glibj.zip"
++LIBRARY_PATH="-Djava.library.path=${PARENT_DIR}/lib/classpath"
++exec ${REAL_DIR}/cacao ${LIBRARY_PATH} ${1+"$@"}
++
+--
+2.7.4
+
recipes-core/cacao/cacao-initial-native_0.98.bb +1 -0
index 2a8ced5..caaf53c 100644
@@ -15,6 +15,7 @@ SRC_URI = "\
         file://cacao-0.98-initial.patch \
         file://disable_hw_exceptions.patch \
         file://cacao-0.9.8-initial-fix-gc-undefined-behaviour.patch \
+        file://cacao-0.9.8-do-not-rely-on-absolute-paths.patch \
         "
 
 # libjvm disabled - it would conflict with cacao-native installations
recipes-core/cacao/cacao_1.6.1.bb +5 -17
index 83f216c..d805523 100644
@@ -11,7 +11,10 @@ DEPENDS = "zlib libtool classpath virtual/javac-native bdwgc"
 RPROVIDES_${PN} = "java2-runtime"
 
 SRC_URI = "http://www.complang.tuwien.ac.at/cacaojvm/download/cacao-${PV}/cacao-${PV}.tar.xz \
-           file://system-boehm-gc.patch"
+           file://system-boehm-gc.patch \
+           file://cacao-1.6.1-do-not-rely-on-absolute-paths.patch \
+"
+
 SRC_URI[md5sum] = "2c18478404afd1cffdd15ad1e9d85a57"
 SRC_URI[sha256sum] = "eecc8bd1b528a028f43d9d1d0c06b97855bbf1d40e03826d911ebbc0b6971e12"
 
@@ -23,13 +26,12 @@ REQUIRED_DISTRO_FEATURES_class-native := ""
 EXTRA_OECONF_class-native = "\
     --enable-debug \
     --with-vm-zip=${datadir}/cacao/vm.zip \
-    --disable-libjvm \
-    \
     --with-java-runtime-library-classes=${datadir}/classpath/glibj.zip \
     --with-java-runtime-library-libdir=${libdir_jni}:${libdir} \
     --with-jni_md_h=${includedir}/classpath \
     --with-jni_h=${includedir}/classpath \
     --disable-test-dependency-checks \
+    --disable-libjvm  \
 "
 
 CACHED_CONFIGUREVARS_class-native += "ac_cv_prog_JAVAC=${STAGING_BINDIR_NATIVE}/ecj-initial"
@@ -37,11 +39,9 @@ CACHED_CONFIGUREVARS_class-native += "ac_cv_prog_JAVAC=${STAGING_BINDIR_NATIVE}/
 EXTRA_OECONF = "\
     --with-vm-zip=${datadir}/cacao/vm.zip \
     --disable-libjvm \
-    \
     --with-build-java-runtime-library-classes=${STAGING_DATADIR}/classpath/glibj.zip \
     --with-jni_h=${STAGING_INCDIR}/classpath \
     --with-jni_md_h=${STAGING_INCDIR}/classpath \
-    \
     --with-java-runtime-library-classes=${datadir}/classpath/glibj.zip \
     --with-java-runtime-library-libdir=${libdir_jni}:${libdir} \
     --disable-test-dependency-checks \
@@ -54,21 +54,9 @@ do_configure_prepend () {
     mkdir -p src/mm/boehm-gc/m4
 }
 
-do_install_append () {
-    rm ${D}/${bindir}/java
-}
-
-do_install_append_class-native () {
-    ln -sf cacao ${D}/${bindir}/java
-}
 
 FILES_${PN} = "${bindir}/${PN} ${libdir}/cacao/lib*.so ${libdir}/lib*.so* ${datadir}/${PN}"
 FILES_${PN}-dbg += "${bindir}/.debug ${libdir}/.debug/lib*.so*"
 FILES_${PN}-doc += "${datadir}/gc"
 
-ALTERNATIVE_${PN} = "java"
-ALTERNATIVE_LINK = "${bindir}/java"
-ALTERNATIVE_TARGET = "${bindir}/cacao"
-ALTERNATIVE_PRIORITY = "10"
-
 BBCLASSEXTEND = "native"
recipes-core/cacao/files/cacao-0.9.8-do-not-rely-on-absolute-paths.patch new file +31 -0
new file mode 100644
index 0000000..7780f58
@@ -0,0 +1,31 @@
+java.in: Do not use hardcode paths
+
+Cacao uses hardcoded paths to various files, if these paths are not
+provided. This causes issues when sharing sstate with otherwise
+identical workers, if build time paths are not identical.
+
+Signed-off-by: Erkka Kääriä <[email protected]>
+
+---
+ cacao-0.98/src/scripts/java.in | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git cacao-0.98/src/scripts/java.in cacao-0.98/src/scripts/java.in
+index 8a402e4..1738897 100644
+--- cacao-0.98/src/scripts/java.in
++++ cacao-0.98/src/scripts/java.in
+@@ -32,4 +32,10 @@
+ ##
+ ## $Id: java.in 5659 2006-10-04 10:37:09Z twisti $
+
+-exec cacao ${1+"$@"}
++SH_DIR=`dirname "$0"`
++CURRENT_DIR=`cd "${SH_DIR}" && pwd`
++PARENT_DIR=`dirname ${CURRENT_DIR}`
++export BOOTCLASSPATH="${PARENT_DIR}/share/cacao-initial/vm.zip:${PARENT_DIR}/share/classpath-initial/glibj.zip"
++
++LIBRARY_PATH="-Djava.library.path=${PARENT_DIR}/lib/classpath-initial"
++exec cacao ${LIBRARY_PATH} ${1+"$@"}
++
+--
+2.7.4
recipes-core/ecj/ecj-bootstrap-native.bb +7 -1
index e159c9d..276a8f0 100644
@@ -27,7 +27,13 @@ inherit native
 do_compile() {
   # Create the start script
   echo "#!/bin/sh" > ecj-bootstrap
-  echo "ECJ_JAR=${STAGING_DATADIR}/java/${JAR}" >> ecj-bootstrap
+
+  # get absolute path to parent directory, and use that as base path for the jar
+  echo "SH_DIR=\`dirname "\$0"\`" >> ecj-bootstrap
+  echo "CURRENT_DIR=\`cd "\${SH_DIR}" && pwd\`" >> ecj-bootstrap
+  echo "PARENT_DIR=\`dirname \${CURRENT_DIR}\`" >> ecj-bootstrap
+
+  echo "ECJ_JAR=\${PARENT_DIR}/share/java/${JAR}" >> ecj-bootstrap
   echo "RUNTIME=java" >> ecj-bootstrap
   cat ecj.in >> ecj-bootstrap
 }
recipes-core/ecj/ecj-initial-native.bb +8 -1
index ed334ed..1792390 100644
@@ -21,11 +21,18 @@ JAR = "ecj-bootstrap.jar"
 do_compile() {
   # Create the start script
   echo "#!/bin/sh" > ecj-initial
-  echo "ECJ_JAR=${STAGING_DATADIR}/java/${JAR}" >> ecj-initial
+
+  # get absolute path to parent directory, and use that as base path for the jar
+  echo "SH_DIR=\`dirname "\$0"\`" >> ecj-initial
+  echo "CURRENT_DIR=\`cd "\${SH_DIR}" && pwd\`" >> ecj-initial
+  echo "PARENT_DIR=\`dirname \${CURRENT_DIR}\`" >> ecj-initial
+
+  echo "ECJ_JAR=\${PARENT_DIR}/share/java/${JAR}" >> ecj-initial
   echo "RUNTIME=java-initial" >> ecj-initial
   cat ecj-initial.in >> ecj-initial
 }
 
+
 do_install() {
   install -d ${D}${bindir}
   install -m 755 ${S}/ecj-initial ${D}${bindir}
Signature · 12 lines
2.7.4

---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki 
Business Identity Code: 0357606 - 4 
Domiciled in Helsinki 

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
#1 lore raw

PATCH 2/3 Openjdk-8: Add -Wno-cpp to CFLAGS in certain makefiles

The security flag '-D_FORTIFY_SOURCE' requires at least -O to work, otherwise a warning is given. If CFLAGS additionally contains -Werror, this warning turns into an error. As Openjdk build system intentionally deoptimizes certains files due to potential bad codegen during optimization, build will fail when both '-D_FORTIFY_SOURCE' and '-Werror' are used. As turning the optimizations back on will likely break things, the warning is silenced instead.

---
 recipes-core/openjdk/openjdk-8_72b05.bb            |  1 +
 recipes-core/openjdk/openjre-8_72b05.bb            |  1 +
 ...openjdk8-silence-d_fortify_source-warning.patch | 54 ++++++++++++++++++++++
 3 files changed, 56 insertions(+)
 create mode 100644 recipes-core/openjdk/patches-openjdk-8/openjdk8-silence-d_fortify_source-warning.patch
recipes-core/openjdk/openjdk-8_72b05.bb +1 -0
index feaf227..ebee782 100644
@@ -11,6 +11,7 @@ PATCHES_URI_append = "\
     file://openjdk8-use_builtin_frame_address_0_rather_than_returning_address_of_local_variable.patch;apply=no \
     file://openjdk8-fix-assembler-flag-handling-in-makefile.patch;apply=no \
     file://openjdk8-fix-adlc-flags.patch;apply=no \
+    file://openjdk8-silence-d_fortify_source-warning.patch;apply=no \
 "
 
 do_compile_append() {
recipes-core/openjdk/openjre-8_72b05.bb +1 -0
index 6202498..c7de5c7 100644
@@ -9,6 +9,7 @@ PATCHES_URI_append = "\
     file://openjdk8-fix-shark-build.patch;apply=no \
     file://openjdk8-fix-shark-stdc++11.patch;apply=no \
     file://openjdk8-use_builtin_frame_address_0_rather_than_returning_address_of_local_variable.patch;apply=no \
+    file://openjdk8-silence-d_fortify_source-warning.patch;apply=no \
 "
 
 do_compile_append() {
recipes-core/openjdk/patches-openjdk-8/openjdk8-silence-d_fortify_source-warning.patch new file +54 -0

54 lines not on this page · raw message

Signature · 12 lines
2.7.4

---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki 
Business Identity Code: 0357606 - 4 
Domiciled in Helsinki 

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
#2 lore raw

PATCH 3/3 openjre-8_72b05.bb: Add missing patches

In reply to Erkka Kääriä

Two patches were only applied to openjdk-8. Apply these to jre as well

---
 recipes-core/openjdk/openjre-8_72b05.bb | 2 ++
 1 file changed, 2 insertions(+)
recipes-core/openjdk/openjre-8_72b05.bb +2 -0
index c7de5c7..d65b205 100644
@@ -9,6 +9,8 @@ PATCHES_URI_append = "\
     file://openjdk8-fix-shark-build.patch;apply=no \
     file://openjdk8-fix-shark-stdc++11.patch;apply=no \
     file://openjdk8-use_builtin_frame_address_0_rather_than_returning_address_of_local_variable.patch;apply=no \
+    file://openjdk8-fix-assembler-flag-handling-in-makefile.patch;apply=no \
+    file://openjdk8-fix-adlc-flags.patch;apply=no \
     file://openjdk8-silence-d_fortify_source-warning.patch;apply=no \
 "
 
Signature · 12 lines
2.7.4

---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki 
Business Identity Code: 0357606 - 4 
Domiciled in Helsinki 

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
#3 lore raw
In reply to Erkka Kääriä

Hi Erkka,

Have a couple of comments about this patch-set:

1. Upstream-Status is missing
2. cacao build fails after applying this patch.

Quoted 8 lines · Erkka Kääriä

Various paths to files are hardcoded in either helper scripts or the resulting binaries (like path to Java class libraries). While this works well when using the files on the build machine, things start breaking down when the sstate gets shared between multiple workers in CI, as the paths between workers can differ.

Instead of using these hardcoded paths, form the paths at runtime and pass them as parameters when required.

<snip>

recipes-core/cacao/cacao_1.6.1.bb do_configure_prepend () { · line 63

Quoted 7 lines
recipes-core/cacao/cacao_1.6.1.bb +0 -7
-do_install_append () {
-    rm ${D}/${bindir}/java
-}
-
-do_install_append_class-native () {
-    ln -sf cacao ${D}/${bindir}/java
-}
# bitbake cacao 
...
NOTE: Executing RunQueue Tasks
ERROR: cacao-1.6.1-r0 do_package: QA Issue: cacao: Files/directories were installed but not shipped in any package:
  /usr/bin/java
  Please set FILES such that these items are packaged. Alternatively if they are unneeded, avoid installing them or delete them within do_install.
  cacao: 1 installed and not shipped files. [installed-vs-shipped]
  ERROR: cacao-1.6.1-r0 do_package: Fatal QA errors found, failing task.
  ERROR: cacao-1.6.1-r0 do_package: Function failed: do_package

Please fix it.

Best Regards,
Maxin