sci-libs/tensorflow: bazel build fixes
authorJason Zaman <perfinion@gentoo.org>
Sat, 19 May 2018 10:21:51 +0000 (18:21 +0800)
committerJason Zaman <perfinion@gentoo.org>
Sun, 20 May 2018 13:45:52 +0000 (21:45 +0800)
Properly include bazelrc, only one is read so include our generated one
instead.
dont sanitize $HOME otherwise .keras ends up in /var/tmp/portage/ (bug
655368)
patch BUILD file so it doesnt strip the outputs

Closes: https://bugs.gentoo.org/655368
Package-Manager: Portage-2.3.24, Repoman-2.3.6

sci-libs/tensorflow/files/tensorflow-1.8.0-0002-dont-strip.patch [new file with mode: 0644]
sci-libs/tensorflow/tensorflow-1.8.0-r1.ebuild [moved from sci-libs/tensorflow/tensorflow-1.8.0.ebuild with 91% similarity]

diff --git a/sci-libs/tensorflow/files/tensorflow-1.8.0-0002-dont-strip.patch b/sci-libs/tensorflow/files/tensorflow-1.8.0-0002-dont-strip.patch
new file mode 100644 (file)
index 0000000..9f828f3
--- /dev/null
@@ -0,0 +1,29 @@
+diff --git a/tensorflow/BUILD b/tensorflow/BUILD
+index cfafffdd13..8ed22ccfea 100644
+--- a/tensorflow/BUILD
++++ b/tensorflow/BUILD
+@@ -470,7 +470,7 @@ tf_cc_shared_object(
+ # excludes all but a subset of function names.
+ # On MacOS, the linker does not support version_script, but has an
+ # an "-exported_symbols_list" command.  -z defs disallows undefined
+-# symbols in object files and -s strips the output.
++# symbols in object files.
+ tf_cc_shared_object(
+     name = "libtensorflow.so",
+@@ -484,7 +484,6 @@ tf_cc_shared_object(
+         "//tensorflow:windows_msvc": [],
+         "//conditions:default": [
+             "-z defs",
+-            "-s",
+             "-Wl,--version-script",  #  This line must be directly followed by the version_script.lds file
+             "$(location //tensorflow/c:version_script.lds)",
+         ],
+@@ -510,7 +509,6 @@ tf_cc_shared_object(
+         "//tensorflow:windows_msvc": [],
+         "//conditions:default": [
+             "-z defs",
+-            "-s",
+             "-Wl,--version-script",  #  This line must be directly followed by the version_script.lds file
+             "$(location //tensorflow:tf_version_script.lds)",
+         ],
similarity index 91%
rename from sci-libs/tensorflow/tensorflow-1.8.0.ebuild
rename to sci-libs/tensorflow/tensorflow-1.8.0-r1.ebuild
index c12a3e04ae0559c4b745531c8194f34da746fa13..98643e5d2cebd4dcac1ece9237c8f83c16f70a5d 100644 (file)
@@ -3,7 +3,7 @@
 
 EAPI=6
 
-PYTHON_COMPAT=( python3_{5,6} )
+PYTHON_COMPAT=( python2_7 python3_{5,6} )
 MY_PV=${PV/_rc/-rc}
 MY_P=${PN}-${MY_PV}
 
@@ -101,6 +101,7 @@ S="${WORKDIR}/${MY_P}"
 DOCS=( AUTHORS CONTRIBUTING.md ISSUE_TEMPLATE.md README.md RELEASE.md )
 PATCHES=(
        "${FILESDIR}/0001-pip_package-modularize-build-script-to-allow-distros.patch"
+       "${FILESDIR}/tensorflow-1.8.0-0002-dont-strip.patch"
 )
 
 bazel-get-cpu-flags() {
@@ -140,24 +141,32 @@ setup_bazelrc() {
        # https://github.com/bazelbuild/bazel/blob/76555482873ffcf1d32fb40106f89231b37f850a/src/main/tools/linux-sandbox-pid1.cc#L113
        addpredict /proc
 
-       echo "startup --batch" > "${T}/bazelrc" || die
+       mkdir -p "${T}/bazel-cache" || die
+       mkdir -p "${T}/bazel-distdir" || die
+
+       cat > "${T}/bazelrc" <<-EOF
+       startup --batch
+
+       # dont strip HOME, portage sets a temp per-package dir
+       build --action_env HOME
 
-       # make bazel respect $MAKEOPTS
-       echo "build --jobs=$(makeopts_jobs) $(bazel-get-flags)" >> "${T}/bazelrc" || die
-       echo "build --compilation_mode=opt --host_compilation_mode=opt" >> "${T}/bazelrc" || die
+       # make bazel respect MAKEOPTS
+       build --jobs=$(makeopts_jobs) $(bazel-get-flags)
+       build --compilation_mode=opt --host_compilation_mode=opt
 
        # Use standalone strategy to deactivate the bazel sandbox, since it
        # conflicts with FEATURES=sandbox.
-       echo "build --verbose_failures --spawn_strategy=standalone --genrule_strategy=standalone" >> "${T}/bazelrc" || die
-       echo "build --noshow_loading_progress" >> "${T}/bazelrc" || die
-       echo "test --verbose_failures --spawn_strategy=standalone --genrule_strategy=standalone" >> "${T}/bazelrc" || die
-       echo "test --verbose_test_summary --noshow_loading_progress" >> "${T}/bazelrc" || die
+       build --spawn_strategy=standalone --genrule_strategy=standalone
+       test --spawn_strategy=standalone --genrule_strategy=standalone
+
+       build --strip=never
+       build --verbose_failures --noshow_loading_progress
+       test --verbose_test_summary --verbose_failures --noshow_loading_progress
 
        # make bazel only fetch distfiles from the cache
-       mkdir -p "${T}/bazel-cache" || die
-       mkdir -p "${T}/bazel-distdir" || die
-       echo "fetch --repository_cache=${T}/bazel-cache/ --experimental_distdir=${T}/bazel-distdir/" >> "${T}/bazelrc" || die
-       echo "build --repository_cache=${T}/bazel-cache/ --experimental_distdir=${T}/bazel-distdir/" >> "${T}/bazelrc" || die
+       fetch --repository_cache=${T}/bazel-cache/ --experimental_distdir=${T}/bazel-distdir/
+       build --repository_cache=${T}/bazel-cache/ --experimental_distdir=${T}/bazel-distdir/
+       EOF
 }
 
 bazel_multibuild_wrapper() {
@@ -170,8 +179,8 @@ bazel_multibuild_wrapper() {
 ebazel() {
        setup_bazelrc
 
-       echo Running: bazel --bazelrc="${T}/bazelrc" --output_base="${BAZEL_OUTPUT_BASE}" "$@"
-       bazel --bazelrc="${T}/bazelrc" --output_base="${BAZEL_OUTPUT_BASE}" $@ || die
+       echo Running: bazel --output_base="${BAZEL_OUTPUT_BASE}" "$@"
+       bazel --output_base="${BAZEL_OUTPUT_BASE}" $@ || die
 }
 
 load_distfiles() {
@@ -235,6 +244,9 @@ src_configure() {
                export PYTHON_BIN_PATH="${PYTHON}"
                export PYTHON_LIB_PATH="${PYTHON_SITEDIR}"
 
+               # only one bazelrc is read, import our one before configure sets its options
+               echo "import ${T}/bazelrc" >> ./.bazelrc
+
                # this is not autoconf
                ./configure || die
        }