Some Windows fixes
This commit is contained in:
parent
5398895e5e
commit
08ca8706b9
@ -475,7 +475,11 @@ pub fn compileCSourceFile(context: *const Context, arguments: []const []const u8
|
||||
} else {
|
||||
const debug_args = true;
|
||||
if (debug_args) {
|
||||
const home_dir = std.posix.getenv("HOME") orelse unreachable;
|
||||
const home_dir = switch (@import("builtin").os.tag) {
|
||||
.linux, .macos => std.posix.getenv("HOME") orelse unreachable,
|
||||
.windows => try std.process.getEnvVarOwned(context.allocator, "USERPROFILE"),
|
||||
else => @compileError("OS not supported"),
|
||||
};
|
||||
var list = UnpinnedArray(u8){};
|
||||
for (arguments) |arg| {
|
||||
try list.append_slice(context.my_allocator, arg);
|
||||
@ -572,6 +576,9 @@ pub fn compileCSourceFile(context: *const Context, arguments: []const []const u8
|
||||
.macos => {
|
||||
try target_triple_buffer.append_slice(context.my_allocator, "macos-");
|
||||
},
|
||||
.windows => {
|
||||
try target_triple_buffer.append_slice(context.my_allocator, "windows-");
|
||||
},
|
||||
else => @compileError("OS not supported"),
|
||||
}
|
||||
|
||||
@ -647,6 +654,7 @@ pub fn compileCSourceFile(context: *const Context, arguments: []const []const u8
|
||||
},
|
||||
else => unreachable, //@compileError("ABI not supported"),
|
||||
},
|
||||
.windows => &.{},
|
||||
else => @compileError("OS not supported"),
|
||||
};
|
||||
|
||||
@ -3230,7 +3238,7 @@ pub const Type = union(enum) {
|
||||
array: Type.Array,
|
||||
polymorphic: Type.Polymorphic,
|
||||
|
||||
pub const Polymorphic = struct{
|
||||
pub const Polymorphic = struct {
|
||||
parameters: []const Token.Index,
|
||||
instantiations: MyHashMap(u32, *Debug.Declaration.Global) = .{},
|
||||
node: Node.Index,
|
||||
@ -3243,7 +3251,7 @@ pub const Type = union(enum) {
|
||||
|
||||
pub fn add_instantiation(polymorphic: *Polymorphic, unit: *Unit, context: *const Context, types: []const V.Comptime, original_declaration: *Debug.Declaration.Global, type_index: Type.Index) !void {
|
||||
var name = UnpinnedArray(u8){};
|
||||
const original_name = unit.getIdentifier( original_declaration.declaration.name);
|
||||
const original_name = unit.getIdentifier(original_declaration.declaration.name);
|
||||
try name.append_slice(context.my_allocator, original_name);
|
||||
try name.append(context.my_allocator, '(');
|
||||
|
||||
@ -7627,7 +7635,7 @@ pub const Builder = struct {
|
||||
});
|
||||
|
||||
const struct_type = unit.structs.get(struct_index);
|
||||
const struct_options = & struct_type.kind.@"struct".options;
|
||||
const struct_options = &struct_type.kind.@"struct".options;
|
||||
|
||||
var parameter_types = UnpinnedArray(Token.Index){};
|
||||
|
||||
@ -8838,7 +8846,7 @@ pub const Builder = struct {
|
||||
const ty = unit.types.get(type_index);
|
||||
switch (ty.*) {
|
||||
.pointer => |_| switch (value) {
|
||||
.@"comptime_int" => |ct_int| switch (ct_int.value) {
|
||||
.comptime_int => |ct_int| switch (ct_int.value) {
|
||||
0 => return .null_pointer,
|
||||
else => unreachable,
|
||||
},
|
||||
@ -12133,7 +12141,7 @@ pub const Builder = struct {
|
||||
else => |t| @panic(@tagName(t)),
|
||||
}
|
||||
} else {
|
||||
const id = unit.getIdentifier( struct_type.scope.scope.declarations.key_pointer[0]);
|
||||
const id = unit.getIdentifier(struct_type.scope.scope.declarations.key_pointer[0]);
|
||||
_ = id; // autofix
|
||||
unreachable;
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ pub fn allocate_virtual_memory(size: usize, flags: packed struct {
|
||||
pub fn free_virtual_memory(slice: []align(page_size) const u8) void {
|
||||
switch (os) {
|
||||
.windows => {
|
||||
std.os.windows.VirtualFree(slice.ptr, slice.len, std.os.windows.MEM_RELEASE);
|
||||
std.os.windows.VirtualFree(@constCast(@ptrCast(slice.ptr)), slice.len, std.os.windows.MEM_RELEASE);
|
||||
},
|
||||
else => {
|
||||
std.posix.munmap(slice);
|
||||
|
@ -77,6 +77,7 @@ pub fn link(context: *const Compilation.Context, options: linker.Options) !void
|
||||
try argv.append(context.my_allocator, "/usr/lib/crtn.o");
|
||||
}
|
||||
},
|
||||
.windows => {},
|
||||
else => @compileError("OS not supported"),
|
||||
}
|
||||
|
||||
|
@ -49,15 +49,15 @@ var my_allocator = PageAllocator{};
|
||||
pub fn main() !void {
|
||||
var arena_allocator = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
||||
const allocator = arena_allocator.allocator();
|
||||
var arg_it = std.process.ArgIterator.init();
|
||||
var arg_it = try std.process.ArgIterator.initWithAllocator(allocator);
|
||||
var args = library.UnpinnedArray([]const u8){};
|
||||
const context = try Compilation.createContext(allocator, &my_allocator.allocator);
|
||||
while (arg_it.next()) |arg| {
|
||||
try args.append(context.my_allocator, arg);
|
||||
}
|
||||
const arguments = args.slice();
|
||||
const debug_args = true;
|
||||
if (debug_args) {
|
||||
const debug_args = false;
|
||||
if (debug_args and @import("builtin").os.tag != .windows) {
|
||||
assert(arguments.len > 0);
|
||||
const home_dir = std.posix.getenv("HOME") orelse unreachable;
|
||||
const timestamp = std.time.milliTimestamp();
|
||||
|
12
build.zig
12
build.zig
@ -43,7 +43,7 @@ pub fn build(b: *std.Build) !void {
|
||||
});
|
||||
|
||||
var target_query = b.standardTargetOptionsQueryOnly(.{});
|
||||
const abi = b.option(std.Target.Abi, "abi", "This option modifies the ABI used for the compiler") orelse if (static) switch (os) {
|
||||
const abi = b.option(std.Target.Abi, "abi", "This option modifies the ABI used for the compiler") orelse if (static) switch (target_query.os_tag orelse @import("builtin").os.tag) {
|
||||
else => target_query.abi,
|
||||
.linux => b: {
|
||||
const os_release = try std.fs.cwd().readFileAlloc(b.allocator, "/etc/os-release", 0xffff);
|
||||
@ -107,6 +107,7 @@ pub fn build(b: *std.Build) !void {
|
||||
compiler.want_lto = false;
|
||||
|
||||
compiler.linkLibC();
|
||||
if (target.result.os.tag == .windows) compiler.linkage = .dynamic;
|
||||
|
||||
const zstd = if (target.result.os.tag == .windows) "zstd.lib" else "libzstd.a";
|
||||
|
||||
@ -349,7 +350,7 @@ pub fn build(b: *std.Build) !void {
|
||||
"libclangTransformer.a",
|
||||
};
|
||||
|
||||
if (static) {
|
||||
if (static or target.result.os.tag == .windows) {
|
||||
if (os == .linux) compiler.linkage = .static;
|
||||
compiler.linkLibCpp();
|
||||
|
||||
@ -448,10 +449,17 @@ pub fn build(b: *std.Build) !void {
|
||||
return err;
|
||||
}
|
||||
},
|
||||
.windows => {},
|
||||
else => |tag| @panic(@tagName(tag)),
|
||||
}
|
||||
}
|
||||
|
||||
if (target.result.os.tag == .windows) {
|
||||
compiler.linkSystemLibrary("ole32");
|
||||
compiler.linkSystemLibrary("version");
|
||||
compiler.linkSystemLibrary("uuid");
|
||||
}
|
||||
|
||||
const install_exe = b.addInstallArtifact(compiler, .{});
|
||||
b.getInstallStep().dependOn(&install_exe.step);
|
||||
b.installDirectory(.{
|
||||
|
@ -521,7 +521,7 @@ pub fn main() !void {
|
||||
|
||||
switch (@import("builtin").os.tag) {
|
||||
.macos => {},
|
||||
// .macos => {},
|
||||
.windows => {},
|
||||
.linux => switch (@import("builtin").abi) {
|
||||
.gnu => runCmakeTests(allocator, "test/cc_linux") catch {
|
||||
errors = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user