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

Add support for multi version bitcode libraries #1250

Merged
merged 9 commits into from
Nov 4, 2020

Conversation

MartinNowack
Copy link
Contributor

Currently, KLEE only supports one version of the runtime library.
This is a problem if different setups are needed, e.g. 32bit vs. 64bit or different optimisations.

Moreover, an additional external build system is used to handle the generation of one single bitcode library instance.

This PR simplifies and provides a cmake-only based solution that allows arbitrary runtime library configurations, compilation and their setup.
Moreover, it contains several clean-ups and modernisations of the cmake build system.
Last point, worth to mention, this PR sets the requirement for cmake to 3.5 which is still ancient and even supported by Ubuntu 16.04 as default.

@kren1
Copy link
Contributor

kren1 commented Apr 6, 2020

200 deleted lines, I like it :D

@codecov
Copy link

codecov bot commented Apr 6, 2020

Codecov Report

Merging #1250 into master will increase coverage by 0.00%.
The diff coverage is 85.18%.

@@           Coverage Diff           @@
##           master    #1250   +/-   ##
=======================================
  Coverage   69.18%   69.19%           
=======================================
  Files         154      154           
  Lines       18389    18400   +11     
  Branches     4086     4089    +3     
=======================================
+ Hits        12723    12731    +8     
  Misses       3903     3903           
- Partials     1763     1766    +3     
Impacted Files Coverage Δ
tools/klee/main.cpp 70.32% <83.33%> (-0.01%) ⬇️
include/klee/Core/Interpreter.h 100.00% <100.00%> (ø)
lib/Core/Executor.cpp 76.56% <100.00%> (+<0.01%) ⬆️

Copy link
Contributor

@jbuening jbuening left a comment

Choose a reason for hiding this comment

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

Great to see this particularly uggly part of the build system gone! I also appreciate bumping the required cmake version at least somewhat. 👍 Besides from a question that I'll post below, I only found some very minor things while taking a look at your changes.

CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Show resolved Hide resolved
if (${LLVM_VERSION_MAJOR} GREATER 4)
set(O0OPT "${O0OPT} -Xclang -disable-O0-optnone")
list(APPEND COMMON_CC_FLAGS "-Xclang" "-disable-O0-optnone")
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you remove -O0 from COMMON_CC_FLAGS on purpose? If yes, why keep -disable-O0-optnone 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.

-O0 should be the default optimisation - -disable-O0-optnone should have no influence if any higher level is selected.
I didn't want to have any optimisation settings as part of the common flags.

runtime/klee-libc/Makefile.cmake.bitcode Show resolved Hide resolved
runtime/Intrinsic/CMakeLists.txt Show resolved Hide resolved
runtime/FreeStanding/CMakeLists.txt Outdated Show resolved Hide resolved
@jbuening
Copy link
Contributor

jbuening commented Apr 7, 2020

@MartinNowack Great work! However, there is one thing that I don't understand: You write that this PR "allows arbitrary runtime library configurations", but somehow I fail to see how I would choose whether to have assertions enabled or which optimization level I want for the runtime libraries? (Not sure if you are ultimately aiming at this, but I think it would be great if it were possible to choose these parameters at runtime in a future version of KLEE)

@MartinNowack
Copy link
Contributor Author

@jbuening Great! Thanks a lot for your review. I'm going to add suggested changes.
To answer your question: https://github.com/klee/klee/pull/1250/files#diff-726b77028646514cca3f1416f7d91237R15 . You add a new name, e.g. "my_super_opt" and specialise the flags:

set(LIB_BC_SUFFIX
        64
        32
        MY_SUPER_OPT
        )

set(LIB_BC_FLAGS_MY_SUPER_OPT
        -O42
        )

And it will automatically generate a set of KLEE runtime libraries with this optimisation and that suffix.
KLEE currently just auto-selects 32bit vs. 64bit but this can be easily extended and generalised.

@kren1
Copy link
Contributor

kren1 commented Apr 7, 2020

@MartinNowack that was my concern too. I fail to see how this is used. Maybe just add the above GitHub comment as a code comment somewhere

@ccadar
Copy link
Contributor

ccadar commented Nov 3, 2020

@MartinNowack This looks nice! There's some useful cleanup and it's great that the runtime libraries are built more similarly to the rest of the code. However, I feel you need to add some documentation; I'm a bit confused about how to use this. I also don't know how this would solve the include in #1337, can you explain?
Would you have time to add a few notes about this at https://klee.github.io/docs/developers-guide/#build-system?

Two other minor points:

  • Freestanding is a standalone word; not sure why we spell it FreeStanding ;)
  • Why did you remove the clean_all target? Does everything get cleaned with make clean now?

Thanks!

@MartinNowack
Copy link
Contributor Author

@ccadar Thanks for your review. I added some more detailed documentation. This should solve most of your questions.
If not, let me know such that I can make changes on this PR or the other. The inclusion is solved by referencing the same file in each CMakeLists.txt subdirectories needed.

  • clean_all used to clean in addition the doxygen and the runtime libraries. Both is now possible as files are tracked now directly by cmake and not externally anymore.
  • FreeStanding good question how this ended up there - but this can be changed easily.

@ccadar
Copy link
Contributor

ccadar commented Nov 3, 2020

Thanks, @MartinNowack, that's really excellent documentation!
I guess my only remaining comment is about the new option you added, --library-suffix. I feel suffix refers to an implementation detail, so perhaps we should use something like build? And library sounds more general than it really is, so perhaps --runtime-build? What do you think?

@ccadar
Copy link
Contributor

ccadar commented Nov 4, 2020

@MartinNowack I see you changed the option name to --runtime-build, thanks. I assume that's the only change, right?
If so, let's merge this!

@MartinNowack
Copy link
Contributor Author

@ccadar Yes, I made your recommended changes. The build is finally through. This is ready to go.

@ccadar
Copy link
Contributor

ccadar commented Nov 4, 2020

Cool, thanks again for the excellent changes!

@ccadar ccadar merged commit a4250b2 into klee:master Nov 4, 2020
@251
Copy link
Contributor

251 commented Nov 6, 2020

@MartinNowack
Maybe I missed the documentation but how do I configure what runtimes to build? Seems I can't override LIB_BC_SUFFIX with -D during configure.

@MartinNowack
Copy link
Contributor Author

It builds all. LIB_BC_SUFFIX just selects the default. You can choose a different one via --library-suffix.

@MartinNowack MartinNowack deleted the cmake_bitcode_build branch November 6, 2020 15:02
@251
Copy link
Contributor

251 commented Nov 6, 2020

@MartinNowack

It builds all.

It attempts to build all and fails on my system for I don't want nor need a 32-bit libc on it. This should definitely be configurable.

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.

5 participants