From d99f184df7a9f8bf1cafed503cca34c616134fcd Mon Sep 17 00:00:00 2001 From: Aleksandr Solovev Date: Tue, 5 Nov 2024 16:56:03 +0100 Subject: [PATCH] fix: add cycle linking for mkl_core(bazel) (#2967) --- .ci/pipeline/ci.yml | 15 ++++++--------- dev/bazel/deps/mkl.tpl.BUILD | 13 ++++++++++++- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/.ci/pipeline/ci.yml b/.ci/pipeline/ci.yml index 227bc890af7..b0d1433d9d5 100755 --- a/.ci/pipeline/ci.yml +++ b/.ci/pipeline/ci.yml @@ -534,15 +534,12 @@ jobs: --test_thread_mode=par displayName: 'cpp-examples-thread-release-static' - # The issue that bazel doesnt link MKL libs via -Wl, --start-group.. - # oneDAL make build pass this test - # TODO: add cycle linking in bazel - # - script: | - # export DALROOT=`pwd`/bazel-bin/release/daal/latest - # bazel test //examples/oneapi/cpp:all \ - # --test_link_mode=release_dynamic \ - # --test_thread_mode=par - # displayName: 'cpp-examples-thread-release-dynamic' + - script: | + export DALROOT=`pwd`/bazel-bin/release/daal/latest + bazel test //examples/oneapi/cpp:all \ + --test_link_mode=release_dynamic \ + --test_thread_mode=par + displayName: 'cpp-examples-thread-release-dynamic' - script: | bazel test //cpp/daal:tests diff --git a/dev/bazel/deps/mkl.tpl.BUILD b/dev/bazel/deps/mkl.tpl.BUILD index cf492886f09..161aec2991b 100644 --- a/dev/bazel/deps/mkl.tpl.BUILD +++ b/dev/bazel/deps/mkl.tpl.BUILD @@ -22,11 +22,22 @@ cc_library( "lib/libmkl_tbb_thread.a", ], linkopts = [ + # The source libraries have circular symbol dependencies. To successfully build this cc_library, + # oneMKL requires wrapping the libraries with -Wl,--start-group and -Wl,--end-group. + "-Wl,--start-group", + "$(location lib/libmkl_core.a)", + "$(location lib/libmkl_intel_ilp64.a)", + "$(location lib/libmkl_tbb_thread.a)", + "-Wl,--end-group", "-lpthread", + "-lm", + "-ldl", ], deps = [ ":headers", - ] + ], + alwayslink = 1, + linkstatic = 1, ) cc_library(