Merge branch 'main' into signing_guide

This commit is contained in:
Brendan Hansknecht 2023-09-10 03:48:29 +00:00 committed by GitHub
commit 74471cb83a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 154 additions and 93 deletions

57
.github/workflows/devtools_test.yml vendored Normal file
View File

@ -0,0 +1,57 @@
on:
pull_request:
name: Test the devtools nix files
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
devtools-test:
name: devtools-test
runs-on: [ubuntu-20.04]
timeout-minutes: 120
steps:
- uses: actions/checkout@v3
- name: Only run all steps if flake.lock changed
id: checklock
run: |
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep 'flake.lock'; then
echo "Flake.lock was changed. Testing devtools nix files..."
echo "::set-output name=changed::true"
else
echo "Flake.lock was not changed. No need to run tests."
echo "::set-output name=changed::false"
fi
- uses: cachix/install-nix-action@v23
if: steps.checklock.outputs.changed == 'true'
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: test devtools/flake.nix
if: steps.checklock.outputs.changed == 'true'
id: devtools_test_step
run: |
sed -i "s|/home/username/gitrepos/roc|$(realpath .)|g" devtools/flake.nix
cat devtools/flake.nix
mkdir -p ../temp
cp devtools/flake.nix ../temp
cp devtools/flake.lock ../temp
cd ../temp
git init
git add flake.nix flake.lock
nix develop
- name: Print tip on fail
if: steps.devtools_test_step.outcome == 'failure'
run: |
echo "The devtools test failed, this can likely be fixed by"
echo "locally deleting devtools/flake.lock and following the"
echo "instructions in devtools/README.md. This will create a"
echo "new flake.lock you should use to replace the old devtools/flake.lock"

View File

