Remove Zig
All checks were successful
CI / ci (MinSizeRel, ubuntu-latest) (pull_request) Successful in 1m5s
CI / ci (Release, ubuntu-latest) (pull_request) Successful in 1m2s
CI / ci (RelWithDebInfo, ubuntu-latest) (pull_request) Successful in 1m4s
CI / ci (Debug, ubuntu-latest) (pull_request) Successful in 2m37s
All checks were successful
CI / ci (MinSizeRel, ubuntu-latest) (pull_request) Successful in 1m5s
CI / ci (Release, ubuntu-latest) (pull_request) Successful in 1m2s
CI / ci (RelWithDebInfo, ubuntu-latest) (pull_request) Successful in 1m4s
CI / ci (Debug, ubuntu-latest) (pull_request) Successful in 2m37s
This commit is contained in:
parent
58b02efc63
commit
453f488427
32
build.bat
32
build.bat
@ -1,32 +0,0 @@
|
||||
@echo off
|
||||
setlocal enableextensions
|
||||
|
||||
if not defined BB_CI (
|
||||
set BB_CI=0
|
||||
)
|
||||
|
||||
if not defined BB_BUILD_TYPE (
|
||||
set BB_BUILD_TYPE=debug
|
||||
)
|
||||
|
||||
if not defined BB_ERROR_ON_WARNINGS (
|
||||
set BB_ERROR_ON_WARNINGS=%BB_CI%
|
||||
)
|
||||
|
||||
if not defined BB_ERROR_LIMIT (
|
||||
set /a BB_ERROR_LIMIT=1-%BB_CI%
|
||||
)
|
||||
|
||||
set BUILD_DIR=cache
|
||||
mkdir %BUILD_DIR% > NUL 2>&1
|
||||
set BUILD_OUT=cache\build.exe
|
||||
set BB_ERROR_ON_WARNINGS=%BB_CI%
|
||||
|
||||
REM if "%BB_CI%" == "0" (
|
||||
REM %VK_SDK_PATH%\Bin\glslangValidator.exe -V bootstrap\std\shaders\rect.vert -o cache\rect.vert.spv --quiet || exit /b 1
|
||||
REM %VK_SDK_PATH%\Bin\glslangValidator.exe -V bootstrap\std\shaders\rect.frag -o cache\rect.frag.spv --quiet || exit /b 1
|
||||
REM )
|
||||
|
||||
|
||||
cl /Zi /Y- /Gm- /std:clatest /diagnostics:caret -FC /nologo build.c /Fd%BUILD_DIR%\ /Fo%BUILD_DIR%\ /Fe%BUILD_OUT% -Ibootstrap -DBB_TIMETRACE=0 -DBB_BUILD_TYPE=\"%BB_BUILD_TYPE%\" -DBB_CI=%BB_CI% -DBB_ERROR_ON_WARNINGS=%BB_ERROR_ON_WARNINGS% -DBB_ERROR_LIMIT=%BB_ERROR_LIMIT% /link /INCREMENTAL:NO || exit /b 1
|
||||
%BUILD_OUT%
|
367
build.zig
367
build.zig
@ -1,367 +0,0 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
fn run_process_and_capture_stdout(b: *std.Build, argv: []const []const u8) ![]const u8 {
|
||||
const result = std.process.Child.run(.{
|
||||
.allocator = b.allocator,
|
||||
.argv = argv,
|
||||
}) catch |err| return err;
|
||||
switch (result.term) {
|
||||
.Exited => |exit_code| {
|
||||
if (exit_code != 0) {
|
||||
return error.SpawnError;
|
||||
}
|
||||
},
|
||||
else => return error.SpawnError,
|
||||
}
|
||||
|
||||
return result.stdout;
|
||||
}
|
||||
|
||||
fn file_find_in_path(allocator: std.mem.Allocator, file_name: []const u8, path_env: []const u8, extension: []const u8) ?[]const u8 {
|
||||
const path_env_separator = switch (builtin.os.tag) {
|
||||
.windows => ';',
|
||||
else => ':',
|
||||
};
|
||||
const path_separator = switch (builtin.os.tag) {
|
||||
.windows => '\\',
|
||||
else => '/',
|
||||
};
|
||||
var env_it = std.mem.splitScalar(u8, path_env, path_env_separator);
|
||||
const result: ?[]const u8 = while (env_it.next()) |dir_path| {
|
||||
const full_path = std.mem.concatWithSentinel(allocator, u8, &.{ dir_path, &[1]u8{path_separator}, file_name, extension }, 0) catch unreachable;
|
||||
const file = std.fs.cwd().openFile(full_path, .{}) catch continue;
|
||||
file.close();
|
||||
break full_path;
|
||||
} else null;
|
||||
return result;
|
||||
}
|
||||
|
||||
fn executable_find_in_path(allocator: std.mem.Allocator, file_name: []const u8, path_env: []const u8) ?[]const u8 {
|
||||
const extension = switch (builtin.os.tag) {
|
||||
.windows => ".exe",
|
||||
else => "",
|
||||
};
|
||||
return file_find_in_path(allocator, file_name, path_env, extension);
|
||||
}
|
||||
|
||||
const CmakeBuildType = enum {
|
||||
Debug,
|
||||
RelWithDebInfo,
|
||||
MinSizeRel,
|
||||
Release,
|
||||
|
||||
fn from_zig_build_type(o: std.builtin.OptimizeMode) CmakeBuildType {
|
||||
return switch (o) {
|
||||
.Debug => .Debug,
|
||||
.ReleaseSafe => .RelWithDebInfo,
|
||||
.ReleaseSmall => .MinSizeRel,
|
||||
.ReleaseFast => .Release,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
var system_llvm: bool = undefined;
|
||||
var target: std.Build.ResolvedTarget = undefined;
|
||||
var optimize: std.builtin.OptimizeMode = undefined;
|
||||
var env: std.process.EnvMap = undefined;
|
||||
|
||||
const BuildMode = enum {
|
||||
debug_none,
|
||||
debug_fast,
|
||||
debug_size,
|
||||
soft_optimize,
|
||||
optimize_for_speed,
|
||||
optimize_for_size,
|
||||
aggressively_optimize_for_speed,
|
||||
aggressively_optimize_for_size,
|
||||
};
|
||||
|
||||
pub fn build(b: *std.Build) !void {
|
||||
env = try std.process.getEnvMap(b.allocator);
|
||||
target = b.standardTargetOptions(.{});
|
||||
optimize = b.standardOptimizeOption(.{});
|
||||
system_llvm = b.option(bool, "system_llvm", "Link against system LLVM libraries") orelse false;
|
||||
|
||||
const c_abi = b.addObject(.{
|
||||
.name = "c_abi",
|
||||
.link_libc = true,
|
||||
.root_module = b.createModule(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.link_libc = true,
|
||||
.sanitize_c = false,
|
||||
}),
|
||||
.optimize = optimize,
|
||||
});
|
||||
c_abi.addCSourceFiles(.{
|
||||
.files = &.{"tests/c_abi.c"},
|
||||
.flags = &.{"-g"},
|
||||
});
|
||||
|
||||
const path = env.get("PATH") orelse unreachable;
|
||||
|
||||
const stack_trace_library = b.addObject(.{
|
||||
.name = "stack_trace",
|
||||
.root_module = b.createModule(.{
|
||||
.target = target,
|
||||
.optimize = .ReleaseFast,
|
||||
.root_source_file = b.path("src/stack_trace.zig"),
|
||||
.link_libc = true,
|
||||
}),
|
||||
});
|
||||
|
||||
const exe_mod = b.createModule(.{
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.link_libc = true,
|
||||
.sanitize_c = false,
|
||||
});
|
||||
const configuration = b.addOptions();
|
||||
configuration.addOptionPath("c_abi_object_path", c_abi.getEmittedBin());
|
||||
exe_mod.addOptions("configuration", configuration);
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "bloat-buster",
|
||||
.root_module = exe_mod,
|
||||
.link_libc = true,
|
||||
});
|
||||
exe.addObject(stack_trace_library);
|
||||
var llvm_libs = std.ArrayList([]const u8).init(b.allocator);
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
const llvm_config_path = if (b.option([]const u8, "llvm_prefix", "LLVM prefix")) |llvm_prefix| blk: {
|
||||
const full_path = try std.mem.concat(b.allocator, u8, &.{ llvm_prefix, "/bin/llvm-config" });
|
||||
const f = std.fs.cwd().openFile(full_path, .{}) catch return error.llvm_not_found;
|
||||
f.close();
|
||||
break :blk full_path;
|
||||
} else if (system_llvm) executable_find_in_path(b.allocator, "llvm-config", path) orelse return error.llvm_not_found else blk: {
|
||||
const home_env = switch (@import("builtin").os.tag) {
|
||||
.windows => "USERPROFILE",
|
||||
else => "HOME",
|
||||
};
|
||||
const home_path = env.get(home_env) orelse unreachable;
|
||||
const is_ci = std.mem.eql(u8, (env.get("BB_CI") orelse "0"), "1");
|
||||
const download_dir = try std.mem.concat(b.allocator, u8, &.{ home_path, "/Downloads" });
|
||||
std.fs.makeDirAbsolute(download_dir) catch {};
|
||||
const cmake_build_type = if (is_ci) CmakeBuildType.from_zig_build_type(optimize) else CmakeBuildType.Release;
|
||||
const version_string = "20.1.2";
|
||||
const llvm_base = try std.mem.concat(b.allocator, u8, &.{ "llvm_", version_string, "_", @tagName(target.result.cpu.arch), "-", @tagName(target.result.os.tag), "-", @tagName(cmake_build_type) });
|
||||
const base = try std.mem.concat(b.allocator, u8, &.{ download_dir, "/", llvm_base });
|
||||
const full_path = try std.mem.concat(b.allocator, u8, &.{ base, "/bin/llvm-config" });
|
||||
|
||||
const f = std.fs.cwd().openFile(full_path, .{}) catch {
|
||||
const url = try std.mem.concat(b.allocator, u8, &.{ "https://github.com/birth-software/llvm/releases/download/v", version_string, "/", llvm_base, ".7z" });
|
||||
var result = try std.process.Child.run(.{
|
||||
.allocator = b.allocator,
|
||||
.argv = &.{ "wget", "-P", download_dir, url },
|
||||
.max_output_bytes = std.math.maxInt(usize),
|
||||
});
|
||||
var success = false;
|
||||
switch (result.term) {
|
||||
.Exited => |exit_code| {
|
||||
success = exit_code == 0;
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
std.debug.print("{s}\n{s}\n", .{ result.stdout, result.stderr });
|
||||
}
|
||||
|
||||
if (success) {
|
||||
const file_7z = try std.mem.concat(b.allocator, u8, &.{ base, ".7z" });
|
||||
result = try std.process.Child.run(.{
|
||||
.allocator = b.allocator,
|
||||
.argv = &.{ "7z", "x", try std.mem.concat(b.allocator, u8, &.{ "-o", download_dir }), file_7z },
|
||||
.max_output_bytes = std.math.maxInt(usize),
|
||||
});
|
||||
success = false;
|
||||
switch (result.term) {
|
||||
.Exited => |exit_code| {
|
||||
success = exit_code == 0;
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
std.debug.print("{s}\n{s}\n", .{ result.stdout, result.stderr });
|
||||
}
|
||||
|
||||
break :blk full_path;
|
||||
}
|
||||
|
||||
return error.llvm_not_found;
|
||||
};
|
||||
|
||||
f.close();
|
||||
break :blk full_path;
|
||||
};
|
||||
|
||||
const llvm_config_invocation = try run_process_and_capture_stdout(b, &.{
|
||||
llvm_config_path,
|
||||
"--cxxflags",
|
||||
"--libdir",
|
||||
"--build-mode",
|
||||
"--libs",
|
||||
});
|
||||
var it = std.mem.splitScalar(u8, llvm_config_invocation, '\n');
|
||||
|
||||
const llvm_cxx_flags_chunk = it.next() orelse unreachable;
|
||||
var llvm_cxx_flags_it = std.mem.splitScalar(u8, llvm_cxx_flags_chunk, ' ');
|
||||
while (llvm_cxx_flags_it.next()) |llvm_cxx_flag| {
|
||||
try flags.append(llvm_cxx_flag);
|
||||
}
|
||||
|
||||
const llvm_lib_dir = it.next() orelse unreachable;
|
||||
const llvm_build_mode_string = it.next() orelse unreachable;
|
||||
const llvm_build_mode = inline for (@typeInfo(CmakeBuildType).@"enum".fields) |field| {
|
||||
if (std.mem.eql(u8, llvm_build_mode_string, field.name)) {
|
||||
break @field(CmakeBuildType, field.name);
|
||||
}
|
||||
} else unreachable;
|
||||
|
||||
const llvm_lib_chunk = it.next() orelse unreachable;
|
||||
var llvm_lib_it = std.mem.splitScalar(u8, llvm_lib_chunk, ' ');
|
||||
while (llvm_lib_it.next()) |llvm_lib| {
|
||||
const llvm_lib_arg = std.mem.trimLeft(u8, llvm_lib, "-l");
|
||||
try llvm_libs.append(llvm_lib_arg);
|
||||
}
|
||||
|
||||
if (llvm_build_mode == .Debug) {
|
||||
try flags.append("-g");
|
||||
}
|
||||
|
||||
try flags.append("-fno-rtti");
|
||||
|
||||
exe.addLibraryPath(.{ .cwd_relative = llvm_lib_dir });
|
||||
|
||||
const a = std.fs.cwd().openDir("/usr/lib/x86_64-linux-gnu/", .{});
|
||||
if (a) |_| {
|
||||
var dir = a catch unreachable;
|
||||
dir.close();
|
||||
exe.addLibraryPath(.{ .cwd_relative = "/usr/lib/x86_64-linux-gnu/" });
|
||||
} else |err| {
|
||||
err catch {};
|
||||
}
|
||||
|
||||
exe.addCSourceFiles(.{
|
||||
.files = &.{"src/llvm.cpp"},
|
||||
.flags = flags.items,
|
||||
});
|
||||
|
||||
var dir = try std.fs.cwd().openDir("/usr/include/c++", .{
|
||||
.iterate = true,
|
||||
});
|
||||
var iterator = dir.iterate();
|
||||
const gcc_version = while (try iterator.next()) |entry| {
|
||||
if (entry.kind == .directory) {
|
||||
break entry.name;
|
||||
}
|
||||
} else return error.include_cpp_dir_not_found;
|
||||
dir.close();
|
||||
const general_cpp_include_dir = try std.mem.concat(b.allocator, u8, &.{ "/usr/include/c++/", gcc_version });
|
||||
exe.addIncludePath(.{ .cwd_relative = general_cpp_include_dir });
|
||||
|
||||
{
|
||||
const arch_cpp_include_dir = try std.mem.concat(b.allocator, u8, &.{ general_cpp_include_dir, "/x86_64-pc-linux-gnu" });
|
||||
const d2 = std.fs.cwd().openDir(arch_cpp_include_dir, .{});
|
||||
if (d2) |_| {
|
||||
var d = d2 catch unreachable;
|
||||
d.close();
|
||||
exe.addIncludePath(.{ .cwd_relative = arch_cpp_include_dir });
|
||||
} else |err| err catch {};
|
||||
}
|
||||
|
||||
{
|
||||
const arch_cpp_include_dir = try std.mem.concat(b.allocator, u8, &.{ "/usr/include/x86_64-linux-gnu/c++/", gcc_version });
|
||||
const d2 = std.fs.cwd().openDir(arch_cpp_include_dir, .{});
|
||||
if (d2) |_| {
|
||||
var d = d2 catch unreachable;
|
||||
d.close();
|
||||
exe.addIncludePath(.{ .cwd_relative = arch_cpp_include_dir });
|
||||
} else |err| err catch {};
|
||||
}
|
||||
|
||||
var found_libcpp = false;
|
||||
|
||||
if (std.fs.cwd().openFile("/usr/lib/libstdc++.so.6", .{})) |file| {
|
||||
file.close();
|
||||
found_libcpp = true;
|
||||
exe.addObjectFile(.{ .cwd_relative = "/usr/lib/libstdc++.so.6" });
|
||||
} else |err| {
|
||||
err catch {};
|
||||
}
|
||||
|
||||
if (std.fs.cwd().openFile("/usr/lib/x86_64-linux-gnu/libstdc++.so.6", .{})) |file| {
|
||||
file.close();
|
||||
found_libcpp = true;
|
||||
exe.addObjectFile(.{ .cwd_relative = "/usr/lib/x86_64-linux-gnu/libstdc++.so.6" });
|
||||
} else |err| {
|
||||
err catch {};
|
||||
}
|
||||
|
||||
if (!found_libcpp) {
|
||||
return error.libcpp_not_found;
|
||||
}
|
||||
|
||||
const needed_libraries: []const []const u8 = &.{ "unwind", "z", "zstd" };
|
||||
for (needed_libraries) |lib| {
|
||||
exe.linkSystemLibrary(lib);
|
||||
}
|
||||
|
||||
for (llvm_libs.items) |lib| {
|
||||
exe.linkSystemLibrary(lib);
|
||||
}
|
||||
|
||||
const lld_libs: []const []const u8 = &.{ "lldCommon", "lldCOFF", "lldELF", "lldMachO", "lldMinGW", "lldWasm" };
|
||||
for (lld_libs) |lib| {
|
||||
exe.linkSystemLibrary(lib);
|
||||
}
|
||||
|
||||
b.installArtifact(exe);
|
||||
|
||||
for ([_]bool{ false, true }) |is_test| {
|
||||
const run_step_name = switch (is_test) {
|
||||
true => "test",
|
||||
false => "run",
|
||||
};
|
||||
|
||||
const debug_step_name = switch (is_test) {
|
||||
true => "debug_test",
|
||||
false => "debug",
|
||||
};
|
||||
|
||||
const command = b.addRunArtifact(exe);
|
||||
command.step.dependOn(b.getInstallStep());
|
||||
|
||||
if (is_test) {
|
||||
command.addArg("test");
|
||||
}
|
||||
|
||||
if (b.args) |args| {
|
||||
command.addArgs(args);
|
||||
}
|
||||
|
||||
const run_step = b.step(run_step_name, "");
|
||||
run_step.dependOn(&command.step);
|
||||
|
||||
const debug_command = std.Build.Step.Run.create(b, b.fmt("{s} {s}", .{ debug_step_name, exe.name }));
|
||||
debug_command.addArg("gdb");
|
||||
debug_command.addArg("-ex");
|
||||
debug_command.addArg("r");
|
||||
debug_command.addArg("--args");
|
||||
debug_command.addArtifactArg(exe);
|
||||
|
||||
if (is_test) {
|
||||
debug_command.addArg("test");
|
||||
}
|
||||
|
||||
if (b.args) |args| {
|
||||
debug_command.addArgs(args);
|
||||
}
|
||||
|
||||
const debug_step = b.step(debug_step_name, "");
|
||||
debug_step.dependOn(&debug_command.step);
|
||||
}
|
||||
}
|
61
old_build.sh
61
old_build.sh
@ -1,61 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
|
||||
MY_CWD=$PWD
|
||||
|
||||
if [[ -z "${BB_CI-}" ]]; then
|
||||
BB_CI=0
|
||||
fi
|
||||
|
||||
if [[ -z "${BB_BUILD_TYPE-}" ]]; then
|
||||
BB_BUILD_TYPE=debug
|
||||
fi
|
||||
|
||||
if [[ -z "${BB_ERROR_ON_WARNINGS-}" ]]; then
|
||||
BB_ERROR_ON_WARNINGS=$BB_CI
|
||||
fi
|
||||
|
||||
if [[ -z "${BB_ERROR_LIMIT-}" ]]; then
|
||||
BB_ERROR_LIMIT=$((1 - BB_CI))
|
||||
fi
|
||||
|
||||
BB_COMPILE_SHADERS=0
|
||||
|
||||
BUILD_DIR=cache
|
||||
LARGE_ASSET_BASE_URL=https://github.com/birth-software/bloat-buster/releases/download/large-assets
|
||||
mkdir -p $BUILD_DIR
|
||||
|
||||
if [[ ! -f "$BUILD_DIR/large_assembly.s" ]]; then
|
||||
cd $BUILD_DIR
|
||||
wget $LARGE_ASSET_BASE_URL/large_assembly.s -o large_assembly.s
|
||||
cd $MY_CWD
|
||||
fi
|
||||
|
||||
if [[ "${BB_COMPILE_SHADERS}" == "1" ]]; then
|
||||
glslangValidator -V bootstrap/std/shaders/rect.vert -o $BUILD_DIR/rect.vert.spv --quiet
|
||||
glslangValidator -V bootstrap/std/shaders/rect.frag -o $BUILD_DIR/rect.frag.spv --quiet
|
||||
fi
|
||||
|
||||
BUILD_OUT=$BUILD_DIR/build
|
||||
C_COMPILER=clang
|
||||
TIME_TRACE=1
|
||||
BB_TIMETRACE=0
|
||||
GCC_ARGS=
|
||||
CLANG_ARGS=
|
||||
TIME_TRACE_ARG=
|
||||
|
||||
if [[ $C_COMPILER == "clang"* ]]; then
|
||||
CLANG_ARGS=-ferror-limit=1
|
||||
if [[ "$TIME_TRACE" == "1" ]]; then
|
||||
CLANG_ARGS="$CLANG_ARGS -ftime-trace"
|
||||
BB_TIMETRACE=1
|
||||
else
|
||||
CLANG_ARGS="$CLANG_ARGS -ftime-trace"
|
||||
fi
|
||||
elif [[ $C_COMPILER == "gcc"* ]]; then
|
||||
GCC_ARGS=-fmax-errors=1
|
||||
fi
|
||||
|
||||
$C_COMPILER build.c -g -o $BUILD_OUT -Ibootstrap -std=gnu2x $CLANG_ARGS $GCC_ARGS -DBB_TIMETRACE=$BB_TIMETRACE -DBB_CI=$BB_CI -DBB_BUILD_TYPE=\"$BB_BUILD_TYPE\" -DBB_ERROR_ON_WARNINGS=$BB_ERROR_ON_WARNINGS -DBB_ERROR_LIMIT=$BB_ERROR_LIMIT
|
||||
$BUILD_OUT $@
|
||||
exit 0
|
1901
src/LLVM.zig
1901
src/LLVM.zig
File diff suppressed because it is too large
Load Diff
10784
src/bootstrap.zig
10784
src/bootstrap.zig
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
#include <compiler.h>
|
||||
#include <compiler.hpp>
|
||||
|
||||
fn void compile(Arena* arena, Options options)
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <lib.h>
|
||||
#include <lib.hpp>
|
||||
#include <llvm-c/Types.h>
|
||||
#define report_error() trap()
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <compiler.h>
|
||||
#include <llvm.h>
|
||||
#include <compiler.hpp>
|
||||
#include <llvm.hpp>
|
||||
|
||||
enum class EvaluationKind
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <lib.h>
|
||||
#include <lib.hpp>
|
||||
void entry_point(Slice<const char*> arguments, Slice<char* const> environment);
|
||||
int main(int argc, const char* argv[], char* const envp[])
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <lib.h>
|
||||
#include <lib.hpp>
|
||||
using uid_t = u32;
|
||||
using gid_t = u32;
|
||||
using off_t = s64;
|
||||
|
3159
src/lib.zig
3159
src/lib.zig
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
#include <llvm.h>
|
||||
#include <llvm.hpp>
|
||||
|
||||
#include "llvm/Config/llvm-config.h"
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <lib.h>
|
||||
#include <lib.hpp>
|
||||
#include <llvm-c/Core.h>
|
||||
#include <llvm-c/DebugInfo.h>
|
||||
#include <llvm-c/Analysis.h>
|
296
src/llvm_api.zig
296
src/llvm_api.zig
@ -1,296 +0,0 @@
|
||||
const llvm = @import("LLVM.zig");
|
||||
const lld = llvm.lld;
|
||||
|
||||
const Bool = c_int;
|
||||
|
||||
pub extern fn llvm_context_create_module(context: *llvm.Context, name: llvm.String) *llvm.Module;
|
||||
pub extern fn LLVMContextCreate() *llvm.Context;
|
||||
pub extern fn LLVMCreateBuilderInContext(context: *llvm.Context) *llvm.Builder;
|
||||
|
||||
pub extern fn LLVMGetOperand(value: *llvm.Value, index: c_uint) *llvm.Value;
|
||||
pub extern fn LLVMSetAlignment(value: *llvm.Value, alignment: c_uint) void;
|
||||
pub extern fn llvm_instruction_is_call_base(instruction: *llvm.Instruction) bool;
|
||||
|
||||
// Module
|
||||
pub extern fn llvm_module_create_global_variable(module: *llvm.Module, global_type: *llvm.Type, is_constant: bool, linkage: llvm.LinkageType, initial_value: *llvm.Constant, name: llvm.String, before: ?*llvm.GlobalVariable, thread_local_mode: llvm.ThreadLocalMode, address_space: c_uint, externally_initialized: bool) *llvm.GlobalVariable;
|
||||
pub extern fn LLVMSetUnnamedAddress(global: *llvm.GlobalVariable, unnamed_address: llvm.GlobalVariable.UnnamedAddress) void;
|
||||
pub extern fn llvm_module_create_function(module: *llvm.Module, function_type: *llvm.Type.Function, linkage_type: llvm.LinkageType, address_space: c_uint, name: llvm.String) *llvm.Function;
|
||||
pub extern fn llvm_context_create_basic_block(context: *llvm.Context, name: llvm.String, parent: ?*llvm.Function) *llvm.BasicBlock;
|
||||
pub extern fn LLVMGetNextBasicBlock(basic_block: *llvm.BasicBlock) ?*llvm.BasicBlock;
|
||||
pub extern fn LLVMDeleteBasicBlock(basic_block: *llvm.BasicBlock) void;
|
||||
pub extern fn LLVMGetLastBasicBlock(function: *llvm.Function) *llvm.BasicBlock;
|
||||
pub extern fn LLVMGetBasicBlockParent(basic_block: *llvm.BasicBlock) ?*llvm.BasicBlock;
|
||||
pub extern fn LLVMAppendExistingBasicBlock(function: *llvm.Function, basic_block: *llvm.BasicBlock) void;
|
||||
pub extern fn LLVMInsertExistingBasicBlockAfterInsertBlock(builder: *llvm.Builder, basic_block: *llvm.BasicBlock) void;
|
||||
|
||||
pub extern fn LLVMSetValueName2(value: *llvm.Value, name_pointer: [*]const u8, name_length: usize) void;
|
||||
pub extern fn llvm_value_use_empty(value: *llvm.Value) bool;
|
||||
pub extern fn llvm_value_has_one_use(value: *llvm.Value) bool;
|
||||
pub extern fn llvm_value_to_branch(value: ?*llvm.Value) ?*llvm.Instruction.Branch;
|
||||
pub extern fn LLVMReplaceAllUsesWith(old: *llvm.Value, new: *llvm.Value) void;
|
||||
|
||||
pub extern fn LLVMGetSuccessor(branch: *llvm.Instruction.Branch, index: c_uint) *llvm.BasicBlock;
|
||||
pub extern fn LLVMIsConditional(branch: *llvm.Instruction.Branch) bool;
|
||||
pub extern fn LLVMGetInstructionParent(instruction: *llvm.Instruction) *llvm.BasicBlock;
|
||||
|
||||
pub extern fn llvm_basic_block_is_empty(basic_block: *llvm.BasicBlock) bool;
|
||||
pub extern fn llvm_basic_block_user_begin(basic_block: *llvm.BasicBlock) ?*llvm.Value;
|
||||
pub extern fn llvm_basic_block_delete(basic_block: *llvm.BasicBlock) void;
|
||||
pub extern fn LLVMGetBasicBlockTerminator(basic_block: *llvm.BasicBlock) ?*llvm.Value;
|
||||
|
||||
pub extern fn LLVMSetFunctionCallConv(function: *llvm.Function, calling_convention: llvm.CallingConvention) void;
|
||||
pub extern fn LLVMGetFunctionCallConv(function: *llvm.Function) llvm.CallingConvention;
|
||||
|
||||
pub extern fn LLVMSetInstructionCallConv(instruction: *llvm.Instruction.CallBase, calling_convention: llvm.CallingConvention) void;
|
||||
|
||||
pub extern fn LLVMGetParams(function: *llvm.Function, argument_buffer: [*]*llvm.Argument) void;
|
||||
|
||||
pub extern fn llvm_function_to_string(function: *llvm.Function) llvm.String;
|
||||
pub extern fn llvm_function_verify(function: *llvm.Function, error_message: *llvm.String) bool;
|
||||
pub extern fn llvm_module_verify(module: *llvm.Module, error_message: *llvm.String) bool;
|
||||
|
||||
pub extern fn llvm_module_to_string(module: *llvm.Module) llvm.String;
|
||||
|
||||
// Builder API
|
||||
pub extern fn LLVMPositionBuilderAtEnd(builder: *llvm.Builder, basic_block: *llvm.BasicBlock) void;
|
||||
pub extern fn LLVMClearInsertionPosition(builder: *llvm.Builder) void;
|
||||
pub extern fn LLVMGetInsertBlock(builder: *llvm.Builder) ?*llvm.BasicBlock;
|
||||
|
||||
pub extern fn llvm_find_return_value_dominating_store(builder: *llvm.Builder, return_alloca: *llvm.Value, element_type: *llvm.Type) ?*llvm.Instruction.Store;
|
||||
|
||||
pub extern fn LLVMDeleteInstruction(instruction: *llvm.Instruction) void;
|
||||
pub extern fn LLVMInstructionEraseFromParent(instruction: *llvm.Instruction) void;
|
||||
|
||||
pub extern fn LLVMBuildRet(builder: *llvm.Builder, value: ?*llvm.Value) void;
|
||||
pub extern fn LLVMBuildAdd(builder: *llvm.Builder, left: *llvm.Value, right: *llvm.Value, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildSub(builder: *llvm.Builder, left: *llvm.Value, right: *llvm.Value, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildMul(builder: *llvm.Builder, left: *llvm.Value, right: *llvm.Value, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildSDiv(builder: *llvm.Builder, left: *llvm.Value, right: *llvm.Value, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildUDiv(builder: *llvm.Builder, left: *llvm.Value, right: *llvm.Value, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildSRem(builder: *llvm.Builder, left: *llvm.Value, right: *llvm.Value, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildURem(builder: *llvm.Builder, left: *llvm.Value, right: *llvm.Value, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildShl(builder: *llvm.Builder, left: *llvm.Value, right: *llvm.Value, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildAShr(builder: *llvm.Builder, left: *llvm.Value, right: *llvm.Value, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildLShr(builder: *llvm.Builder, left: *llvm.Value, right: *llvm.Value, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildAnd(builder: *llvm.Builder, left: *llvm.Value, right: *llvm.Value, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildOr(builder: *llvm.Builder, left: *llvm.Value, right: *llvm.Value, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildXor(builder: *llvm.Builder, left: *llvm.Value, right: *llvm.Value, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildICmp(builder: *llvm.Builder, predicate: llvm.IntPredicate, left: *llvm.Value, right: *llvm.Value, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildBr(builder: *llvm.Builder, block: *llvm.BasicBlock) *llvm.Value;
|
||||
pub extern fn LLVMBuildCondBr(builder: *llvm.Builder, condition: *llvm.Value, taken: *llvm.BasicBlock, not_taken: *llvm.BasicBlock) *llvm.Value;
|
||||
pub extern fn LLVMBuildNeg(builder: *llvm.Builder, value: *llvm.Value, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildNot(builder: *llvm.Builder, value: *llvm.Value, name: [*:0]const u8) *llvm.Value;
|
||||
|
||||
pub extern fn llvm_builder_create_alloca(builder: *llvm.Builder, ty: *llvm.Type, address_space: c_uint, name: llvm.String) *llvm.Value;
|
||||
pub extern fn LLVMBuildStore(builder: *llvm.Builder, value: *llvm.Value, pointer: *llvm.Value) *llvm.Value;
|
||||
pub extern fn LLVMBuildLoad2(builder: *llvm.Builder, ty: *llvm.Type, pointer: *llvm.Value, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildCall2(builder: *llvm.Builder, ty: *llvm.Type.Function, pointer: *llvm.Value, argument_pointer: [*]const *llvm.Value, argument_count: c_uint, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildStructGEP2(builder: *llvm.Builder, struct_type: *llvm.Type.Struct, pointer: *llvm.Value, index: c_uint, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildGEP2(builder: *llvm.Builder, ty: *llvm.Type, aggregate: *llvm.Value, index_pointer: [*]const *llvm.Value, index_count: c_uint, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildInBoundsGEP2(builder: *llvm.Builder, ty: *llvm.Type, aggregate: *llvm.Value, index_pointer: [*]const *llvm.Value, index_count: c_uint, name: [*:0]const u8) *llvm.Value;
|
||||
|
||||
pub extern fn LLVMBuildInsertValue(builder: *llvm.Builder, aggregate: *llvm.Value, element: *llvm.Value, index: c_uint, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildExtractValue(builder: *llvm.Builder, aggregate: *llvm.Value, index: c_uint, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildUnreachable(builder: *llvm.Builder) *llvm.Value;
|
||||
pub extern fn LLVMBuildMemCpy(builder: *llvm.Builder, destination: *llvm.Value, destination_alignment: c_uint, source: *llvm.Value, source_alignment: c_uint, size: *llvm.Value) *llvm.Value;
|
||||
pub extern fn LLVMBuildMemSet(builder: *llvm.Builder, pointer: *llvm.Value, value: *llvm.Value, value_count: *llvm.Value, alignment: c_uint) *llvm.Value;
|
||||
pub extern fn LLVMBuildPhi(builder: *llvm.Builder, ty: *llvm.Type, name: [*:0]const u8) *llvm.Instruction.Phi;
|
||||
pub extern fn LLVMAddIncoming(phi: *llvm.Instruction.Phi, incoming_value_pointer: [*]const *llvm.Value, incoming_basic_block_pointer: [*]const *llvm.BasicBlock, incoming_count: c_uint) void;
|
||||
pub extern fn LLVMBuildSelect(builder: *llvm.Builder, condition: *llvm.Value, true_value: *llvm.Value, false_value: *llvm.Value, name: [*:0]const u8) *llvm.Value;
|
||||
|
||||
pub extern fn LLVMBuildVAArg(builder: *llvm.Builder, va_list: *llvm.Value, arg_type: *llvm.Type, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildSwitch(builder: *llvm.Builder, discriminant: *llvm.Value, else_basic_block: *llvm.BasicBlock, case_count: c_uint) *llvm.Instruction.Switch;
|
||||
pub extern fn LLVMAddCase(switchi: *llvm.Instruction.Switch, case_value: *llvm.Value, case_block: *llvm.BasicBlock) void;
|
||||
|
||||
// Casts
|
||||
pub extern fn LLVMBuildIntCast2(builder: *llvm.Builder, value: *llvm.Value, destination_type: *llvm.Type, is_signed: Bool, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildZExt(builder: *llvm.Builder, value: *llvm.Value, destination_type: *llvm.Type, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildSExt(builder: *llvm.Builder, value: *llvm.Value, destination_type: *llvm.Type, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildTrunc(builder: *llvm.Builder, value: *llvm.Value, destination_type: *llvm.Type, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildIntToPtr(builder: *llvm.Builder, value: *llvm.Value, destination_type: *llvm.Type, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildPtrToInt(builder: *llvm.Builder, value: *llvm.Value, destination_type: *llvm.Type, name: [*:0]const u8) *llvm.Value;
|
||||
pub extern fn LLVMBuildPointerCast(builder: *llvm.Builder, value: *llvm.Value, ty: *llvm.Type, name: [*:0]const u8) *llvm.Value;
|
||||
|
||||
pub extern fn LLVMGetCurrentDebugLocation2(builder: *llvm.Builder) ?*llvm.DI.Location;
|
||||
pub extern fn LLVMSetCurrentDebugLocation2(builder: *llvm.Builder, location: ?*llvm.DI.Location) void;
|
||||
|
||||
pub extern fn LLVMTypeOf(value: *llvm.Value) *llvm.Type;
|
||||
pub extern fn LLVMSizeOf(ty: *llvm.Type) *llvm.Constant;
|
||||
pub extern fn LLVMAlignOf(ty: *llvm.Type) *llvm.Constant;
|
||||
pub extern fn LLVMGlobalGetValueType(value: *llvm.GlobalValue) *llvm.Type;
|
||||
pub extern fn LLVMGetInitializer(global_variable: *llvm.GlobalVariable) *llvm.Constant;
|
||||
pub extern fn LLVMSetInitializer(global_variable: *llvm.GlobalVariable, initializer: *llvm.Constant) void;
|
||||
pub extern fn LLVMDeleteGlobal(global_variable: *llvm.GlobalVariable) void;
|
||||
pub extern fn llvm_global_variable_delete(global_variable: *llvm.GlobalVariable) void;
|
||||
pub extern fn llvm_value_is_instruction(value: *llvm.Value) bool;
|
||||
|
||||
// Intrinsics
|
||||
pub extern fn LLVMLookupIntrinsicID(name_pointer: [*]const u8, name_length: usize) llvm.Intrinsic.Id;
|
||||
pub extern fn LLVMGetNamedFunction(module: *llvm.Module, name: [*:0]const u8) *llvm.Function;
|
||||
pub extern fn LLVMGetIntrinsicDeclaration(module: *llvm.Module, intrinsic_id: llvm.Intrinsic.Id, parameter_type_pointer: [*]const *llvm.Type, parameter_type_count: usize) *llvm.Value;
|
||||
pub extern fn LLVMIntrinsicGetType(context: *llvm.Context, intrinsic_id: llvm.Intrinsic.Id, parameter_type_pointer: [*]const *llvm.Type, parameter_type_count: usize) *llvm.Type.Function;
|
||||
|
||||
// Attributes
|
||||
pub extern fn llvm_attribute_list_build(context: *llvm.Context, options: *const llvm.Attribute.List.Options, call_site: bool) *llvm.Attribute.List;
|
||||
pub extern fn llvm_function_set_attributes(function: *llvm.Function, attribute_list: *llvm.Attribute.List) void;
|
||||
pub extern fn llvm_call_base_set_attributes(function: *llvm.Instruction.CallBase, attribute_list: *llvm.Attribute.List) void;
|
||||
|
||||
// pub extern fn LLVMGetEnumAttributeKindForName(name_pointer: [*]const u8, name_length: usize) llvm.Attribute.Kind;
|
||||
//
|
||||
// pub extern fn LLVMCreateEnumAttribute(context: *llvm.Context, kind: llvm.Attribute.Kind, value: u64) *llvm.Attribute;
|
||||
// pub extern fn LLVMCreateTypeAttribute(context: *llvm.Context, kind: llvm.Attribute.Kind, ty: *llvm.Type) *llvm.Attribute;
|
||||
// pub extern fn LLVMCreateConstantRangeAttribute(context: *llvm.Context, kind: llvm.Attribute.Kind, bit_count: c_uint, lower_words: [*]const u64, upper_words: [*]const u64) *llvm.Attribute;
|
||||
// pub extern fn LLVMCreateStringAttribute(context: *llvm.Context, key_pointer: [*]const u8, key_length: c_uint, value_pointer: [*]const u8, value_length: usize) *llvm.Attribute;
|
||||
//
|
||||
// pub extern fn LLVMAddAttributeAtIndex(function: *llvm.Function, attribute_index: llvm.Attribute.Index, attribute: *llvm.Attribute) void;
|
||||
// pub extern fn LLVMAddCallSiteAttribute(call: *llvm.Instruction.Call, attribute_index: llvm.Attribute.Index, attribute: *llvm.Attribute) void;
|
||||
|
||||
// TYPES
|
||||
// Types: integers
|
||||
pub extern fn LLVMVoidTypeInContext(context: *llvm.Context) *llvm.Type;
|
||||
pub extern fn LLVMInt1TypeInContext(context: *llvm.Context) *llvm.Type.Integer;
|
||||
pub extern fn LLVMInt8TypeInContext(context: *llvm.Context) *llvm.Type.Integer;
|
||||
pub extern fn LLVMInt16TypeInContext(context: *llvm.Context) *llvm.Type.Integer;
|
||||
pub extern fn LLVMInt32TypeInContext(context: *llvm.Context) *llvm.Type.Integer;
|
||||
pub extern fn LLVMInt64TypeInContext(context: *llvm.Context) *llvm.Type.Integer;
|
||||
pub extern fn LLVMInt128TypeInContext(context: *llvm.Context) *llvm.Type.Integer;
|
||||
pub extern fn LLVMIntTypeInContext(context: *llvm.Context, bit_count: c_uint) *llvm.Type.Integer;
|
||||
|
||||
// Types: floating point
|
||||
pub extern fn LLVMHalfTypeInContext(context: *llvm.Context) *llvm.Type;
|
||||
pub extern fn LLVMBFloatTypeInContext(context: *llvm.Context) *llvm.Type;
|
||||
pub extern fn LLVMFloatTypeInContext(context: *llvm.Context) *llvm.Type;
|
||||
pub extern fn LLVMDoubleTypeInContext(context: *llvm.Context) *llvm.Type;
|
||||
pub extern fn LLVMFP128TypeInContext(context: *llvm.Context) *llvm.Type;
|
||||
|
||||
// Types: functions
|
||||
pub extern fn LLVMFunctionType(return_type: *llvm.Type, parameter_type_pointer: [*]const *llvm.Type, parameter_type_count: c_uint, is_var_arg: Bool) *llvm.Type.Function;
|
||||
pub extern fn LLVMIsFunctionVarArg(function_type: *llvm.Type.Function) Bool;
|
||||
pub extern fn LLVMGetReturnType(function_type: *llvm.Type.Function) *llvm.Type;
|
||||
pub extern fn LLVMSetSubprogram(function: *llvm.Function, subprogram: *llvm.DI.Subprogram) void;
|
||||
pub extern fn LLVMGetSubprogram(function: *llvm.Function) ?*llvm.DI.Subprogram;
|
||||
pub extern fn llvm_subprogram_replace_type(subprogram: *llvm.DI.Subprogram, subroutine_type: *llvm.DI.Type.Subroutine) void;
|
||||
pub extern fn LLVMCountParamTypes(function_type: *llvm.Type.Function) c_uint;
|
||||
pub extern fn LLVMGetParamTypes(function_type: *llvm.Type.Function, types: [*]*llvm.Type) void;
|
||||
|
||||
// Types: struct
|
||||
pub extern fn LLVMStructSetBody(struct_type: *llvm.Type.Struct, element_type_pointer: [*]const *llvm.Type, element_type_count: c_uint, is_packed: Bool) void;
|
||||
pub extern fn llvm_context_create_forward_declared_struct_type(context: *llvm.Context, name: llvm.String) *llvm.Type.Struct;
|
||||
pub extern fn llvm_context_create_struct_type(context: *llvm.Context, element_types_pointer: [*]const *llvm.Type, element_type_count: usize, name: llvm.String, is_packed: bool) *llvm.Type.Struct;
|
||||
pub extern fn llvm_context_get_struct_type(context: *llvm.Context, element_types_pointer: [*]const *llvm.Type, element_type_count: usize, is_packed: bool) *llvm.Type.Struct;
|
||||
|
||||
// Types: arrays
|
||||
pub extern fn LLVMArrayType2(element_type: *llvm.Type, element_count: u64) *llvm.Type.Array;
|
||||
|
||||
// Types: pointers
|
||||
pub extern fn LLVMPointerTypeInContext(context: *llvm.Context, address_space: c_uint) *llvm.Type.Pointer;
|
||||
|
||||
// Types: vectors
|
||||
pub extern fn LLVMVectorType(element_type: *llvm.Type, element_count: c_uint) *llvm.Type.FixedVector;
|
||||
pub extern fn LLVMScalableVectorType(element_type: *llvm.Type, element_count: c_uint) *llvm.Type.ScalableVector;
|
||||
|
||||
pub extern fn LLVMGetTypeKind(ty: *llvm.Type) llvm.Type.Kind;
|
||||
|
||||
pub extern fn llvm_integer_type_get_bit_count(integer_type: *llvm.Type.Integer) c_uint;
|
||||
|
||||
// VALUES
|
||||
pub extern fn LLVMGetPoison(type: *llvm.Type) *llvm.Value;
|
||||
pub extern fn LLVMConstNeg(constant: *llvm.Constant) *llvm.Constant;
|
||||
pub extern fn LLVMConstNull(type: *llvm.Type) *llvm.Constant;
|
||||
pub extern fn LLVMConstInt(type: *llvm.Type.Integer, value: c_ulonglong, sign_extend: Bool) *llvm.Constant.Integer;
|
||||
pub extern fn LLVMConstIntGetZExtValue(constant: *llvm.Constant) u64;
|
||||
pub extern fn LLVMConstIntGetSExtValue(constant: *llvm.Constant) i64;
|
||||
pub extern fn LLVMConstArray2(element_type: *llvm.Type, value_pointer: [*]const *llvm.Constant, value_length: u64) *llvm.Constant;
|
||||
pub extern fn LLVMConstStructInContext(context: *llvm.Context, constant_value_pointer: [*]const *llvm.Constant, constant_value_count: c_uint, is_packed: c_uint) *llvm.Constant;
|
||||
pub extern fn LLVMConstNamedStruct(struct_type: *llvm.Type.Struct, constant_value_pointer: [*]const *llvm.Constant, constant_value_count: c_uint) *llvm.Constant;
|
||||
pub extern fn LLVMConstStringInContext2(context: *llvm.Context, string_pointer: [*]const u8, string_length: usize, dont_null_terminate: Bool) *llvm.Constant;
|
||||
|
||||
pub extern fn LLVMGetValueKind(value: *llvm.Value) llvm.Value.Kind;
|
||||
pub extern fn LLVMIsConstant(value: *llvm.Value) Bool;
|
||||
|
||||
// Debug info API
|
||||
pub extern fn LLVMCreateDIBuilder(module: *llvm.Module) *llvm.DI.Builder;
|
||||
pub extern fn LLVMDIBuilderFinalize(builder: *llvm.DI.Builder) void;
|
||||
pub extern fn LLVMDIBuilderCreateFile(builder: *llvm.DI.Builder, file_name: llvm.String, directory_name: llvm.String) *llvm.DI.File;
|
||||
pub extern fn LLVMDIBuilderCreateCompileUnit(builder: *llvm.DI.Builder, language: llvm.Dwarf.SourceLanguage, file: *llvm.DI.File, producer_name: llvm.String, optimized: Bool, flags: llvm.String, runtime_version: c_uint, split_name: llvm.String, dwarf_emission_kind: llvm.Dwarf.EmissionKind, debug_with_offset_id: c_uint, split_debug_inlining: Bool, debug_info_for_profiling: Bool, sysroot: llvm.String, sdk: llvm.String) *llvm.DI.CompileUnit;
|
||||
pub extern fn LLVMDIBuilderCreateSubroutineType(builder: *llvm.DI.Builder, file: *llvm.DI.File, parameter_type_pointer: [*]const *llvm.DI.Type, parameter_type_count: c_uint, flags: llvm.DI.Flags) *llvm.DI.Type.Subroutine;
|
||||
pub extern fn LLVMDIBuilderCreateFunction(builder: *llvm.DI.Builder, scope: *llvm.DI.Scope, name: llvm.String, linkage_name: llvm.String, file: *llvm.DI.File, line_number: c_uint, type: ?*llvm.DI.Type.Subroutine, local_to_unit: Bool, is_definition: Bool, scope_line: c_uint, flags: llvm.DI.Flags, is_optimized: Bool) *llvm.DI.Subprogram;
|
||||
pub extern fn LLVMDIBuilderFinalizeSubprogram(builder: *llvm.DI.Builder, subprogram: *llvm.DI.Subprogram) void;
|
||||
pub extern fn LLVMDIBuilderCreateExpression(builder: *llvm.DI.Builder, address: ?[*]const u64, length: u64) *llvm.DI.Expression;
|
||||
pub extern fn LLVMDIBuilderCreateDebugLocation(context: *llvm.Context, line: c_uint, column: c_uint, scope: *llvm.DI.Scope, inlined_at: ?*llvm.DI.Metadata) *llvm.DI.Location;
|
||||
pub extern fn LLVMDIBuilderCreateBasicType(builder: *llvm.DI.Builder, name_pointer: [*]const u8, name_length: usize, bit_count: u64, dwarf_type: llvm.Dwarf.Type, flags: llvm.DI.Flags) *llvm.DI.Type;
|
||||
pub extern fn LLVMDIBuilderCreateAutoVariable(builder: *llvm.DI.Builder, scope: *llvm.DI.Scope, name_pointer: [*]const u8, name_length: usize, file: *llvm.DI.File, line: c_uint, type: *llvm.DI.Type, always_preserve: Bool, flags: llvm.DI.Flags, align_in_bits: u32) *llvm.DI.LocalVariable;
|
||||
pub extern fn LLVMDIBuilderInsertDeclareRecordAtEnd(builder: *llvm.DI.Builder, storage: *llvm.Value, local_variable: *llvm.DI.LocalVariable, expression: *llvm.DI.Expression, debug_location: *llvm.DI.Location, basic_block: *llvm.BasicBlock) *llvm.DI.Record;
|
||||
pub extern fn LLVMDIBuilderCreateParameterVariable(builder: *llvm.DI.Builder, scope: *llvm.DI.Scope, name_pointer: [*]const u8, name_length: usize, argument_number: c_uint, file: *llvm.DI.File, line: c_uint, type: *llvm.DI.Type, always_preserve: Bool, flags: llvm.DI.Flags) *llvm.DI.LocalVariable;
|
||||
pub extern fn LLVMDIBuilderCreateGlobalVariableExpression(builder: *llvm.DI.Builder, scope: *llvm.DI.Scope, name_pointer: [*]const u8, name_length: usize, linkage_name_pointer: [*]const u8, linkage_name_length: usize, file: *llvm.DI.File, line: c_uint, global_type: *llvm.DI.Type, local_to_unit: Bool, expression: *llvm.DI.Expression, declaration: ?*llvm.DI.Metadata, align_in_bits: u32) *llvm.DI.GlobalVariableExpression;
|
||||
pub extern fn llvm_global_variable_add_debug_info(global_variable: *llvm.GlobalVariable, debug_global_variable: *llvm.DI.GlobalVariableExpression) void;
|
||||
pub extern fn LLVMDIBuilderCreateLexicalBlock(builder: *llvm.DI.Builder, scope: *llvm.DI.Scope, file: *llvm.DI.File, line: c_uint, column: c_uint) *llvm.DI.LexicalBlock;
|
||||
pub extern fn LLVMDIBuilderCreateReplaceableCompositeType(builder: *llvm.DI.Builder, tag: c_uint, name_pointer: [*]const u8, name_length: usize, scope: *llvm.DI.Scope, file: *llvm.DI.File, line: c_uint, runtime_language: c_uint, bit_size: u64, align_in_bits: u32, flags: llvm.DI.Flags, unique_identifier_pointer: ?[*]const u8, unique_identifier_length: usize) *llvm.DI.Type.Composite;
|
||||
pub extern fn LLVMDIBuilderCreateArrayType(builder: *llvm.DI.Builder, element_count: u64, align_in_bits: u32, element_type: *llvm.DI.Type, subscript_pointer: ?[*]const *llvm.DI.Metadata, subscript_count: c_uint) *llvm.DI.Type.Composite;
|
||||
pub extern fn LLVMDIBuilderCreateStructType(builder: *llvm.DI.Builder, scope: *llvm.DI.Scope, name_pointer: [*]const u8, name_length: usize, file: *llvm.DI.File, line: c_uint, bit_size: u64, align_in_bits: u32, flags: llvm.DI.Flags, derived_from: ?*llvm.DI.Type, member_pointer: [*]const *llvm.DI.Type.Derived, member_length: c_uint, runtime_language: c_uint, vtable_holder: ?*llvm.DI.Metadata, unique_id_pointer: ?[*]const u8, unique_id_length: usize) *llvm.DI.Type.Composite;
|
||||
pub extern fn LLVMDIBuilderCreateUnionType(builder: *llvm.DI.Builder, scope: *llvm.DI.Scope, name_pointer: [*]const u8, name_length: usize, file: *llvm.DI.File, line: c_uint, bit_size: u64, align_in_bits: u32, flags: llvm.DI.Flags, member_pointer: [*]const *llvm.DI.Type.Derived, member_length: c_uint, runtime_language: c_uint, unique_id_pointer: ?[*]const u8, unique_id_length: usize) *llvm.DI.Type.Composite;
|
||||
pub extern fn LLVMDIBuilderCreateMemberType(builder: *llvm.DI.Builder, scope: *llvm.DI.Scope, name_pointer: [*]const u8, name_length: usize, file: *llvm.DI.File, line: c_uint, bit_size: u64, align_in_bits: u32, bit_offset: u64, flags: llvm.DI.Flags, member_type: *llvm.DI.Type) *llvm.DI.Type.Derived;
|
||||
pub extern fn LLVMDIBuilderCreateBitFieldMemberType(builder: *llvm.DI.Builder, scope: *llvm.DI.Scope, name_pointer: [*]const u8, name_length: usize, file: *llvm.DI.File, line: c_uint, bit_size: u64, bit_offset: u64, bit_storage_offset: u64, flags: llvm.DI.Flags, member_type: *llvm.DI.Type) *llvm.DI.Type.Derived;
|
||||
pub extern fn LLVMDIBuilderCreatePointerType(builder: *llvm.DI.Builder, element_type: *llvm.DI.Type, bit_size: u64, align_in_bits: u32, address_space: c_uint, name_pointer: [*]const u8, name_length: usize) *llvm.DI.Type.Derived;
|
||||
pub extern fn LLVMDIBuilderCreateEnumerator(builder: *llvm.DI.Builder, name_pointer: [*]const u8, name_length: usize, value: i64, is_unsigned: Bool) *llvm.DI.Enumerator;
|
||||
pub extern fn LLVMDIBuilderCreateEnumerationType(builder: *llvm.DI.Builder, scope: *llvm.DI.Scope, name_pointer: [*]const u8, name_length: usize, file: *llvm.DI.File, line: c_uint, bit_size: u64, align_in_bits: u32, enumerator_pointer: [*]const *llvm.DI.Enumerator, enumerator_count: c_uint, backing_type: *llvm.DI.Type) *llvm.DI.Type.Composite;
|
||||
pub extern fn LLVMDIBuilderCreateTypedef(builder: *llvm.DI.Builder, ty: *llvm.DI.Type, name_pointer: [*]const u8, name_length: usize, file: *llvm.DI.File, line_number: c_uint, scope: *llvm.DI.Scope, align_in_bits: u32) *llvm.DI.Type.Derived;
|
||||
|
||||
pub extern fn LLVMMetadataReplaceAllUsesWith(forward: *llvm.DI.Type.Composite, complete: *llvm.DI.Type.Composite) void;
|
||||
|
||||
// Target
|
||||
pub extern fn llvm_default_target_triple() llvm.String;
|
||||
pub extern fn llvm_host_cpu_name() llvm.String;
|
||||
pub extern fn llvm_host_cpu_features() llvm.String;
|
||||
|
||||
pub extern fn llvm_create_target_machine(create: *const llvm.Target.Machine.Create, error_message: *llvm.String) ?*llvm.Target.Machine;
|
||||
pub extern fn llvm_module_set_target(module: *llvm.Module, target_machine: *llvm.Target.Machine) void;
|
||||
|
||||
pub extern fn llvm_module_run_optimization_pipeline(module: *llvm.Module, target_machine: *llvm.Target.Machine, options: llvm.OptimizationPipelineOptions) void;
|
||||
pub extern fn llvm_module_run_code_generation_pipeline(module: *llvm.Module, target_machine: *llvm.Target.Machine, options: llvm.CodeGenerationPipelineOptions) llvm.CodeGenerationPipelineResult;
|
||||
|
||||
pub fn get_initializer(comptime llvm_arch: llvm.Architecture) type {
|
||||
const arch_name = @tagName(llvm_arch);
|
||||
return struct {
|
||||
pub const initialize_target_info = @extern(*const fn () callconv(.C) void, .{
|
||||
.name = "LLVMInitialize" ++ arch_name ++ "TargetInfo",
|
||||
});
|
||||
pub const initialize_target = @extern(*const fn () callconv(.C) void, .{
|
||||
.name = "LLVMInitialize" ++ arch_name ++ "Target",
|
||||
});
|
||||
pub const initialize_target_mc = @extern(*const fn () callconv(.C) void, .{
|
||||
.name = "LLVMInitialize" ++ arch_name ++ "TargetMC",
|
||||
});
|
||||
pub const initialize_asm_printer = @extern(*const fn () callconv(.C) void, .{
|
||||
.name = "LLVMInitialize" ++ arch_name ++ "AsmPrinter",
|
||||
});
|
||||
pub const initialize_asm_parser = @extern(*const fn () callconv(.C) void, .{
|
||||
.name = "LLVMInitialize" ++ arch_name ++ "AsmParser",
|
||||
});
|
||||
pub const initialize_disassembler = @extern(*const fn () callconv(.C) void, .{
|
||||
.name = "LLVMInitialize" ++ arch_name ++ "Disassembler",
|
||||
});
|
||||
|
||||
pub fn initialize(options: llvm.TargetInitializerOptions) void {
|
||||
initialize_target_info();
|
||||
initialize_target();
|
||||
initialize_target_mc();
|
||||
|
||||
if (options.asm_printer) {
|
||||
initialize_asm_printer();
|
||||
}
|
||||
|
||||
if (options.asm_parser) {
|
||||
initialize_asm_parser();
|
||||
}
|
||||
|
||||
if (options.disassembler) {
|
||||
initialize_disassembler();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// LLD
|
||||
|
||||
pub extern fn lld_elf_link(argument_pointer: [*:null]const ?[*:0]const u8, argument_length: u64, exit_early: bool, disable_output: bool) lld.Result;
|
335
src/main.zig
335
src/main.zig
@ -1,335 +0,0 @@
|
||||
const lib = @import("lib.zig");
|
||||
const configuration = @import("configuration");
|
||||
const os = lib.os;
|
||||
const llvm = @import("LLVM.zig");
|
||||
const Arena = lib.Arena;
|
||||
|
||||
const compiler = @import("bootstrap.zig");
|
||||
const BuildMode = compiler.BuildMode;
|
||||
|
||||
test {
|
||||
_ = lib;
|
||||
_ = llvm;
|
||||
_ = compiler;
|
||||
}
|
||||
|
||||
fn fail() noreturn {
|
||||
lib.libc.exit(1);
|
||||
}
|
||||
|
||||
const Command = enum {
|
||||
@"test",
|
||||
compile,
|
||||
};
|
||||
|
||||
const Compile = struct {
|
||||
relative_file_path: [:0]const u8,
|
||||
build_mode: BuildMode,
|
||||
has_debug_info: bool,
|
||||
silent: bool,
|
||||
};
|
||||
|
||||
fn compile_file(arena: *Arena, compile: Compile) compiler.Options {
|
||||
const relative_file_path = compile.relative_file_path;
|
||||
if (relative_file_path.len < 5) {
|
||||
fail();
|
||||
}
|
||||
|
||||
const extension_start = lib.string.last_character(relative_file_path, '.') orelse fail();
|
||||
if (!lib.string.equal(relative_file_path[extension_start..], ".bbb")) {
|
||||
fail();
|
||||
}
|
||||
|
||||
const separator_index = lib.string.last_character(relative_file_path, '/') orelse 0;
|
||||
const base_start = separator_index + @intFromBool(separator_index != 0 or relative_file_path[separator_index] == '/');
|
||||
const base_name = relative_file_path[base_start..extension_start];
|
||||
|
||||
const is_compiler = lib.string.equal(relative_file_path, "src/compiler.bbb");
|
||||
const output_path_dir = arena.join_string(&.{
|
||||
base_cache_dir,
|
||||
if (is_compiler) "/compiler/" else "/",
|
||||
@tagName(compile.build_mode),
|
||||
"_",
|
||||
if (compile.has_debug_info) "di" else "nodi",
|
||||
});
|
||||
|
||||
os.make_directory(base_cache_dir);
|
||||
if (is_compiler) {
|
||||
os.make_directory(base_cache_dir ++ "/compiler");
|
||||
}
|
||||
|
||||
os.make_directory(output_path_dir);
|
||||
|
||||
const output_path_base = arena.join_string(&.{
|
||||
output_path_dir,
|
||||
"/",
|
||||
base_name,
|
||||
});
|
||||
|
||||
const output_object_path = arena.join_string(&.{ output_path_base, ".o" });
|
||||
const output_executable_path = output_path_base;
|
||||
|
||||
const file_content = lib.file.read(arena, relative_file_path);
|
||||
const file_path = os.absolute_path(arena, relative_file_path);
|
||||
const c_abi_object_path = arena.duplicate_string(configuration.c_abi_object_path);
|
||||
|
||||
const convert_options = compiler.Options{
|
||||
.executable = output_executable_path,
|
||||
.objects = if (lib.string.equal(base_name, "c_abi")) &.{ output_object_path, c_abi_object_path } else &.{output_object_path},
|
||||
.name = base_name,
|
||||
.build_mode = compile.build_mode,
|
||||
.content = file_content,
|
||||
.path = file_path,
|
||||
.has_debug_info = compile.has_debug_info,
|
||||
.target = compiler.Target.get_native(),
|
||||
.silent = compile.silent,
|
||||
};
|
||||
|
||||
compiler.compile(arena, convert_options);
|
||||
|
||||
return convert_options;
|
||||
}
|
||||
|
||||
const base_cache_dir = "bb-cache";
|
||||
|
||||
pub const panic = lib.panic_struct;
|
||||
pub const std_options = lib.std_options;
|
||||
pub const main = lib.main;
|
||||
|
||||
pub fn entry_point(arguments: []const [*:0]const u8, environment: [*:null]const ?[*:0]const u8) void {
|
||||
lib.GlobalState.initialize();
|
||||
const arena = lib.global.arena;
|
||||
|
||||
if (arguments.len < 2) {
|
||||
lib.print_string("error: Not enough arguments\n");
|
||||
fail();
|
||||
}
|
||||
|
||||
const command = lib.string.to_enum(Command, lib.cstring.to_slice(arguments[1])) orelse fail();
|
||||
|
||||
switch (command) {
|
||||
.compile => {
|
||||
if (arguments.len < 3) {
|
||||
lib.libc.exit(1);
|
||||
}
|
||||
|
||||
var build_mode = compiler.BuildMode.debug_none;
|
||||
var has_debug_info = true;
|
||||
|
||||
if (arguments.len >= 4) {
|
||||
const build_mode_string = lib.cstring.to_slice(arguments[3]);
|
||||
build_mode = lib.string.to_enum(compiler.BuildMode, build_mode_string) orelse lib.libc.exit(1);
|
||||
}
|
||||
|
||||
if (arguments.len >= 5) {
|
||||
const has_debug_info_string = lib.cstring.to_slice(arguments[4]);
|
||||
has_debug_info = if (lib.string.equal(has_debug_info_string, "true")) true else if (lib.string.equal(has_debug_info_string, "false")) false else lib.libc.exit(1);
|
||||
}
|
||||
|
||||
const relative_file_path = lib.cstring.to_slice(arguments[2]);
|
||||
_ = compile_file(arena, .{
|
||||
.relative_file_path = relative_file_path,
|
||||
.build_mode = build_mode,
|
||||
.has_debug_info = has_debug_info,
|
||||
.silent = false,
|
||||
});
|
||||
},
|
||||
.@"test" => {
|
||||
if (arguments.len != 2) {
|
||||
fail();
|
||||
}
|
||||
|
||||
const stop_at_failure = true;
|
||||
|
||||
var build_modes: [@typeInfo(BuildMode).@"enum".fields.len]BuildMode = undefined;
|
||||
inline for (@typeInfo(BuildMode).@"enum".fields, 0..) |field, field_index| {
|
||||
const build_mode = @field(BuildMode, field.name);
|
||||
build_modes[field_index] = build_mode;
|
||||
}
|
||||
|
||||
for (names) |name| {
|
||||
for (build_modes) |build_mode| {
|
||||
for ([2]bool{ true, false }) |has_debug_info| {
|
||||
const position = arena.position;
|
||||
defer arena.restore(position);
|
||||
|
||||
const relative_file_path = arena.join_string(&.{ "tests/", name, ".bbb" });
|
||||
const compile_result = compile_file(arena, .{
|
||||
.relative_file_path = relative_file_path,
|
||||
.build_mode = build_mode,
|
||||
.has_debug_info = has_debug_info,
|
||||
.silent = true,
|
||||
});
|
||||
|
||||
const result = lib.os.run_child_process(arena, &.{compile_result.executable}, environment, .{
|
||||
.stdout = .inherit,
|
||||
.stderr = .inherit,
|
||||
.null_file_descriptor = null,
|
||||
});
|
||||
|
||||
if (!result.is_successful()) {
|
||||
lib.print_string("[BOOTSTRAP] Failed to run test ");
|
||||
lib.print_string(name);
|
||||
lib.print_string(" with build mode ");
|
||||
lib.print_string(@tagName(build_mode));
|
||||
lib.print_string("\n");
|
||||
|
||||
if (stop_at_failure) {
|
||||
lib.libc.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const relative_file_path = arena.join_string(&.{"src/compiler.bbb"});
|
||||
for (build_modes) |build_mode| {
|
||||
for ([2]bool{ true, false }) |has_debug_info| {
|
||||
const position = arena.position;
|
||||
defer arena.restore(position);
|
||||
|
||||
const compile_result = compile_file(arena, .{
|
||||
.relative_file_path = relative_file_path,
|
||||
.build_mode = build_mode,
|
||||
.has_debug_info = has_debug_info,
|
||||
.silent = true,
|
||||
});
|
||||
|
||||
for (names[0..1]) |name| {
|
||||
for (build_modes) |self_hosted_build_mode| {
|
||||
for ([2]bool{ true, false }) |self_hosted_has_debug_info| {
|
||||
const self_hosted_relative_file_path = arena.join_string(&.{ "tests/", name, ".bbb" });
|
||||
// TODO: investigar corrupcion de memoria en compile_result.executable porque compile_file borra la memoria
|
||||
const result = lib.os.run_child_process(arena, &.{ compile_result.executable, "compile", self_hosted_relative_file_path, @tagName(self_hosted_build_mode), if (self_hosted_has_debug_info) "true" else "false" }, environment, .{
|
||||
.stdout = .inherit,
|
||||
.stderr = .inherit,
|
||||
.null_file_descriptor = null,
|
||||
});
|
||||
|
||||
if (!result.is_successful()) {
|
||||
lib.print_string("[SELF-HOSTED] Failed to compile ");
|
||||
lib.print_string(name);
|
||||
lib.print_string(" with build mode ");
|
||||
lib.print_string(@tagName(build_mode));
|
||||
lib.print_string(" and debug info ");
|
||||
lib.print_string(if (has_debug_info) "on" else "off");
|
||||
lib.print_string(", with self-hosted build mode ");
|
||||
lib.print_string(@tagName(self_hosted_build_mode));
|
||||
lib.print_string(" and self-hosted debug info ");
|
||||
lib.print_string(if (self_hosted_has_debug_info) "on" else "off");
|
||||
lib.print_string("\n");
|
||||
|
||||
if (stop_at_failure) {
|
||||
lib.libc.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const names = &[_][]const u8{
|
||||
"minimal",
|
||||
"comments",
|
||||
"constant_add",
|
||||
"constant_and",
|
||||
"constant_div",
|
||||
"constant_mul",
|
||||
"constant_rem",
|
||||
"constant_or",
|
||||
"constant_sub",
|
||||
"constant_xor",
|
||||
"constant_shift_left",
|
||||
"constant_shift_right",
|
||||
"minimal_stack",
|
||||
"minimal_stack_arithmetic",
|
||||
"minimal_stack_arithmetic2",
|
||||
"minimal_stack_arithmetic3",
|
||||
"extend",
|
||||
"stack_negation",
|
||||
"stack_add",
|
||||
"stack_sub",
|
||||
"integer_max",
|
||||
"integer_hex",
|
||||
"basic_pointer",
|
||||
"basic_call",
|
||||
"pointer",
|
||||
"pointer_cast",
|
||||
"u1_return",
|
||||
"local_type_inference",
|
||||
"global",
|
||||
"function_pointer",
|
||||
"extern",
|
||||
"byte_size",
|
||||
"basic_branch",
|
||||
"basic_array",
|
||||
"basic_enum",
|
||||
"argv",
|
||||
"assignment_operators",
|
||||
"basic_enum",
|
||||
"basic_slice",
|
||||
"basic_string",
|
||||
"basic_varargs",
|
||||
"basic_while",
|
||||
"not_pointer",
|
||||
"bits",
|
||||
"bits_no_backing_type",
|
||||
"bits_return_u1",
|
||||
"bits_zero",
|
||||
"comparison",
|
||||
"global_struct",
|
||||
"if_no_else",
|
||||
"if_no_else_void",
|
||||
"indirect",
|
||||
"indirect_struct",
|
||||
"indirect_varargs",
|
||||
"ret_c_bool",
|
||||
"return_type_builtin",
|
||||
"return_u64_u64",
|
||||
"select",
|
||||
"slice",
|
||||
"small_struct_ints",
|
||||
"struct_assignment",
|
||||
"struct",
|
||||
"struct_u64_u64",
|
||||
"struct_varargs",
|
||||
"struct_zero",
|
||||
"unreachable",
|
||||
"varargs",
|
||||
"c_abi0",
|
||||
"c_abi1",
|
||||
"c_med_struct_ints",
|
||||
"c_ret_struct_array",
|
||||
"c_split_struct_ints",
|
||||
"c_string_to_slice",
|
||||
"c_struct_with_array",
|
||||
"c_function_pointer",
|
||||
"c_abi",
|
||||
"string_to_enum",
|
||||
"abi_enum_bool",
|
||||
"empty_if",
|
||||
"else_if",
|
||||
"else_if_complicated",
|
||||
"shortcircuiting_if",
|
||||
"field_access_left_assign",
|
||||
"for_each",
|
||||
"pointer_decay",
|
||||
"enum_name",
|
||||
"slice_of_slices",
|
||||
"type_alias",
|
||||
"integer_formats",
|
||||
"return_small_struct",
|
||||
"basic_macro",
|
||||
"generic_macro",
|
||||
"for_each_int",
|
||||
"bool_array",
|
||||
"basic_union",
|
||||
"constant_global_reference",
|
||||
"generic_pointer_macro",
|
||||
"break_continue",
|
||||
"noreturn_macro",
|
||||
};
|
@ -1,4 +1,4 @@
|
||||
#include <compiler.h>
|
||||
#include <compiler.hpp>
|
||||
|
||||
enum class ValueIntrinsic
|
||||
{
|
||||
|
@ -1,20 +0,0 @@
|
||||
const std = @import("std");
|
||||
export fn enable_signal_handlers() void {
|
||||
std.debug.attachSegfaultHandler();
|
||||
}
|
||||
|
||||
export fn dump_stack_trace(return_address: usize) void {
|
||||
const stderr = std.io.getStdErr().writer();
|
||||
if (@import("builtin").strip_debug_info) {
|
||||
stderr.print("Unable to dump stack trace: debug info stripped\n", .{}) catch return;
|
||||
return;
|
||||
}
|
||||
const debug_info = std.debug.getSelfDebugInfo() catch |err| {
|
||||
stderr.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}) catch return;
|
||||
return;
|
||||
};
|
||||
std.debug.writeCurrentStackTrace(stderr, debug_info, std.io.tty.detectConfig(std.io.getStdErr()), return_address) catch |err| {
|
||||
stderr.print("Unable to dump stack trace: {s}\n", .{@errorName(err)}) catch return;
|
||||
return;
|
||||
};
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user