Cosmos.Asm.Build compiles handwritten assembly sources into object files that are linked with the NativeAOT output.
Flow chart
flowchart TD
A[GetYasm] --> B[FindSourceFilesForYasm]
B --> C[BuildYasm]
C --> D[.obj files under cosmos/asm]
Parameters
| Name | Description | Default |
|---|---|---|
YasmPath |
Full path to the yasm executable. Auto-detected by GetYasm if not set. |
Unix: /usr/bin/yasm; Windows: resolved via where yasm |
AsmSearchPath |
One or more directories to scan (non-recursive) for *.asm. |
none |
AsmFiles |
Explicit list of *.asm files to compile (added to scan results). |
none |
AsmOutputPath |
Directory for compiled object files. | $(IntermediateOutputPath)/cosmos/asm/ |
Notes:
- On Unix,
YasmPathalso defaults from props if empty; on all platformsGetYasmattempts to locateyasmon PATH. - When
RuntimeIdentifieris set (e.g.,linux-x64),FindSourceFilesForYasmwill prefer an architecture subfolder if present (e.g.,<searchDir>/x64/).
Tasks
| Task | Description | Depends On |
|---|---|---|
GetYasm |
Resolves YasmPath using which (Unix) or where (Windows). |
none |
FindSourceFilesForYasm |
Cleans inputs, applies arch overrides, and discovers *.asm under AsmSearchPath. |
Build |
BuildYasm |
Invokes YasmBuildTask for each file with -felf64, writing to AsmOutputPath. |
FindSourceFilesForYasm; GetYasm |
CleanYasm |
Removes $(IntermediateOutputPath)/cosmos/asm/. |
Clean |
Detailed Workflow
GetYasmattempts to setYasmPathfrom the system (which yasmorwhere yasm). You can overrideYasmPathin your project.FindSourceFilesForYasm:- Removes any nonexistent entries from
AsmSearchPathandAsmFiles(emits warnings). - If
RuntimeIdentifieris set, replaces anyAsmSearchPaththat contains a matching arch subfolder with that subfolder (e.g.,x64). - Builds a non-recursive search pattern
%(AsmSearchPath.FullPath)/*.asmand adds results toAsmFiles(deduplicated).
- Removes any nonexistent entries from
BuildYasmcalls theYasmBuildTaskfor each file:- Computes a SHA1 of the source and emits
<name>-<sha1>.objintoAsmOutputPath. - Executes
yasm -felf64 -o <output.obj> <input.asm>.
- Computes a SHA1 of the source and emits
CleanYasmdeletes thecosmos/asmintermediate folder duringClean.
Outputs
- Object files in
$(IntermediateOutputPath)/cosmos/asm/named as<sourceName>-<sha1>.objwhere<sha1>is the content hash of the source. This guarantees deterministic, cache-friendly names across builds.