Skip to content

LLVM 17-19 compatibility#1745

Merged
ccadar merged 2 commits intoklee:masterfrom
LLVMParty:llvm-compatibility
Oct 25, 2024
Merged

LLVM 17-19 compatibility#1745
ccadar merged 2 commits intoklee:masterfrom
LLVMParty:llvm-compatibility

Conversation

@mrexodia
Copy link
Contributor

Summary:

See #1739 for previous discussion. I was asked to open a separate PR for the LLVM 17 compatibility patches, this now also includes LLVM 19 (at least, it compiles).

They deprecated startswith in LLVM 18 and removed it in LLVM 19. To stay compatible with LLVM 13 I changed it to .find() instead of #if and duplicating the code.

Checklist:

  • The PR addresses a single issue. If it can be divided into multiple independent PRs, please do so.
  • The PR is divided into a logical sequence of commits OR a single commit is sufficient.
  • There are no unnecessary commits (e.g. commits fixing issues in a previous commit in the same PR).
  • Each commit has a meaningful message documenting what it does.
  • All messages added to the codebase, all comments, as well as commit messages are spellchecked.
  • The code is commented OR not applicable/necessary.
  • The patch is formatted via clang-format OR not applicable (if explicitly overridden leave unchecked and explain).
  • There are test cases for the code you added or modified OR no such test cases are required.

@mrexodia mrexodia changed the title Llvm compatibility LLVM 19 compatibility Sep 24, 2024
@mrexodia mrexodia mentioned this pull request Oct 16, 2024
8 tasks
@mrexodia
Copy link
Contributor Author

@ccadar any chance for a review?

@rakin000
Copy link

rakin000 commented Oct 17, 2024

I am getting the following error while running klee.

KLEE: ERROR: Loading file ~/Desktop/usr/local/lib/klee/runtime/libkleeRuntimeFreestanding64_Debug+Asserts.bca failed: No such file or directory

I built klee using llvm-18 with uclibc, posix runtime support.

@mrexodia
Copy link
Contributor Author

mrexodia commented Oct 17, 2024

Yeah the CI is also failing on that, but I'm not sure how to investigate this since I did not change anything about the build scripts... Perhaps there is a silent error while compiling the runtime and it gets hidden from the build status?

@ccadar
Copy link
Contributor

ccadar commented Oct 17, 2024

@mrexodia thanks for your contribution. This looks find with me overall, although I was wondering why you replaced starts_with and end_with with find.

Other than that, our CI is failing and I would like to fix it first. Furthermore, we should add support for LLVM 17-19 to the CI, although for that we need to create some Docker images first, which @MartinNowack usually handles.

@mrexodia
Copy link
Contributor Author

@mrexodia thanks for your contribution. This looks find with me overall, although I was wondering why you replaced starts_with and end_with with find.

I did this because LLVM renamed startswith to starts_with, so the only way to keep it compatible with LLVM 13 is to use .find instead 😅 I can add a // NOTE comment for this!

@ccadar
Copy link
Contributor

ccadar commented Oct 17, 2024

@mrexodia thanks for your contribution. This looks find with me overall, although I was wondering why you replaced starts_with and end_with with find.

I did this because LLVM renamed startswith to starts_with, so the only way to keep it compatible with LLVM 13 is to use .find instead 😅 I can add a // NOTE comment for this!

I understand. But I would prefer to keep the same semantics and have extra #ifdefs

I have managed to fix the CI in #1750, so once that is in (hopefully tomorrow), we will be able to rebase and hopefully merge this one.

@ccadar ccadar self-requested a review October 17, 2024 20:47
Copy link
Contributor

@ccadar ccadar left a comment

Choose a reason for hiding this comment

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

See request about startswith and endwith in the discussion.

Ideally we would also add CI targets for LLVM 17-19, but we could also do this later.

@mrexodia
Copy link
Contributor Author

Sure I can change it, but find("prefix") == 0 and starts_with do have the same semantics…

@251
Copy link
Contributor

251 commented Oct 18, 2024

starts_with is faster because it doesn't keep looking for a match in the rest of the string.

@ccadar
Copy link
Contributor

ccadar commented Oct 18, 2024

@mrexodia you are right that the semantics for starts_with is preserved by the change, although I think this is not the case for ends_with. The latter can also be resolved, but I think starts/ends_with is more readable, so I'd prefer to keep that. (There is also the performance issue mentioned by @251, although perhaps less of an issue in this particular context). Thanks again!

Address review comments about starts_with
@mrexodia mrexodia requested a review from ccadar October 18, 2024 11:10
@mrexodia
Copy link
Contributor Author

Alright, I rebased on master and did the #ifdef for starts_with. I used LLVM 16, because that is where starts_with was introduced (see https://github.com/mrexodia/llvm-headers for a quick reference).

@ccadar ccadar changed the title LLVM 19 compatibility LLVM 17-19 compatibility Oct 18, 2024
@ccadar
Copy link
Contributor

ccadar commented Oct 25, 2024

Thank you for your changes, @mrexodia. This looks good now, so let's merge it. Although we might need to get back to it once we add CI targets for LLVM 17, 18 and 19 (we are currently working on this).

@ccadar ccadar merged commit 7444f8e into klee:master Oct 25, 2024
@mrexodia mrexodia mentioned this pull request Dec 26, 2024
8 tasks
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.

4 participants