Melee Build Fixup
You are an expert at fixing build issues in the Melee decompilation project. This skill focuses on resolving compilation errors AFTER a function has been matched to its assembly - the matching work is done, but the build is broken.
When to Use This Skill
Use /decomp-fixup when:
- •A matched function causes build failures
- •Headers have
UNK_RET/UNK_PARAMSthat need real signatures - •Callers need updates after signature changes
- •Struct definitions are causing type errors
- •Build is failing due to missing prototypes
Use /decomp instead when:
- •You need to match assembly (get 100% match)
- •You're starting fresh on a function
Finding Functions That Need Fixes
# Check state for functions that may need build fixes melee-agent state status # Look for functions in "committed" state that may have broken builds # Or check functions with known issues melee-agent state status <function_name>
Diagnosing Build Errors
Step 1: Run the Build
cd <worktree> && python configure.py && ninja
The build requires function prototypes by default (same as CI). Common error types:
| Error Pattern | Cause | Solution |
|---|---|---|
implicit declaration of function | Missing prototype | Add to header |
conflicting types for 'func' | Header/impl mismatch | Fix header signature |
too few arguments to function | Signature changed | Update callers |
too many arguments to function | Signature changed | Update callers |
incompatible pointer type | Type mismatch | Fix types |
unknown type name | Missing include/typedef | Add include |
Step 2: Locate the Header
Function headers are typically in:
melee/include/melee/<module>/forward.h # Forward declarations melee/include/melee/<module>/<file>.h # Full declarations
Example paths:
- •
ft_*functions:melee/include/melee/ft/forward.hormelee/include/melee/ft/ftcommon.h - •
lb*functions:melee/include/melee/lb/forward.h - •
gr*functions:melee/include/melee/gr/forward.h
Step 3: Find Callers
When you change a function's signature, find and fix all callers:
grep -r "function_name" <worktree>/src/melee/ grep -r "function_name" <worktree>/include/melee/
Common Fixes
Fix 1: Header Signature Mismatch
Problem: Header has stub declaration, implementation has real signature.
// Before (in header - stub declaration): /* 0D7268 */ UNK_RET ftCo_800D7268(UNK_PARAMS); // After (matches implementation): /* 0D7268 */ void ftCo_800D7268(Fighter* fp, s32 arg1);
Steps:
- •Find the implementation in
src/melee/ - •Copy the exact signature
- •Update the header declaration
- •Keep the
/* address */comment if present
Fix 2: UNK_RET to Real Return Type
// Before: UNK_RET func(s32 x); // After (if implementation returns void): void func(s32 x); // After (if implementation returns a value): s32 func(s32 x);
Note: M2C_UNK can be used as a placeholder return type when the actual type is still being determined.
Fix 3: UNK_PARAMS to Real Parameters
// Before: void func(UNK_PARAMS); // After (from implementation): void func(HSD_GObj* gobj, s32 action_id, float frame);
Fix 4: Updating Callers
When a signature changes from void foo(void) to void foo(s32 arg):
// Before (caller): foo(); // After (caller - must pass argument): foo(0); // Or appropriate value based on context
Finding the right argument:
- •Check assembly at call sites
- •Look at r3/r4/etc register values before
blinstruction - •Check if there's a pattern in similar functions
Fix 5: Missing Parameter Names
Headers need parameter names for documentation, but types must match:
// Before (missing names): void func(s32, float, HSD_GObj*); // After (with names): void func(s32 action, float frame, HSD_GObj* gobj);
Fix 6: Struct/Type Issues
If a struct field type is wrong:
// Workaround in code (temporary fix): #define DMG_X1898(fp) (*(float*)&(fp)->dmg.x1898) // Better: Fix the struct definition in the header // Before: s32 x1898; // After: float x1898;
Workflow
Quick Fix (Single Function)
# 1. Check build error
cd <worktree> && ninja 2>&1 | head -50
# 2. Find header location
grep -r "function_name" <worktree>/include/
# 3. Find implementation
grep -r "function_name" <worktree>/src/melee/
# 4. Compare signatures and fix header
# 5. Find and fix callers if signature changed
grep -r "function_name(" <worktree>/src/melee/
# 6. Rebuild and verify
ninja
Batch Fix (Multiple Issues)
# 1. Get full error list cd <worktree> && python configure.py && ninja 2>&1 | tee build_errors.txt # 2. Categorize errors grep "conflicting types" build_errors.txt grep "implicit declaration" build_errors.txt grep "too few arguments" build_errors.txt # 3. Fix in dependency order (headers first, then callers)
Committing Fixes
After fixing build issues:
# Verify build passes cd <worktree> && python configure.py && ninja # Commit the fix (in the worktree) git add -A git commit -m "Fix build: update <function> signature in header"
Commit message patterns:
- •
Fix build: update ftCo_800D7268 signature in header - •
Fix build: add missing prototype for lbColl_80008440 - •
Fix build: update callers for gr_800123AB signature change
Checklist Before Committing
- • Build passes
- • No merge conflict markers in files
- • Header signatures match implementations exactly
- • All callers updated if signature changed
- • No
UNK_RET/UNK_PARAMSleft for functions you've implemented
Common Mistakes
- •Fixing implementation instead of header - If match is 100%, don't touch the .c file
- •Forgetting callers - One signature change can break many files
- •Wrong worktree - Make sure you're in the right subdirectory worktree
- •Partial fixes - Don't commit until ALL errors are resolved
- •Changing matched code - Only fix headers/callers, not the matched implementation
Type Reference
Common types in Melee:
- •
s8,s16,s32- signed integers - •
u8,u16,u32- unsigned integers - •
f32,f64- floats - •
BOOL- boolean (actually s32) - •
HSD_GObj*- game object pointer - •
Fighter*- fighter state pointer - •
Vec3- 3D vector struct - •
M2C_UNK- unknown type placeholder
What NOT to Do
- •Don't modify matched code - The .c implementation is correct, fix the header
- •Always verify build passes - Prototype requirements are enforced by default
- •Don't leave partial fixes - Fix everything or nothing
- •Don't guess signatures - Check the actual implementation
- •Don't ignore callers - They WILL break if signature changes
Troubleshooting
| Issue | Solution |
|---|---|
| Can't find header | Check include/melee/<module>/forward.h |
| Multiple declarations | Search all .h files, update all of them |
| Caller in different worktree | Note the file, fix when you work on that subdirectory |
| Circular dependency | May need forward declaration |
| Build still fails after fix | Run ninja -t clean && ninja for full rebuild |