Skip to content

goto-cc: compile files named *.cxx as C++ - #9613

Draft
tautschnig wants to merge 2 commits into
diffblue:developfrom
tautschnig:kiro/goto-cc-cxx-suffixes
Draft

tautschnig wants to merge 2 commits into
diffblue:developfrom
tautschnig:kiro/goto-cc-cxx-suffixes

Conversation

@tautschnig

Copy link
Copy Markdown
Collaborator

GCC (manual, "Options Controlling the Kind of Output"), Clang and Visual
Studio compile a file named *.cxx as C++ source code. goto-cc's gcc mode
did not preprocess such a file, and compilet did not consider it a
source file, so goto-gcc -c x.cxx -o x.o silently produced a native
object file without a goto-cc section, and goto-cc x.cxx no goto
program. The C++ front end already registers the cxx extension.

Add .cxx to the files that gcc mode preprocesses and to the source files
that compilet compiles; it was the only C++ source suffix of GCC's list
missing (.cc, .cp, .cxx, .cpp, .CPP, .c++, .C, and .ii for preprocessed
C++). C++ header files (.hh, .H, .hp, .hxx, .hpp, .HPP, .h++, .tcc)
remain ignored, as GCC turns them into precompiled headers, as do
GCC 15's C++20 module unit suffixes (.cppm, .ixx, .ccm, .cxxm, .c++m),
as the C++ front end does not support modules.

Co-authored-by: Kiro kiro-agent@users.noreply.github.com

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a 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.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

GCC (manual, "Options Controlling the Kind of Output"), Clang and Visual
Studio compile a file named *.cxx as C++ source code. goto-cc's gcc mode
did not preprocess such a file, and compilet did not consider it a
source file, so `goto-gcc -c x.cxx -o x.o` silently produced a native
object file without a goto-cc section, and `goto-cc x.cxx` no goto
program. The C++ front end already registers the cxx extension.

Add .cxx to the files that gcc mode preprocesses and to the source files
that compilet compiles; it was the only C++ source suffix of GCC's list
missing (.cc, .cp, .cxx, .cpp, .CPP, .c++, .C, and .ii for preprocessed
C++). C++ header files (.hh, .H, .hp, .hxx, .hpp, .HPP, .h++, .tcc)
remain ignored, as GCC turns them into precompiled headers, as do
GCC 15's C++20 module unit suffixes (.cppm, .ixx, .ccm, .cxxm, .c++m),
as the C++ front end does not support modules.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
@codecov

codecov Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.34%. Comparing base (cf12e35) to head (e6b3a08).
⚠️ Report is 55 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #9613      +/-   ##
===========================================
+ Coverage    81.28%   81.34%   +0.05%     
===========================================
  Files         1725     1727       +2     
  Lines       191618   191748     +130     
  Branches        73       73              
===========================================
+ Hits        155763   155982     +219     
+ Misses       35855    35766      -89     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Without -o, `gcc -c` writes <base name>.o for each source file. In
hybrid mode, goto-gcc moves the goto binaries that it wrote aside, runs
the native compiler and then adds them to the native object files. It
predicted the names of the goto binaries from those input files that
need preprocessing (.c and C++ source suffixes) instead of those it
compiled, so:

- `goto-gcc -c x.i` (or x.ii) and `goto-gcc -c -x c x.src` compiled the
  file, but the native object file then replaced the goto binary: x.o
  had no goto-cc section;
- `goto-gcc -c p/x.c q/x.c` failed with "Rename failed" when moving
  x.o aside for the second time, while gcc writes x.o twice and keeps
  the second one.

compilet now records the object files it writes in mode COMPILE_ONLY
(and ASSEMBLE_ONLY), and gcc mode uses that list, without duplicates.
The new tests compile without -o and thus write x.o next to their
sources, so the clean target of regression/goto-gcc now removes all
object files.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
@tautschnig
tautschnig force-pushed the kiro/goto-cc-cxx-suffixes branch from c7ea020 to e6b3a08 Compare December 4, 2026 09:40

This branch has not been deployed

No deployments
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