Skip to content

Commit

Permalink
workaround to fix the x86_64 build
Browse files Browse the repository at this point in the history
  • Loading branch information
gballet committed Aug 10, 2023
1 parent 16201e8 commit 9980921
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 15 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
- name: Set up Zig
uses: korandoru/setup-zig@v1
with:
zig-version: master
zig-version: 0.11.0

- name: Build
run: zig build
run: git submodule --init --recursive && zig build

lint:
runs-on: self-hosted
Expand All @@ -30,7 +30,7 @@ jobs:
- name: Set up Zig
uses: korandoru/setup-zig@v1
with:
zig-version: master
zig-version: 0.11.0

- name: Lint
run: zig fmt --check src/*.zig
Expand All @@ -43,7 +43,20 @@ jobs:
- name: Set up Zig
uses: korandoru/setup-zig@v1
with:
zig-version: master
zig-version: 0.11.0

- name: Test
run: zig build test
run: git submodule --init --recursive && zig build test

build-aarch64:
runs-on: self-hosted
steps:
- uses: actions/checkout@v2

- name: Set up Zig
uses: korandoru/setup-zig@v1
with:
zig-version: 0.11.0

- name: Test
run: git submodule --init --recursive && zig build -Dtarget="aarch64-linux"
39 changes: 29 additions & 10 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
.target = target,
});
ethash.addCSourceFiles(&[_][]const u8{"ethash/lib/keccak/keccak.c"}, &[_][]const u8{"-Wall"});
const cflags = [_][]const u8{
"-Wall", "-O3", "-fvisibility=hidden",
"-fvisibility-inlines-hidden", "-Wpedantic", "-Werror",
"-Wextra", "-Wshadow", "-Wconversion",
"-Wsign-conversion", "-Wno-unknown-pragmas", "-fno-stack-protector",
"-Wimplicit-fallthrough", "-Wmissing-declarations", "-Wno-attributes",
"-Wextra-semi", "-fno-exceptions", "-fno-rtti",
"-Wno-strict-prototypes", // this one is used by glue.c to avoid a warning that does not disappear when the prototype is added.
};
ethash.addCSourceFiles(&[_][]const u8{"ethash/lib/keccak/keccak.c"}, &cflags);
ethash.addIncludePath(LazyPath{ .path = "ethash/include" });
ethash.linkLibC();
ethash.linkLibCpp();
Expand All @@ -34,6 +43,15 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
.target = target,
});
const cppflags = [_][]const u8{
"-Wall", "-std=c++20", "-O3",
"-fvisibility=hidden", "-fvisibility-inlines-hidden", "-Wpedantic",
"-Werror", "-Wextra", "-Wshadow",
"-Wconversion", "-Wsign-conversion", "-Wno-unknown-pragmas",
"-fno-stack-protector", "-Wimplicit-fallthrough", "-Wmissing-declarations",
"-Wno-attributes", "-Wextra-semi", "-fno-exceptions",
"-fno-rtti",
};
evmone.addCSourceFiles(&[_][]const u8{
"evmone/lib/evmone/advanced_analysis.cpp",
"evmone/lib/evmone/eof.cpp",
Expand All @@ -45,15 +63,8 @@ pub fn build(b: *std.Build) void {
"evmone/lib/evmone/tracing.cpp",
"evmone/lib/evmone/baseline_instruction_table.cpp",
"evmone/lib/evmone/vm.cpp",
}, &[_][]const u8{
"-Wall", "-std=c++20", "-O3",
"-fvisibility=hidden", "-fvisibility-inlines-hidden", "-Wpedantic",
"-Werror", "-Wextra", "-Wshadow",
"-Wconversion", "-Wsign-conversion", "-Wno-unknown-pragmas",
"-fno-stack-protector", "-Wimplicit-fallthrough", "-Wmissing-declarations",
"-Wno-attributes", "-Wextra-semi", "-fno-exceptions",
"-fno-rtti",
});
}, &cppflags);

evmone.addIncludePath(LazyPath{ .path = "evmone/evmc/include" });
evmone.addIncludePath(LazyPath{ .path = "evmone/include" });
evmone.addIncludePath(LazyPath{ .path = "intx/include" });
Expand All @@ -73,6 +84,14 @@ pub fn build(b: *std.Build) void {
});
exe.addIncludePath(LazyPath{ .path = "evmone/include/evmone" });
exe.addIncludePath(LazyPath{ .path = "evmone/evmc/include" });
if (target.getCpuArch() == .x86_64) {
// On x86_64, some functions are missing from the static library,
// so we define dummy functions to make sure that it compiles.
exe.addCSourceFile(.{
.file = .{ .path = "src/glue.c" },
.flags = &cflags,
});
}
exe.linkLibrary(ethash);
exe.linkLibrary(evmone);
exe.linkLibC();
Expand Down
10 changes: 10 additions & 0 deletions src/glue.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// These are dummy functions that are used to link to
// missing builtin functions. This is a workaround for
// finding where the real functions are defined, and
// linking to them.

void __cpu_indicator_init() {
}

void __cpu_model() {
}

0 comments on commit 9980921

Please sign in to comment.