Enabling SWIFTSHADER_EMIT_COVERAGE

22 views
Skip to first unread message

Nipun Garg

unread,
May 4, 2020, 7:15:27 PM5/4/20
to swiftshader
 Hi,

I'm trying to build SwiftShader with SWIFTSHADER_EMIT_COVERAGE enabled in order to perform coverage of the Vulkan API.

When I try to build SwiftShader with SWIFTSHADER_EMIT_COVERAGE, the build fails with the following message:

/usr/bin/ld: cannot find -lllvm-with-cov
collect2
: error: ld returned 1 exit status
tests
/regres/cov/turbo-cov/CMakeFiles/turbo-cov.dir/build.make:103: recipe for target 'turbo-cov' failed
make
[2]: *** [turbo-cov] Error 1
CMakeFiles/Makefile2:5177: recipe for target 'tests/regres/cov/turbo-cov/CMakeFiles/turbo-cov.dir/all' failed
make
[1]: *** [tests/regres/cov/turbo-cov/CMakeFiles/turbo-cov.dir/all] Error 2
make
[1]: *** Waiting for unfinished jobs....

I went through the third_party subdirectory and it seems to me that the library llvm-with-cov is built only in the third_party/llvm-10.0 subdirectory and not the llvm-7.0 subdirectory. Moreover, when I called "cmake .." in the build directory, only the build/llvm-7.0 directory was created. I might be mistaken but I can't seem to find a way to tell the system to use llvm-10.0 instead.

What should be the proper way to enable SWIFTSHADER_EMIT_COVERAGE?

Regards
Nipun

Ben Clayton

unread,
May 5, 2020, 7:44:31 AM5/5/20
to Nipun Garg, swiftshader
Hi Nipun,

SWIFTSHADER_EMIT_COVERAGE was added to generate coverage information under a very specific build environment (clang-10 toolchain, CMake option SWIFTSHADER_LLVM_VERSION=10.0).
That said, it's not too much work to enable coverage for gcc / other LLVM toolchains. I've created https://swiftshader-review.googlesource.com/c/SwiftShader/+/44728 which should allow you to build with gcc / clang coverage generation enabled without these restrictions.

Please give this a try and let me know if this fixes your build issues.

Cheers,
Ben

--
You received this message because you are subscribed to the Google Groups "swiftshader" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swiftshader...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/swiftshader/b5078a50-38a0-48d5-ac11-b6e2022f940f%40googlegroups.com.

Nipun Garg

unread,
May 6, 2020, 1:15:10 AM5/6/20
to swiftshader
Hi Ben,

I used the changes in the above link and it compiled successfully. I'm trying to use the compiled .so file with my Vulkan application.

If I'm understanding this correctly, all I have to do is replace the libvulkan.so.1 file provided in the Vulkan SDK with the file that was built to use SwiftShader, right? I'm using the following command to build my application on a Linux system:

g++ ... -L/path/to/swiftshader/build/Linux -lvulkan ...

Then, the above command cannot seem to find libvulkan.so unless I explicity link the .so file as path/to/swiftshader/build/Linux/libvulkan.so.1. Even when that does work, it seems to have undefined references as follows:

g++ -std=c++17 -I/home/nipun/SwiftShader/include/vulkan -coverage -g -o ShadedCubeApp main.cpp app.cpp /home/nipun/SwiftShader/build/Linux/libvulkan.so.1 `pkg-config --static --libs glfw3` -lpthread -coverage
/tmp/cc5Htusp.o: In function `ShadedCubeApp::createSwapchain()':
/home/nipun/vulkanSampleApp/app.cpp:384: undefined reference to `
vkCreateSwapchainKHR'
/home/nipun/vulkanSampleApp/app.cpp:386: undefined reference to `vkGetSwapchainImagesKHR'

/home/nipun/vulkanSampleApp/app.cpp:388: undefined reference to `vkGetSwapchainImagesKHR'
/tmp/cc5Htusp.o: In function `
ShadedCubeApp::cleanupSwapchain()':
/home/nipun/vulkanSampleApp/app.cpp:943: undefined reference to `vkDestroySwapchainKHR'

/tmp/cc5Htusp.o: In function `ShadedCubeApp::drawFrame()':
/home/nipun/vulkanSampleApp/app.cpp:985: undefined reference to `
vkAcquireNextImageKHR'
/home/nipun/vulkanSampleApp/app.cpp:1028: undefined reference to `vkQueuePresentKHR'

collect2
: error: ld returned 1 exit status
Makefile:10: recipe for target 'ShadedCubeApp' failed

Are there any other compiled libraries that I have to link against in order to make it work?

Regards
Nipun

Alexis Hétu

unread,
May 6, 2020, 8:16:59 AM5/6/20
to Nipun Garg, swiftshader
Hi Nipun,

  The SwiftShader Vulkan library is meant to be used with the Vulkan loader.
  You have to set the environment variable VK_ICD_FILENAMES to your path to the json file (which itself points to the vulkan library). In your case, I assume it would be the json file located in /home/nipun/SwiftShader/build/Linux/

Alexis

--
You received this message because you are subscribed to the Google Groups "swiftshader" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swiftshader...@googlegroups.com.

Nipun Garg

unread,
May 10, 2020, 7:31:03 AM5/10/20
to swiftshader
Hi Alexis

Thanks for tip. It's working well now.

Regards
Nipun
To unsubscribe from this group and stop receiving emails from it, send an email to swift...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages