Skip to content

Commit 9ae091f

Browse files
authored
Upgrade .NET to 8.0 and update build scripts. (#22)
1 parent 9e9dbb7 commit 9ae091f

22 files changed

+165
-111
lines changed

.dockerignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.dockerignore
2+
3+
ci/docker/Dockerfile
4+
ci/docker/Dockerfile.base
5+
ci/build-image.sh
6+
7+
integration-test/output

.github/workflows/build.yml

+10-18
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Setup .NET
2222
uses: actions/setup-dotnet@v1
2323
with:
24-
dotnet-version: '6.0.x'
24+
dotnet-version: '8.0.x'
2525
- name: Install Souffle
2626
run: brew install --HEAD souffle-lang/souffle/souffle
2727
- name: Build Souffle program
@@ -55,14 +55,14 @@ jobs:
5555
- name: Setup .NET
5656
uses: actions/setup-dotnet@v1
5757
with:
58-
dotnet-version: '6.0.x'
58+
dotnet-version: '8.0.x'
5959
- name: Build dotnet
6060
run: |
6161
dotnet build
6262
dotnet test --verbosity normal
6363
6464
build-linux:
65-
runs-on: ubuntu-20.04
65+
runs-on: ubuntu-22.04
6666
steps:
6767
- uses: actions/checkout@v2
6868
with:
@@ -85,37 +85,29 @@ jobs:
8585
- name: Setup .NET
8686
uses: actions/setup-dotnet@v1
8787
with:
88-
dotnet-version: '6.0.x'
88+
dotnet-version: '8.0.x'
8989
- name: Setup cmake
9090
uses: jwlawson/[email protected]
9191
with:
9292
cmake-version: '3.21.x'
9393
- name: Setup dependencies
9494
run: |
95-
sudo chmod +x ci/install-lit.sh && sudo ./ci/install-lit.sh
96-
sudo chmod +x ci/install-llvm.sh && sudo ./ci/install-llvm.sh
97-
sudo chmod +x ci/install-mono.sh && sudo ./ci/install-mono.sh
95+
sudo ./ci/install-lit.sh
96+
sudo ./ci/install-llvm.sh
97+
sudo ./ci/install-mono.sh
9898
- name: Build Souffle programs from scratch
9999
run: |
100100
cd $GITHUB_WORKSPACE/souffle && rm -r bin/ && ./build-all-with-docker.sh
101101
- name: Build dotnet
102102
run: |
103103
dotnet build
104104
dotnet test --verbosity normal
105-
- name: Configure LIT test cases
106-
run: |
107-
mkdir build
108-
cd build
109-
cmake ..
110-
- name: Integration test
111-
run: |
112-
cd build
113105
lit integration-test -v
114106
115107
release:
116108
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
117109
needs: [build-macos, build-windows, build-linux]
118-
runs-on: ubuntu-20.04
110+
runs-on: ubuntu-22.04
119111
steps:
120112
- uses: actions/checkout@v2
121113
with:
@@ -138,7 +130,7 @@ jobs:
138130
- name: Setup .NET
139131
uses: actions/setup-dotnet@v1
140132
with:
141-
dotnet-version: '6.0.x'
133+
dotnet-version: '8.0.x'
142134
- name: Build Souffle programs from scratch
143135
run: |
144136
cd $GITHUB_WORKSPACE/souffle && rm -r bin/ && ./build-all-with-docker.sh
@@ -159,7 +151,7 @@ jobs:
159151
mirror:
160152
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
161153
needs: [build-macos, build-windows, build-linux]
162-
runs-on: ubuntu-20.04
154+
runs-on: ubuntu-22.04
163155
steps:
164156
- uses: actions/checkout@v2
165157
with:

.github/workflows/docker-ubuntu.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
- name: Build the Docker image
2121
# On purpose Souffle programs aren't compiled from scratch.
2222
# This is helpful if we forget to update the ones shipped in the repository.
23-
run: cd $GITHUB_WORKSPACE && docker build . --file Dockerfile --tag net-ssa:net-ssa
23+
run: cd $GITHUB_WORKSPACE && ./ci/build-image.sh

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Custom entries
22

33
build/
4+
integration-test/output/
45

56
## Ignore Visual Studio temporary files, build results, and
67
## files generated by popular Visual Studio add-ons.

Dockerfile

-21
This file was deleted.

Dockerfile-souffle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:20.04
1+
FROM ubuntu:22.04
22

33
COPY . /net-ssa
44

README.md

+38-35
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
11
# net-ssa [![.NET (build, test and release if necessary)](https://github.com/m-carrasco/net-ssa/actions/workflows/build.yml/badge.svg?branch=main&event=push)](https://github.com/m-carrasco/net-ssa/actions/workflows/build.yml) [![Docker image](https://github.com/m-carrasco/net-ssa/actions/workflows/docker-ubuntu.yml/badge.svg?branch=main&event=push)](https://github.com/m-carrasco/net-ssa/actions/workflows/docker-ubuntu.yml) ![Nuget](https://img.shields.io/nuget/v/net-ssa-lib)
22

3-
Microsoft's high-level programming languages, such as C#, are compiled to CIL bytecode. The instruction set architecture of CIL operates on a stack virtual machine with local variables. CIL instruction's operands are implicit because they are elements in the stack. `net-ssa` provides a register-based intermediate representation for CIL where operands become explicit.
43

5-
Using CIL properties, it is possible to know for every instruction which slots of the stack it consumes. Similarly, it is possible to know how many elements it pushes into the stack. `net-ssa` computes its initial representation promoting stack slots into registers. In this form, a stack slot promoted to register can be defined more than once. Local variables are accessed through store and load instructions (like LLVM-IR).
4+
Microsoft's high-level programming languages, such as C#, are compiled into Common Intermediate Language (CIL) bytecode. The CIL instruction set operates on a stack virtual machine with implicit operands, as they are elements within the stack. `net-ssa` introduces a register-based intermediate representation for CIL, making operands explicit.
65

7-
The initial register-based representation can be transformed into SSA form. SSA guarantees that every register is only defined once, and its unique definition dominates its uses. This transformation is based on dominance frontiers and partially implemented in Datalog.
6+
CIL properties allow `net-ssa` to determine the stack slots consumed and the pushed elements amount for each instruction. The initial representation involves promoting stack slots into registers using this information. In this stage, a stack slot promoted to a register may have multiple definitions. Local variables are accessed through store and load instructions, similar to LLVM-IR.
87

9-
`net-ssa` can be either used as a library `net-ssa-lib` or as command-line application `net-ssa-cli`.
8+
The initial register-based representation can undergo transformation into Static Single Assignment (SSA) form. SSA ensures that each register is defined only once, and its unique definition dominates its uses. This transformation relies on dominance frontiers and is partially implemented in Datalog.
109

11-
If you have any questions or suggestions, feel free to open an issue to discuss it.
10+
`net-ssa` can be employed either as a library (`net-ssa-lib`) or as a command-line application (`net-ssa-cli`).
11+
12+
Feel free to open an issue to discuss any questions or suggestions you may have.
1213

1314
### Table of Contents
1415

15-
* [Quick setup](#quick-setup)
16-
* [Build from sources](#build-from-sources)
17-
* [Build native dependencies](#build-native-dependencies)
18-
* [Example: net-ssa-cli](#disassembling-with-net-ssa-cli)
19-
* [Example: net-ssa-lib](#disassembling-with-net-ssa-lib)
20-
* [Type inference analysis](#type-inference-analysis)
21-
* [Contributing](#contributing)
22-
* [Acknowledgements](#acknowledgements)
16+
- [net-ssa ](#net-ssa---)
17+
- [Table of Contents](#table-of-contents)
18+
- [Mirror](#mirror)
19+
- [Quick setup](#quick-setup)
20+
- [Build from sources](#build-from-sources)
21+
- [Ubuntu 22.04](#ubuntu-2204)
22+
- [Windows and macOS](#windows-and-macos)
23+
- [Build native dependencies](#build-native-dependencies)
24+
- [Examples](#examples)
25+
- [Disassembling with net-ssa-cli](#disassembling-with-net-ssa-cli)
26+
- [Disassembling with net-ssa-lib](#disassembling-with-net-ssa-lib)
27+
- [Type inference analysis](#type-inference-analysis)
28+
- [Simple type inference analysis](#simple-type-inference-analysis)
29+
- [Precise type inference analysis](#precise-type-inference-analysis)
30+
- [Contributing](#contributing)
31+
- [Acknowledgements](#acknowledgements)
32+
- [License](#license)
2333

2434
## Mirror
2535

@@ -29,43 +39,36 @@ This is caused by Github's Git LFS bandwidth, which is 1GB per month.
2939
## Quick setup
3040

3141
It is possible to develop and test `net-ssa` without installing any dependency in your system but [Docker](https://docs.docker.com/get-docker/).
32-
However, it is adviced to compile the project at least once in the host system. This is mainly for downloading dependencies and correctly setting up any IDE.
3342

3443
1. `git clone [email protected]:m-carrasco/net-ssa.git`
3544
2. `cd net-ssa`
3645
3. `git lfs checkout`
3746
* Install [git lfs](https://git-lfs.github.com/)
38-
4. `dotnet build && dotnet test`
39-
* This is optional, it requires installing dotnet.
40-
5. `docker build -t net-ssa/net-ssa .`
41-
6. `docker run --name dev -v $(pwd):/net-ssa -ti net-ssa/net-ssa`
42-
* This is now an interactive container. `$(pwd)` of the host is shared with the container as `net-ssa` source code folder.
43-
7. Introduce changes in the source code using your IDE as usual.
44-
8. Build and test in the container, execute these commands in the container terminal:
45-
* `cd build`
46-
* `(cd /net-ssa && dotnet build)`
47-
* `lit integration-test/ -vvv`
48-
* `exit # once you finish working`
49-
9. `docker start -i dev # to resume the container terminal`
50-
47+
4. `./scripts/build-image.sh`
48+
5. `./scripts/tmp-container.sh`
49+
* This is now an interactive and temporary container.
50+
* The host's folder containing the repository is shared with the container. In the container, this is located at `/home/ubuntu/net-ssa/`.
51+
6. Introduce changes in the source code using your IDE as usual.
52+
7. Build and test in the container, execute these commands in the container terminal:
53+
* `dotnet build`
54+
* `dotnet test`
55+
* `lit integration-test/ -vvv`
5156

5257
## Build from sources
5358

54-
### Ubuntu 20.04
59+
### Ubuntu 22.04
5560

5661
1. `cd net-ssa`
5762
2. `git lfs checkout`
5863
* Install [git lfs](https://git-lfs.github.com/)
5964
3. `dotnet build`
6065
4. `dotnet test`
61-
5. `mkdir build`
62-
6. `cd build && cmake ..`
63-
7. `lit integration-test/ -vvv`
66+
5. `lit integration-test/ -vvv`
6467

65-
To know the required dependencies for the integration tests (`cmake` and `lit` step), please check the [Dockerfile](https://github.com/m-carrasco/net-ssa/blob/main/Dockerfile).
68+
Please check the [Dockerfile](https://github.com/m-carrasco/net-ssa/blob/main/Dockerfile) to know which dependencies must be installed.
6669
The Dockerfile executes the shell scripts under the [ci](https://github.com/m-carrasco/net-ssa/tree/main/ci) folder. You would just need to execute them once in your system.
6770

68-
### Windows and MacOS
71+
### Windows and macOS
6972

7073
The steps are the same as in Ubuntu. The project building and unit testing is done in the CI. Yet, the integration tests aren't configured.
7174
Anyway, the dependencies should be the same as in Ubuntu. If you encounter any problem while trying this, please open an issue.
@@ -75,9 +78,9 @@ Anyway, the dependencies should be the same as in Ubuntu. If you encounter any p
7578
`net-ssa` has native dependencies, which are shipped in the project already. You shouldn't need to build them. Usually, this is only required for development. The supported systems are:
7679
* Linux - x86-64
7780
* Windows - x86-64
78-
* MacOS - x86-64 and arm64
81+
* macOS - x86-64 and arm64
7982

80-
In case they must be re-built, [`./net-ssa/souffle/build-all-with-docker.sh`](https://github.com/m-carrasco/net-ssa/blob/main/souffle/build-all-with-docker.sh) is available. The script compiles these dependencies from scratch using the source code in your repository. Under the hood, the script isolates this process using Docker. This only builds the Linux and Windows dependencies. Cross-compilation for MacOS is incredible difficult. If you are a MacOS user, check the CI to figure out the required dependencies and execute `build-souffle-macos-x86-64-arm64.sh`.
83+
In case they must be re-built, [`./net-ssa/souffle/build-all-with-docker.sh`](https://github.com/m-carrasco/net-ssa/blob/main/souffle/build-all-with-docker.sh) is available. The script compiles these dependencies from scratch using the source code in your repository. Under the hood, the script isolates this process using Docker. This only builds the Linux and Windows dependencies. Cross-compilation for macOS is incredible difficult. If you are a macOS user, check the CI to figure out the required dependencies and execute `build-souffle-macos-x86-64-arm64.sh`.
8184

8285
## Examples
8386

ci/build-image.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -e
3+
4+
CURRENT_DIR=$(dirname "$(readlink -f "$0")")
5+
6+
pushd $CURRENT_DIR/..
7+
8+
BASE_IMAGE=net-ssa-base:latest
9+
docker build --file $CURRENT_DIR/docker/Dockerfile.base --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) -t $BASE_IMAGE .
10+
docker build --file $CURRENT_DIR/docker/Dockerfile --build-arg BASE_IMAGE=$BASE_IMAGE -t net-ssa:latest .
11+
12+
popd

ci/docker/Dockerfile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ARG BASE_IMAGE
2+
FROM ${BASE_IMAGE}
3+
4+
COPY --chown=ubuntu:mygroup . ${NET_SSA_SRC_DIR}
5+
6+
RUN dotnet build && \
7+
dotnet test --verbosity normal && \
8+
lit ./integration-test -vv

ci/docker/Dockerfile.base

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
ARG REPO=mcr.microsoft.com/dotnet/sdk
2+
FROM $REPO:8.0-jammy
3+
4+
ARG USER_ID
5+
ARG GROUP_ID
6+
7+
# Create a new group and user with the specified IDs
8+
# Set up passwordless sudo access for the non-root user
9+
RUN groupadd -g $GROUP_ID mygroup && \
10+
useradd -u $USER_ID -g $GROUP_ID ubuntu && \
11+
apt-get update && \
12+
apt-get install --no-install-recommends -y sudo && \
13+
echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
14+
15+
# Switch to the new user
16+
USER ubuntu
17+
RUN sudo mkdir -p /home/ubuntu && sudo chown -R ubuntu:mygroup /home/ubuntu
18+
19+
ENV NET_SSA_SRC_DIR=/home/ubuntu/net-ssa/
20+
COPY --chown=ubuntu:mygroup ./ci/ ${NET_SSA_SRC_DIR}/ci
21+
22+
RUN sudo ${NET_SSA_SRC_DIR}/ci/install-souffle.sh && \
23+
sudo ${NET_SSA_SRC_DIR}/ci/install-lit.sh && \
24+
sudo ${NET_SSA_SRC_DIR}/ci/install-llvm.sh && \
25+
sudo ${NET_SSA_SRC_DIR}/ci/install-mono.sh
26+
27+
28+
WORKDIR ${NET_SSA_SRC_DIR}

ci/install-cmake.sh

-3
This file was deleted.

ci/install-lit.sh

100644100755
File mode changed.

ci/install-llvm.sh

100644100755
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22
set -e
3-
apt-get install -y clang++-12 llvm-12 llvm-12-tools && ln -s /usr/bin/llvm-config-12 /usr/bin/llvm-config
3+
apt-get install -y clang++-12 llvm-12 llvm-12-tools

ci/install-mingw32.sh

100644100755
File mode changed.

ci/install-mono.sh

100644100755
File mode changed.

ci/install-souffle.sh

100644100755
File mode changed.

ci/tmp-container.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -e
3+
4+
CURRENT_DIR=$(dirname "$(readlink -f "$0")")
5+
6+
pushd $CURRENT_DIR/..
7+
docker run --rm -it -v $(pwd):/home/ubuntu/net-ssa net-ssa:latest
8+
popd

0 commit comments

Comments
 (0)