dsw / oink-stack

Oink is a collaboration of C++ static analysis tools.
http://danielwilkerson.com/oink/index.html
154 stars 34 forks source link

Cmake #25

Open rpavlik opened 1 year ago

rpavlik commented 1 year ago

I've integrated a few PR's, as well as started on a CMake build system, which can successfully build astgen, elkhound, and elsa/ccparse.

dsw commented 1 year ago

Could we discuss these? Please find my personal email at danielwilkerson.com .

On Mon, Nov 21, 2022 at 3:26 PM Ryan A. Pavlik @.***> wrote:

I've integrated a few PR's, as well as started on a CMake build system, which can successfully build astgen, elkhound, and elsa/ccparse.

You can view, comment on, or merge this pull request online at:

https://github.com/dsw/oink-stack/pull/25 Commit Summary

File Changes

(24 files https://github.com/dsw/oink-stack/pull/25/files)

Patch Links:

— Reply to this email directly, view it on GitHub https://github.com/dsw/oink-stack/pull/25, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAL6XCEAEPSCU3OJ4M7HNLWJQAJBANCNFSM6AAAAAASHFHJIM . You are receiving this because you are subscribed to this thread.Message ID: @.***>

KubaO commented 1 year ago

This work has been done a couple times already it would seem :)

https://github.com/KubaO/elkhound is cloned from a repo that had cmake transition done in 2019. Tim Wanders did that work, according to the repo messages. It looks like elkhound is used by text adventure game aficionados to parse the adventures.

I've done some work on it so that it's self-contained with MSVC - winflex and winbison are included as a part of the build. Not used on Unix of course. Thanks to cmake, the root folder of the repo can be opened with recent versions of Visual Studio.

I've also dragged a lot of the code into the next decade. My goal is to keep it building with C++14.

There were a couple little bugs here and there I caught - related to 64-bit compatibility and heisenbugs.

I dropped all the containers in smbase (yes, all of them) and replaced those with C++ standard library. ASTList is a thin wrapper around std::vector, kept just to avoid having to do mechanical modifications that cause noise in the diffs.

This took some work to keep the whole thing working correctly (I hope). The changes consist of small self-contained commits, and my intention was to keep the thing building and passing tests for every commit. There are 230 commits done over the last month's worth of evenings :) I needed a GLR parser nicer to use than Bison, and that's how I found elkhound.

The original code used linked lists a lot and that's a performance killer on modern systems - at least with typical allocators. Where I could, I moved from lists of pointers to vectors of ideally values, or pointers if absolutely necessary. There are very few places where std::forward_list and std::list had to be used, and I'm not convinced those will stay that way.

I've also included fmt::format, and a free-standing implementation of string_view. The code is being slowly migrated to use those as/when needed.

The overall idea is to use movable values to where they help maintain performance while obviating old optimizations. E.g. I've carefully de-optimized the GLR core to make the code readable by the average person (like myself :). The generated code is still excellent due to man-centuries of effort spent on modern compilers :)

Long-term, I imagine this should use the excellent mimalloc memory allocator, since it provides very lightweight heaps, with excellent locality based on object size; creating and destroying them often is no problem.