AsmFoundation.Sdk
0.1.0
See the version list below for details.
<Sdk Name="AsmFoundation.Sdk" Version="0.1.0" />
#:sdk AsmFoundation.Sdk@0.1.0
AsmFoundation.Sdk
Enterprise-grade project, dependency and build management for x86-64 assembly, on MSBuild and NuGet.
An .asmproj sits in a solution next to .csproj projects and builds with
dotnet build:
- NASM sources become a Linux shared library (
.so), static library (.a) or executable. - Asm libraries are shared as NuGet packages, pinned by version like any .NET dependency.
- ProjectReference and PackageReference work as they do in a
.csproj. dotnet packwrites a native package that both asm and .NET projects can consume.
Nothing needs to be installed. Restore downloads a bundled toolchain (NASM plus
LLVM's ld.lld and llvm-ar) for Windows, Linux or macOS build machines. Every
build machine produces the same Linux x86-64 ELF output.
Quick start
global.json:
{ "msbuild-sdks": { "AsmFoundation.Sdk": "0.1.0" } }
Hello/Hello.asmproj:
<Project Sdk="AsmFoundation.Sdk">
<PropertyGroup>
<AsmLibraryName>hello</AsmLibraryName>
</PropertyGroup>
</Project>
Hello/hello.asm:
default rel
section .text
global hello_add:function
hello_add: ; int hello_add(int a, int b)
lea eax, [rdi + rsi]
ret
section .note.GNU-stack noalloc noexec nowrite progbits
dotnet build Hello/Hello.asmproj
In a .slnx, give the project the generic MSBuild project type:
<Project Path="Hello/Hello.asmproj" Type="13B669BE-BB05-4DDF-9536-439F39A36129" />.
What a project can produce
OutputType |
Output | Notes |
|---|---|---|
Library (default) |
lib<name>.so |
position-independent code required (default rel, calls wrt ..plt) |
StaticLibrary |
lib<name>.a |
deterministic archive with a symbol index |
Exe |
<name> |
static _start (freestanding), or a PIE entering main (see AsmRuntime) |
Objects |
.o files only |
for other projects to link |
<AsmProduceStaticLibrary>true</AsmProduceStaticLibrary> also writes
lib<name>.a next to a shared library.
Settings
| Property / item | Default | Meaning |
|---|---|---|
AsmLibraryName |
project name | base name of the output |
AsmRuntime |
Freestanding |
Libc: link glibc dynamically (DT_NEEDED libc.so.6) through a generated stub, so no Linux sysroot is needed. An Exe then starts in main. Needs glibc 2.34+ at run time. |
AsmEntryPoint |
_start |
entry symbol of an Exe |
AsmDefineConstants, AsmDefine items |
DEBUG in Debug |
NASM -D symbols |
AsmIncludeDirectory items |
include/, the project folder |
NASM -I paths |
AsmFlags, AsmLinkFlags |
extra NASM / linker arguments | |
AsmLinkLibrary items |
extra .a / .so link inputs |
|
AsmLibcSymbol items |
libc functions missing from the stub's list | |
TreatWarningsAsErrors |
false |
NASM -w+error |
AsmToolchain |
Bundled |
System uses nasm, ld and ar from PATH |
Sharing libraries
Between projects: a
ProjectReferenceto another.asmprojadds itsinclude/folder and links its library.To a
.csproj: aProjectReferencefrom a.csprojbuilds the.asmprojand copies its.sonext to the program, ready for[LibraryImport].As a package:
dotnet packwrites this layout:Path Contents include/the public include files native/linux-x64/lib<name>.athe static library runtimes/linux-x64/native/lib<name>.sothe shared library build/<id>.propsthe generated props A consuming
.asmprojgets the package's include files and library frombuild/<id>.props. A consuming.csprojgets the.so.
Source, documentation and samples: https://github.com/AsmFoundation/AsmSdk.
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.