Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating repo for transfer to the .NET Foundation #180

Merged
merged 4 commits into from
Nov 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
136 changes: 136 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Contributor Covenant Code of Conduct

This copy of the Code of Conduct is provided for convenience. Any deviations
from the original source are unintentional and are superseded by the original
source available at https://dotnetfoundation.org/about/code-of-conduct.

## Preamble

The .NET Foundation was created to foster an open, innovative and inclusive
community around open source .NET. To clarify expected behaviour in our
communities we have adopted the Contributor Covenant. This code of conduct has
been adopted by many other open source communities and we feel it expresses our
values well.

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall
community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or advances
of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others’ private information, such as a physical or email address,
without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for
moderation decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail
address, posting via an official social media account, or acting as an
appointed representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
conduct@dotnetfoundation.org. All complaints will be reviewed and investigated
promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of
actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or permanent
ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the
community.

## Attribution

This Code of Conduct is adapted from the Contributor Covenant, version 2.0,
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by Mozilla’s code of conduct enforcement ladder.

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
8 changes: 4 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -36,9 +36,9 @@

<!-- Default settings that explicitly differ from the Sdk.targets defaults-->
<PropertyGroup>
<Authors>Microsoft and Contributors</Authors>
<Authors>.NET Foundation and Contributors</Authors>
<BaseOutputPath>$(BaseArtifactsPath)bin/$(BaseArtifactsPathSuffix)/</BaseOutputPath>
<Company>Microsoft</Company>
<Company>.NET Foundation</Company>
<ContinuousIntegrationBuild Condition="'$(BUILD_BUILDNUMBER)' != ''">true</ContinuousIntegrationBuild>
<PackageOutputPath>$(BaseArtifactsPath)pkg/$(Configuration)/</PackageOutputPath>
<Product>LLVMSharp</Product>
@@ -51,7 +51,7 @@
<PropertyGroup>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)Open.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorPublicKey>00240000048000009400000006020000002400005253413100040000010001004b86c4cb78549b34bab61a3b1800e23bfeb5b3ec390074041536a7e3cbd97f5f04cf0f857155a8928eaa29ebfd11cfbbad3ba70efea7bda3226c6a8d370a4cd303f714486b6ebc225985a638471e6ef571cc92a4613c00b8fa65d61ccee0cbe5f36330c9a01f4183559f1bef24cc2917c6d913e3a541333a1d05d9bed22b38cb</AssemblyOriginatorPublicKey>
<Copyright>Copyright © Microsoft and Contributors</Copyright>
<Copyright>Copyright © .NET Foundation and Contributors</Copyright>
<Description>LLVMSharp is a multi-platform .NET Standard library for accessing the LLVM infrastructure.</Description>
<Features>strict</Features>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
@@ -60,7 +60,7 @@
<MinClientVersion>4.3</MinClientVersion>
<NeutralLanguage>en-US</NeutralLanguage>
<OverwriteReadOnlyFiles>true</OverwriteReadOnlyFiles>
<PackageLicenseExpression>NCSA</PackageLicenseExpression>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>$(RepositoryUrl)</PackageProjectUrl>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<PublicSign>false</PublicSign>
20 changes: 20 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# The MIT License (MIT)

Copyright © .NET Foundation and Contributors. All Rights Reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 changes: 0 additions & 12 deletions LICENSE.txt

This file was deleted.

9 changes: 5 additions & 4 deletions LLVMSharp.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28922.388
# Visual Studio Version 17
VisualStudioVersion = 17.1.31903.286
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8CB270E5-F45F-4E85-A3D8-8B2440CC79E1}"
ProjectSection(SolutionItems) = preProject
@@ -10,10 +10,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.gitignore = .gitignore
build.cmd = build.cmd
build.sh = build.sh
CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
LICENSE.txt = LICENSE.txt
NOTICE.txt = NOTICE.txt
LICENSE.md = LICENSE.md
NOTICE.md = NOTICE.md
pack.cmd = pack.cmd
pack.sh = pack.sh
README.md = README.md
File renamed without changes.
129 changes: 33 additions & 96 deletions README.md
Original file line number Diff line number Diff line change
@@ -9,11 +9,41 @@ LLVMSharp is a multi-platform .NET Standard library for accessing the LLVM infra
| Ubuntu 16.04 x64 | [![Build Status](https://dev.azure.com/ms/LLVMSharp/_apis/build/status/microsoft.LLVMSharp?branchName=main&jobName=ubuntu_debug_x64)](https://dev.azure.com/ms/LLVMSharp/_build/latest?definitionId=156&branchName=main) | [![Build Status](https://dev.azure.com/ms/LLVMSharp/_apis/build/status/microsoft.LLVMSharp?branchName=main&jobName=ubuntu_release_x64)](https://dev.azure.com/ms/LLVMSharp/_build/latest?definitionId=156&branchName=main) |
| MacOS x64 | [![Build Status](https://dev.azure.com/ms/LLVMSharp/_apis/build/status/microsoft.LLVMSharp?branchName=main&jobName=macos_debug_x64)](https://dev.azure.com/ms/LLVMSharp/_build/latest?definitionId=156&branchName=main) | [![Build Status](https://dev.azure.com/ms/LLVMSharp/_apis/build/status/microsoft.LLVMSharp?branchName=main&jobName=macos_release_x64)](https://dev.azure.com/ms/LLVMSharp/_build/latest?definitionId=156&branchName=main) |

[![Join the chat at https://gitter.im/mjsabby/LLVMSharp](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mjsabby/LLVMSharp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
A nuget package for the project is provided here: https://www.nuget.org/packages/llvmsharp.

[**LLVMSharp NuGet Package**](http://www.nuget.org/packages/LLVMSharp) for .NET Core 2.0+ (Linux, macOS, Windows) and .NET Framework 4+ - each version is built from the corresponding LLVM Release.
A convenience package which provides the native libLLVM library for several platforms is provided here: https://www.nuget.org/packages/libLLVM

## Building LLVMSharp
NOTE: These may be out of date as compared to the latest sources. New versions are published as appropriate and a nightly feed is not currently available.

## Table of Contents

* [Code of Conduct](#code-of-conduct)
* [License](#license)
* [Features](#features)
* [Building LLVMSharp](#building-llvmsharp)

### Code of Conduct

LLVMSharp and everyone contributing (this includes issues, pull requests, the
wiki, etc) must abide by the .NET Foundation Code of Conduct:
https://dotnetfoundation.org/about/code-of-conduct.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at conduct@dotnetfoundation.org.

### License

Copyright (c) .NET Foundation and Contributors. All Rights Reserved.
Licensed under the MIT License (MIT).
See [LICENSE.md](LICENSE.md) in the repository root for more information.

### Features

* Auto-generated using LLVM C headers files, and supports all functionality exposed by them (more than enough to build a full compiler)
* Type safe (LLVMValueRef and LLVMTypeRef are different types, despite being pointers internally)
* Nearly identical to LLVM C APIs, e.g. LLVMModuleCreateWithName in C, vs. LLVM.ModuleCreateWithName (notice the . in the C# API)

### Building LLVMSharp

On Linux using .NET Core:

@@ -32,96 +62,3 @@ On Windows using .NET Core
:> cd LLVMSharp
:> dotnet build
```

## Features

* Auto-generated using LLVM C headers files, and supports all functionality exposed by them (more than enough to build a full compiler)
* Type safe (LLVMValueRef and LLVMTypeRef are different types, despite being pointers internally)
* Nearly identical to LLVM C APIs, e.g. LLVMModuleCreateWithName in C, vs. LLVM.ModuleCreateWithName (notice the . in the C# API)

## Kaleidoscope Tutorials

There's a [C# translation of the LLVM official Kaleidoscope Tutorial](http://ice1000.org/llvm-cs/en/).

Much of the tutorial is already implemented here, and has some nice improvements like the Visitor pattern for code generation to make the LLVM code stand out and help you bootstrap your compiler.

The tutorials have been tested to run on Windows and Linux, however the build (using MSBuild) uses the Nuget packages, hence require some editing to run on Linux.

[Chapter 3](samples/KaleidoscopeTutorial/Chapter3)

[Chapter 4](samples/KaleidoscopeTutorial/Chapter4)

[Chapter 5](samples/KaleidoscopeTutorial/Chapter5)

## Conventions

* Types are exactly how they are defined in the C bindings, for example: LLVMTypeRef

* Functions are put in a C# class called LLVM and the LLVM prefix is removed from the functions, for example: LLVM.ModuleCreateWithName("LLVMSharpIntro");

## Example application

```csharp
using System;
using System.Runtime.InteropServices;
using LLVMSharp.Interop;

internal sealed class Program
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int Add(int a, int b);

private static void Main(string[] args)
{
LLVMModuleRef mod = LLVMModuleRef.CreateWithName("LLVMSharpIntro");

LLVMTypeRef[] param_types = new LLVMTypeRef[2] { LLVMTypeRef.Int32, LLVMTypeRef.Int32 };
LLVMTypeRef ret_type = LLVMTypeRef.CreateFunction(LLVMTypeRef.Int32, param_types);
LLVMValueRef sum = mod.AddFunction("sum", ret_type);

LLVMBasicBlockRef entry = sum.AppendBasicBlock("entry");

LLVMBuilderRef builder = LLVMBuilderRef.Create(mod.Context);
builder.PositionAtEnd(entry);
LLVMValueRef tmp = builder.BuildAdd(sum.Params[0], sum.Params[1], "tmp");
builder.BuildRet(tmp);

if (!mod.TryVerify(LLVMVerifierFailureAction.LLVMPrintMessageAction, out var error))
{
Console.WriteLine($"Error: {error}");
}

LLVM.LinkInMCJIT();

LLVM.InitializeX86TargetMC();
LLVM.InitializeX86Target();
LLVM.InitializeX86TargetInfo();
LLVM.InitializeX86AsmParser();
LLVM.InitializeX86AsmPrinter();

LLVMMCJITCompilerOptions options = new LLVMMCJITCompilerOptions { NoFramePointerElim = 1 };
if (!mod.TryCreateMCJITCompiler(out var engine, ref options, out error))
{
Console.WriteLine($"Error: {error}");
}

var addMethod = (Add)Marshal.GetDelegateForFunctionPointer(engine.GetPointerToGlobal(sum), typeof(Add));
int result = addMethod(10, 10);

Console.WriteLine("Result of sum is: " + result);

if (mod.WriteBitcodeToFile("sum.bc") != 0)
{
Console.WriteLine("error writing bitcode to file, skipping");
}

mod.Dump();
builder.Dispose();
engine.Dispose();
}
}
````

## Microsoft Open Source Code of Conduct

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@
<metadata minClientVersion="2.12">
<id>libLLVM.runtime.freebsd.11-x64</id>
<version>12.0.0</version>
<authors>Microsoft and Contributors</authors>
<owners>Microsoft and Contributors</owners>
<authors>.NET Foundation and Contributors</authors>
<owners>.NET Foundation and Contributors</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<license type="expression">Apache-2.0 WITH LLVM-exception</license>
<projectUrl>https://github.com/microsoft/llvmsharp</projectUrl>
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@
<metadata minClientVersion="2.12">
<id>libLLVM.runtime.freebsd.11-x86</id>
<version>12.0.0</version>
<authors>Microsoft and Contributors</authors>
<owners>Microsoft and Contributors</owners>
<authors>.NET Foundation and Contributors</authors>
<owners>.NET Foundation and Contributors</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<license type="expression">Apache-2.0 WITH LLVM-exception</license>
<projectUrl>https://github.com/microsoft/llvmsharp</projectUrl>
Original file line number Diff line number Diff line change
@@ -3,8 +3,8 @@
<metadata minClientVersion="2.12">
<id>libLLVM.runtime.linux-arm</id>
<version>12.0.0</version>
<authors>Microsoft and Contributors</authors>
<owners>Microsoft and Contributors</owners>
<authors>.NET Foundation and Contributors</authors>
<owners>.NET Foundation and Contributors</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<license type="expression">Apache-2.0 WITH LLVM-exception</license>
<projectUrl>https://github.com/microsoft/llvmsharp</projectUrl>
Loading