Skip to content

Commit

Permalink
fix: build errors (#424)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 authored Dec 24, 2023
1 parent 725cf39 commit fed3798
Show file tree
Hide file tree
Showing 51 changed files with 5,795 additions and 4,797 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'
22 changes: 11 additions & 11 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
haxe,
java,
javascript,
julia,
# julia,
kotlin,
# lisp,
lua,
Expand All @@ -67,7 +67,7 @@ jobs:
- 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 @@ -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 @@ -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: 8
- uses: actions/download-artifact@v3
with:
# Artifact name
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: 8
- 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']
}
3 changes: 1 addition & 2 deletions bench/algorithm/json-serde/1.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"crypto/md5"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"strconv"
)
Expand All @@ -19,7 +18,7 @@ func main() {
n, _ = strconv.Atoi(os.Args[2])
}
var data GeoData
jsonStr, _ := ioutil.ReadFile(fileName + ".json")
jsonStr, _ := os.ReadFile(fileName + ".json")
json.Unmarshal([]byte(jsonStr), &data)
printHash(data.ToJsonString())
array := make([]GeoData, 0, n)
Expand Down
5 changes: 2 additions & 3 deletions bench/algorithm/json-serde/1.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub fn main() !void {
defer std.process.argsFree(global_allocator, args);

const file = if (args.len > 1) blk: {
var file_name = try std.mem.concat(global_allocator, u8, &.{ args[1], ".json" });
const file_name = try std.mem.concat(global_allocator, u8, &.{ args[1], ".json" });
defer global_allocator.free(file_name);
break :blk try std.fs.cwd().openFile(file_name, .{});
} else try std.fs.cwd().openFile("sample.json", .{});
Expand Down Expand Up @@ -70,9 +70,8 @@ const Geometry = struct {
// and end up with the correct md5 (compared with 1.js)
pub fn jsonStringify(
value: Geometry,
_: json.StringifyOptions,
out_stream: anytype,
) @TypeOf(out_stream).Error!void {
) !void {
const typestr =
\\{"type":"
;
Expand Down
3 changes: 1 addition & 2 deletions bench/algorithm/json-serde/2-ffi.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"crypto/md5"
"fmt"
"io/ioutil"
"os"
"strconv"

Expand All @@ -20,7 +19,7 @@ func main() {
n, _ = strconv.Atoi(os.Args[2])
}
var data GeoData
jsonStr, _ := ioutil.ReadFile(fileName + ".json")
jsonStr, _ := os.ReadFile(fileName + ".json")
json.Unmarshal([]byte(jsonStr), &data)
printHash(data.ToJsonString())
array := make([]GeoData, 0, n)
Expand Down
8 changes: 4 additions & 4 deletions bench/algorithm/lru/1.zig
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,23 @@ fn LinkedList(comptime T: type) type {
const Self = @This();

pub fn init(allocator: Allocator) !*Self {
var list = try allocator.create(Self);
const list = try allocator.create(Self);
list.* = .{ .allocator = allocator };
return list;
}

pub fn deinit(self: *Self) void {
var ptr = self.head;
while (ptr != null) {
var tmp = ptr.?;
const tmp = ptr.?;
ptr = tmp.next;
self.allocator.destroy(tmp);
}
self.allocator.destroy(self);
}

pub fn add(self: *Self, data: T) !*Node {
var node = try self.allocator.create(Node);
const node = try self.allocator.create(Node);
node.* = .{ .data = data };
self.__add_node(node);
self.len += 1;
Expand Down Expand Up @@ -172,7 +172,7 @@ fn LRU(
}

pub fn get(self: *Self, key: K) ?V {
var node = self.keys.get(key);
const node = self.keys.get(key);
if (node == null) {
return null;
}
Expand Down
Loading

0 comments on commit fed3798

Please sign in to comment.