Skip to content

compilation: use upstream symbol-prefix and binutil resolution - #214

Draft
hunhoffe wants to merge 1 commit into
develfrom
dedupe-symbol-prefix
Draft

hunhoffe wants to merge 1 commit into
develfrom
dedupe-symbol-prefix

Conversation

@hunhoffe

Copy link
Copy Markdown
Collaborator

Important

Blocked on a wheel containing both Xilinx/mlir-aie#3584 and Xilinx/mlir-aie#. Newest nightly is 1.4.4.dev18+gf5196d8 — the commit before #3584 — and requirements.txt pins 1.4.4.dev4. That bump belongs here; CI fails until the wheel exists. Draft until then.

mlir-aie now provides prefix_symbols_in_object() and resolves llvm-objcopy, llvm-nm and llvm-ar via aie.utils.config, so the copies here can go. −105 lines.

Added

  • Nothing; this only drops local implementations in favour of upstream ones.

Changed

  • KernelCompilationRule emits one PythonCallbackCompilationCommand calling upstream prefix_symbols_in_object() instead of hand-building the nm → rename-map → objcopy pipeline. Two commands instead of three, and no .symbol_map / .symbol_map.syms litter beside every prefixed object.
  • _rename_symbols() and ArchiveCompilationRule take tool paths from aie.utils.config.objcopy_path() / ar_path().
  • AIEContext.compilation_rules no longer threads peano_dir through.

Removed

  • _prefix_symbols() and its two platform implementations — a Windows branch shelling out to an inline python -c, and a POSIX branch running nm and awk under sh. Upstream also reads the symbol name as the last field rather than awk's positional $3.
  • _find_tool() / _find_working_tool() / _tool_runs(). These existed because upstream looked only in the mlir-aie bin/ dir and couldn't find llvm-nm/llvm-ar, which ship with peano. Upstream now searches both trees and has the execute-it-first guard, so this is duplication, not a workaround.
  • ArchiveCompilationRule.__init__, which no longer needs either path.

PR Merge Checklist

  1. The PR is rebased on the latest devel commit and pointing to devel.
  2. Your PR has been reviewed and approved.
  3. All checks are passing.

mlir-aie now provides prefix_symbols_in_object() and resolves llvm-objcopy,
llvm-nm and llvm-ar through aie.utils.config, so the copies here can go.

_prefix_symbols() built the nm -> rename-map -> objcopy pipeline by hand and
carried a separate implementation per platform: a Windows branch that shelled
out to an inline python -c script, and a POSIX branch that ran nm and awk
under sh. Both are replaced by one PythonCallbackCompilationCommand, which
also drops the .symbol_map and .symbol_map.syms files this left beside every
prefixed object. The upstream parser reads the symbol name as the last field
rather than awk's positional $3.

_find_tool/_find_working_tool/_tool_runs searched peano_dir, mlir_aie_dir and
PATH, because upstream's resolvers looked only in the mlir-aie bin directory
and would not find llvm-nm or llvm-ar, which ship with peano instead. Upstream
searches both trees as of the config change, so this is now duplicated logic
rather than a workaround, and the execute-it-first guard that _find_working_tool
added lives there too. peano_dir is no longer threaded into the rules, and
ArchiveCompilationRule needs no constructor at all.

Verified by compiling a real kernel through KernelCompilationRule with
prefix_symbols set and reading the object back with llvm-nm: symbols come out
as op0_add_one and op0_helper_fn, from two commands instead of three. The
fusion tests that exercise this in anger need XRT, which this host lacks;
they fail identically with and without this change.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant