Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile third_party/ktx/lib/basisu/zstd/zstd.c failed when -Og is passed #1089

Open
sandy-lcq opened this issue Jul 8, 2024 · 3 comments
Open

Comments

@sandy-lcq
Copy link
Contributor

sandy-lcq commented Jul 8, 2024

Hi,

I am compiling Vulkan Sample with yocto project, and found that when -Og is passed to the compile command, the build will failed with following error, without -Og, it can build success.
Error:
In function 'ZSTD_compressBlock_lazy_generic',
inlined from 'ZSTD_compressBlock_lazy2' at /mnt/lts24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/git/third_party/ktx/lib/basisu/zstd/zstd.c:21900:12:
/mnt/lts24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/git/third_party/ktx/lib/basisu/zstd/zstd.c:21551:30: error: inlining failed in call to 'always_inline' 'ZSTD_HcFindBestMatch_selectMLS': function not considered for inlining
21551 | FORCE_INLINE_TEMPLATE size_t ZSTD_HcFindBestMatch_selectMLS (
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/lts24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/git/third_party/ktx/lib/basisu/zstd/zstd.c:21736:32: note: called from here
21736 | size_t const ml2 = searchMax(ms, ip, iend, &offsetFound);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
....

The whole compile command :
/mnt/lts24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/recipe-sysroot-native/usr/bin/x86_64-wrs-linux/x86_64-wrs-linux-gcc --sysroot=/mnt/lts24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/recipe-sysroot -DBASISD_SUPPORT_KTX2_ZSTD=0 -DBASISU_NO_ITERATOR_DEBUG_LEVEL -DKTX_FEATURE_WRITE=0 -DLIBKTX -DROOT_PATH_SIZE=35 -DVK_NO_PROTOTYPES -DVK_USE_PLATFORM_DISPLAY_KHR -I/mnt/lts24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/git/third_party/ktx/include -I/mnt/lts24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/git/third_party/ktx/lib -I/mnt/lts24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/git/third_party/ktx/lib/basisu/zstd -I/mnt/lts24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/git/third_party/ktx/lib/basisu/transcoder -I/mnt/lts24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/git/third_party/ktx/other_include -I/mnt/lts24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/git/third_party/vulkan/include -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -fstack-protector-strong -Og -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/mnt/lts24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/recipe-sysroot -Og -g -feliminate-unused-debug-types -fcanon-prefix-map -fmacro-prefix-map=/mnt/lts24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/git=/usr/src/debug/vulkan-samples/git -fdebug-prefix-map=/mnt/lts24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/git=/usr/src/debug/vulkan-samples/git -fmacro-prefix-map=/mnt/lts24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/build=/usr/src/debug/vulkan-samples/git -fdebug-prefix-map=/mnt/lts24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/build=/usr/src/debug/vulkan-samples/git -fdebug-prefix-map=/mnt/lts24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/recipe-sysroot= -fmacro-prefix-map=/mnt/lts24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/recipe-sysroot= -fdebug-prefix-map=/mnt/lts24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/recipe-sysroot-native= -pipe -DNDEBUG -fPIC -MD -MT third_party/CMakeFiles/ktx.dir/ktx/lib/basisu/zstd/zstd.c.o -MF third_party/CMakeFiles/ktx.dir/ktx/lib/basisu/zstd/zstd.c.o.d -o third_party/CMakeFiles/ktx.dir/ktx/lib/basisu/zstd/zstd.c.o -c /mnt/lts24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/git/third_party/ktx/lib/basisu/zstd/zstd.c

gcc version
gcc version 13.2.0 (GCC)

Analyze
Refer https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107931, we can know, it is not suggest to use always_inline + indirect function call. zstd.c should be changed to fix this. For linux, Eg:
-FORCE_INLINE_TEMPLATE size_t ZSTD_HcFindBestMatch_extDict_selectMLS (
+static __inline__ size_t ZSTD_HcFindBestMatch_extDict_selectMLS (

I checked latest https://github.com/KhronosGroup/KTX-Software, seems above line already not existed, since zstd.c is updated. So should we update ktx? and I am not sure if latest ktx have similar issue.

@SaschaWillems
Copy link
Collaborator

Before we update the KTX submodule in our repo, can you make sure that the latest KTX version actually compiles with your setup?

@sandy-lcq
Copy link
Contributor Author

Hi,

I tired to verify above issue with latest stable version v4.3.2 of KTX-Software. But since changes between current ktx and v4.3.2, third_party/CMakeLists.txt is not suitable for v4.3.2, eg: there is no lib/stream.h in v4.3.2, so I cannot do the whole compile of vulkan-samples with v4.3.2. Then I switched to just compile with following command to verify if the issue still exist with v4.3.2's zstd.c:
/mnt/24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/recipe-sysroot-native/usr/bin/x86_64-wrs-linux/x86_64-wrs-linux-gcc --sysroot=/mnt/24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/recipe-sysroot -DBASISD_SUPPORT_KTX2_ZSTD=0 -DBASISU_NO_ITERATOR_DEBUG_LEVEL -DKTX_FEATURE_WRITE=0 -DLIBKTX -DROOT_PATH_SIZE=35 -DVK_NO_PROTOTYPES -DVK_USE_PLATFORM_DISPLAY_KHR -I/mnt/24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/git/third_party/ktx/include -I/mnt/24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/git/third_party/ktx/lib -I/mnt/24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/git/third_party/ktx/lib/basisu/zstd -I/mnt/24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/git/third_party/ktx/lib/basisu/transcoder -I/mnt/24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/git/third_party/ktx/other_include -I/mnt/24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/git/third_party/vulkan/include -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -fstack-protector-strong -Og -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/mnt/24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/recipe-sysroot -Og -g -feliminate-unused-debug-types -fcanon-prefix-map -fmacro-prefix-map=/mnt/24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/git=/usr/src/debug/vulkan-samples/git -fdebug-prefix-map=/mnt/24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/git=/usr/src/debug/vulkan-samples/git -fmacro-prefix-map=/mnt/24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/build=/usr/src/debug/vulkan-samples/git -fdebug-prefix-map=/mnt/24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/build=/usr/src/debug/vulkan-samples/git -fdebug-prefix-map=/mnt/24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/recipe-sysroot= -fmacro-prefix-map=/mnt/24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/recipe-sysroot= -fdebug-prefix-map=/mnt/24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/recipe-sysroot-native= -pipe -DNDEBUG -fPIC -MD -MT third_party/zstd.c.o -MF third_party/zstd.c.o.d -o third_party/zstd.c.o -c /mnt/24/build/tmp-glibc/work/core2-64-wrs-linux/vulkan-samples/git/git/third_party/ktx/lib/basisu/zstd/zstd.c

And it compiled successfully, and zstd.c.o and zstd.c.o.d is generated.

@SaschaWillems
Copy link
Collaborator

Thanks for confirming. We will update ktx to a newer version, but no ETA on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants