Skip to content
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

cmake: build correctly with globally installed z3 #502

Merged
merged 1 commit into from
Aug 19, 2021

Conversation

gerion0
Copy link
Contributor

@gerion0 gerion0 commented Aug 18, 2021

I have no clue of cmake but this seems to enable building against a globally installed z3 (like per a distribution package).

@yuleisui
Copy link
Collaborator

yuleisui commented Aug 19, 2021

We plan to remove cudd in the near future and Z3 will be part of SVF's third-party lib later.

1ac1476

I found the issue for missing z3 due to an extra SVF_Z3 macro. I have just removed it. This should solve the problem. However, your patch seems to solve the same problem that build.sh does. Please let me whether the current upstream works or if you want to change anything in CMakelist.txt to make it more robust.

@yuleisui
Copy link
Collaborator

We plan to remove cudd in the near future and Z3 will be part of SVF's third-party lib later.

I found the issue for missing z3 due to an extra SVF_Z3 macro. I have just removed it. This should solve the problem. However, your patch seems to solve the same problem that build.sh does. Please let me whether the current upstream works or if you want to change anything in CMakelist.txt to make it more robust.

@yuleisui yuleisui closed this Aug 19, 2021
@yuleisui yuleisui reopened this Aug 19, 2021
@gerion0
Copy link
Contributor Author

gerion0 commented Aug 19, 2021

Sorry, I don't get, what you mean. In the current master, z3 is already a hard dependency, because of:

add_llvm_library(Svf STATIC ${SOURCES} LINK_LIBS Cudd ${Z3_DIR}/bin/libz3.a)

(Source)

However, this line forced z3 to be

  • statically linked
  • laying in a directory bin/

This forces z3 to be exactly the z3 that is downloaded with build.sh. But this is not always the case. The Debian package for example has z3 as /usr/lib/x86_64-linux-gnu/libz3.so.4 (Source). CMake can access this package (and the correct build flags) via pkgconfig. My patch enables both, the current building via an externally downloaded z3 (as it is done in build.sh) and a building against a globally installed z3 that is found via pkgconfig.

Enabling the build only with build.sh does not serve my needs. I'm embedding SVF as meson subproject that calles cmake directly.

With my patch it should be enough to execute this (on a Debian/Ubuntu) to successfully compile SVF:

$ sudo apt install libz3-dev llvm-11-dev
$ mkdir build && cd build
$ cmake -G "Ninja" -DLLVM_DIR="/usr/lib/llvm-11" ..
$ ninja

@yuleisui
Copy link
Collaborator

I see. However, for my build on mac os, there is a compilation error (z3++.h not found) if we do not include Z3_DIR here: https://github.com/SVF-tools/SVF/pull/502/files#diff-1e7de1ae2d059d21e1dd75d5812d5a34b0222cef273b7c3a2af62eb747f9d20aL56.

BTW: what do you want to do here: https://github.com/SVF-tools/SVF/pull/502/files#diff-1e7de1ae2d059d21e1dd75d5812d5a34b0222cef273b7c3a2af62eb747f9d20aR55?

@yuleisui
Copy link
Collaborator

I see. However, for my build on mac os, there is a compilation error (z3++.h not found) if we do not include Z3_DIR here: https://github.com/SVF-tools/SVF/pull/502/files#diff-1e7de1ae2d059d21e1dd75d5812d5a34b0222cef273b7c3a2af62eb747f9d20aL56.

BTW: what do you want to do here: https://github.com/SVF-tools/SVF/pull/502/files#diff-1e7de1ae2d059d21e1dd75d5812d5a34b0222cef273b7c3a2af62eb747f9d20aR55?

my build command:

./build.sh

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/include
${Z3_DIR}/include/)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to include ${Z3_INSTALLS} here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be fixed.

@gerion0
Copy link
Contributor Author

gerion0 commented Aug 19, 2021

BTW: what do you want to do here: https://github.com/SVF-tools/SVF/pull/502/files#diff-1e7de1ae2d059d21e1dd75d5812d5a34b0222cef273b7c3a2af62eb747f9d20aR55?

This resolves a relative path to the build directory for Z3_DIR in an absolute path. If I remember correctly, the linker had problems with relative paths.

@yuleisui yuleisui merged commit 49bb55f into SVF-tools:master Aug 19, 2021
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.

2 participants