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

autocxx-reduce may need to try to build the resulting code #493

Closed
adetaylor opened this issue May 14, 2021 · 2 comments · Fixed by #521
Closed

autocxx-reduce may need to try to build the resulting code #493

adetaylor opened this issue May 14, 2021 · 2 comments · Fixed by #521

Comments

@adetaylor
Copy link
Collaborator

Sometimes problems show up only when building the resulting C++ code (e.g. #489, #490, #491). It would be good to be able to minimize the test cases based on C++ compilation results. We should probably make it possible to build the Rust code too.

@adetaylor
Copy link
Collaborator Author

This turns out to be annoyingly hard, because the reduction process wants to work on a single preprocessed file, yet the .cxx files generated by autocxx try to #include a bunch of headers (including transitively via cxx.h). They obviously conflict.

@adetaylor
Copy link
Collaborator Author

adetaylor commented May 19, 2021

Here are the things which need to be done here:

  • Clean up test_gen a bit (Use generate_all! in s2 example. #497). Unrelated in theory, but may help with subsequent changes.
  • Add a reduction test (in Attempt to build .rs and .cxx code in reduction. #495 but doesn't work yet).
  • Stick include guards around the preprocessed header, before passing it into creduce. Surround with include guards #516 . This is because when we compile gen0.cc as produced by cxx_gen, it includes the preprocessed header via two routes:
    • Via a direct include! directive which we put into the cxx::bridge
    • Via the include! directive for autocxxgen.h which in turn #includes the preprocessed header.
      (The code in Attempt to build .rs and .cxx code in reduction. #495 does this using an --omit-includes autocxx_gen flag, but include guards would probably be better).
  • When generating the preprocessed header in engine/src/lib.rs, before preprocessing, append #includes for all system headers which cxx ever includes in its generated C++ code. There's no current API to get that list out of cxx_gen so we will either need to add it, or hard-code it. The idea is that the preprocessed header is fully hermetic and we need never refer to local headers during the reduction process. Include all in preprocess #508.
  • When reducing, make fake blank headers for each of those headers.
  • Add an optional precompilation step to the interestingness test, triggered by command-line argument to autocxx_reduce.
    • Allow override of the clang used, using the CLANG_PATH code which already exists
  • Add an optional postcompilation step to the interestingness test, triggered by command-line argument to autocxx_reduce.
  • Possibly: In autocxxgen.h, as generated by engine/src/conversion/codegen_cpp/mod.rs, #include the preprocessed header before any additional headers required by the generated C++ (for example string, memory, cxx.h). Specifically, we need to include the preprocessed header before including cxx.h so that the preprocessed header continues to define symbols like CXXBRIDGE1_RUST_STRING. That way, when the compiler reads cxx.h it won't come across duplicate definitions of the cxx types. I'm not sure this is actually necessary any more.

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 a pull request may close this issue.

1 participant