sm
This commit is contained in:
@@ -309,6 +309,8 @@ pub fn compileCWithEmcc(
|
||||
allocator: std.mem.Allocator,
|
||||
io: std.Io,
|
||||
infos: []const CImportInfo,
|
||||
target_config: @import("target.zig").TargetConfig,
|
||||
tmp_dir: []const u8,
|
||||
) ![]const []const u8 {
|
||||
var paths = std.ArrayList([]const u8).empty;
|
||||
var obj_idx: usize = 0;
|
||||
@@ -317,11 +319,15 @@ pub fn compileCWithEmcc(
|
||||
if (info.sources.len == 0) continue;
|
||||
|
||||
for (info.sources) |src| {
|
||||
const out_path = try std.fmt.allocPrint(allocator, "/tmp/sx_emcc_{d}.o", .{obj_idx});
|
||||
const out_path = try std.fmt.allocPrint(allocator, "{s}/sx_emcc_{d}.o", .{ tmp_dir, obj_idx });
|
||||
obj_idx += 1;
|
||||
|
||||
var argv = std.ArrayList([]const u8).empty;
|
||||
try argv.appendSlice(allocator, &.{ "emcc", "-c", "-O2", src, "-o", out_path });
|
||||
// wasm64: compile C sources with memory64 support
|
||||
if (target_config.isWasm64()) {
|
||||
try argv.append(allocator, "-sMEMORY64");
|
||||
}
|
||||
// Add include paths
|
||||
for (info.includes) |inc| {
|
||||
try argv.append(allocator, try std.fmt.allocPrint(allocator, "-I{s}", .{dirName(inc)}));
|
||||
@@ -355,11 +361,12 @@ pub fn writeCObjectFiles(
|
||||
allocator: std.mem.Allocator,
|
||||
io: std.Io,
|
||||
obj_bufs: []c.LLVMMemoryBufferRef,
|
||||
tmp_dir: []const u8,
|
||||
) ![]const []const u8 {
|
||||
var paths = std.ArrayList([]const u8).empty;
|
||||
|
||||
for (obj_bufs, 0..) |buf, i| {
|
||||
const path = try std.fmt.allocPrint(allocator, "/tmp/sx_c_{d}.o", .{i});
|
||||
const path = try std.fmt.allocPrint(allocator, "{s}/sx_c_{d}.o", .{ tmp_dir, i });
|
||||
const start = c.LLVMGetBufferStart(buf);
|
||||
const size = c.LLVMGetBufferSize(buf);
|
||||
const data = @as([*]const u8, @ptrCast(start))[0..size];
|
||||
|
||||
Reference in New Issue
Block a user