io icon indicating copy to clipboard operation
io copied to clipboard

libwebp fails to build with gcc 10

Open hrw opened this issue 2 years ago • 6 comments

/usr/bin/ld.gold: error: bazel-out/aarch64-fastbuild/bin/external/libwebp/_objs/libwebp/rescaler_utils.pic.o: multiple definition of 'VP8GetCPUInfo' 
/usr/bin/ld.gold: bazel-out/aarch64-fastbuild/bin/external/libwebp/_objs/libwebp/webp_dec.pic.o: previous definition here
/usr/bin/ld.gold: error: bazel-out/aarch64-fastbuild/bin/external/libwebp/_objs/libwebp/buffer_dec.pic.o: multiple definition of 'VP8GetCPUInfo'          
/usr/bin/ld.gold: bazel-out/aarch64-fastbuild/bin/external/libwebp/_objs/libwebp/webp_dec.pic.o: previous definition here
/usr/bin/ld.gold: error: bazel-out/aarch64-fastbuild/bin/external/libwebp/_objs/libwebp/frame_dec.pic.o: multiple definition of 'VP8GetCPUInfo'    
/usr/bin/ld.gold: bazel-out/aarch64-fastbuild/bin/external/libwebp/_objs/libwebp/webp_dec.pic.o: previous definition here
/usr/bin/ld.gold: error: bazel-out/aarch64-fastbuild/bin/external/libwebp/_objs/libwebp/utils.pic.o: multiple definition of 'VP8GetCPUInfo'           
/usr/bin/ld.gold: bazel-out/aarch64-fastbuild/bin/external/libwebp/_objs/libwebp/webp_dec.pic.o: previous definition here

There are more of them.

hrw avatar Aug 25 '21 16:08 hrw

This is not architecture issue but GCC 10 which defaults to "-fno-common".

This workarounds it but it should be done some better way:

diff --git a/third_party/libwebp.BUILD b/third_party/libwebp.BUILD
index 4dea61e3..380a11e5 100644
--- a/third_party/libwebp.BUILD
+++ b/third_party/libwebp.BUILD
@@ -28,6 +28,9 @@ cc_library(
         "imageio/imageio_util.h",
         "examples/unicode.h",
     ],
+    copts = [
+        "-fcommon",
+    ],
     defines = [
         "WEBP_EXTERN=",
     ],

hrw avatar Aug 30 '21 10:08 hrw

Some background: https://github.com/intel/intel-hybrid-driver/issues/27

hrw avatar Aug 30 '21 10:08 hrw

Or (after coffee):

diff --git a/third_party/libwebp.BUILD b/third_party/libwebp.BUILD
index 4dea61e3..7fbd86bd 100644
--- a/third_party/libwebp.BUILD
+++ b/third_party/libwebp.BUILD
@@ -28,9 +28,6 @@ cc_library(
         "imageio/imageio_util.h",
         "examples/unicode.h",
     ],
-    defines = [
-        "WEBP_EXTERN=",
-    ],
     includes = [
         "src",
     ],

hrw avatar Aug 30 '21 10:08 hrw

@hrw, @cfRod

Some hits that may be found useful for you too:

  • Build fully pass on aarch64 & x86_64 using public copr infra , log details can be consulted
  • Unsure about WEBP/GCS-FS issue, you can look into .spec script for this particular flow on aarch64/x86_64.
  • Uses TF_SYSTEM_LIBS letting tf/bazel to pick up external libs&tools (solve many problems with hermetism).
  • It also include generation of tflite, tflite_c for edge capabilities within tensorflow.

cbalint13 avatar Sep 04 '21 10:09 cbalint13

Hi @cbalint13, I can't view either links unfortunately.

cfRod avatar Sep 06 '21 08:09 cfRod

Hi @cbalint13, I can't view either links unfortunately.

@cfRod Updated the previous comment, replaced URL hints with more permanent links to git tracker.

As remark:

  • webp is "dragged" in by libjpeg (if I recall properly), having TF_SYSTEM_LIBS you will just use system/distro's one.
  • there is always a lib that may potentially fail in the hermetism of bazel, TF_SYSTEM_LIBS may be useful to avoid these.

cbalint13 avatar Sep 06 '21 08:09 cbalint13