-
Notifications
You must be signed in to change notification settings - Fork 441
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
Modernise CMake script #1305
Modernise CMake script #1305
Conversation
…or SVF; exported SVF CMake package so SVF can be included using `find_package(SVF)`; verious bug-fixes for facilitate this
…build as well as passing it as a command-line argument
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1305 +/- ##
==========================================
+ Coverage 64.62% 65.29% +0.67%
==========================================
Files 225 225
Lines 23856 23968 +112
==========================================
+ Hits 15418 15651 +233
+ Misses 8438 8317 -121
|
@yuleisui did you have another chance to take a look at these changes? I think it should all be properly functional now! :) |
This looks to be a major change to the cmake. I would like to keep this posted for sometime so that anyone else could review before I merge it. @xudon9 could you also take a look? |
I am not an expert in CMake. After your change, I am wondering about how an SVF subproject could utilize |
… build type) and enabled LTO & Position Independent Code also when SVF is compiled as a static library
Of course! I submitted the changes as a pull request, please let me know what you think! Note that I also changed some of the symbols that were exported through the CMake package (e.g. now SVF's build type is accessible when importing the SVF package), as well as enabling LTO & compiling with Position Independent Code so that transitive references are properly locatable. |
Thanks for the update. Once the main SVF repo is updated, a new SVF-npm is uploaded. In SVF-example and many other subprojects, SVF is installed via npm. I assume there is no need to change the folder layout of SVF-npm or any environment variables here: https://github.com/SVF-tools/SVF-npm? |
No problem!
I don't think so, no. Nothing has been changed about the way the files are laid out during the build phase. The only difference is that, with these changes, people are able to use SVF as a regular CMake package (in the same way that you'd include something like LLVM in a project) if they want to. The old way of using SVF (i.e. explicitly using directories like |
Thanks and will merge towards end of this week or early next. |
@Johanmyst I have just merged your cmake patch. It has a problem with this error https://github.com/SVF-tools/SVF/actions/runs/7537407715/job/20516284438#step:5:14006 It looks to me that the FILE_SET variable is not defined: Line 132 in 520a08f
|
FILE_SET is only supported after cmake 3.2.3 which most ubuntu and windows do not support. Could you remove FILE_SET and use something else? |
This patch looks to be a workaround solution: #1328 |
@yuleisui Can I assume this is resolved then? |
Yes, that issue is resolved. However, assistance is still needed to modify CMake so that the folder layout generated in both Release-Build and Debug-Build is consistent with the layout in the installation directory. This would be good for any developer would like to debug locally compiled SVF without modifying the environmental variables. It is also good for us to copy the Release-Build folder directly to npm without installing... Could you help ensure that the folder layout in Release-Build mirrors that of the installation directory? This includes placing 'svfllvm.a' and 'svfcore.a' under the 'lib' directory, as well as putting the *.cmake files under 'cmake/SVF'. Layout under Release-Build:Layout under the Install directory: |
I've made some changes to the build system (see commit #47c14a0), but I don't really see how modifying the default build directory layout would be beneficial. Of course, some files could be relocated during the build phase (e.g. similar to how If anything, I'd argue no longer building the tools in |
The reason for maintaining a consistent layout is that when the SVF repository and a sub-project coexist on someone's local machine, differing layouts can lead to confusion about which executable to debug. This is because you have to run 'make install' each time you want to debug your svfllvm library through a subproject, which significantly hampers local debugging efficiency. Personally, I prefer to have the same layout, where the binaries are already in place, requiring only minor adjustments for libraries. As for the headers, they should not pose an issue, as we can easily upload them to SVF's npm by copying the ones from the root of the source folder. |
This pull request contains a number of optimisations/modernisations to the CMake infrastructure. The main improvement is that SVF can now be included in other projects using CMake's
find_package(SVF)
command (including specifying version requirements). The CMake SVF package exports the following symbols/targets (available after callingfind_package(SVF)
):SvfCore
andSvfLLVM
shared library targets; can be linked directly through[target_]link_libraries([target] SvfCore|SvfLLVM)
cfl
,dvf
,llvm2svf
,mta
,saber
,svf-ex
, andwpa
binaries.config.cmake.in
:SVF_INSTALL_ROOT
: installation prefix where SVF was installedSVF_INSTALL_[BIN|LIB|INCLUDE]_DIR
: respective subdirectories in installationSVF_INSTALL_EXTAPI_[DIR|FILE]
: directory containing/path toextapi.bc
SVF_SANITIZE
(string): sanitiser used when building SVFSVF_COVERAGE
(boolean): whether SVF was built with runtime instrumentationSVF_WARN_AS_ERROR
(boolean): whether SVF was compiled with compiler warnings treated as errorsSVF_EXPORT_DYNAMIC
(boolean): whether (unused) dynamic symbols were exported to the dynamic symbol tableSVF_ENABLE_ASSERTIONS
(boolean): whether assertions/debug things were enabledAdditionally, the following small fixes/changes were applied:
extapi.bc
is more easily configurable (not yet through command line option)SvfCore
andSvfLLVM
are added as export targets of SVF packageFILE_SET HEADERS
)GLOB_RECURSE
to find source files/headers instead of applyingGLOB
in every subdirectory ofsvf
/svf-llvm
to ensure new source directories are automatically includedextapi.bc
usingadd_custom_command()
rather thanadd_custom_target()
as the latter is intended for commands without any output, while the prior is intended for commands that generate output files. A dependency on the generated outputextapi.bc
is defined from a custom target to the new custom command, thereby ensuringextapi.bc
is correctly interpreted by CMake (e.g. to include it in the defaultclean
target)I've tested this on Linux using LLVM 15.0.7 and all seems functional both using the old approach as well as including SVF in projects through
find_package(SVF)
. Please let me know what you think/if you encounter any issues!