-
Notifications
You must be signed in to change notification settings - Fork 32
merge cc #431
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR merges a comprehensive test suite for C99 data types and type aliasing into the cc compiler project. The changes establish a robust foundation for testing various C type systems including primitives, composites, pointers, and type qualifiers.
Key Changes:
- Added extensive test coverage for C data types (primitives, structs, unions, pointers, arrays, typedef, bitfields)
- Introduced common test utilities for compiling and running C code
- Added parse module structure for AST and parser components
- Integrated cc module into workspace
Reviewed changes
Copilot reviewed 45 out of 70 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| cc/tests/datatypes/typedef_type.rs | Tests for typedef type aliasing including pointers, structs, and casting |
| cc/tests/datatypes/struct_type.rs | Tests for struct composite types with nested structures and pointer access |
| cc/tests/datatypes/short.rs | Comprehensive operator tests for short and unsigned short types |
| cc/tests/datatypes/pointer_type.rs | Tests for C99 pointer semantics including arithmetic and void pointers |
| cc/tests/datatypes/mod.rs | Module definition organizing datatype test submodules |
| cc/tests/datatypes/mixed_cmp.rs | Tests for C99 mixed-type comparison and arithmetic conversions |
| cc/tests/datatypes/longlong.rs | Tests for long long and unsigned long long types with all operators |
| cc/tests/datatypes/longdouble.rs | Tests for long double type with floating-point operations |
| cc/tests/datatypes/long.rs | Tests for long and unsigned long types with all operators |
| cc/tests/datatypes/int.rs | Tests for int and unsigned int types with all operators |
| cc/tests/datatypes/float.rs | Tests for float and double types with conversions |
| cc/tests/datatypes/char.rs | Tests for char, signed char, and unsigned char with character literals |
| cc/tests/datatypes/bool.rs | Tests for C99 _Bool type with conversion semantics |
| cc/tests/datatypes/bitfield_type.rs | Tests for C99 bitfield support in structures |
| cc/tests/datatypes/array_type.rs | Tests for C99 array types with multi-dimensional arrays |
| cc/tests/common/mod.rs | Common utilities for compiling and running C test code |
| cc/parse/mod.rs | Parse module structure for AST and parser |
| Cargo.toml | Added cc module to workspace members |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary Root Cause of CI Failures The failing tests (varargs_caller_comprehensive and varargs_float_args) were caused by a calling convention mismatch on Apple ARM64 (Darwin/macOS). The Apple ARM64 ABI differs from standard AAPCS64 for variadic functions: - AAPCS64 (Linux): Variadic arguments use normal register allocation (x0-x7 for integers, d0-d7 for floats) - Apple ARM64 (Darwin): ALL variadic arguments must be passed on the stack, not in registers Our codegen was using the same register-based passing for all platforms, which worked on Linux but failed on the macOS CI runners (Apple Silicon). Fix Applied Modified cc/arch/aarch64/codegen.rs emit_call() function to: 1. Detect Darwin variadic calls via insn.variadic_arg_start and target.os == MacOS 2. For Darwin variadic calls: Pass fixed args in registers as normal, but push all variadic arguments onto the stack 3. For Linux/FreeBSD: Keep existing behavior (registers for all args) Assembly Comparison Before (incorrect for Darwin): mov w2, #42 ; variadic arg in register - WRONG bl _sprintf After (correct for Darwin): mov w9, #42 str x9, [sp, #-16]! ; variadic arg on stack - CORRECT bl _sprintf add sp, sp, #16 Additional Feature Added --print-targets CLI argument that displays available target architectures, matching clang's behavior: $ ./target/release/pcc --print-targets Registered Targets: aarch64 - AArch64 (little endian) x86-64 - 64-bit X86: EM64T and AMD64 Files Modified - cc/arch/aarch64/codegen.rs - Fixed variadic argument passing for Darwin - cc/main.rs - Added --print-targets argument Test Results - All 313 tests pass locally on x86-64 - The varargs tests should now pass on the macOS aarch64 CI runner Sources: - https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst - https://dyncall.org/docs/manual/manualse11.html
No description provided.