Skip to content

[SYCL] Correctly track dependencies when using check-sycl target #3964

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

Closed
wants to merge 2 commits into from

Conversation

jchlanda
Copy link
Contributor

check-sycl should only depend on sycl-toolchain. Currently building those two targets from a fresh checkout will result in linker errors:

/usr/bin/ld: cannot find -lgtest_main
/usr/bin/ld: cannot find -lgtest
/usr/bin/ld: cannot find -lLLVMTestingSupport                                      
clang-13: error: linker command failed with exit code 1 (use -v to see invocation) 

Admittedly, this is somewhat an edge case, as the problem goes away when all targets are build prior to running check-sycl.

This patch ensures that gtest and gtest_main are known to cmake before it parses projects, so the dependencies can be correctly tracked.
Additional, it fixes a bug in handling of the libraries when creating SYCL executable, as well as adds llvm-dis to the list of SYCL test dependencies (needed by lit tests).

@jchlanda jchlanda requested review from bader and a team as code owners June 21, 2021 16:37
@jchlanda jchlanda requested a review from s-kanaev June 21, 2021 16:37
@bader
Copy link
Contributor

bader commented Jun 21, 2021

check-sycl should only depend on sycl-toolchain. Currently building those two targets from a fresh checkout will result in linker errors:

/usr/bin/ld: cannot find -lgtest_main
/usr/bin/ld: cannot find -lgtest
/usr/bin/ld: cannot find -lLLVMTestingSupport                                      
clang-13: error: linker command failed with exit code 1 (use -v to see invocation) 

Admittedly, this is somewhat an edge case, as the problem goes away when all targets are build prior to running check-sycl.

This patch ensures that gtest and gtest_main are known to cmake before it parses projects, so the dependencies can be correctly tracked.

I'm not sure if 946cf57 is the right way to fix this problem. If so, I would expect someone from the community will encounter this edge case already and fit it. More likely it's a bug in SYCL project CMake files which do not set all dependencies properly (e.g. use Google Test libraries in link command w/o setting dependency on the project building them).
@vladimirlaz, could you check, please?

@vladimirlaz
Copy link
Contributor

check-sycl should only depend on sycl-toolchain. Currently building those two targets from a fresh checkout will result in linker errors:

/usr/bin/ld: cannot find -lgtest_main
/usr/bin/ld: cannot find -lgtest
/usr/bin/ld: cannot find -lLLVMTestingSupport                                      
clang-13: error: linker command failed with exit code 1 (use -v to see invocation) 

Admittedly, this is somewhat an edge case, as the problem goes away when all targets are build prior to running check-sycl.
This patch ensures that gtest and gtest_main are known to cmake before it parses projects, so the dependencies can be correctly tracked.

I'm not sure if 946cf57 is the right way to fix this problem. If so, I would expect someone from the community will encounter this edge case already and fit it. More likely it's a bug in SYCL project CMake files which do not set all dependencies properly (e.g. use Google Test libraries in link command w/o setting dependency on the project building them).
@vladimirlaz, could you check, please?

As far as see we add gtest, gtest_main, LLVMSupport and LLVMTestingSupport libraries to the linkage of tests in SYCLUnitTests target (https://github.com/intel/llvm/blob/sycl/sycl/cmake/modules/AddSYCLUnitTest.cmake#L98).
But there is no target dependencies properly configured. So if google test package is installed in the system or corresponding targets are prebuilt. In our CI we build check-llvm which does google test and LLVM test infra build before we run check-sycl. I suggest to add corresponding target dependencies to functions defined in https://github.com/intel/llvm/blob/sycl/sycl/cmake/modules/AddSYCLUnitTest.cmake.

@bader
Copy link
Contributor

bader commented Jun 23, 2021

But there is no target dependencies properly configured.

I don't think this is the case. We add those libraries as dependencies in add_sycl_executable macro - https://github.com/intel/llvm/blob/sycl/sycl/cmake/modules/AddSYCLExecutable.cmake#L38-L42. But dependencies are added only if there is corresponding CMake target already. That's why 946cf57 helps here.
@jchlanda, if you would like to proceed with 946cf57, I suggest we commit it to llorg directly.
I personally I think there should be no order in which cmake sees the targets and it's better to be handled in SYCL project cmake files.

@jchlanda
Copy link
Contributor Author

Took 946cf57 to the mainline llvm (https://reviews.llvm.org/D104848) and cdde151 is superficial, closing.

@jchlanda jchlanda closed this Jun 24, 2021
@bader
Copy link
Contributor

bader commented Jun 24, 2021

Thanks! We pull llorg commits once a week, so once https://reviews.llvm.org/D104848 is committed we can expect it to appear in this repository within a week.

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

Successfully merging this pull request may close these issues.

3 participants