@ -1005,12 +1005,12 @@ expect
# We have decided not to expose the standard roc hashing algorithm.
# This is to avoid external dependence and the need for versioning.
# The current implementation is a form of [Wyhash final3](https://github.com/wangyi-fudan/wyhash/blob/a5995b98ebfa7bd38bfadc0919326d2e7aabb805/wyhash.h).
# The current implementation is a form of [Wyhash final4](https://github.com/wangyi-fudan/wyhash/blob/77e50f267fbc7b8e2d09f2d455219adb70ad4749/wyhash.h).
# It is 64bit and little endian specific currently.
# TODO: wyhash is slow for large keys, use something like cityhash if the keys are too long.
# TODO: Add a builtin to distinguish big endian systems and change loading orders.
# TODO: Switch out Wymum on systems with slow 128bit multiplication.
LowLevelHasher := { originalSeed : U64, state : U64 } implements [
LowLevelHasher := { initializedSeed : U64, state : U64 } implements [
Hasher {
addBytes,
addU8,
@ -1036,14 +1036,30 @@ createLowLevelHasher = \seedOpt ->
when seedOpt is
PseudoRandSeed -> pseudoSeed {}
WithSeed s -> s
@LowLevelHasher { originalSeed: seed, state: seed }
@LowLevelHasher { initializedSeed: initSeed seed, state: seed }
combineState : LowLevelHasher, { a : U64, b : U64, seed : U64, length : U64 } -> LowLevelHasher
combineState = \@LowLevelHasher { originalSeed, state }, { a, b, seed, length } ->
tmp = wymix (Num.bitwiseXor wyp1 a) (Num.bitwiseXor seed b)
hash = wymix (Num.bitwiseXor wyp1 length) tmp
combineState = \@LowLevelHasher { initializedSeed, state }, { a, b, seed, length } ->
mum =
a
|> Num.bitwiseXor wyp1
|> wymum (Num.bitwiseXor b seed)
nexta =
mum.lower
|> Num.bitwiseXor wyp0
|> Num.bitwiseXor length
nextb =
mum.upper
|> Num.bitwiseXor wyp1
hash = wymix nexta nextb
@LowLevelHasher { originalSeed, state: wymix state hash }
@LowLevelHasher { initializedSeed, state: wymix state hash }
initSeed = \seed ->
seed
|> Num.bitwiseXor wyp0
|> wymix wyp1
|> Num.bitwiseXor seed
complete = \@LowLevelHasher { state } -> state
@ -1052,8 +1068,7 @@ complete = \@LowLevelHasher { state } -> state
# like using the output of the last hash as the seed to the current hash.
# I am simply not sure the tradeoffs here. Theoretically this method is more sound.
# Either way, the performance will be similar and we can change this later.
addU8 = \@LowLevelHasher { originalSeed, state }, u8 ->
seed = Num.bitwiseXor originalSeed wyp0
addU8 = \@LowLevelHasher { initializedSeed, state }, u8 ->
p0 = Num.toU64 u8
a =
Num.shiftLeftBy p0 16
@ -1061,10 +1076,9 @@ addU8 = \@LowLevelHasher { originalSeed, state }, u8 ->
|> Num.bitwiseOr p0
b = 0
combineState (@LowLevelHasher { originalSeed, state }) { a, b, seed, length: 1 }
combineState (@LowLevelHasher { initializedSeed, state }) { a, b, seed: initializedSeed, length: 1 }
addU16 = \@LowLevelHasher { originalSeed, state }, u16 ->
seed = Num.bitwiseXor originalSeed wyp0
addU16 = \@LowLevelHasher { initializedSeed, state }, u16 ->
p0 = Num.bitwiseAnd u16 0xFF |> Num.toU64
p1 = Num.shiftRightZfBy u16 8 |> Num.toU64
a =
@ -1073,26 +1087,23 @@ addU16 = \@LowLevelHasher { originalSeed, state }, u16 ->
|> Num.bitwiseOr p1
b = 0
combineState (@LowLevelHasher { originalSeed, state }) { a, b, seed, length: 2 }
combineState (@LowLevelHasher { initializedSeed, state }) { a, b, seed: initializedSeed, length: 2 }
addU32 = \@LowLevelHasher { originalSeed, state }, u32 ->
seed = Num.bitwiseXor originalSeed wyp0
addU32 = \@LowLevelHasher { initializedSeed, state }, u32 ->
p0 = Num.toU64 u32
a = Num.shiftLeftBy p0 32 |> Num.bitwiseOr p0
combineState (@LowLevelHasher { originalSeed, state }) { a, b: a, seed, length: 4 }
combineState (@LowLevelHasher { initializedSeed, state }) { a, b: a, seed: initializedSeed, length: 4 }
addU64 = \@LowLevelHasher { originalSeed, state }, u64 ->
seed = Num.bitwiseXor originalSeed wyp0
addU64 = \@LowLevelHasher { initializedSeed, state }, u64 ->
p0 = Num.bitwiseAnd 0xFFFF_FFFF u64
p1 = Num.shiftRightZfBy u64 32
a = Num.shiftLeftBy p0 32 |> Num.bitwiseOr p1
b = Num.shiftLeftBy p1 32 |> Num.bitwiseOr p0
combineState (@LowLevelHasher { originalSeed, state }) { a, b, seed, length: 8 }
combineState (@LowLevelHasher { initializedSeed, state }) { a, b, seed: initializedSeed, length: 8 }
addU128 = \@LowLevelHasher { originalSeed, state }, u128 ->
seed = Num.bitwiseXor originalSeed wyp0
addU128 = \@LowLevelHasher { initializedSeed, state }, u128 ->
lower = u128 |> Num.toU64
upper = Num.shiftRightZfBy u128 64 |> Num.toU64
p0 = Num.bitwiseAnd 0xFFFF_FFFF lower
@ -1102,12 +1113,11 @@ addU128 = \@LowLevelHasher { originalSeed, state }, u128 ->
a = Num.shiftLeftBy p0 32 |> Num.bitwiseOr p2
b = Num.shiftLeftBy p3 32 |> Num.bitwiseOr p1
combineState (@LowLevelHasher { originalSeed, state }) { a, b, seed, length: 16 }
combineState (@LowLevelHasher { initializedSeed, state }) { a, b, seed: initializedSeed, length: 16 }
addBytes : LowLevelHasher, List U8 -> LowLevelHasher
addBytes = \@LowLevelHasher { originalSeed, state }, list ->
addBytes = \@LowLevelHasher { initializedSeed, state }, list ->
length = List.len list
seed = Num.bitwiseXor originalSeed wyp0
abs =
if length <= 16 then
if length >= 4 then
@ -1117,17 +1127,17 @@ addBytes = \@LowLevelHasher { originalSeed, state }, list ->
(wyr4 list (Num.subWrap length 4) |> Num.shiftLeftBy 32)
|> Num.bitwiseOr (wyr4 list (Num.subWrap length 4 |> Num.subWrap x))
{ a, b, seed }
{ a, b, seed: initializedSeed }
else if length > 0 then
{ a: wyr3 list 0 length, b: 0, seed }
{ a: wyr3 list 0 length, b: 0, seed: initializedSeed }
else
{ a: 0, b: 0, seed }
{ a: 0, b: 0, seed: initializedSeed }
else if length <= 48 then
hashBytesHelper16 seed list 0 length
hashBytesHelper16 initializedSeed list 0 length
else
hashBytesHelper48 seed seed seed list 0 length
hashBytesHelper48 initializedSeed initializedSeed initializedSeed list 0 length
combineState (@LowLevelHasher { originalSeed, state }) { a: abs.a, b: abs.b, seed: abs.seed, length: Num.toU64 length }
combineState (@LowLevelHasher { initializedSeed, state }) { a: abs.a, b: abs.b, seed: abs.seed, length: Num.toU64 length }
hashBytesHelper48 : U64, U64, U64, List U8, Nat, Nat -> { a : U64, b : U64, seed : U64 }
hashBytesHelper48 = \seed, see1, see2, list, index, remaining ->
@ -1240,7 +1250,7 @@ expect
|> addBytes []
|> complete
hash == 0x1C3F_F8BF_07F9_B0B3
hash == 0xD59C59757DBBE6B3
expect
hash =
@ -1248,7 +1258,7 @@ expect
|> addBytes [0x42]
|> complete
hash == 0x8F9F_0A1E_E06F_0D52
hash == 0x38CE03D0E61AF963
expect
hash =
@ -1256,7 +1266,7 @@ expect
|> addU8 0x42
|> complete
hash == 0x8F9F_0A1E_E06F_0D52
hash == 0x38CE03D0E61AF963
expect
hash =
@ -1264,7 +1274,7 @@ expect
|> addBytes [0xFF, 0xFF]
|> complete
hash == 0x86CC_8B71_563F_F084
hash == 0xE1CB2FA0D6A64113
expect
hash =
@ -1272,7 +1282,7 @@ expect
|> addU16 0xFFFF
|> complete
hash == 0x86CC_8B71_563F_F084
hash == 0xE1CB2FA0D6A64113
expect
hash =
@ -1280,7 +1290,7 @@ expect
|> addBytes [0x36, 0xA7]
|> complete
hash == 0xD1A5_0F24_2536_84F8
hash == 0x26B8319EDAF81B15
expect
hash =
@ -1288,7 +1298,7 @@ expect
|> addU16 0xA736
|> complete
hash == 0xD1A5_0F24_2536_84F8
hash == 0x26B8319EDAF81B15
expect
hash =
@ -1296,7 +1306,7 @@ expect
|> addBytes [0x00, 0x00, 0x00, 0x00]
|> complete
hash == 0x3762_ACB1_7604_B541
hash == 0xA187D7CA074F9EE7
expect
hash =
@ -1304,7 +1314,7 @@ expect
|> addU32 0x0000_0000
|> complete
hash == 0x3762_ACB1_7604_B541
hash == 0xA187D7CA074F9EE7
expect
hash =
@ -1312,7 +1322,7 @@ expect
|> addBytes [0xA9, 0x2F, 0xEE, 0x21]
|> complete
hash == 0x20F3_3FD7_D32E_C7A9
hash == 0xA499EFE4C1454D09
expect
hash =
@ -1320,7 +1330,7 @@ expect
|> addU32 0x21EE_2FA9
|> complete
hash == 0x20F3_3FD7_D32E_C7A9
hash == 0xA499EFE4C1454D09
expect
hash =
@ -1328,7 +1338,7 @@ expect
|> addBytes [0x5D, 0x66, 0xB1, 0x8F, 0x68, 0x44, 0xC7, 0x03, 0xE1, 0xDD, 0x23, 0x34, 0xBB, 0x9A, 0x42, 0xA7]
|> complete
hash == 0xA16F_DDAA_C167_74C7
hash == 0xDD39A206AED64C73
expect
hash =
@ -1336,7 +1346,7 @@ expect
|> addU128 0xA742_9ABB_3423_DDE1_03C7_4468_8FB1_665D
|> complete
hash == 0xA16F_DDAA_C167_74C7
hash == 0xDD39A206AED64C73
expect
hash =
@ -1344,7 +1354,7 @@ expect
|> Hash.hashStrBytes "abcdefghijklmnopqrstuvwxyz"
|> complete
hash == 0xBEE0_A8FD_E990_D285
hash == 0x51C59DF5B1D15F40
expect
hash =
@ -1352,7 +1362,7 @@ expect
|> Hash.hashStrBytes "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|> complete
hash == 0xB3C5_8528_9D82_A6EF
hash == 0xD8D0A129D97A4E95
expect
hash =
@ -1360,7 +1370,7 @@ expect
|> Hash.hashStrBytes "1234567890123456789012345678901234567890123456789012345678901234567890"
|> complete
hash == 0xDB6B_7997_7A55_BA03
hash == 0x8188065B44FB4AAA
expect
hash =
@ -1368,7 +1378,7 @@ expect
|> addBytes (List.repeat 0x77 100)
|> complete
hash == 0x171F_EEE2_B764_8E5E
hash == 0x47A2A606EADF3378
# Note, had to specify u8 in the lists below to avoid ability type resolution error.
# Apparently it won't pick the default integer.
@ -1378,7 +1388,7 @@ expect
|> Hash.hashUnordered [8u8, 82u8, 3u8, 8u8, 24u8] List.walk
|> complete
hash == 0x999F_B530_3529_F17D
hash == 0xB2E8254C08F16B20
expect
hash1 =

View File

@ -1,28 +1,28 @@
procedure Dict.1 (Dict.556):
let Dict.565 : List {[], []} = Array [];
let Dict.572 : U64 = 0i64;
let Dict.573 : U64 = 8i64;
let Dict.566 : List U64 = CallByName List.11 Dict.572 Dict.573;
let Dict.569 : I8 = CallByName Dict.39;
let Dict.570 : U64 = 8i64;
let Dict.567 : List I8 = CallByName List.11 Dict.569 Dict.570;
let Dict.568 : U64 = 0i64;
let Dict.564 : {List {[], []}, List U64, List I8, U64} = Struct {Dict.565, Dict.566, Dict.567, Dict.568};
ret Dict.564;
procedure Dict.1 (Dict.554):
let Dict.563 : List {[], []} = Array [];
let Dict.570 : U64 = 0i64;
let Dict.571 : U64 = 8i64;
let Dict.564 : List U64 = CallByName List.11 Dict.570 Dict.571;
let Dict.567 : I8 = CallByName Dict.39;
let Dict.568 : U64 = 8i64;
let Dict.565 : List I8 = CallByName List.11 Dict.567 Dict.568;
let Dict.566 : U64 = 0i64;
let Dict.562 : {List {[], []}, List U64, List I8, U64} = Struct {Dict.563, Dict.564, Dict.565, Dict.566};
ret Dict.562;
procedure Dict.39 ():
let Dict.571 : I8 = -128i64;
ret Dict.571;
let Dict.569 : I8 = -128i64;
ret Dict.569;
procedure Dict.4 (Dict.562):
let Dict.100 : U64 = StructAtIndex 3 Dict.562;
let #Derived_gen.8 : List {[], []} = StructAtIndex 0 Dict.562;
procedure Dict.4 (Dict.560):
let Dict.101 : U64 = StructAtIndex 3 Dict.560;
let #Derived_gen.8 : List {[], []} = StructAtIndex 0 Dict.560;
dec #Derived_gen.8;
let #Derived_gen.7 : List U64 = StructAtIndex 1 Dict.562;
let #Derived_gen.7 : List U64 = StructAtIndex 1 Dict.560;
dec #Derived_gen.7;
let #Derived_gen.6 : List I8 = StructAtIndex 2 Dict.562;
let #Derived_gen.6 : List I8 = StructAtIndex 2 Dict.560;
dec #Derived_gen.6;
ret Dict.100;
ret Dict.101;
procedure List.11 (List.124, List.125):
let List.536 : List I8 = CallByName List.68 List.125;

View File

@ -340,6 +340,7 @@ pub fn load_types(
let function_kind = FunctionKind::LambdaSet;
let arena = &Bump::new();
let LoadedModule {
module_id: home,
mut can_problems,
mut type_problems,
mut declarations_by_id,
@ -371,13 +372,6 @@ pub fn load_types(
}
});
// find the platform's main module
let home = declarations_by_id
.keys()
.find(|id| format!("{id:?}").trim_start_matches("pf.").is_empty())
.copied()
.unwrap();
let decls = declarations_by_id.remove(&home).unwrap();
let subs = solved.inner_mut();

6
devtools/README.md Normal file → Executable file
View File

@ -7,10 +7,10 @@ The flake in this folder is meant for vscode, feel free to create a PR if you'li
Further steps:
1. Copy the flake.nix and flake.lock file to a new folder outside of the roc repo folder.
1. Copy the flake.nix and flake.lock file from the devtools folder to a new folder outside of the roc repo folder.
1. Run `git init` in the new folder.
1. Execute `git add flake.nix`, nix will error if you don't do this.
1. Change `roc.url = "path:/home/username/gitrepos/roc9/roc";` to the location of the roc folder on your machine.
1. Execute `git add flake.nix flake.lock`, nix will error if you don't do this.
1. Change `roc.url = "path:/home/username/gitrepos/roc";` to the location of the roc folder on your machine.
1. Follow instructions about vscode extensions [here](#extensions).
1. add other dev tools you like in the `devInputs` list. You can search for those [here](https://search.nixos.org/packages).
1. Run `nix develop`.

28
devtools/flake.lock Normal file → Executable file
View File

@ -5,11 +5,11 @@
"systems": "systems"
},
"locked": {
"lastModified": 1681202837,
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
"lastModified": 1692799911,
"narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
"rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44",
"type": "github"
},
"original": {
@ -93,17 +93,17 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1674860021,
"narHash": "sha256-ES4XUf/AlPp8RetKR6WlWgYEZ7bLWI7k6reHp2q9rqY=",
"lastModified": 1690279121,
"narHash": "sha256-XoPGhV1UJQPue6RiehAu7lQwKss3J1B/K0QtVOMD83A=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "9f4346eac544cc0db5eb7d889e71eac0f9c8b9eb",
"rev": "821c72743ceae44bdd09718d47cab98fd5fd90af",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixpkgs",
"rev": "9f4346eac544cc0db5eb7d889e71eac0f9c8b9eb",
"rev": "821c72743ceae44bdd09718d47cab98fd5fd90af",
"type": "github"
}
},
@ -115,13 +115,13 @@
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1682784625,
"narHash": "sha256-QUncKiwgpmHajo601NNHOjeUG2/vrGp1oMgxnPhq900=",
"path": "/home/username/gitrepos/roc9/roc",
"lastModified": 1694000770,
"narHash": "sha256-92bAbPmwXxD6rwaAViG5O9r91ZBh9bqaZhM3egPCjuw=",
"path": "/home/anton/gitrepos/roc",
"type": "path"
},
"original": {
"path": "/home/username/gitrepos/roc9/roc",
"path": "/home/anton/gitrepos/roc",
"type": "path"
}
},
@ -140,11 +140,11 @@
]
},
"locked": {
"lastModified": 1682389182,
"narHash": "sha256-8t2nmFnH+8V48+IJsf8AK51ebXNlVbOSVYOpiqJKvJE=",
"lastModified": 1690252178,
"narHash": "sha256-9oEz822bvbHobfCUjJLDor2BqW3I5tycIauzDlzOALY=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "74f1a64dd28faeeb85ef081f32cad2989850322c",
"rev": "8d64353ca827002fb8459e44d49116c78d868eba",
"type": "github"
},
"original": {

4
devtools/flake.nix Normal file → Executable file
View File

@ -3,7 +3,7 @@
inputs = {
# change this path to the path of your roc folder
roc.url = "path:/home/username/gitrepos/roc9/roc";
roc.url = "path:/home/username/gitrepos/roc";
# to easily make configs for multiple architectures
flake-utils.url = "github:numtide/flake-utils";
};
@ -35,7 +35,7 @@
publisher = "benjamin-thomas";
version = "0.0.4";
# keep this sha for the first run, nix will tell you the correct one to change it to
sha256 = "sha256-mabNegZ+XPQ6EIHFk6jz2mAPLHAU6Pm3w0SiFB7IE+s=";
sha256 = "sha256-USZiXdvYa8hxj62cy6hdiS5c2tIDIQxSyux684lyAEY=";
}
]
;