P5.3: on_build(cb) build-callback registrar; callback takes BuildOptions
Per user design: on_build(build) is the build-callback registrar (a free fn), generalizing set_post_link_callback — the callback is (opt: BuildOptions) -> bool and the compiler invokes it post-codegen WITH the BuildOptions handle. - VM: callCompilerFn 'on_build' arm + legacy handleOnBuild, both set post_link_callback_fn + a new BuildConfig.post_link_takes_options flag. - comptime_vm: runEntry refactored to runEntryArgs(extra) (implicit ctx + explicit args); new public runBuildCallback(..., pass_options) passes the opaque BuildOptions handle (one word) after the ctx. The fat-config marshaling fear is moot — the handle is a single null-sentinel word. - core.invokeByFuncId/invokeByName take pass_options (was an unused args slice); main.zig passes comp.getPostLinkTakesOptions(). - build.sx: on_build decl (set_post_link_callback kept for now). Smoke test examples/1664-platform-on-build-callback (AOT): #run on_build(build) with build :: (opt: BuildOptions) -> bool; the callback is invoked with the handle arg (runEntryArgs param-count match) and runs the primitives. Benign .ir churn (37 snapshots: type table +1 for the on_build fn type + global renumber; behavior identical). 705/0 both gates.
This commit is contained in:
18
examples/1664-platform-on-build-callback.sx
Normal file
18
examples/1664-platform-on-build-callback.sx
Normal file
@@ -0,0 +1,18 @@
|
||||
#import "modules/std.sx";
|
||||
#import "modules/build.sx";
|
||||
#import "modules/compiler.sx";
|
||||
|
||||
// P5.3 smoke test — `on_build(build)` registers the build callback (the Phase 5
|
||||
// form), and the compiler invokes it post-codegen WITH the BuildOptions handle
|
||||
// as an arg (`build :: (opt: BuildOptions) -> bool`). This exercises the VM
|
||||
// entry that passes an explicit arg after the implicit context (runEntryArgs).
|
||||
// The callback uses the build-pipeline primitives (no opt accessors yet) and
|
||||
// returns true; AOT observes success via the build exit code.
|
||||
|
||||
build :: (opt: BuildOptions) -> bool abi(.compiler) {
|
||||
obj := emit_object();
|
||||
return obj.len > 0;
|
||||
}
|
||||
#run on_build(build);
|
||||
|
||||
main :: () { print("runtime main\n"); }
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -668,6 +668,9 @@ declare i64 @build_options() #0
|
||||
; Function Attrs: nounwind
|
||||
declare void @set_post_link_callback(i64, ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @on_build(ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @spaces.44(ptr, i32) #0
|
||||
|
||||
|
||||
@@ -1170,6 +1170,9 @@ declare i64 @build_options() #0
|
||||
; Function Attrs: nounwind
|
||||
declare void @set_post_link_callback(i64, ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @on_build(ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @spaces.44(ptr, i32) #0
|
||||
|
||||
|
||||
@@ -1186,6 +1186,9 @@ declare i64 @build_options() #0
|
||||
; Function Attrs: nounwind
|
||||
declare void @set_post_link_callback(i64, ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @on_build(ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @spaces.44(ptr, i32) #0
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1162,6 +1162,9 @@ declare i64 @build_options() #0
|
||||
; Function Attrs: nounwind
|
||||
declare void @set_post_link_callback(i64, ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @on_build(ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @spaces.44(ptr, i32) #0
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1188,6 +1188,9 @@ declare i64 @build_options() #0
|
||||
; Function Attrs: nounwind
|
||||
declare void @set_post_link_callback(i64, ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @on_build(ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @spaces.44(ptr, i32) #0
|
||||
|
||||
|
||||
@@ -1164,6 +1164,9 @@ declare i64 @build_options() #0
|
||||
; Function Attrs: nounwind
|
||||
declare void @set_post_link_callback(i64, ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @on_build(ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @spaces.44(ptr, i32) #0
|
||||
|
||||
|
||||
@@ -1162,6 +1162,9 @@ declare i64 @build_options() #0
|
||||
; Function Attrs: nounwind
|
||||
declare void @set_post_link_callback(i64, ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @on_build(ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @spaces.44(ptr, i32) #0
|
||||
|
||||
|
||||
@@ -1162,6 +1162,9 @@ declare i64 @build_options() #0
|
||||
; Function Attrs: nounwind
|
||||
declare void @set_post_link_callback(i64, ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @on_build(ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @spaces.44(ptr, i32) #0
|
||||
|
||||
|
||||
@@ -1162,6 +1162,9 @@ declare i64 @build_options() #0
|
||||
; Function Attrs: nounwind
|
||||
declare void @set_post_link_callback(i64, ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @on_build(ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @spaces.44(ptr, i32) #0
|
||||
|
||||
|
||||
@@ -1162,6 +1162,9 @@ declare i64 @build_options() #0
|
||||
; Function Attrs: nounwind
|
||||
declare void @set_post_link_callback(i64, ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @on_build(ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @spaces.44(ptr, i32) #0
|
||||
|
||||
|
||||
@@ -1162,6 +1162,9 @@ declare i64 @build_options() #0
|
||||
; Function Attrs: nounwind
|
||||
declare void @set_post_link_callback(i64, ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @on_build(ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @spaces.44(ptr, i32) #0
|
||||
|
||||
|
||||
@@ -1162,6 +1162,9 @@ declare i64 @build_options() #0
|
||||
; Function Attrs: nounwind
|
||||
declare void @set_post_link_callback(i64, ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @on_build(ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @spaces.44(ptr, i32) #0
|
||||
|
||||
|
||||
@@ -1162,6 +1162,9 @@ declare i64 @build_options() #0
|
||||
; Function Attrs: nounwind
|
||||
declare void @set_post_link_callback(i64, ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @on_build(ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @spaces.44(ptr, i32) #0
|
||||
|
||||
|
||||
@@ -1162,6 +1162,9 @@ declare i64 @build_options() #0
|
||||
; Function Attrs: nounwind
|
||||
declare void @set_post_link_callback(i64, ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @on_build(ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @spaces.44(ptr, i32) #0
|
||||
|
||||
|
||||
@@ -675,6 +675,9 @@ declare i64 @build_options() #0
|
||||
; Function Attrs: nounwind
|
||||
declare void @set_post_link_callback(i64, ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare void @on_build(ptr) #0
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare ptr @spaces.44(ptr, i32) #0
|
||||
|
||||
|
||||
1
examples/expected/1664-platform-on-build-callback.build
Normal file
1
examples/expected/1664-platform-on-build-callback.build
Normal file
@@ -0,0 +1 @@
|
||||
{ "aot": true }
|
||||
1
examples/expected/1664-platform-on-build-callback.exit
Normal file
1
examples/expected/1664-platform-on-build-callback.exit
Normal file
@@ -0,0 +1 @@
|
||||
0
|
||||
1
examples/expected/1664-platform-on-build-callback.stderr
Normal file
1
examples/expected/1664-platform-on-build-callback.stderr
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
1
examples/expected/1664-platform-on-build-callback.stdout
Normal file
1
examples/expected/1664-platform-on-build-callback.stdout
Normal file
@@ -0,0 +1 @@
|
||||
runtime main
|
||||
Reference in New Issue
Block a user