-
Notifications
You must be signed in to change notification settings - Fork 0
Description
coretrace::compiler is currently built on top of Clang, but many real-world C/C++ codebases are written with GCC as the primary compiler and rely on a variety of GCC-specific extensions and builtins. As a result, compiling these projects with coretrace::compiler can fail or produce incomplete IR because certain GCC features are not recognized or are handled differently by Clang.
This issue tracks the work needed to make coretrace::compiler more GCC-compatible so that existing GCC-oriented codebases can be analyzed without requiring intrusive code changes.
Goals
• Make it possible to run coretrace::compiler on code that is originally written for GCC with minimal or no source modifications.
• Provide a compatibility layer (or configuration options) that:
• Maps common GCC builtins to equivalent Clang intrinsics or portable alternatives.
• Handles / ignores selected GCC-specific attributes and pragmas gracefully.
• Aligns default compilation flags and predefined macros as closely as reasonable to GCC behavior (where it matters for analysis).
Scope / Tasks
• Identify and categorize GCC-specific constructs that currently break or degrade analysis, for example:
• GCC builtins (e.g. _builtin*, vector intrinsics, etc.).
• GCC-specific attributes (e.g. attribute((packed)), attribute((aligned)), attribute((unused)), etc.).
• GCC pragmas or extensions that Clang rejects or treats differently.
• Implement a GCC compatibility layer in coretrace::compiler, which may include:
• A mapping table from GCC builtins to Clang intrinsics or standard APIs.
• Shims or fallbacks for unsupported builtins when they are not critical for IR generation.
• Logic to interpret, translate or safely ignore non-critical GCC attributes/pragma usage.
• (Maybe) Expose an option (e.g. --gcc-compat or similar) that enables this compatibility mode explicitly.
• Add documentation describing:
• Which GCC extensions are supported, translated, or ignored.
• Recommended flags to use when compiling GCC-oriented projects with coretrace::compiler.
• Extend the test suite with representative GCC-style code:
• Unit tests for builtin mappings.
• Integration tests on small C/C++ samples that mimic common GCC usage patterns.
Acceptance Criteria
• Typical C/C++ projects that assume GCC as the primary compiler can be compiled to IR through coretrace::compiler with:
• No hard failures due to the most common GCC builtins, attributes, or pragmas.
• Clear diagnostics when a GCC-specific feature cannot be supported or has been ignored.
• A dedicated section in the documentation explains how to use GCC compatibility mode and details its current limitations.
• New tests are in place and pass in CI, covering the compatibility layer behavior.