lightpanda-io / browser

The open-source browser made for headless usage
https://lightpanda.io
GNU Affero General Public License v3.0
152 stars 0 forks source link

build: add -Dx86 option to enable x86 backend #244

Open krichprollsch opened 5 months ago

krichprollsch commented 5 months ago

see https://ziglang.org/download/0.12.0/release-notes.html#x86-Backend

krichprollsch commented 5 months ago

The binary panics at runtime.

$ zig build  -Dx86=true get -- 'https://blg.tch.re'
steps [2/4] zig build-exe browsercore-get Debug native... ELF Flush... debug(browser): starting GET https://blg.tch.re
info(browser): GET https://blg.tch.re/ http.Status.ok
debug(browser): header content-type: text/html; charset=utf-8
debug(browser): parse html with charset utf-8
debug(browser): start js env
debug(browser): setup global env
debug(browser): wait: thread 29279 panic: reached unreachable code
Unwind error at address `:0x80a6523` (error.AddressOutOfRange), trace may be incomplete

/usr/local/zig-0.12.1/lib/std/posix.zig:1223:23: 0x80aa9cb in write ()
            .FAULT => unreachable,
                      ^
/usr/local/zig-0.12.1/lib/std/fs/File.zig:1240:23: 0x8045b88 in write ()
    return posix.write(self.handle, bytes);
                      ^
/usr/local/zig-0.12.1/lib/std/io.zig:316:27: 0x82cf1bf in write ()
            return writeFn(self.context, bytes);
                          ^
/usr/local/zig-0.12.1/lib/std/io.zig:356:27: 0x811f63f in typeErasedWriteFn ()
            return writeFn(ptr.*, bytes);
                          ^
/usr/local/zig-0.12.1/lib/std/io/Writer.zig:12:24: 0x80cdec3 in write ()
    return self.writeFn(self.context, bytes);
                       ^
/usr/local/zig-0.12.1/lib/std/io/Writer.zig:18:32: 0x8061809 in writeAll ()
        index += try self.write(bytes[index..]);
                               ^
/usr/local/zig-0.12.1/lib/std/fmt.zig:1043:28: 0x811ef53 in formatBuf__anon_20844 ()
        try writer.writeAll(buf);
                           ^
/usr/local/zig-0.12.1/lib/std/fmt.zig:637:37: 0x814ecef in formatType__anon_21585 ()
                    return formatBuf(value, options, writer);
                                    ^
