Add C++ compiler support (g++, libstdc++) #2

Open
opened 2026-09-24 09:52:19 +02:00 by sid · 0 comments
Owner

CodeWarrior ships a C++ compiler for the HC12/S12/S12X family. This repo's GCC builds are C-only (--enable-languages=c): there is no m68hc11-elf-g++, no libstdc++, and no C++ runtime. Code written against CodeWarrior's C++ mode cannot be migrated, and developers cannot use C++ for new projects.

Current state

  • pkgs/gcc-m68hc11.nix (GCC 3.3.6-s12x) configures with --enable-languages=c.
  • pkgs/gcc-4.3.6.nix (GCC 4.3.6 forward port) also uses --enable-languages=c.
  • m68hc11-elf-g++ does not exist in the built toolchain.

Proposed scope

  • Configure both GCCs (or at least the 4.3.6 port) with --enable-languages=c,c++.
  • Build and install a freestanding libstdc++ for the m68hc11-elf target and its multilibs (m68hc12, m9s12x, mshort, mlong-calls).
  • Ensure newlib headers are usable from C++ (extern "C" guards, etc.) and that the C++ runtime avoids features that pull in large unwind/threading code unsuitable for an 8-bit/16-bit MCU.
  • Keep the C-only packages available for size/regression comparison.

Acceptance criteria

  • m68hc11-elf-g++ accepts and compiles a small C++ program for -m68hc11, -m68hc12, and -m9s12x.
  • A minimal C++ program (virtual call, new/delete via freestanding operator new, static constructor) links and runs under gdb-sim.
  • Adding C++ does not regress the existing C build checks (flake.nix: check-compile-matrix, check-compiler-diff, sim checks).

References

  • pkgs/gcc-m68hc11.nix, pkgs/gcc-4.3.6.nix
  • flake.nix (multilib and check wiring)
CodeWarrior ships a C++ compiler for the HC12/S12/S12X family. This repo's GCC builds are C-only (`--enable-languages=c`): there is no `m68hc11-elf-g++`, no `libstdc++`, and no C++ runtime. Code written against CodeWarrior's C++ mode cannot be migrated, and developers cannot use C++ for new projects. ## Current state - `pkgs/gcc-m68hc11.nix` (GCC 3.3.6-s12x) configures with `--enable-languages=c`. - `pkgs/gcc-4.3.6.nix` (GCC 4.3.6 forward port) also uses `--enable-languages=c`. - `m68hc11-elf-g++` does not exist in the built toolchain. ## Proposed scope - Configure both GCCs (or at least the 4.3.6 port) with `--enable-languages=c,c++`. - Build and install a freestanding `libstdc++` for the `m68hc11-elf` target and its multilibs (m68hc12, m9s12x, mshort, mlong-calls). - Ensure newlib headers are usable from C++ (extern "C" guards, etc.) and that the C++ runtime avoids features that pull in large unwind/threading code unsuitable for an 8-bit/16-bit MCU. - Keep the C-only packages available for size/regression comparison. ## Acceptance criteria - `m68hc11-elf-g++` accepts and compiles a small C++ program for `-m68hc11`, `-m68hc12`, and `-m9s12x`. - A minimal C++ program (virtual call, `new`/`delete` via freestanding operator new, static constructor) links and runs under `gdb-sim`. - Adding C++ does not regress the existing C build checks (`flake.nix`: `check-compile-matrix`, `check-compiler-diff`, sim checks). ## References - `pkgs/gcc-m68hc11.nix`, `pkgs/gcc-4.3.6.nix` - `flake.nix` (multilib and check wiring)
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sid/m68hc11-toolchain#2
No description provided.