oneapi-src / oneDNN

oneAPI Deep Neural Network Library (oneDNN)
https://uxlfoundation.org
Apache License 2.0
3.64k stars 1.01k forks source link

Unable to statically link oneDNN if it is built with `-DDNNL_VERBOSE=OFF` #2197

Closed dawid-sabat closed 3 weeks ago

dawid-sabat commented 3 weeks ago

Summary

If I build oneDNN with flag: -DDNNL_VERBOSE=OFF I'm unable to to link my application with oneDNN lib I created first.

Version

3.6 gitsha1:0a52986714f6644e17663a7b65c47e299a3e9bd5

Environment

This doesn't look like an environment related issue.

Steps to reproduce

Compiler to build oneDNN: GCC 14. Building oneDNN with following flags:

    cmake -GNinja -S . -B build \
          -DCMAKE_BUILD_TYPE=Release \
          -DCMAKE_C_FLAGS_RELEASE="-O2 -DNDEBUG -w" \
          -DCMAKE_CXX_FLAGS_RELEASE="-O2 -DNDEBUG -w -fno-var-tracking-assignments" \
          -DCMAKE_INSTALL_PREFIX=$prefix \
          -DDNNL_BUILD_EXAMPLES=OFF \
          -DDNNL_BUILD_TESTS=OFF \
          -DDNNL_CPU_RUNTIME="SEQ" \
          -DDNNL_ENABLE_CPU_ISA_HINTS=OFF \
          -DDNNL_ENABLE_ITT_TASKS=OFF \
          -DDNNL_ENABLE_JIT_PROFILING=OFF \
          -DDNNL_ENABLE_MAX_CPU_ISA=ON \
          -DDNNL_ENABLE_PRIMITIVE="matmul;eltwise" \
          -DDNNL_LIBRARY_TYPE="STATIC" \
          -DDNNL_VERBOSE=OFF \
          -DONEDNN_BUILD_GRAPH=OFF

Observed behavior

Log error when I compile my application and try to link oneDNN:

/usr/local/lib64/gcc/x86_64-generic-linux/14/../../../../x86_64-generic-linux/bin/ld: /usr/local/lib64/libdnnl.a(eltwise.cpp.o): in function `void dnnl::impl::verbose_printf<char const*, char const*, char const*, int>(char const*, char const*, char const*, char const*, int)':
eltwise.cpp:(.text._ZN4dnnl4impl14verbose_printfIJPKcS3_S3_iEEEvS3_DpT_[_ZN4dnnl4impl14verbose_printfIJPKcS3_S3_iEEEvS3_DpT_]+0xda): undefined reference to `dnnl::impl::verbose_printf_impl(char const*, dnnl::impl::verbose_t::flag_kind)'
/usr/local/lib64/gcc/x86_64-generic-linux/14/../../../../x86_64-generic-linux/bin/ld: /usr/local/lib64/libdnnl.a(eltwise.cpp.o): in function `void dnnl::impl::verbose_printf<char const*, char const*, char const*, char const*, int>(char const*, char const*, char const*, char const*, char const*, int)':
eltwise.cpp:(.text._ZN4dnnl4impl14verbose_printfIJPKcS3_S3_S3_iEEEvS3_DpT_[_ZN4dnnl4impl14verbose_printfIJPKcS3_S3_S3_iEEEvS3_DpT_]+0xdf): undefined reference to `dnnl::impl::verbose_printf_impl(char const*, dnnl::impl::verbose_t::flag_kind)'
/usr/local/lib64/gcc/x86_64-generic-linux/14/../../../../x86_64-generic-linux/bin/ld: /usr/local/lib64/libdnnl.a(eltwise.cpp.o): in function `void dnnl::impl::verbose_printf<char const*, char const*, char const*, char const*, char const*, int>(char const*, char const*, char const*, char const*, char const*, char const*, int)':
eltwise.cpp:(.text._ZN4dnnl4impl14verbose_printfIJPKcS3_S3_S3_S3_iEEEvS3_DpT_[_ZN4dnnl4impl14verbose_printfIJPKcS3_S3_S3_S3_iEEEvS3_DpT_]+0xe7): undefined reference to `dnnl::impl::verbose_printf_impl(char const*, dnnl::impl::verbose_t::flag_kind)'
/usr/local/lib64/gcc/x86_64-generic-linux/14/../../../../x86_64-generic-linux/bin/ld: /usr/local/lib64/libdnnl.a(eltwise.cpp.o): in function `void dnnl::impl::verbose_printf<char const*, char const*, char const*, int, char const*, int, char const*, int>(char const*, char const*, char const*, char const*, int, char const*, int, char const*, int)':
eltwise.cpp:(.text._ZN4dnnl4impl14verbose_printfIJPKcS3_S3_iS3_iS3_iEEEvS3_DpT_[_ZN4dnnl4impl14verbose_printfIJPKcS3_S3_iS3_iS3_iEEEvS3_DpT_]+0x101): undefined reference to `dnnl::impl::verbose_printf_impl(char const*, dnnl::impl::verbose_t::flag_kind)'
/usr/local/lib64/gcc/x86_64-generic-linux/14/../../../../x86_64-generic-linux/bin/ld: /usr/local/lib64/libdnnl.a(engine.cpp.o): in function `dnnl_engine_create':
engine.cpp:(.text+0x3c7): undefined reference to `dnnl::impl::verbose_printf_impl(char const*, dnnl::impl::verbose_t::flag_kind)'
/usr/local/lib64/gcc/x86_64-generic-linux/14/../../../../x86_64-generic-linux/bin/ld: /usr/local/lib64/libdnnl.a(engine.cpp.o):engine.cpp:(.text+0x77a): more undefined references to `dnnl::impl::verbose_printf_impl(char const*, dnnl::impl::verbose_t::flag_kind)' follow
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

What repeats is undefined reference todnnl::impl::verbose_printf_impl`

If I recompile oneDNN with -DDNNL_VERBOSE=ON the issue goes away.

Expected behavior

Linking process is successful with oneDNN built with -DDNNL_VERBOSE=ON

yehudaorel commented 3 weeks ago

Hi @dawid-sabat, Thank you for raising the issue!

Seems like this issue was fixed by common: verbose: fix the build for ONEDNN_VERBOSE=OFF, which was not included in v3.6 release.

Could you please give main branch a try and see if the issue persists? I was not able to reproduce the issue using latest.

dawid-sabat commented 3 weeks ago

Great! I'll try this out and report back to you.

dawid-sabat commented 3 weeks ago

I rebuilt my toolchain and the application.

Looks like patching oneDNN 3.6 with this commit solves the issue: common: verbose: fix the build for ONEDNN_VERBOSE=OFF

@yehudaorel thanks for pointing to the commit that fixes my issue. I can patch up oneDNN in my toolchain for now and pick up the next release when its ready.

We can close this issue.

vpirogov commented 3 weeks ago

Backported the patch to rls-v3.6 branch.