Files
llgo/_demo/embedded/export_test/test.sh
xgopilot 060a2dea06 feat: support //export with different symbol names for embedded targets
Implements support for TinyGo-style //export directive that allows
exporting functions with symbol names different from the Go function name.

This is essential for embedded development where hardware specifications
require specific symbol names (e.g., ARM Cortex-M interrupt handlers like
LPSPI2_IRQHandler, SysTick_Handler).

Changes:
- Modified cl/import.go to support two export formats:
  1. //export ExportName (TinyGo-style, export name can differ from function name)
  2. //export FuncName ExportName (Go-style, explicit function and export names)
- Added test case in _demo/embedded/export_test/ with nm verification

Example usage:
  //export LPSPI2_IRQHandler
  func interruptLPSPI2() {
      // exported as LPSPI2_IRQHandler
  }

Fixes #1378

🤖 Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
2025-10-31 03:31:39 +00:00

44 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
set -e
echo "Testing //export with different symbol names..."
# Set LLGO_ROOT to repository root
export LLGO_ROOT=/workspace
# Build the test program
echo "Building test program..."
/workspace/llgo build -o test_export main.go || exit 1
# Check for expected symbols using nm
echo "Verifying symbols with nm..."
# Should find LPSPI2_IRQHandler (not interruptLPSPI2)
if nm test_export | grep -q "T LPSPI2_IRQHandler"; then
echo "✓ Symbol LPSPI2_IRQHandler found"
else
echo "✗ Symbol LPSPI2_IRQHandler not found"
echo "Available symbols:"
nm test_export | grep " T "
exit 1
fi
# Should find SysTick_Handler (not systemTickHandler)
if nm test_export | grep -q "T SysTick_Handler"; then
echo "✓ Symbol SysTick_Handler found"
else
echo "✗ Symbol SysTick_Handler not found"
exit 1
fi
# Should find Add (same name)
if nm test_export | grep -q "T Add"; then
echo "✓ Symbol Add found"
else
echo "✗ Symbol Add not found"
exit 1
fi
echo ""
echo "All symbol checks passed! ✓"