Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
9443c69
Only build tests on native targets
rtfeldman Nov 5, 2025
0cf9ed0
Fix platform detection
rtfeldman Nov 5, 2025
6ddd0ba
Make a proper app/platform structure for the test
rtfeldman Nov 6, 2025
728cee5
Don't use deprecated writer
rtfeldman Nov 6, 2025
88a1ce1
Clean up a bunch of dead code
rtfeldman Nov 6, 2025
a1d2c72
Make a comment accurate
rtfeldman Nov 6, 2025
d0d92b2
Remove a fallback
rtfeldman Nov 6, 2025
b85b05c
Fix CI
rtfeldman Nov 6, 2025
fe93921
Fix regression
rtfeldman Nov 6, 2025
f8eb94c
Fix some platform stuff
rtfeldman Nov 6, 2025
ea7420d
Fix CI
rtfeldman Nov 6, 2025
f880f64
Introduce .e_hosted_lambda
rtfeldman Nov 6, 2025
981737b
Do more in-place mutation
rtfeldman Nov 6, 2025
6028a52
Pass through hosted fns
rtfeldman Nov 6, 2025
db05231
Fix a bunch of things
rtfeldman Nov 7, 2025
10721e0
Fix zero-sized type handling in interpreter and improve root_is_platf…
rtfeldman Nov 7, 2025
f527e46
Fix host to pass arguments as tuple struct
rtfeldman Nov 7, 2025
d9d878b
Fix fx test app to use zero parameters and expose platform modules
rtfeldman Nov 7, 2025
1ba947a
Simplify platform hosted functions to annotation-only
rtfeldman Nov 7, 2025
ef9a1af
Get hosted effectful fns working
rtfeldman Nov 8, 2025
b638183
Clean up a bunch of debug stuff
rtfeldman Nov 8, 2025
7833d38
Get Stdin.line! working
rtfeldman Nov 8, 2025
8393d05
Drop some debug logging
rtfeldman Nov 8, 2025
f3a848f
Dynamically discover hosted thing names
rtfeldman Nov 8, 2025
1fe4fd6
More fixes
rtfeldman Nov 8, 2025
ca6abe3
Fix tests
rtfeldman Nov 8, 2025
3794500
Fix tests
rtfeldman Nov 8, 2025
bfcc2e0
Remove unnecessary .md files
rtfeldman Nov 8, 2025
7284a39
Merge remote-tracking branch 'origin/main' into improve-platform-modules
rtfeldman Nov 8, 2025
64a4c8e
Fix playground
rtfeldman Nov 8, 2025
3a8b219
fix lints
rtfeldman Nov 8, 2025
4362d79
zig fmt
rtfeldman Nov 8, 2025
e73aa74
Fix serialization test size
rtfeldman Nov 8, 2025
c984993
Fix Ubuntu CI
rtfeldman Nov 8, 2025
008de6d
Try to fix Windows
rtfeldman Nov 9, 2025
590a532
wip
rtfeldman Nov 7, 2025
8286c71
Use list_get_unsafe to get List.get working
rtfeldman Nov 7, 2025
f42eeb3
Get more List.get stuff working
rtfeldman Nov 7, 2025
c708f7e
Move list_get_unsafe to top level
rtfeldman Nov 7, 2025
70b24f1
Clean up some stuff
rtfeldman Nov 8, 2025
60fd987
Move list_get_unsafe to end of file
rtfeldman Nov 8, 2025
98c5b6c
Add everything to scope as appropriate
rtfeldman Nov 8, 2025
74aeced
Remove an unnecessary comment
rtfeldman Nov 8, 2025
2af948b
zig fmt
rtfeldman Nov 8, 2025
5261daf
Fix some deserialization
rtfeldman Nov 8, 2025
16aca66
Change some things to debug assertions
rtfeldman Nov 8, 2025
065d23f
Drop some comments
rtfeldman Nov 8, 2025
2043771
Reduce canonicalization passes
rtfeldman Nov 8, 2025
fa11e04
Drop some unnecessary reintroductions
rtfeldman Nov 8, 2025
00d0e65
Update tests
rtfeldman Nov 8, 2025
c65eefc
Do less rebuilding and scanning
rtfeldman Nov 8, 2025
17d3f6a
clean up some comments
rtfeldman Nov 8, 2025
0c55505
Report shadowing more consistently
rtfeldman Nov 8, 2025
b0ffa37
Clean up helpers and don't use them unnecesssarily
rtfeldman Nov 8, 2025
1d61e92
Revert an unnecessary loop.
rtfeldman Nov 8, 2025
7bd9d64
Remove some unnecessary stuff
rtfeldman Nov 8, 2025
2a0410e
Make Builtin itself un-importable
rtfeldman Nov 8, 2025
80a4729
zig fmt
rtfeldman Nov 8, 2025
bb11dde
Extract updatePlaceholder
rtfeldman Nov 8, 2025
75966be
Fix CI
rtfeldman Nov 8, 2025
2c683da
Do stuff in a less bad way
rtfeldman Nov 8, 2025
6e10489
Clean up some test code
rtfeldman Nov 8, 2025
e83bc46
More canonicalization fixes
rtfeldman Nov 8, 2025
4861838
Fix shadowing detection regression
rtfeldman Nov 8, 2025
d5e5e2b
More fixes
rtfeldman Nov 8, 2025
2af2921
Fix merge conflicts
rtfeldman Nov 8, 2025
c37d540
More fixes
rtfeldman Nov 8, 2025
e63fc11
Delete an obsolete comment
rtfeldman Nov 8, 2025
70d7e03
More fixes
rtfeldman Nov 8, 2025
79e8a54
zig fmt
rtfeldman Nov 8, 2025
03fa30c
Fix Ubuntu CI
rtfeldman Nov 8, 2025
7e35ca6
Fix stuff
rtfeldman Nov 9, 2025
b67f0d2
Fix Ubuntu CI panic and update snapshots
rtfeldman Nov 9, 2025
5ab3164
Improve a comment
rtfeldman Nov 9, 2025
614df0d
Remove unused imports
rtfeldman Nov 9, 2025
067a1db
Revert modules.zig back to origin/main
rtfeldman Nov 9, 2025
78e5155
Revert base/mod.zig to origin/main
rtfeldman Nov 9, 2025
e2720cf
Merge branch 'main' into improve-platform-modules
rtfeldman Nov 9, 2025
45491ef
Remove some obsolete tests
rtfeldman Nov 9, 2025
5c39c78
Delete unused tests
rtfeldman Nov 9, 2025
b3278f0
Run fx tests
rtfeldman Nov 9, 2025
2b8ea00
Add missing test
rtfeldman Nov 9, 2025
8f5a527
Fix duplicates
rtfeldman Nov 9, 2025
b602b74
Merge remote-tracking branch 'origin/main' into improve-platform-modules
rtfeldman Nov 9, 2025
3bb4890
Remove obsolete HostedIO.roc
rtfeldman Nov 10, 2025
5acbce1
Clean up some host stuff
rtfeldman Nov 10, 2025
e919425
Revert config.zig to origin/main
rtfeldman Nov 10, 2025
8f309fc
Delete unrelated thing
rtfeldman Nov 10, 2025
3ec0302
Drop an unused module
rtfeldman Nov 10, 2025
1c78bc0
Revert fmt and Filesystem to origin/main
rtfeldman Nov 10, 2025
ff50300
Update some comments
rtfeldman Nov 10, 2025
473bf1a
Use heap allocations for buffers
rtfeldman Nov 10, 2025
d3adb5f
Fix bugs around handling of root being platform
rtfeldman Nov 10, 2025
e08b59b
Simplify a canonicalization thing
rtfeldman Nov 10, 2025
0506064
Remove a hack
rtfeldman Nov 10, 2025
930d937
Fix unused warnings
rtfeldman Nov 10, 2025
d7e2973
Fix tests
rtfeldman Nov 10, 2025
fa309b4
Fix unused checking
rtfeldman Nov 10, 2025
c5aa34d
Fix more tests
rtfeldman Nov 10, 2025
7f6502e
Merge remote-tracking branch 'origin/main' into improve-platform-modules
rtfeldman Nov 10, 2025
862246f
Change how exposing works in type modules
rtfeldman Nov 10, 2025
aeeaa6e
Expose type-qualified names for nested associated items
rtfeldman Nov 10, 2025
9ee67ea
More fixes
rtfeldman Nov 10, 2025
ae39ded
More canonicalization fixes
rtfeldman Nov 11, 2025
a3f414a
Fix eval of e_lambda_external
rtfeldman Nov 11, 2025
c75173d
Merge remote-tracking branch 'origin/main' into improve-platform-modules
rtfeldman Nov 11, 2025
6555a8e
Fix eval
rtfeldman Nov 11, 2025
65c5c7e
Fix some more stuff
rtfeldman Nov 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,43 @@ pub fn build(b: *std.Build) void {
const is_native = target.query.isNativeCpu() and target.query.isNativeOs() and (target.query.isNativeAbi() or target.result.abi.isMusl());
const is_windows = target.result.os.tag == .windows;

// fx platform effectful functions test - only run when not cross-compiling
if (target.query.isNativeCpu() and target.query.isNativeOs() and target.query.isNativeAbi()) {
// Create fx test platform host static library
const test_platform_fx_host_lib = createTestPlatformHostLib(
b,
"test_platform_fx_host",
"test/fx/platform/host.zig",
target,
optimize,
roc_modules,
);

// Copy the fx test platform host library to the source directory
const copy_test_fx_host = b.addUpdateSourceFiles();
const test_fx_host_filename = if (target.result.os.tag == .windows) "host.lib" else "libhost.a";
copy_test_fx_host.addCopyFileToSource(test_platform_fx_host_lib.getEmittedBin(), b.pathJoin(&.{ "test/fx/platform", test_fx_host_filename }));
b.getInstallStep().dependOn(&copy_test_fx_host.step);

const fx_platform_test = b.addTest(.{
.name = "fx_platform_test",
.root_module = b.createModule(.{
.root_source_file = b.path("src/cli/test/fx_platform_test.zig"),
.target = target,
.optimize = optimize,
}),
.filters = test_filters,
});

const run_fx_platform_test = b.addRunArtifact(fx_platform_test);
if (run_args.len != 0) {
run_fx_platform_test.addArgs(run_args);
}
// Ensure host library is copied before running the test
run_fx_platform_test.step.dependOn(&copy_test_fx_host.step);
tests_summary.addRun(&run_fx_platform_test.step);
}

var build_afl = false;
if (!is_native) {
std.log.warn("Cross compilation does not support fuzzing (Only building repro executables)", .{});
Expand Down Expand Up @@ -864,6 +901,21 @@ fn addMainExe(
copy_cross_int_host.addCopyFileToSource(cross_int_host_lib.getEmittedBin(), b.pathJoin(&.{ "test/int/platform/targets", cross_target.name, "libhost.a" }));
b.getInstallStep().dependOn(&copy_cross_int_host.step);

// Create cross-compiled str host library
const cross_str_host_lib = createTestPlatformHostLib(
b,
b.fmt("test_platform_str_host_{s}", .{cross_target.name}),
"test/str/platform/host.zig",
cross_resolved_target,
optimize,
roc_modules,
);

// Copy to target-specific directory
const copy_cross_str_host = b.addUpdateSourceFiles();
copy_cross_str_host.addCopyFileToSource(cross_str_host_lib.getEmittedBin(), b.pathJoin(&.{ "test/str/platform/targets", cross_target.name, "libhost.a" }));
b.getInstallStep().dependOn(&copy_cross_str_host.step);

// Generate glibc stubs for gnu targets
if (cross_target.query.abi == .gnu) {
const glibc_stub = generateGlibcStub(b, cross_resolved_target, cross_target.name);
Expand Down
2 changes: 1 addition & 1 deletion src/build/builtin_compiler/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ fn compileModule(
}

// When compiling Builtin itself, pass null for module_envs so setupAutoImportedBuiltinTypes doesn't run
can_result.* = try Can.init(module_env, parse_ast, null);
can_result.* = try Can.init(module_env, parse_ast, null, false);

try can_result.canonicalizeFile();
try can_result.validateForChecking();
Expand Down
20 changes: 16 additions & 4 deletions src/builtins/host_abi.zig
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ pub const RocCall = fn (
///
/// This is used in both calls from actual hosts as well as evaluation of constants
/// inside the Roc compiler itself.
/// Function pointer type for hosted functions provided by the platform.
/// All hosted functions follow the RocCall ABI: (ops, ret_ptr, args_ptr).
pub const HostedFn = *const fn (*RocOps, *anyopaque, *anyopaque) callconv(.c) void;

/// Array of hosted function pointers provided by the platform.
/// These are sorted alphabetically by function name during canonicalization.
pub const HostedFunctions = extern struct {
count: u32,
fns: [*]HostedFn,
};

/// Operations that the host provides to Roc code, including memory management,
/// panic handling, and platform-specific effects.
pub const RocOps = extern struct {
/// The host provides this pointer, and Roc passes it to each of the following
/// function pointers as a second argument. This lets the host do things like use
Expand All @@ -51,10 +64,9 @@ pub const RocOps = extern struct {
/// Called when the Roc program crashes, e.g. due to integer overflow.
/// The host should handle this gracefully and stop execution of the Roc program.
roc_crashed: *const fn (*const RocCrashed, *anyopaque) callconv(.c) void,
/// At the end of this struct, the host must include all the functions
/// it wants to provide to the Roc program for the Roc program to call
/// (e.g. I/O operations and such).
host_fns: *anyopaque,
/// Hosted functions provided by the platform (sorted alphabetically by name).
/// These are effectful operations like I/O that the platform provides to Type Modules.
hosted_fns: HostedFunctions,

/// Helper function to crash the Roc program, returns control to the host.
pub fn crash(self: *RocOps, msg: []const u8) void {
Expand Down
2 changes: 1 addition & 1 deletion src/builtins/utils.zig
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub const TestEnv = struct {
.roc_dbg = rocDbgFn,
.roc_expect_failed = rocExpectFailedFn,
.roc_crashed = rocCrashedFn,
.host_fns = undefined, // No host functions in tests
.hosted_fns = .{ .count = 0, .fns = undefined }, // No host functions in tests
};
}
return &self.ops.?;
Expand Down
Loading
Loading