Skip to content

Commit

Permalink
fix: build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 committed Dec 24, 2023
1 parent 725cf39 commit b455998
Show file tree
Hide file tree
Showing 51 changed files with 4,487 additions and 3,213 deletions.
18 changes: 11 additions & 7 deletions .github/lua.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
#!/usr/bin/bash

set -euo pipefail

LUA_VERSION="5.4.6"
# https://www.lua.org/ftp/#
pushd /tmp
curl -R -O http://www.lua.org/ftp/lua-5.4.4.tar.gz
tar zxf lua-5.4.4.tar.gz
pushd lua-5.4.4
curl -L -R -O http://www.lua.org/ftp/lua-$LUA_VERSION.tar.gz
tar zxf lua-$LUA_VERSION.tar.gz
pushd lua-$LUA_VERSION
make all test
# sudo ln -sf $PWD/src/luac /usr/bin/luac
# sudo ln -sf $PWD/src/lua /usr/bin/lua
sudo make install
popd
popd
# cp /tmp/lua-5.4.4/src/lua ./bench/include/lua/out
# cp /tmp/lua-$LUA_VERSION/src/lua ./bench/include/lua/out
luac -v
lua -v
# ./bench/include/lua/out/lua -v

git clone https://github.com/LuaJIT/LuaJIT.git /tmp/LuaJIT
LUAJIT_VERSION=2.1.0-beta3
git clone --branch v$LUAJIT_VERSION https://github.com/LuaJIT/LuaJIT.git /tmp/LuaJIT
pushd /tmp/LuaJIT
make
sudo make install
luajit-2.1.0-beta3 -v
sudo ln -sf luajit-2.1.0-beta3 /usr/local/bin/luajit
luajit-$LUAJIT_VERSION -v
sudo ln -sf luajit-$LUAJIT_VERSION /usr/local/bin/luajit
popd
luajit -v
# cp /tmp/LuaJIT/src/luajit ./bench/include/lua/out
Expand Down
2 changes: 2 additions & 0 deletions .github/nim.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/bash

set -euo pipefail

curl https://nim-lang.org/choosenim/init.sh -sSf > choosenim.sh
sh choosenim.sh -y
sudo ln -sf $HOME/.nimble/bin/choosenim /usr/bin/choosenim
Expand Down
4 changes: 3 additions & 1 deletion .github/odin.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/sh
#!/usr/bin/bash

set -euo pipefail

VERSION=dev-2023-05
FILE_NAME=odin-ubuntu-amd64-$VERSION.zip
Expand Down
2 changes: 1 addition & 1 deletion .github/v.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ cd /tmp/vlang
make && ./v -version
./v symlink
v --version
v install hanabi1224.biginteger || echo 'ignore failure'
# v install hanabi1224.biginteger || echo 'ignore failure'
102 changes: 53 additions & 49 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,55 +19,55 @@ jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
fail-fast: false
matrix:
os: [ubuntu-22.04]
lang: [
acton,
c,
chapel,
codon,
cpp,
csharp,
crystal,
d,
dart,
# elixir,
# fortran,
go,
# hacklang,
# haskell,
haxe,
java,
javascript,
julia,
kotlin,
# lisp,
lua,
# nelua,
nim,
ocaml,
odin,
perl,
php,
# pony,
python,
# racket,
ruby,
rust,
swift,
typescript,
v,
wasm,
# wren,
zig,
# chapel,
# codon,
# cpp,
# csharp,
# crystal,
# d,
# dart,
# # elixir,
# # fortran,
# go,
# # hacklang,
# # haskell,
# haxe,
# java,
# javascript,
# # julia,
# kotlin,
# # lisp,
# lua,
# # nelua,
# nim,
# ocaml,
# odin,
# perl,
# php,
# # pony,
# python,
# # racket,
# ruby,
# rust,
# swift,
# typescript,
# v,
# wasm,
# # wren,
# zig,
]
steps:
- run: lscpu
- run: dotnet --info
- uses: actions/setup-dotnet@v3
with:
dotnet-version: "7.x"
dotnet-version: "8.x"
- name: Install
run: |
echo '# placeholder' > $PROFILE
Expand Down Expand Up @@ -243,7 +243,7 @@ jobs:
steps:
- run: echo 'dummy step as PR gate'
bench:
if: github.ref == 'refs/heads/main'
# if: github.ref == 'refs/heads/main'
needs: [build]
runs-on: ${{ matrix.os }}
strategy:
Expand All @@ -254,19 +254,19 @@ jobs:
- run: lscpu
- uses: actions/setup-dotnet@v3
with:
dotnet-version: "7.x"
dotnet-version: "8.x"
- name: Install
run: |
dotnet --info
echo '# placeholder' > $PROFILE
sudo apt-get update -y
- uses: actions/checkout@v3
- name: Check CPU Model
run: |
source $PROFILE
pushd bench
dotnet run -c Release --project tool -- --task checkcpu
popd
# - name: Check CPU Model
# run: |
# source $PROFILE
# pushd bench
# dotnet run -c Release --project tool -- --task checkcpu
# popd
- run: ./.github/acton.sh
- run: ./.github/codon.sh
- run: ./.github/clang.sh
Expand Down Expand Up @@ -319,7 +319,7 @@ jobs:
path: bench/build/_results/**/*
if-no-files-found: error
publish:
if: github.ref == 'refs/heads/main'
# if: github.ref == 'refs/heads/main'
needs: [bench]
runs-on: ${{ matrix.os }}
strategy:
Expand All @@ -329,10 +329,10 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18.x
- uses: pnpm/action-setup@v2
with:
version: 7
version: latest
- uses: actions/download-artifact@v3
with:
# Artifact name
Expand All @@ -347,6 +347,10 @@ jobs:
pushd website
pnpm i
pnpm content
- name: Site Publish (dev)
env:
VERCEL_PUBLISH_TOKEN: ${{ secrets.VERCEL_PUBLISH_TOKEN }}
run: vercel website --confirm -t $VERCEL_PUBLISH_TOKEN || echo 'ignore errors'
- name: Site Publish
if: github.ref == 'refs/heads/main'
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18.x
- uses: pnpm/action-setup@v2
with:
version: 7
version: latest
- run: pnpm --version
- run: vercel --version
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion bench/algorithm/binarytrees/1.zig
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const Node = struct {
right: ?*Self = null,

pub fn init(allocator: Allocator) !*Self {
var node = try allocator.create(Self);
const node = try allocator.create(Self);
node.* = .{ .allocator = allocator };
return node;
}
Expand Down
22 changes: 11 additions & 11 deletions bench/algorithm/edigits/1.zig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Pair = struct {
pub fn main() !void {
const stdout = std.io.getStdOut().writer();
const n = try get_n();
var k = binary_search(n);
const k = binary_search(n);
var pair = try sum_terms(0, k - 1);
defer pair.deinit();
var p = pair.p;
Expand All @@ -33,9 +33,9 @@ pub fn main() !void {
defer tmp.deinit();
try bigint.Managed.mul(&tmp, &answer, &a);
try bigint.Managed.divFloor(&answer, &a, &tmp, &q);
var str = try answer.toString(global_allocator, 10, std.fmt.Case.lower);
const str = try answer.toString(global_allocator, 10, std.fmt.Case.lower);
var i: usize = 0;
var n_usize = @as(usize, @as(u32, @bitCast(n)));
const n_usize = @as(usize, @as(u32, @bitCast(n)));
while (i < n_usize) {
var sb = [10:0]u8{ ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' };
var j: usize = i;
Expand All @@ -54,14 +54,14 @@ pub fn main() !void {

fn sum_terms(a: i32, b: i32) anyerror!Pair {
if (b == a + 1) {
var p = try bigint.Managed.initSet(global_allocator, 1);
var q = try bigint.Managed.initSet(global_allocator, b);
const p = try bigint.Managed.initSet(global_allocator, 1);
const q = try bigint.Managed.initSet(global_allocator, b);
return Pair{
.p = p,
.q = q,
};
}
var mid: i32 = @divFloor((a + b), 2);
const mid: i32 = @divFloor((a + b), 2);
var pair_left: Pair = try sum_terms(a, mid);
defer pair_left.deinit();
var pair_right: Pair = try sum_terms(mid, b);
Expand All @@ -85,7 +85,7 @@ fn binary_search(n: i32) i32 {
b *= 2;
}
while (b - a > 1) {
var m: i32 = @divFloor(a + b, 2);
const m: i32 = @divFloor(a + b, 2);
if (test_k(n, m)) {
b = m;
} else {
Expand All @@ -99,10 +99,10 @@ fn test_k(n: i32, k: i32) bool {
if (k < 0) {
return false;
}
var float_k: f64 = @floatFromInt(k);
var float_n: f64 = @floatFromInt(n);
var ln_k_factorial = float_k * (math.ln(float_k) - 1.0) + 0.5 * math.ln(math.tau);
var log_10_k_factorial = ln_k_factorial / math.ln10;
const float_k: f64 = @floatFromInt(k);
const float_n: f64 = @floatFromInt(n);
const ln_k_factorial = float_k * (math.log(f64, math.e, float_k) - 1.0) + 0.5 * math.log(f64, math.e, math.tau);
const log_10_k_factorial = ln_k_factorial / math.ln10;
return log_10_k_factorial >= float_n + 50.0;
}

Expand Down
4 changes: 2 additions & 2 deletions bench/algorithm/fannkuch-redux/1.v
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn main() {
println('${sum}\nPfannkuchen(${n}) = ${flips}')
}

[direct_array_access]
@[direct_array_access]
fn fannkuchredux(n int) (int, int) {
mut perm1 := [32]int{}
for i in 0 .. perm1.len {
Expand Down Expand Up @@ -77,7 +77,7 @@ fn fannkuchredux(n int) (int, int) {
return n, n
}

[direct_array_access; inline]
@[direct_array_access; inline]
fn swap(mut array [32]int, i int, j int) {
tmp := array[i]
array[i] = array[j]
Expand Down
2 changes: 1 addition & 1 deletion bench/algorithm/fannkuch-redux/3-i.zig
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ inline fn advance_array(_array: u128, count: *[16]u8) u128 {

fn fannkuchRedux(n: u4) [2]i32 {
var _current: u128 = 0x0F_0E_0D_0C_0B_0A_09_08_07_06_05_04_03_02_01_00;
var _count = [1]u8{0} ** 16;
const _count = [1]u8{0} ** 16;
var max_rev: i32 = 0;

// Trivial cases, not implemented
Expand Down
31 changes: 19 additions & 12 deletions bench/algorithm/http-server/1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

static class Program
Expand Down Expand Up @@ -75,21 +76,27 @@ private static async Task<int> SendAsync(string api, int value)
}
}

private static IWebHostBuilder CreateWebHostBuilder(int port)
{
return WebHost.CreateDefaultBuilder()
.SuppressStatusMessages(true)
.ConfigureLogging((context, logging) =>
private static IHostBuilder CreateWebHostBuilder(int port) =>
Host.CreateDefaultBuilder()
.ConfigureAppConfiguration((hostingContext, config) =>
{
logging.ClearProviders();
config.AddJsonFile("appsettings.json",
optional: true,
reloadOnChange: false);
})
.UseKestrel(options =>
.ConfigureWebHostDefaults(webBuilder =>
{
options.Limits.MaxRequestBodySize = null;
options.ListenLocalhost(port);
})
.UseStartup<Startup>();
}
webBuilder.SuppressStatusMessages(true).ConfigureLogging((context, logging) =>
{
logging.ClearProviders();
})
.UseKestrel(options =>
{
options.Limits.MaxRequestBodySize = null;
options.ListenLocalhost(port);
})
.UseStartup<Startup>();
});
}

public sealed class MyController : Controller
Expand Down
4 changes: 2 additions & 2 deletions bench/algorithm/http-server/1.v
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct App {
vweb.Context
}

['/api'; post]
@['/api'; post]
pub fn (mut app App) api() vweb.Result {
data := json.decode(Payload, app.req.data) or {
Payload{
Expand All @@ -49,5 +49,5 @@ pub fn (mut app App) api() vweb.Result {
}

struct Payload {
value int [json: 'value']
value int @[json: 'value']
}
Loading

0 comments on commit b455998

Please sign in to comment.