Skip to content

[aiecc] Reject unknown command-line arguments before -- (#2989)#3066

Open
hunhoffe wants to merge 5 commits into
mainfrom
aiecc-strict-args-2989
Open

[aiecc] Reject unknown command-line arguments before -- (#2989)#3066
hunhoffe wants to merge 5 commits into
mainfrom
aiecc-strict-args-2989

Conversation

@hunhoffe
Copy link
Copy Markdown
Collaborator

Summary

Closes #2989. aiecc previously declared a cl::Sink list that quietly absorbed every unrecognized command-line argument and forwarded them to host compilation. That meant typos like --aie-genrate-npu-insts (missing e) silently turned into clang flags, and the user got no signal that their option was unknown.

This change drops the sink and adds an explicit -- separator:

  • Anything before -- must be a recognized aiecc option or a positional input file. Unknown flags are a hard error from
    cl::ParseCommandLineOptions.
  • Anything after -- is captured verbatim into hostExtraArgs and passed straight to the host compiler in user-specified order. Host source files mixed in are picked up by getHostSourceFiles() as well.

Behavior for existing recognized options

-I/foo, -L/bar, -lbaz, -o test.elf, --sysroot=..., --host-target=... are all already registered as aiecc options (cl::Prefix lists cl::opt). They keep working without --. The vast majority of in-tree tests need no changes.

The only flags that genuinely have to move past -- are ones aiecc never knew about — typically -Wl,... linker flags, -D defines, etc.

Tests

  • New test/aiecc/unknown_args_rejected.mlir covers --garbage, the --aie-genrate-npu-insts typo from the issue, and the post--- passthrough path.
  • test/aiecc/cpp_host_compile.mlir HOSTFULL run line updated to demonstrate the -- form.

Required follow-up: Xilinx/mlir-air

The 26 lit files under mlir-air/test/airhost/*/run.lit invoke aiecc through the %airhost_libs% substitution, which expands to -Wl,--whole-archive -lairhost -Wl,-R... -Wl,-rpath,... -Wl,--no-whole-archive -lpthread -lstdc++ -lsysfs -ldl -lrt -lelf. The -Wl,... flags were absorbed by the legacy sink and are not recognized aiecc options. After this lands, those tests will fail until they're updated to insert -- after the input MLIR — aiecc.py %S/aie.mlir -- -I... %airhost_libs% %S/test.cpp -o %T/test.elf. A companion PR will follow.

amd/iron is unaffected — its callers only pass recognized aiecc flags.

Test plan

  • Verify mlir-air companion PR before merging this one

hunhoffe and others added 2 commits May 12, 2026 11:36
aiecc previously declared a `cl::Sink` list that absorbed every
unrecognized command-line argument and forwarded them to host
compilation. This silently swallowed typos like `--aie-genrate-npu-insts`
and made it impossible to tell aiecc-targeted flags apart from
host-compiler passthrough.

Pre-split argv on the first standalone `--`. Everything before is parsed
by `cl::ParseCommandLineOptions` with no sink, so unrecognized flags
become hard errors. Everything after is captured verbatim into a new
`hostExtraArgs` vector and emitted in user-specified order during host
compilation. Host source files appearing among the post-`--` args are
also picked up by `getHostSourceFiles()`.

Adds `test/aiecc/unknown_args_rejected.mlir` covering `--garbage`, the
`--aie-genrate-npu-insts` typo from the issue, and the post-`--`
passthrough path. Updates `cpp_host_compile.mlir`'s HOSTFULL run line to
demonstrate the `--` separator form.

Existing aiecc-recognized options (-I, -L, -l, -o, --sysroot, etc.) keep
working without `--` since they bind to their own cl::opt/cl::list
declarations.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 12, 2026

Coverage Report

Created: 2026-05-13 18:40

Click here for information about interpreting this report.

FilenameFunction CoverageLine CoverageRegion CoverageBranch Coverage
Totals- - - -
Generated by llvm-cov -- llvm version 18.1.3

hunhoffe and others added 2 commits May 13, 2026 11:52
These three Makefiles passed --aie-generate-npu alongside the real
--aie-generate-npu-insts flag; the former was silently ignored before
this PR's strict argument check and is now a hard error.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
@hunhoffe hunhoffe marked this pull request as ready for review May 13, 2026 19:55
@hunhoffe hunhoffe requested a review from erwei-xilinx May 13, 2026 19:55
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.

aiecc should reject unknown command-line arguments

2 participants