Created
June 12, 2024 16:41
-
-
Save kassane/45f91db17771bb3a5b920c9bb885c52b to your computer and use it in GitHub Desktop.
build ldc2-druntime using Zig build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! Based on: https://github.com/denizzzka/ldc-external_druntime_backend/blob/external_druntime_backend_support/runtime/druntime/meson.build | |
const std = @import("std"); | |
const abs = @import("abs"); | |
const builtin = @import("builtin"); | |
pub fn build(b: *std.Build) !void { | |
// ldc2/ldmd2 not have mingw-support | |
const target = b.standardTargetOptions(.{ | |
.default_target = if (builtin.os.tag == .windows) | |
try std.Target.Query.parse(.{ | |
.arch_os_abi = "native-windows-msvc", | |
}) | |
else | |
.{}, | |
}); | |
const optimize = b.standardOptimizeOption(.{}); | |
const source = switch (target.result.cpu.arch) { | |
.aarch64, .arm, .aarch64_32, .aarch64_be, .armeb => &[_][]const u8{"src/ldc/arm_unwind.c"} ++ src, | |
else => src, | |
}; | |
const threadAsm = b.addAssembly(.{ | |
.name = "threadasm", | |
.target = target, | |
.optimize = optimize, | |
.source_file = b.path("src/core/threadasm.S"), | |
}); | |
try buildD(b, .{ | |
.name = "druntime", | |
.kind = .lib, | |
.target = target, | |
.optimize = optimize, | |
.sources = source, | |
.dflags = &.{ | |
"-Isrc", | |
"-w", | |
"-conf=", | |
"-defaultlib=", | |
// Versions | |
"--d-version=AsmExternal", // used by fiber module | |
"--d-version=OnlyLowMemUnittest", //disables memory-greedy unittests | |
}, | |
.artifact = threadAsm, | |
.use_zigcc = true, | |
}); | |
} | |
fn buildD(b: *std.Build, options: abs.DCompileStep) !void { | |
const exe = try abs.ldcBuildStep(b, options); | |
b.default_step.dependOn(&exe.step); | |
} | |
const src = &[_][]const u8{ | |
"src/core/bitop.d", | |
"src/core/cpuid.d", | |
"src/core/gc/config.d", | |
"src/core/gc/gcinterface.d", | |
"src/core/gc/registry.d", | |
"src/core/demangle.d", | |
"src/core/exception.d", | |
"src/core/internal/abort.d", | |
"src/core/internal/array/appending.d", | |
"src/core/internal/array/capacity.d", | |
"src/core/internal/array/concatenation.d", | |
"src/core/internal/array/equality.d", | |
"src/core/internal/array/utils.d", | |
"src/core/internal/backtrace/unwind.d", | |
"src/core/internal/container/common.d", | |
"src/core/internal/convert.d", | |
"src/core/internal/container/treap.d", | |
"src/core/internal/entrypoint.d", | |
"src/core/internal/gc/bits.d", | |
"src/core/internal/gc/impl/conservative/gc.d", | |
"src/core/internal/gc/impl/manual/gc.d", | |
"src/core/internal/gc/impl/proto/gc.d", | |
"src/core/internal/gc/os.d", | |
"src/core/internal/gc/proxy.d", | |
"src/core/internal/lifetime.d", | |
"src/core/internal/parseoptions.d", | |
"src/core/internal/qsort.d", | |
"src/core/internal/spinlock.d", | |
"src/core/internal/string.d", | |
"src/core/internal/traits.d", | |
"src/core/internal/util/array.d", | |
"src/core/lifetime.d", | |
"src/core/runtime.d", | |
"src/core/memory.d", | |
"src/core/sync/condition.d", | |
"src/core/sync/event.d", | |
"src/core/sync/exception.d", | |
"src/core/sync/semaphore.d", | |
"src/core/time.d", | |
"src/core/thread/fiber.d", | |
"src/core/thread/osthread.d", | |
"src/core/thread/threadbase.d", | |
"src/core/thread/threadgroup.d", | |
"src/core/thread/types.d", | |
"src/core/thread/context.d", | |
"src/core/thread/package.d", | |
"src/core/stdc/fenv.d", | |
"src/core/stdc/errno.d", | |
"src/core/stdc/stdint.d", | |
"src/core/stdc/stdio.d", | |
"src/core/stdc/wchar_.d", | |
"src/object.d", | |
"src/rt/adi.d", | |
"src/rt/aaA.d", | |
"src/rt/arraycat.d", | |
"src/rt/cast_.d", | |
"src/rt/config.d", | |
"src/rt/critical_.d", | |
"src/rt/deh.d", | |
"src/rt/deh_win64_posix.d", | |
"src/rt/dmain2.d", | |
"src/rt/dwarfeh.d", | |
"src/rt/ehalloc.d", | |
"src/rt/invariant.d", | |
"src/rt/lifetime.d", | |
"src/rt/memory.d", | |
"src/rt/minfo.d", | |
"src/rt/monitor_.d", | |
"src/rt/profilegc.d", | |
"src/rt/tlsgc.d", | |
"src/rt/util/typeinfo.d", | |
"src/rt/util/utility.d", | |
"src/rt/sections.d", | |
"src/rt/sections_android.d", | |
"src/rt/sections_elf_shared.d", | |
"src/rt/sections_ldc.d", | |
"src/rt/sections_osx_x86.d", | |
// "src/ldc/sanitizers_optionally_linked.d", | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.{ | |
.name = "druntime", | |
.version = "0.0.1", | |
.dependencies = .{ | |
.abs = .{ | |
.url = "git+https://github.com/kassane/anotherBuildStep#4cb71185673f600091b92aa082db33f7f6b0d38c", | |
.hash = "1220c7e6dc78a53c0504f93a4c9e885b8293873b799b7c755793f7d46a5309d5b6ed", | |
}, | |
}, | |
.paths = .{""}, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/home/kassane/ldc-bootstrap/out/zig-x86_64-linux-musl-baseline/zig build-obj /home/kassane/ldc-bootstrap/ldc/runtime/druntime/src/core/threadasm.S -OReleaseSafe -Mroot --cache-dir /home/kassane/ldc-bootstrap/ldc/runtime/druntime/.zig-cache --global-cache-dir /home/kassane/.cache/zig --name threadasm --listen=- | |
/home/kassane/ldc-bootstrap/out/host/bin/ldmd2 -lib -fvisibility=hidden -Isrc -w -conf= -defaultlib= --d-version=AsmExternal --d-version=OnlyLowMemUnittest -O3 -release -enable-inlining -boundscheck=safeonly -vcolumns -od=/home/kassane/ldc-bootstrap/ldc/runtime/druntime/.zig-cache/o/14aa04743dbb632965b320ade3466ef4 -cache=/home/kassane/ldc-bootstrap/ldc/runtime/druntime/.zig-cache/o/14aa04743dbb632965b320ade3466ef4 -oq -cleanup-obj -disable-verify -Hkeep-all-bodies -i -I/home/kassane/.cache/zig/p/1220c7e6dc78a53c0504f93a4c9e885b8293873b799b7c755793f7d46a5309d5b6ed/src src/core/bitop.d src/core/cpuid.d src/core/gc/config.d src/core/gc/gcinterface.d src/core/gc/registry.d src/core/demangle.d src/core/exception.d src/core/internal/abort.d src/core/internal/array/appending.d src/core/internal/array/capacity.d src/core/internal/array/concatenation.d src/core/internal/array/equality.d src/core/internal/array/utils.d src/core/internal/backtrace/unwind.d src/core/internal/container/common.d src/core/internal/convert.d src/core/internal/container/treap.d src/core/internal/entrypoint.d src/core/internal/gc/bits.d src/core/internal/gc/impl/conservative/gc.d src/core/internal/gc/impl/manual/gc.d src/core/internal/gc/impl/proto/gc.d src/core/internal/gc/os.d src/core/internal/gc/proxy.d src/core/internal/lifetime.d src/core/internal/parseoptions.d src/core/internal/qsort.d src/core/internal/spinlock.d src/core/internal/string.d src/core/internal/traits.d src/core/internal/util/array.d src/core/lifetime.d src/core/runtime.d src/core/memory.d src/core/sync/condition.d src/core/sync/event.d src/core/sync/exception.d src/core/sync/semaphore.d src/core/time.d src/core/thread/fiber.d src/core/thread/osthread.d src/core/thread/threadbase.d src/core/thread/threadgroup.d src/core/thread/types.d src/core/thread/context.d src/core/thread/package.d src/core/stdc/fenv.d src/core/stdc/errno.d src/core/stdc/stdint.d src/core/stdc/stdio.d src/core/stdc/wchar_.d src/object.d src/rt/adi.d src/rt/aaA.d src/rt/arraycat.d src/rt/cast_.d src/rt/config.d src/rt/critical_.d src/rt/deh.d src/rt/deh_win64_posix.d src/rt/dmain2.d src/rt/dwarfeh.d src/rt/ehalloc.d src/rt/invariant.d src/rt/lifetime.d src/rt/memory.d src/rt/minfo.d src/rt/monitor_.d src/rt/profilegc.d src/rt/tlsgc.d src/rt/util/typeinfo.d src/rt/util/utility.d src/rt/sections.d src/rt/sections_android.d src/rt/sections_elf_shared.d src/rt/sections_ldc.d src/rt/sections_osx_x86.d -vdmd -Xcc=-v -mtriple=x86_64-linux-gnu -mcpu=znver3 -of=/home/kassane/ldc-bootstrap/ldc/runtime/druntime/zig-out/lib/druntime --gcc=/home/kassane/ldc-bootstrap/ldc/runtime/druntime/zig-out/tools/zcc --linker=/home/kassane/ldc-bootstrap/ldc/runtime/druntime/zig-out/tools/zcc /home/kassane/ldc-bootstrap/ldc/runtime/druntime/.zig-cache/o/ee8c4a36b4ea11ed42c228aa23ac10b6/threadasm.o | |
-- Invoking: /home/kassane/ldc-bootstrap/out/host/bin/ldc2 -ldmd -lib -oq -cleanup-obj -fvisibility=hidden -Isrc -w -conf= -defaultlib= --d-version=AsmExternal --d-version=OnlyLowMemUnittest -O3 -release -enable-inlining -boundscheck=safeonly -vcolumns -od=/home/kassane/ldc-bootstrap/ldc/runtime/druntime/.zig-cache/o/14aa04743dbb632965b320ade3466ef4 -cache=/home/kassane/ldc-bootstrap/ldc/runtime/druntime/.zig-cache/o/14aa04743dbb632965b320ade3466ef4 -oq -cleanup-obj -disable-verify -Hkeep-all-bodies -i -I/home/kassane/.cache/zig/p/1220c7e6dc78a53c0504f93a4c9e885b8293873b799b7c755793f7d46a5309d5b6ed/src src/core/bitop.d src/core/cpuid.d src/core/gc/config.d src/core/gc/gcinterface.d src/core/gc/registry.d src/core/demangle.d src/core/exception.d src/core/internal/abort.d src/core/internal/array/appending.d src/core/internal/array/capacity.d src/core/internal/array/concatenation.d src/core/internal/array/equality.d src/core/internal/array/utils.d src/core/internal/backtrace/unwind.d src/core/internal/container/common.d src/core/internal/convert.d src/core/internal/container/treap.d src/core/internal/entrypoint.d src/core/internal/gc/bits.d src/core/internal/gc/impl/conservative/gc.d src/core/internal/gc/impl/manual/gc.d src/core/internal/gc/impl/proto/gc.d src/core/internal/gc/os.d src/core/internal/gc/proxy.d src/core/internal/lifetime.d src/core/internal/parseoptions.d src/core/internal/qsort.d src/core/internal/spinlock.d src/core/internal/string.d src/core/internal/traits.d src/core/internal/util/array.d src/core/lifetime.d src/core/runtime.d src/core/memory.d src/core/sync/condition.d src/core/sync/event.d src/core/sync/exception.d src/core/sync/semaphore.d src/core/time.d src/core/thread/fiber.d src/core/thread/osthread.d src/core/thread/threadbase.d src/core/thread/threadgroup.d src/core/thread/types.d src/core/thread/context.d src/core/thread/package.d src/core/stdc/fenv.d src/core/stdc/errno.d src/core/stdc/stdint.d src/core/stdc/stdio.d src/core/stdc/wchar_.d src/object.d src/rt/adi.d src/rt/aaA.d src/rt/arraycat.d src/rt/cast_.d src/rt/config.d src/rt/critical_.d src/rt/deh.d src/rt/deh_win64_posix.d src/rt/dmain2.d src/rt/dwarfeh.d src/rt/ehalloc.d src/rt/invariant.d src/rt/lifetime.d src/rt/memory.d src/rt/minfo.d src/rt/monitor_.d src/rt/profilegc.d src/rt/tlsgc.d src/rt/util/typeinfo.d src/rt/util/utility.d src/rt/sections.d src/rt/sections_android.d src/rt/sections_elf_shared.d src/rt/sections_ldc.d src/rt/sections_osx_x86.d -Xcc=-v -mtriple=x86_64-linux-gnu -mcpu=znver3 -of=/home/kassane/ldc-bootstrap/ldc/runtime/druntime/zig-out/lib/druntime --gcc=/home/kassane/ldc-bootstrap/ldc/runtime/druntime/zig-out/tools/zcc --linker=/home/kassane/ldc-bootstrap/ldc/runtime/druntime/zig-out/tools/zcc /home/kassane/ldc-bootstrap/ldc/runtime/druntime/.zig-cache/o/ee8c4a36b4ea11ed42c228aa23ac10b6/threadasm.o | |
Build Summary: 3/3 steps succeeded | |
install success | |
└─ druntime success 5s MaxRSS:287M | |
└─ zig build-obj threadasm ReleaseSafe native success 23ms MaxRSS:42M |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated
https://github.com/kassane/druntime-zigbuild