-
Notifications
You must be signed in to change notification settings - Fork 517
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 C++ test to ci #1770
Comments
Would this necessarily need to be repeated for all targets? Like (C++, GNU/Linux, x86_64), (C++, GNU/Linux, ARM64). Or would it be enough to try with MSVC on AMD64, g++ on amd64 linux, and clang++ on amd64 linux? |
Interested in helping with this, but want to make sure I understand the specific requirements. |
I'm not a C++ developer myself (traumatic memories from undergraduate concurrency classes) so I defer to those who work with C++ regularly. |
I suppose the other relevant question is which version of C++ to support. A common one is C++17 right now I believe. C++11 is probably an okay baseline.
|
I don't think we take advantage of any super modern C++ features. I also don't see us needing anything newer than C++11 in the near future. So in the interest of compatibility I would agree with using C++11 as the primary version we test against. |
That sounds good to me. I can write something up for that.
The flow is basically just compile with `g++` in C++11 mode instead of a C compiler and ensure that it passes, right?
Not some sort of static check instead?
|
I think that's sufficient for now. Maybe have it run the test suite as well ( |
Does this warrant having a compile option like |
I don't think so. |
Sounds good! |
Okay, sweet, I've got it working by modifying CMakeLists.txt and src/CMakeLists.txt. It's building as expected and passing the tests with Is it poor form to have a GitHub Action that modifies the aforementioned files during runtime to insert the directives? I was considering using environment variables, but my initial attempt was too crude. |
IMO this would be "suboptimal". In my view there should be |
Hmm, fair point. I'll look through the CMake documentation. I'm sure there's a way via switches or environment variables to tell CMake to set the language to CXX or to recognize the existing files as being C++. |
I'm a bit curious why it was required to modify CmakeLists.txt. I was expecting it to be something like It's also worth mentioning that as part of this we would want to link against a simple c++ test program. It could be something as simple as creating a signature context and exiting. The original reason for this issue was because the headers we were using were fine when linking with a C program because the problematic code blocks were hidden behind So we will for sure want to have a test that:
|
My initial thinking was to set the project language to include C++ and then set the targets file type to C++. Your solution seems preferable. One thing I have to check is whether it compiles all of the files as C++ and not just a subset. I'll write a little C++ test program. |
Seems like |
Can confirm that the behaviour before was an anomaly.
Seems ninja and/or CMake are resistant to the idea of having CMAKE_C_COMPILER set to clang++ for example. |
Ah I see. Then I think it's fine that we simply test linking liboqs (compiled with a c compiler) with a c++ test program. That will at least solve the concerns I had. :) Thanks for working on this btw! |
https://gist.github.com/aidenfoxivey/242ec40423b086a242c46993d7a4e22f Maybe something like this is a good choice? It's a minimally modified version of I've got it compiling (not linking yet) with C++11 standard. |
I think this is on the right track. I think if we can make it "a little more c++y" that would be great. maybe consider using |
Got it working! I'm going to make sure it's reliable and then I'll open a PR. |
Nice work! If you'd like to try sanity checking that the linking fails when it should, try removing this curly brace Line 323 in 7f4c89b
This should cause some wild compiler errors because of messed up scoping. :) Edit: Make sure that you edit the |
https://gist.github.com/aidenfoxivey/242ec40423b086a242c46993d7a4e22f Perhaps this is more C++ friendly. |
Seems that for the first time in my experience of using clang, the compiler warning is simple and not bonkers. |
I also checked this with I'm pretty sure I can conclude then that I've not introduced new leaks. |
https://gist.github.com/aidenfoxivey/7a41d2c6088eae59ae2960b8eede21d5 Here's what I've got for a GitHub action. The bit I'm still trying to figure out is whether |
I believe this issue can be closed now. |
There was an issue compiling the
stateful-sigs
branch forC++
, but CI was passing. We should probably add a simple c++ test to CI to prevent issues like this in the future.The text was updated successfully, but these errors were encountered: