Skip to content

Commit

Permalink
Merge branch 'main' into issue-80666
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotas authored Jul 24, 2024
2 parents 3a3b902 + 7847b75 commit 7f182b6
Show file tree
Hide file tree
Showing 87 changed files with 1,104 additions and 1,863 deletions.
11 changes: 9 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@
ARG VARIANT="6.0-jammy"
FROM mcr.microsoft.com/devcontainers/dotnet:0-${VARIANT}

# Set up machine requirements to build the repo and the gh CLI
# Clang-16 up is required but Ubuntu 22.04 comes with clang-14 highest, so add clang-18 sources
RUN apt-get update \
&& wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - \
&& apt-get install software-properties-common -y \
&& add-apt-repository "deb http://apt.llvm.org/$(lsb_release -s -c)/ llvm-toolchain-$(lsb_release -s -c)-18 main" -y \
&& apt-get update \
&& apt-get install clang-18 -y

# Set up machine requirements to build the repo and the gh CLI
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
cmake \
llvm \
clang \
build-essential \
python3 \
curl \
Expand Down
11 changes: 9 additions & 2 deletions .devcontainer/wasm-multiThreaded/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@
ARG VARIANT="6.0-jammy"
FROM mcr.microsoft.com/devcontainers/dotnet:0-${VARIANT}

# Set up machine requirements to build the repo and the gh CLI
# Clang-16 up is required but Ubuntu 22.04 comes with clang-14 highest, so add clang-18 sources
RUN apt-get update \
&& wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - \
&& apt-get install software-properties-common -y \
&& add-apt-repository "deb http://apt.llvm.org/$(lsb_release -s -c)/ llvm-toolchain-$(lsb_release -s -c)-18 main" -y \
&& apt-get update \
&& apt-get install clang-18 -y

# Set up machine requirements to build the repo and the gh CLI
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
cmake \
llvm \
clang \
build-essential \
python3 \
curl \
Expand Down
10 changes: 8 additions & 2 deletions .devcontainer/wasm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ ARG VARIANT="6.0-jammy"
FROM mcr.microsoft.com/devcontainers/dotnet:0-${VARIANT}

# Set up machine requirements to build the repo and the gh CLI
# Clang-16 up is required but Ubuntu 22.04 comes with clang-14 highest, so add clang-18 sources
RUN apt-get update \
&& wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - \
&& apt-get install software-properties-common -y \
&& add-apt-repository "deb http://apt.llvm.org/$(lsb_release -s -c)/ llvm-toolchain-$(lsb_release -s -c)-18 main" -y \
&& apt-get update \
&& apt-get install clang-18 -y

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
cmake \
llvm \
clang \
build-essential \
python3 \
curl \
Expand Down
3 changes: 2 additions & 1 deletion docs/workflow/requirements/linux-requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Install the following packages for the toolchain:
* CMake 3.20 or newer
* llvm
* lld
* clang
* clang 16 or newer
* build-essential
* python-is-python3
* curl
Expand All @@ -59,6 +59,7 @@ sudo apt install -y cmake llvm lld clang build-essential \
```

**NOTE**: As of now, Ubuntu's `apt` only has until CMake version 3.16.3 if you're using Ubuntu 20.04 LTS (less in older Ubuntu versions), and version 3.18.4 in Debian 11 (less in older Debian versions). This is lower than the required 3.20, which in turn makes it incompatible with the repo. For this case, we can use the `snap` package manager or the _Kitware APT feed_ to get a new enough version of CMake.
**NOTE**: If you have Ubuntu 22.04 LTS and older and your `apt` does not have clang version 16, you can add `"deb http://apt.llvm.org/$(lsb_release -s -c)/ llvm-toolchain-$(lsb_release -s -c)-18 main"` repository to your `apt`. See how we do it for linux-based containers [here](./../../../.devcontainer/Dockerfile).

For snap:

Expand Down
8 changes: 4 additions & 4 deletions eng/pipelines/coreclr/templates/build-perf-sample-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ steps:
displayName: clean bindir

- ${{ if and(eq(parameters.osGroup, 'ios'), eq(parameters.nameSuffix, 'iOSMono')) }}:
- script: make build-appbundle TARGET=ios MONO_ARCH=arm64 MONO_CONFIG=Release AOT=True USE_LLVM=False DEPLOY_AND_RUN=false STRIP_DEBUG_SYMBOLS=false HYBRID_GLOBALIZATION=${{ parameters.hybridGlobalization }}
- script: make build-appbundle TARGET_OS=ios TARGET_ARCH=arm64 BUILD_CONFIG=Release AOT=True USE_LLVM=False DEPLOY_AND_RUN=false STRIP_DEBUG_SYMBOLS=false HYBRID_GLOBALIZATION=${{ parameters.hybridGlobalization }}
env:
DevTeamProvisioning: '-'
workingDirectory: $(Build.SourcesDirectory)/src/mono/sample/iOS
Expand All @@ -60,7 +60,7 @@ steps:
- script: rm -r -f $(Build.SourcesDirectory)/src/mono/sample/iOS/bin
workingDirectory: $(Build.SourcesDirectory)/src/mono/sample/iOS
displayName: Clean bindir
- script: make build-appbundle TARGET=ios MONO_ARCH=arm64 MONO_CONFIG=Release AOT=True USE_LLVM=False DEPLOY_AND_RUN=false STRIP_DEBUG_SYMBOLS=true HYBRID_GLOBALIZATION=${{ parameters.hybridGlobalization }}
- script: make build-appbundle TARGET_OS=ios TARGET_ARCH=arm64 BUILD_CONFIG=Release AOT=True USE_LLVM=False DEPLOY_AND_RUN=false STRIP_DEBUG_SYMBOLS=true HYBRID_GLOBALIZATION=${{ parameters.hybridGlobalization }}
env:
DevTeamProvisioning: '-'
workingDirectory: $(Build.SourcesDirectory)/src/mono/sample/iOS
Expand All @@ -82,7 +82,7 @@ steps:
- script: rm -r -f $(Build.SourcesDirectory)/src/mono/sample/iOS/bin
workingDirectory: $(Build.SourcesDirectory)/src/mono/sample/iOS
displayName: Clean bindir
- script: make build-appbundle TARGET=ios MONO_ARCH=arm64 MONO_CONFIG=Release AOT=True USE_LLVM=True DEPLOY_AND_RUN=false STRIP_DEBUG_SYMBOLS=false HYBRID_GLOBALIZATION=${{ parameters.hybridGlobalization }}
- script: make build-appbundle TARGET_OS=ios TARGET_ARCH=arm64 BUILD_CONFIG=Release AOT=True USE_LLVM=True DEPLOY_AND_RUN=false STRIP_DEBUG_SYMBOLS=false HYBRID_GLOBALIZATION=${{ parameters.hybridGlobalization }}
env:
DevTeamProvisioning: '-'
workingDirectory: $(Build.SourcesDirectory)/src/mono/sample/iOS
Expand All @@ -104,7 +104,7 @@ steps:
- script: rm -r -f $(Build.SourcesDirectory)/src/mono/sample/iOS/bin
workingDirectory: $(Build.SourcesDirectory)/src/mono/sample/iOS
displayName: Clean bindir
- script: make build-appbundle TARGET=ios MONO_ARCH=arm64 MONO_CONFIG=Release AOT=True USE_LLVM=True DEPLOY_AND_RUN=false STRIP_DEBUG_SYMBOLS=true HYBRID_GLOBALIZATION=${{ parameters.hybridGlobalization }}
- script: make build-appbundle TARGET_OS=ios TARGET_ARCH=arm64 BUILD_CONFIG=Release AOT=True USE_LLVM=True DEPLOY_AND_RUN=false STRIP_DEBUG_SYMBOLS=true HYBRID_GLOBALIZATION=${{ parameters.hybridGlobalization }}
env:
DevTeamProvisioning: '-'
workingDirectory: $(Build.SourcesDirectory)/src/mono/sample/iOS
Expand Down
34 changes: 0 additions & 34 deletions src/coreclr/dlls/mscordac/update.pl

This file was deleted.

9 changes: 9 additions & 0 deletions src/coreclr/ilasm/GrammarExtractor/GrammarExtractor.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>$(NetCoreAppToolCurrent)</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
98 changes: 98 additions & 0 deletions src/coreclr/ilasm/GrammarExtractor/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.IO;
using System.Text.RegularExpressions;
using static Patterns;

if (args.Length != 1)
{
Console.Error.WriteLine("Usage: <file>");
return 1;
}

string filePath = args[0];

string fileContent = File.ReadAllText(filePath);

var match = GetRegexExtractMarkers().Match(fileContent);
if (!match.Success)
{
Console.Error.WriteLine("Could not find %% markers");
return 1;
}

//string prefix = match.Groups[1].Value;
string grammar = match.Groups[2].Value;

// Remove any text in {}
var regexRemoveTextInBraces = GetRegexRemoveTextInBraces();
string previousGrammar;

do
{
previousGrammar = grammar;
grammar = regexRemoveTextInBraces.Replace(grammar, "$1");
} while (grammar != previousGrammar);

// Change keyword identifiers into the string they represent (lowercase)
grammar = GetRegexKeywordIdentifiers().Replace(grammar, m => $"'{m.Groups[1].Value.ToLowerInvariant()}'");

// Change assembler directives into their string (lowercase with a period)
grammar = GetRegexAssemblerDirectives().Replace(grammar, m => $"'.{m.Groups[1].Value.ToLowerInvariant()}'");

// Handle special punctuation
grammar = GetRegexEllipsis().Replace(grammar, "'...'");
grammar = GetRegexDcolon().Replace(grammar, "'::'");

// Print the output header
Console.Write(@"// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
Lexical tokens
ID - C style alphaNumeric identifier (e.g. Hello_There2)
DOTTEDNAME - Sequence of dot-separated IDs (e.g. System.Object)
QSTRING - C style quoted string (e.g. ""hi\n"")
SQSTRING - C style singlely quoted string(e.g. 'hi')
INT32 - C style 32 bit integer (e.g. 235, 03423, 0x34FFF)
INT64 - C style 64 bit integer (e.g. -2353453636235234, 0x34FFFFFFFFFF)
FLOAT64 - C style floating point number (e.g. -0.2323, 354.3423, 3435.34E-5)
INSTR_* - IL instructions of a particular class (see opcode.def).
HEXBYTE - 1- or 2-digit hexadecimal number (e.g., A2, F0).
Auxiliary lexical tokens
TYPEDEF_T - Aliased class (TypeDef or TypeRef).
TYPEDEF_M - Aliased method.
TYPEDEF_F - Aliased field.
TYPEDEF_TS - Aliased type specification (TypeSpec).
TYPEDEF_MR - Aliased field/method reference (MemberRef).
TYPEDEF_CA - Aliased Custom Attribute.
----------------------------------------------------------------------------------
START : decls
;");

// Print the output
Console.Write(grammar);

return 0;

internal static partial class Patterns
{
[GeneratedRegex(@"^(.*)%%(.*)%%", RegexOptions.Singleline)]
internal static partial Regex GetRegexExtractMarkers();

[GeneratedRegex(@"\s*([^'])\{[^{}]*\}", RegexOptions.Singleline)]
internal static partial Regex GetRegexRemoveTextInBraces();

[GeneratedRegex(@"\b([A-Z0-9_]+)_\b", RegexOptions.Singleline)]
internal static partial Regex GetRegexKeywordIdentifiers();

[GeneratedRegex(@"\b_([A-Z0-9]+)\b", RegexOptions.Singleline)]
internal static partial Regex GetRegexAssemblerDirectives();

[GeneratedRegex(@"\bELLIPSIS\b", RegexOptions.Singleline)]
internal static partial Regex GetRegexEllipsis();

[GeneratedRegex(@"\bDCOLON\b", RegexOptions.Singleline)]
internal static partial Regex GetRegexDcolon();
}
10 changes: 10 additions & 0 deletions src/coreclr/ilasm/GrammarExtractor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Grammar extractor for IL tools

Tool to extract IL grammar in `Backus-Naur Form (BNF)` from `Yet Another Compiler-Compiler (Yacc)`.

Usage:

```sh
cd runtime
./dotnet.sh run --project src/coreclr/ilasm/GrammarExtractor src/coreclr/ilasm/asmparse.y > src/coreclr/ilasm/prebuilt/asmparse.grammar
```
1 change: 1 addition & 0 deletions src/coreclr/ilasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ $ docker run --rm -v$(pwd):/runtime -w /runtime/src/coreclr/ilasm alpine \
sh -c 'apk add bison && yacc asmparse.y -o prebuilt/asmparse.cpp'
```

To generate grammar, see [GrammarExtractor README](GrammarExtractor/README.md).
59 changes: 0 additions & 59 deletions src/coreclr/ilasm/extractGrammar.pl

This file was deleted.

6 changes: 3 additions & 3 deletions src/coreclr/ilasm/prebuilt/asmparse.grammar
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ dottedName : id
| dottedName '.' dottedName
;

int32 : INT32
int32 : INT32_V
;

int64 : INT64
| INT32
int64 : INT64_V
| INT32_V
;

float64 : FLOAT64
Expand Down
Loading

0 comments on commit 7f182b6

Please sign in to comment.