Issue 607 in webp: libwebp fails to build with clang/LLVM for Windows

256 views
Skip to first unread message

clwal… via monorail

unread,
Apr 24, 2023, 11:38:31 PM4/24/23
to webp-d...@webmproject.org
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 607 by clwal...@gmail.com: libwebp fails to build with clang/LLVM for Windows
https://bugs.chromium.org/p/webp/issues/detail?id=607

When trying to compile libwebp with clang/LLVM for Windows 15.0.1, it fails to build.

The issue is that the CPUID detection logic in dsp\dsp.c doesn't build correctly for this scenario and you get a link failure with a duplicate symbol for VP8GetCPUInfo.

Even if it built correctly, however, the detection wouldn't be right. For clang/LLVM for Windows, the intrinsic you want to use is in cpuid.h and has a slightly different syntax than the intrin.h one that's MSVC specific.


#if defined(__clang__) || defined(__GNUC__)
#include <cpuid.h>
#include <x86intrin.h>

// Replace the MSVC syntax __cpuid(info, fn) with __cpuid(fn, info[0], info[1], info[2], info[3])

// Replace the MSVC syntax __cpuidex(info, fn, sfn) with __cpuid_count(fn, sfn, info[0], info[1], info[2], info[3])

--
You received this message because:
1. The project was configured to send all issue notifications to this address

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

jz… via monorail

unread,
Apr 25, 2023, 9:19:32 PM4/25/23
to webp-d...@webmproject.org
Updates:
Owner: jz...@google.com
Status: Accepted

Comment #1 on issue 607 by jz...@google.com: libwebp fails to build with clang/LLVM for Windows
https://bugs.chromium.org/p/webp/issues/detail?id=607#c1

Thanks for the report. I've been looking at Arm64 and clang-cl recently and those built from what I remember. I can give x86 a try, though Chrome builds without issue and I have an older version of Visual Studio using clang-cl running nightly. Is this Visual Studio 2022? How did you configure the project?

jz… via monorail

unread,
Apr 25, 2023, 10:06:45 PM4/25/23
to webp-d...@webmproject.org

Comment #2 on issue 607 by jz...@google.com: libwebp fails to build with clang/LLVM for Windows
https://bugs.chromium.org/p/webp/issues/detail?id=607#c2

At v1.3.0-34-g4070b271a, I can reproduce the link failure with cmake -DBUILD_SHARED_LIBS=1 and in a quickly tweaked version of Makefile.vc. I'll take a closer look.

Git Watcher via monorail

unread,
Apr 27, 2023, 4:43:20 PM4/27/23
to webp-d...@webmproject.org

Comment #3 on issue 607 by Git Watcher: libwebp fails to build with clang/LLVM for Windows
https://bugs.chromium.org/p/webp/issues/detail?id=607#c3

The following revision refers to this bug:
https://chromium.googlesource.com/webm/libwebp/+/8151f388ebb1c48990598418f84b81955ddc5895

commit 8151f388ebb1c48990598418f84b81955ddc5895
Author: James Zern <jz...@google.com>
Date: Wed Apr 26 20:22:52 2023

move VP8GetCPUInfo declaration to cpu.c

This avoids defining a version in each translation unit when using
__declspec(dllexport) which causes failures due to multiply defined
symbols with clang-cl:

lld-link: error: duplicate symbol: VP8GetCPUInfo
>>> defined at CMakeFiles\webpdecode.dir\Debug\src\dec\alpha_dec.c.obj
>>> defined at CMakeFiles\webpdsp.dir\Debug\src\dsp\dec_sse41.c.obj
...

Bug: webp:607
Change-Id: I6cd1ee75b3db984aa513263a05516e867a64925d

[modify] https://crrev.com/8151f388ebb1c48990598418f84b81955ddc5895/src/dsp/enc.c
[modify] https://crrev.com/8151f388ebb1c48990598418f84b81955ddc5895/src/dsp/yuv.c
[modify] https://crrev.com/8151f388ebb1c48990598418f84b81955ddc5895/src/dsp/filters.c
[modify] https://crrev.com/8151f388ebb1c48990598418f84b81955ddc5895/sharpyuv/sharpyuv_dsp.c
[modify] https://crrev.com/8151f388ebb1c48990598418f84b81955ddc5895/src/dsp/upsampling.c
[modify] https://crrev.com/8151f388ebb1c48990598418f84b81955ddc5895/src/dsp/alpha_processing.c
[modify] https://crrev.com/8151f388ebb1c48990598418f84b81955ddc5895/src/dsp/lossless_enc.c
[modify] https://crrev.com/8151f388ebb1c48990598418f84b81955ddc5895/sharpyuv/sharpyuv.c
[modify] https://crrev.com/8151f388ebb1c48990598418f84b81955ddc5895/src/enc/picture_csp_enc.c
[modify] https://crrev.com/8151f388ebb1c48990598418f84b81955ddc5895/src/dsp/lossless.c
[modify] https://crrev.com/8151f388ebb1c48990598418f84b81955ddc5895/src/dsp/cpu.h
[modify] https://crrev.com/8151f388ebb1c48990598418f84b81955ddc5895/src/dsp/ssim.c
[modify] https://crrev.com/8151f388ebb1c48990598418f84b81955ddc5895/tests/fuzzer/fuzz_utils.h
[modify] https://crrev.com/8151f388ebb1c48990598418f84b81955ddc5895/src/dsp/rescaler.c
[modify] https://crrev.com/8151f388ebb1c48990598418f84b81955ddc5895/src/dsp/cpu.c
[modify] https://crrev.com/8151f388ebb1c48990598418f84b81955ddc5895/src/dsp/cost.c
[modify] https://crrev.com/8151f388ebb1c48990598418f84b81955ddc5895/src/dsp/dec.c
[modify] https://crrev.com/8151f388ebb1c48990598418f84b81955ddc5895/src/dec/vp8_dec.c

jz… via monorail

unread,
Apr 27, 2023, 7:21:57 PM4/27/23
to webp-d...@webmproject.org
Updates:
Labels: v1.3.1
Status: Fixed

Comment #4 on issue 607 by jz...@google.com: libwebp fails to build with clang/LLVM for Windows
https://bugs.chromium.org/p/webp/issues/detail?id=607#c4

With the change in comment #3 the library builds successfully with clang-cl and -DBUILD_SHARED_LIBS=1. As for the cpuid comment, the current detection is working from what I can tell. If you have an example of a difference between the two please file another issue. For now I don't think there's a need to change that code path.
Reply all
Reply to author
Forward
0 new messages