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

Refactor/libs #265

Merged
merged 31 commits into from
Jan 11, 2024
Merged

Refactor/libs #265

merged 31 commits into from
Jan 11, 2024

Conversation

leissa
Copy link
Member

@leissa leissa commented Dec 18, 2023

Moves automaton into its dedicated lib and avoids double compilation.

  • automaton stuff is now in its own lib independent from thorin and regex and gtest-regex simply link against libautomaton
  • thorin/plug/regex/automaton -> automaton
  • you can now build a thorin plugin as SHARED to also link normally against a plugin
  • thorin-regex-gtest makes use of this feature

@leissa leissa marked this pull request as ready for review December 21, 2023 22:13
@leissa leissa requested a review from fodinabor December 21, 2023 22:13
@leissa
Copy link
Member Author

leissa commented Dec 21, 2023

@fodinabor Can you have a look. The automaton stuff is now its own independent lib. I think this is more what you originally intended :)

@leissa
Copy link
Member Author

leissa commented Jan 3, 2024

@fodinabor bump

Copy link
Collaborator

@fodinabor fodinabor left a comment

Choose a reason for hiding this comment

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

Sorry for the delay...

I am somewhat struggling to see the point in having the plugin as a (shared) library. For the gtest suite, there are the "whitebox" automaton tests, which could just as well link the automaton lib statically (I just was to lazy to make it a static lib) as could the regex plugin. When the regex plugins' passes are needed in the gtest suite, it loads the module (.so) anyways via the usual mechanics.

That is not to say that some of the changes might make sense nevertheless, but I don't really see a benefit of having the option for plugins to be compiled as either or..

plugins/regex/CMakeLists.txt Show resolved Hide resolved
@leissa
Copy link
Member Author

leissa commented Jan 5, 2024

I am somewhat struggling to see the point in having the plugin as a (shared) library. For the gtest suite, there are the "whitebox" automaton tests, which could just as well link the automaton lib statically (I just was to lazy to make it a static lib) as could the regex plugin. When the regex plugins' passes are needed in the gtest suite, it loads the module (.so) anyways via the usual mechanics.

Well, one part of my changes is to have the automaton lib as an ordinary lib (which is shared by default but you could also make it static - wouldn't change much). The bigger change is about allowing plugins as a SHARED as opposed to a MODULE lib. So what you are basically saying is that instead of linking against libthorin_regex.so to get access to dfa2matcher and regex2nfa, we should instead use dlopen and then invoke the pass over the usual machinery?
Well, yes, we can do that. Would simplify a couple of things again a bit and maybe add a few lines of boilerplate to gtest/automaton.cpp. I just wanted to get rid of the double compilation without delving too deeply in gtest/automaton.cpp.

@fodinabor
Copy link
Collaborator

fodinabor commented Jan 9, 2024

I would've proposed to link both thorin_gtest and libthorin_regex.so statically against libautomaton.a. That should allow to use for the whitebox tests without dlopen and for the thorin IR tests rely on the implicit dlopen mechanics from the thorin driver as already done atm.. you would still remove the re-compilation, you would just link the static lib twice..

leissa added 2 commits January 9, 2024 17:13
* gtest/automaton.cpp: regex2nfa is now dynamically loaded
* one test case needs still porting
@leissa
Copy link
Member Author

leissa commented Jan 9, 2024

I would've proposed to link both thorin_gtest and libthorin_regex.so statically against libautomaton.a. That should allow to use for the whitebox tests without dlopen and for the thorin IR tests rely on the implicit dlopen mechanics from the thorin driver as already done atm.. you would still remove the re-compilation, you would just link the static lib twice..

As far as I can tell, lib automaton is not the issue here. It doesn't matter whether we link statically or dynamically, no?

I tried my latest commit to dynamically load regex2nfa but trouble is that this thing returns a non-trivial C++ class (std::unique_ptr<automaton::NFA>) that breaks C linkage.

@fodinabor
Copy link
Collaborator

Yeah, that's why I'd propose to have that statically linked, so we don't care about c linkage 🤔

@leissa leissa merged commit 9c09ba9 into master Jan 11, 2024
8 of 12 checks passed
@leissa leissa deleted the refactor/libs branch January 11, 2024 12:52
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