/usr/local/zig-0.12.1/lib/std/fmt.zig:185:23: 0x836727d in format__anon_24139 ()
        try formatType(
                      ^
/usr/local/zig-0.12.1/lib/std/io/Writer.zig:23:26: 0x82bbedb in print__anon_21882 ()
    return std.fmt.format(self, format, args);
                         ^
/usr/local/zig-0.12.1/lib/std/io.zig:324:47: 0x81044af in defaultLog__anon_17726 ()
            return @errorCast(self.any().print(format, args));
                                              ^
/usr/local/zig-0.12.1/lib/std/log.zig:125:22: 0x8075ed1 in log__anon_17238 ()
    std.options.logFn(message_level, scope, format, args);
                     ^
/usr/local/zig-0.12.1/lib/std/log.zig:203:16: 0x803feaf in debug__anon_15743 ()
            log(.debug, scope, format, args);
               ^
/home/pierre/wrk/browser/src/browser/browser.zig:206:22: 0x800ce51 in wait ()
            log.debug("wait: {s}", .{res.result});
                     ^
/home/pierre/wrk/browser/src/main_get.zig:92:18: 0x8010a0d in main ()
    try page.wait();
                 ^
/usr/local/zig-0.12.1/lib/std/start.zig:511:37: 0x80114b0 in main ()
            const result = root.main() catch |err| {
                                    ^
get
└─ run browsercore-get failure
error: the following command terminated unexpectedly:
/home/pierre/wrk/browser/zig-cache/o/98386cf9ef1e9a77acd440e1460ddb69/browsercore-get https://blg.tch.re 
Build Summary: 2/4 steps succeeded; 1 failed (disable with --summary none)
get transitive failure
└─ run browsercore-get failure
error: the following build command failed with exit code 1:
/home/pierre/wrk/browser/zig-cache/o/620cfbc851a541a70d0b82337add7a9a/build /usr/local/zig-0.12.1/zig /home/pierre/wrk/browser /home/pierre/wrk/browser/zig-cache /home/pierre/.cache/zig --seed 0x633ed886 -Z8dcbf04ab2a9a04d -Dx86=true get -- https://blg.tch.re
krichprollsch commented 5 months ago

And tests also panic.

$ zig build -Dx86=true test
steps [2/4] zig test Debug native... ELF Flush... Generate Union: OK
Generate Tuple: OK
thread 29553 panic: incorrect alignment
Unwind error at address `:0x80d9ade` (error.AddressOutOfRange), trace may be incomplete

/home/pierre/wrk/browser/src/netsurf/netsurf.zig:86:64: 0x8094bcc in nodeVtable ()
    const node_aligned: *align(@alignOf(NodeExternal)) NodeT = @alignCast(node);
                                                               ^
/home/pierre/wrk/browser/src/netsurf/netsurf.zig:930:27: 0x802e279 in nodeType ()
    const err = nodeVtable(node).dom_node_get_node_type.?(node, &node_type);
                          ^
/home/pierre/wrk/browser/src/dom/html_collection.zig:388:36: 0x8489f6f in item ()
            if (try parser.nodeType(node) == .element) {
                                   ^
/home/pierre/wrk/browser/src/dom/html_collection.zig:465:39: 0x848ac18 in postAttach ()
            const node = try self.item(i) orelse unreachable;
                                      ^
/home/pierre/wrk/browser/vendor/zig-js-runtime/src/engines/v8/generate.zig:800:13: 0x848b365 in postAttach__anon_28279 ()
        _ = try @call(.auto, f, args);
            ^
/home/pierre/wrk/browser/vendor/zig-js-runtime/src/engines/v8/generate.zig:497:23: 0x848b50e in bindObjectNativeAndJS__anon_28276 ()
        try postAttach(
                      ^
/home/pierre/wrk/browser/vendor/zig-js-runtime/src/engines/v8/generate.zig:598:37: 0x848b80f in setNativeObject__anon_28274 ()
    return try bindObjectNativeAndJS(
                                    ^
/home/pierre/wrk/browser/vendor/zig-js-runtime/src/engines/v8/generate.zig:687:43: 0x860d0e8 in setNativeType__anon_29635 ()
        const js_obj = try setNativeObject(
                                          ^
/home/pierre/wrk/browser/vendor/zig-js-runtime/src/engines/v8/generate.zig:956:37: 0x860d87c in callFunc__anon_26765 ()
        const js_val = setNativeType(
                                    ^
/home/pierre/wrk/browser/vendor/zig-js-runtime/src/engines/v8/generate.zig:1066:21: 0x83ab1b5 in method ()
            callFunc(
                    ^
../../../../v8/src/api/api-arguments-inl.h:146:3: 0x19460e9 in Call (../../../../v8/src/builtins/builtins-api.cc)
../../../../v8/src/builtins/builtins-api.cc:113:36: 0x1944a9f in HandleApiCallHelper<false> (../../../../v8/src/builtins/builtins-api.cc)
../../../../v8/src/builtins/builtins-api.cc:148:5: 0x1943200 in Builtin_Impl_HandleApiCall (../../../../v8/src/builtins/builtins-api.cc)
../../../../v8/src/builtins/builtins-api.cc:135:1: 0x1942b46 in Builtin_HandleApiCall (../../../../v8/src/builtins/builtins-api.cc)
???:?:?: 0x34d04be in ??? (???)
???:?:?: 0x3139e8d in ??? (???)
???:?:?: 0x313269b in ??? (???)
???:?:?: 0x31323c6 in ??? (???)
../../../../v8/src/execution/simulator.h:155:12: 0x1bcd3ea in Invoke (../../../../v8/src/execution/execution.cc)
../../../../v8/src/execution/execution.cc:538:10: 0x1bce46c in CallScript (../../../../v8/src/execution/execution.cc)
../../../../v8/src/api/api.cc:2272:7: 0x184352d in Run (../../../../v8/src/api/api.cc)
/home/pierre/wrk/browser/vendor/zig-js-runtime/vendor/zig-v8/src/binding.cpp:414:54: 0x171a1e3 in v8__Script__Run (/home/pierre/wrk/browser/vendor/zig-js-runtime/vendor/zig-v8/src/binding.cpp)
    return maybe_local_to_ptr(ptr_to_local(&script)->Run(ptr_to_local(&context)));
                                                     ^
/home/pierre/wrk/browser/vendor/zig-js-runtime/vendor/zig-v8/src/v8.zig:1712:30: 0x817b4c4 in run ()
        if (c.v8__Script__Run(self.handle, ctx.handle)) |value| {
                             ^
/home/pierre/wrk/browser/vendor/zig-js-runtime/src/engines/v8/v8.zig:555:28: 0x817beb5 in exec ()
        const res = scr.run(js_ctx) catch {
                           ^
/home/pierre/wrk/browser/vendor/zig-js-runtime/src/engines/v8/v8.zig:394:21: 0x817c3e1 in run ()
        try res.exec(alloc, script, name, self.isolate, self.js_ctx.?, try_catch);
                    ^
/home/pierre/wrk/browser/vendor/zig-js-runtime/src/tests/test_utils.zig:104:23: 0x8109584 in checkCasesAlloc ()
        try js_env.run(alloc, case.src, name, &res, &cbk_res);
                      ^
/home/pierre/wrk/browser/vendor/zig-js-runtime/src/tests/test_utils.zig:79:24: 0x8109eb7 in checkCases ()
    try checkCasesAlloc(fba_alloc, js_env, cases);
                       ^
/home/pierre/wrk/browser/src/dom/document.zig:315:19: 0x810a0fe in testExecFn ()
    try checkCases(js_env, &getElementsByClassName);
                  ^
/home/pierre/wrk/browser/src/run_tests.zig:105:15: 0x806fff3 in testExecFn__anon_16608 ()
    try execFn(alloc, js_env);
              ^
/home/pierre/wrk/browser/src/run_tests.zig:139:23: 0x8026a2d in testsAllExecFn ()
        try testExecFn(alloc, js_env, testFn);
                      ^
/home/pierre/wrk/browser/vendor/zig-js-runtime/src/engine.zig:61:18: 0x80077b3 in loadEnv__anon_12562 ()
    try ctxExecFn(alloc, &js_env);
                 ^
/home/pierre/wrk/browser/src/run_tests.zig:332:26: 0x8008277 in testJSRuntime ()
    try jsruntime.loadEnv(&arena_alloc, null, testsAllExecFn);
                         ^
/home/pierre/wrk/browser/src/run_tests.zig:224:22: 0x801020d in run_js ()
    try testJSRuntime(bench_alloc.allocator());
                     ^
/home/pierre/wrk/browser/src/run_tests.zig:202:51: 0x80110c8 in main ()
    if (run == .all or run == .browser) try run_js(out);
                                                  ^
/home/pierre/wrk/browser/src/test_runner.zig:27:19: 0x801161d in main ()
    try tests.main();
                  ^
/usr/local/zig-0.12.1/lib/std/start.zig:511:37: 0x80119ca in main ()
            const result = root.main() catch |err| {
                                    ^
test
└─ run test failure
error: the following command terminated unexpectedly:
/home/pierre/wrk/browser/zig-cache/o/a4fc9352a98791fb465d2be08291f857/test
Build Summary: 2/4 steps succeeded; 1 failed (disable with --summary none)
test transitive failure
└─ run test failure
error: the following build command failed with exit code 1:
/home/pierre/wrk/browser/zig-cache/o/620cfbc851a541a70d0b82337add7a9a/build /usr/local/zig-0.12.1/zig /home/pierre/wrk/browser /home/pierre/wrk/browser/zig-cache /home/pierre/.cache/zig --seed 0xb2d5b180 -Zc0490e9862bab557 -Dx86=true test