这是indexloc提供的服务,不要输入任何密码
Skip to content

Compiling libjxl with clang and LTO is broken in mingw #4445

@Galaxy4594

Description

@Galaxy4594

I mainly compile libjxl using mingw64, and clang's lto seems to only work with the lld linker. However, sjpeg fails to link properly, meaning djxl, benchmark_xl, and jpegli all fail to compile by default. Only cjxl and jxlinfo can successfully compile.

JPEGXL_ENABLE_LTO works fine with gcc afaik.

A short-term solution would be to disable sjpeg but it would be nice to know why it fails. I've tried compiling sjpeg by itself with clang+lto and it also seems to fail as well, implying the issue is sjpeg's fault and not libjxl's. Is it a build system problem or something deeper?

This is my working LTO build command:
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DJPEGXL_STATIC=ON -DJPEGXL_ENABLE_LTO=ON -DJPEGXL_ENABLE_SJPEG=OFF -DCMAKE_C_FLAGS=-fuse-ld=lld -DCMAKE_CXX_FLAGS=-fuse-ld=lld -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld .. && ninja

Using the command above, enabling sjpeg spits out this error:

ld.lld: error: undefined symbol: std::__once_callable
>>> referenced by C:/msys64/home/user/libjxl/third_party/sjpeg/src/enc.cc
>>>               libsjpeg.a(enc.cc.obj)

OS: Windows, msys2-mingw64
Compiler: Clang 20.1.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions