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

X86 64 gcc #130

Merged
merged 7 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions .github/actions/bench/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ inputs:
gh_token:
description: GitHub access token
required: true
use-nix:
description: Whether to run in the default Nix environment
default: "true"
nix-shell:
description: Run in the specified Nix environment if exists
default: "ci"
custom_shell:
description: The shell to use. Only relevant if use-nix is "false"
description: The shell to use. Only relevant if no nix-shell specified
default: "bash"
cross_prefix:
description: "Binary prefix for cross-compilation builds"
Expand All @@ -42,10 +42,10 @@ runs:
using: composite
steps:
- name: Setup nix
if: ${{ inputs.use-nix }}
if: ${{ inputs.nix-shell != '' }}
uses: ./.github/actions/setup-nix
with:
devShell: ci
devShell: ${{ inputs.nix-shell }}
script: |
ARCH=$(uname -m)
cat >> $GITHUB_STEP_SUMMARY <<-EOF
Expand All @@ -61,7 +61,12 @@ runs:
EOF
- name: Set shell
shell: bash
run: echo SHELL="${{ inputs.use-nix && 'nix develop .#ci -c bash -e {0}' || inputs.custom_shell }}" >> $GITHUB_ENV
run: |
if [[ ${{ inputs.nix-shell }} != '' ]]; then
echo SHELL="nix develop .#${{ inputs.nix-shell }} -c bash -e {0}" >> $GITHUB_ENV
else
echo SHELL="${{ inputs.custom_shell }}" >> $GITHUB_ENV
fi
- name: Run benchmark
shell: ${{ env.SHELL }}
run: |
Expand Down
17 changes: 11 additions & 6 deletions .github/actions/cbmc/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ name: CBMC
description: Run CBMC proofs for MLKEM-C_AArch64

inputs:
use-nix:
description: Whether to run in the default Nix environment
default: "true"
nix-shell:
description: Run in the specified Nix environment if exists
default: "ci-cbmc"
custom_shell:
description: The shell to use. Only relevant if use-nix is 'false'
default: "bash"
Expand All @@ -18,10 +18,10 @@ runs:
steps:
- uses: actions/checkout@v4
- name: Setup nix
if: ${{ inputs.use-nix }}
if: ${{ inputs.nix-shell != '' }}
uses: ./.github/actions/setup-nix
with:
devShell: ci-cbmc
devShell: ${{ inputs.nix-shell }}
script: |
cat >> $GITHUB_STEP_SUMMARY << EOF
## Setup
Expand All @@ -35,7 +35,12 @@ runs:
EOF
- name: Set shell
shell: bash
run: echo SHELL="${{ inputs.use-nix && 'nix develop .#ci-cbmc -c bash -e {0}' || inputs.custom_shell }}" >> $GITHUB_ENV
run: |
if [[ ${{ inputs.nix-shell }} != '' ]]; then
echo SHELL="nix develop .#${{ inputs.nix-shell }} -c bash -e {0}" >> $GITHUB_ENV
else
echo SHELL="${{ inputs.custom_shell }}" >> $GITHUB_ENV
fi
- name: Run CBMC proofs
shell: ${{ env.SHELL }}
run: |
Expand Down
20 changes: 14 additions & 6 deletions .github/actions/functest/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ name: Functional tests
description: Run functional tests for MLKEM-C_AArch64

inputs:
use-nix:
description: Whether to run in the default Nix environment
default: "true"
nix-shell:
description: Run in the specified Nix environment if exists
default: "ci"
custom_shell:
description: The shell to use. Only relevant if no nix-shell specified
default: "bash"
cflags:
description: CFLAGS to pass to compilation
default: ""
Expand All @@ -21,9 +24,9 @@ runs:
steps:
- name: Setup nix
uses: ./.github/actions/setup-nix
if: ${{ inputs.use-nix }}
if: ${{ inputs.nix-shell != '' }}
with:
devShell: ci
devShell: ${{ inputs.nix-shell }}
script: |
ARCH=$(uname -m)
cat >> $GITHUB_STEP_SUMMARY <<-EOF
Expand All @@ -36,7 +39,12 @@ runs:
EOF
- name: Set shell
shell: bash
run: echo SHELL="${{ inputs.use-nix && 'nix develop .#ci -c bash -e {0}' || inputs.custom_shell }}" >> $GITHUB_ENV
run: |
if [[ ${{ inputs.nix-shell }} != '' ]]; then
echo SHELL="nix develop .#${{ inputs.nix-shell }} -c bash -e {0}" >> $GITHUB_ENV
else
echo SHELL="${{ inputs.custom_shell }}" >> $GITHUB_ENV
fi
- name: Run functional tests
id: func_test
shell: ${{ env.SHELL }}
Expand Down
19 changes: 12 additions & 7 deletions .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ name: Lint
description: Lint MLKEM-C_AArch64

inputs:
use-nix:
description: Whether to run in the default Nix environment
default: "true"
nix-shell:
description: Run in the specified Nix environment if exists
default: "ci-linter"
custom_shell:
description: The shell to use. Only relevant if use-nix is 'false'
description: The shell to use. Only relevant if no nix-shell specified
default: "bash"
cross-prefix:
description: Binary prefix for cross compilation
Expand All @@ -17,10 +17,10 @@ runs:
using: composite
steps:
- name: Setup nix
if: ${{ inputs.use-nix }}
if: ${{ inputs.nix-shell != '' }}
uses: ./.github/actions/setup-nix
with:
devShell: ci-linter
devShell: ${{ inputs.nix-shell }}
script: |
cat >> $GITHUB_STEP_SUMMARY << EOF
## Setup
Expand All @@ -33,7 +33,12 @@ runs:
EOF
- name: Set shell
shell: bash
run: echo SHELL="${{ inputs.use-nix && 'nix develop .#ci-linter -c bash -e {0}' || inputs.custom_shell }}" >> $GITHUB_ENV
run: |
if [[ ${{ inputs.nix-shell }} != '' ]]; then
echo SHELL="nix develop .#${{ inputs.nix-shell }} -c bash -e {0}" >> $GITHUB_ENV
else
echo SHELL="${{ inputs.custom_shell }}" >> $GITHUB_ENV
fi
- name: Run linter
shell: ${{ env.SHELL }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bench_ec2_reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
- uses: actions/checkout@v4
- uses: ./.github/actions/bench
with:
use-nix: true
nix-shell: ci
name: ${{ inputs.name }}
cflags: ${{ inputs.cflags }}
archflags: ${{ inputs.archflags }}
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,33 @@ jobs:
arch: 'arm64'
cross-prefix: ' '
cflags: '-DFORCE_AARCH64'
nix-shell: ci
- runner: pqcp-arm64
name: 'ubuntu-latest (aarch64)'
arch: 'aarch64'
cross-prefix: ' '
cflags: '-DFORCE_AARCH64'
nix-shell: 'ci'
- runner: ubuntu-latest
name: 'ubuntu-latest (x86_64, cross)'
arch: 'x86_64'
cross-prefix: 'aarch64-unknown-linux-gnu-'
cflags: '-DFORCE_AARCH64'
nix-shell: 'x86_64-linux-cross-ci'
- runner: ubuntu-latest
name: 'ubuntu-latest (x86_64, native)'
arch: 'x86_64'
cross-prefix: ''
nix-shell: 'ci'
exclude:
- {external: true,
target: {
runner: 'pqcp-arm64',
name: 'ubuntu-latest (aarch64)',
arch: 'aarch64',
cross-prefix: ' ',
cflags: '-DFORCE_AARCH64'
cflags: '-DFORCE_AARCH64',
nix-shell: 'ci'
}}
name: Functional tests (${{ matrix.target.name }})
runs-on: ${{ matrix.target.runner }}
Expand All @@ -49,14 +54,14 @@ jobs:
- name: functest opt
uses: ./.github/actions/functest
with:
use-nix: true
nix-shell: ${{ matrix.target.nix-shell }}
cflags: ${{ matrix.target.cflags }}
cross-prefix: ${{ matrix.target.cross-prefix }}
opt: true
- name: functest non-opt
uses: ./.github/actions/functest
with:
use-nix: true
nix-shell: ${{ matrix.target.nix-shell }}
cflags: ${{ matrix.target.cflags }}
cross-prefix: ${{ matrix.target.cross-prefix }}
opt: false
Expand All @@ -70,7 +75,7 @@ jobs:
- uses: actions/checkout@v4
- uses: ./.github/actions/lint
with:
use-nix: true
nix-shell: ci-linter
cross-prefix: "aarch64-unknown-linux-gnu-"
cbmc:
strategy:
Expand All @@ -82,4 +87,4 @@ jobs:
- uses: actions/checkout@v4
- uses: ./.github/actions/cbmc
with:
use-nix: true
nix-shell: ci-cbmc
6 changes: 3 additions & 3 deletions .github/workflows/ci_ec2_reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
- uses: actions/checkout@v4
- uses: ./.github/actions/functest
with:
use-nix: true
nix-shell: ci
cflags: ${{ inputs.cflags }}
cross-prefix: ${{ inputs.cross-prefix }}
opt: ${{ inputs.opt }}
Expand All @@ -117,7 +117,7 @@ jobs:
- uses: actions/checkout@v4
- uses: ./.github/actions/lint
with:
use-nix: true
nix-shell: ci-linter
cross-prefix: ${{ inputs.cross-prefix }}
cbmc:
name: CBMC ${{ inputs.name }}
Expand All @@ -128,7 +128,7 @@ jobs:
- uses: actions/checkout@v4
- uses: ./.github/actions/cbmc
with:
use-nix: true
nix-shell: ci-cbmc
cross-prefix: ${{ inputs.cross-prefix }}
stop-ec2-runner:
name: Stop ${{ inputs.name }} (${{ inputs.ec2_instance_type }})
Expand Down
71 changes: 53 additions & 18 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,41 @@
black;
};

core =
aarch64-gcc = [
(
pkgs.pkgsCross.aarch64-multiplatform.buildPackages.gcc13.override {
propagateDoc = true;
isGNU = true;
}
)
pkgs.pkgsCross.aarch64-multiplatform.glibc
pkgs.pkgsCross.aarch64-multiplatform.glibc.static
];

native-gcc = [
(pkgs.gcc13.override {
propagateDoc = true;
isGNU = true;
})
pkgs.glibc
pkgs.glibc.static
];

core = { cross ? false }:
let
aarch64-gcc =
pkgs.lib.optionals
(! (pkgs.stdenv.isDarwin && pkgs.stdenv.isAarch64))
[
(
pkgs.pkgsCross.aarch64-multiplatform.buildPackages.gcc13.override {
propagateDoc = true;
isGNU = true;
}
)
pkgs.pkgsCross.aarch64-multiplatform.glibc
pkgs.pkgsCross.aarch64-multiplatform.glibc.static
];
gcc =
if pkgs.stdenv.isDarwin
then
if pkgs.stdenv.isx86_64
then [ ]
else aarch64-gcc
else
if cross
then aarch64-gcc
else native-gcc
;
in
aarch64-gcc ++
gcc ++
builtins.attrValues {
inherit (pkgs)
yq
Expand All @@ -75,16 +93,33 @@
in
{
devShells.default = wrapShell pkgs.mkShellNoCC {
packages = core ++ linters ++ cbmcpkg ++
packages = core { } ++ linters ++ cbmcpkg ++
builtins.attrValues {
inherit (pkgs)
direnv
nix-direnv;
};
};

devShells.ci = wrapShell pkgs.mkShellNoCC { packages = core; };
devShells.ci-cbmc = wrapShell pkgs.mkShellNoCC { packages = (core ++ cbmcpkg); };
devShells.x86_64-linux-cross = wrapShell pkgs.mkShellNoCC {
packages = core { cross = true; } ++ linters ++ cbmcpkg ++
builtins.attrValues {
inherit (pkgs)
direnv
nix-direnv;
};
};

devShells.ci = wrapShell pkgs.mkShellNoCC { packages = core { }; };
devShells.x86_64-linux-cross-ci = wrapShell pkgs.mkShellNoCC {
packages = core { cross = true; };
};

devShells.ci-cbmc = wrapShell pkgs.mkShellNoCC { packages = core { } ++ cbmcpkg; };
devShells.x86_64-linux-cross-ci-cbmc = wrapShell pkgs.mkShellNoCC {
packages = core { cross = true; } ++ cbmcpkg;
};

devShells.ci-linter = wrapShell pkgs.mkShellNoCC { packages = linters; };
};
flake = {
Expand Down
2 changes: 1 addition & 1 deletion mk/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ QEMU = qemu-aarch64

HOST_PLATFORM := $(shell uname -s)-$(shell uname -m)
ifeq ($(HOST_PLATFORM),Linux-x86_64)
CFLAGS += -static
CFLAGS += -z noexecstack
endif

CYCLES ?= NO
Expand Down
Loading