Skip to content

Variant submodule #4344

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

Closed
wants to merge 3 commits into from
Closed

Variant submodule #4344

wants to merge 3 commits into from

Conversation

thk123
Copy link
Contributor

@thk123 thk123 commented Mar 7, 2019

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • [n/a] My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

This is a proposed replacement for #3962 that I hope might be less controversial. It provides the following advantages:

  • tests provided by the original repo are run in our CI
  • easy to find the source of variation

I didn't spend much time on this, so if people don't like it, no harm no fowl, but would quite like to be able to use variant.

/*******************************************************************\

Module: typedef for optional class template. To be replaced with
std::optional once C++17 support is enabled
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be in 'nonstd/' with the existing optional code?

Copy link
Contributor Author

@thk123 thk123 Mar 7, 2019

Choose a reason for hiding this comment

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

Since it is a submodule, I don't think I can change the namespace it is in? Or do you mean, making the using nostd::variantt = ... - the optionalt is declared in the global scope so I figured this was more consistent.

But your comment highlighted a copy-pasta error in the docs - fixed

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thinking about it; just a comment saying // Swap for std::variant when switching to C++17 or something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure I follow, comment currently reads (typo not withstanding):

To be replaced with std::variant once C++17 support is enabled

Is your suggestion your wording is clearer? Happy to change if that is indeed what you mean, but for me they are equivalent

@thk123 thk123 force-pushed the variant-submodule branch from 3355d77 to f0db1cd Compare March 7, 2019 14:30
@thk123 thk123 force-pushed the variant-submodule branch from f0db1cd to dc49182 Compare March 8, 2019 14:16
Full tests are provided in the submodule - this checks that it compiles
and links correctly.
@thk123 thk123 force-pushed the variant-submodule branch 3 times, most recently from cd81a6f to 8437b25 Compare March 8, 2019 15:44
@thk123
Copy link
Contributor Author

thk123 commented Mar 8, 2019

This is failing due to Makefile not linking the variant in util.

Before I spend some time figuring out how Makefiles work again, I would appreciate some indication from @tautschnig / @kroening / @peterschrammel as to whether this approach would be preferable or acceptable way of introducing a variant.

@@ -1,3 +1,6 @@
[submodule "jbmc/lib/java-models-library"]
path = jbmc/lib/java-models-library
url = https://github.com/diffblue/java-models-library.git
[submodule "lib/variant"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of introducing a new top-level folder, can we place this in nonstd/variant instead of lib/variant?

cd lib/variant
mkdir -p build
cd build
cmake -DMPARK_VARIANT_INCLUDE_TESTS="mpark" -DCMAKE_CXX_FLAGS="-std=c++11" ..
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we sure that cmake is installed prior to running this (as this is being run in all Travis jobs)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm good point - what would you suggest - the project is in CMake not Make? (one option of course being: abandon this approach!)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think there's a problem asking for cmake to be installed. Just make sure it's documented/actually done in CI configurations.

nonstd
sys # system
util

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not needed

#ifndef CPROVER_UTIL_VARIANT_H
#define CPROVER_UTIL_VARIANT_H

#include <mpark/variant.hpp>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suppose this works with CMake, but shouldn't this be #include <lib/variant/mpark/variant.hpp>? If that, however, does not work with CMake then we'd need to update INCLUDES in any Makefile that wants to use this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So only the util includes need to change, since all other users should use the variantt wrapper. But happy to do that if that's the preference.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Well, but the variant.h file uses this include, so if I'm in directory X and have a file x/y.cpp that includes variant.h then the preprocessor still needs to know how to resolve that include.

@kroening
Copy link
Member

I am concerned about the following: so far, we have been able to build cbmc from a tarball (I am aware that this doesn't work with jbmc). We would now introduce a compile-time dependency on git, plus the ability to clone that repo.

@@ -0,0 +1,12 @@
// Copyright 2016-2019 Diffblue Limited. All Rights Reserved.
Copy link
Member

Choose a reason for hiding this comment

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

Wrong copyright header

@smowton
Copy link
Contributor

smowton commented Mar 11, 2019

@kroening subtree rather than submodule would fix that

@thk123
Copy link
Contributor Author

thk123 commented Mar 12, 2019

@kroening lmk if @smowton suggestion would work for you and I can swap this over to use a subtree.

@peterschrammel
Copy link
Member

If dependency on a repo that is not under our control is considered a problem we could also fork it into the org.

we have been able to build cbmc from a tarball

Note that CBMC already now requires an extra step (minisat) to build it from a tarball - tracking https://github.com/niklasso/minisat (or a fork of it) through a submodule would be more convenient.

@tautschnig
Copy link
Collaborator

As a rather different suggestion: have people considered to just build using -std=c++17 and just use std::variant? That's not something we can realistically do for CBMC at the moment, but if the main interest in using variant is in downstream projects then those projects could just change their compiler requirements.

@LAJW
Copy link
Contributor

LAJW commented Apr 4, 2019

just build using -std=c++17

I'd love that, and nothing technical is stopping us from doing so. But someone doesn't want that.

Nevertheless, availability of variant in CBMC wouldn't be a bad thing.

@smowton
Copy link
Contributor

smowton commented Apr 4, 2019

If you want a self-sufficient repo but also the ability to easily track what other-repo commit we're using, just subtree it. That would satisfy @kroening's concern

@NlightNFotis
Copy link
Contributor

Closing this PR on the basis of:

  1. Inactivity for about 3 years now.
  2. Significant divergence from mainline (CI is very outdated and merge conflicts exist).

If you believe this has been in err, feel free to reopen the issue.

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.

8 participants