Skip to content

onyx build crashes on musl linux #192

Description

@Sweeistaken

OS: Alpine Linux edge
Compiled Onyx manually with gcc and ovmwasm

Building anything causes an Illegal Instruction error

strace output:

$ strace -f dist/bin/onyx build -r js /home/swee/Git/recaman/onyx-wasm/main.onyx 
execve("dist/bin/onyx", ["dist/bin/onyx", "build", "-r", "js", "/home/swee/Git/recaman/onyx-wasm"...], 0x7ffff76d63b8 /* 60 vars */) = 0
arch_prctl(ARCH_SET_FS, 0x7f426f633b28) = 0
set_tid_address(0x7f426f633f90)         = 26334
brk(NULL)                               = 0x55f04c06d000
brk(0x55f04c06f000)                     = 0x55f04c06f000
mmap(0x55f04c06d000, 4096, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x55f04c06d000
mprotect(0x7f426f630000, 4096, PROT_READ) = 0
mprotect(0x55f02eb6c000, 12288, PROT_READ) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f426f583000
mmap(NULL, 262164, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f426f542000
mmap(NULL, 16777260, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f426e541000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f426e53f000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f426e53d000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f426e53b000
mmap(NULL, 1048620, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f426e43a000
mmap(NULL, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f426e435000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f426e434000
mmap(NULL, 16777260, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f426d433000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f426d432000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f426d431000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f426d430000
mmap(NULL, 36864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f426d427000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f426d426000
stat("/home/swee/.onyx/core/builtin.onyx", {st_mode=S_IFREG|0644, st_size=19473, ...}) = 0
readlink("/home", 0x7ffc3368b5c0, 4067) = -1 EINVAL (Invalid argument)
readlink("/home/swee", 0x7ffc3368b5c0, 4072) = -1 EINVAL (Invalid argument)
readlink("/home/swee/.onyx", 0x7ffc3368b5c0, 4078) = -1 EINVAL (Invalid argument)
readlink("/home/swee/.onyx/core", 0x7ffc3368b5c0, 4083) = -1 EINVAL (Invalid argument)
readlink("/home/swee/.onyx/core/builtin.onyx", 0x7ffc3368b5c0, 4096) = -1 EINVAL (Invalid argument)
open("/home/swee/.onyx/core/builtin.onyx", O_RDONLY|O_LARGEFILE) = 3
lseek(3, 0, SEEK_CUR)                   = 0
lseek(3, 0, SEEK_END)                   = 19473
lseek(3, 0, SEEK_CUR)                   = 19473
lseek(3, 0, SEEK_SET)                   = 0
mmap(NULL, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f426d421000
pread64(3, "package builtin\n\nuse runtime\n\n//"..., 19473, 0) = 19473
close(3)                                = 0
mmap(NULL, 163908, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f426d3f8000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f426d3f7000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f426d3f6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f426d3f5000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f426d3f4000
munmap(0x7f426d3f4000, 4096)            = 0
--- SIGILL {si_signo=SIGILL, si_code=ILL_ILLOPN, si_addr=0x55f02eaa55de} ---
+++ killed by SIGILL +++
Illegal instruction        strace -f dist/bin/onyx build /home/swee/Git/recaman/onyx-wasm/main.onyx

I also tried building with TCC (which was apparently "tested"):

$ ./build.sh compile
Compiling ovmwasm to ../shared/lib/linux_x86_64/lib/libovmwasm.a
src/vm/vm.c:11: error: include file 'x86intrin.h' not found
src/wasm/instance.c:7: error: identifier expected
src/wasm/./module_parsing.h:60: warning: function might return no value: 'parse_valtype'
src/wasm/type.c:34: warning: function might return no value: 'wasm_valtype_new'
Compiling libonyx.so
src/library_main.c:83: error: '__TIMESTAMP__' undeclared
In file included from src/extensions.c:23:
/usr/include/sys/poll.h:1: warning: #warning redirecting incorrect #include <sys/poll.h> to <poll.h>
Compiling onyx executable
tcc: error: undefined symbol 'onyx_error_rank'
tcc: error: undefined symbol 'onyx_error_count'
tcc: error: undefined symbol 'onyx_error_message'
tcc: error: undefined symbol 'onyx_error_filename'
tcc: error: undefined symbol 'onyx_error_line'
tcc: error: undefined symbol 'onyx_error_column'
tcc: error: undefined symbol 'onyx_error_length'
tcc: error: undefined symbol 'onyx_error_line_text'
tcc: error: undefined symbol 'onyx_version_runtime'
tcc: error: undefined symbol 'onyx_set_option_int'
tcc: error: undefined symbol 'onyx_add_mapped_dir'
tcc: error: undefined symbol 'onyx_add_defined_var'
tcc: error: undefined symbol 'onyx_include_file'
tcc: error: undefined symbol 'onyx_output_length'
tcc: error: undefined symbol 'onyx_output_write'
tcc: error: undefined symbol 'onyx_context_create'
tcc: error: undefined symbol 'onyx_pump'
tcc: error: undefined symbol 'onyx_version_major'
tcc: error: undefined symbol 'onyx_version_minor'
tcc: error: undefined symbol 'onyx_version_patch'
tcc: error: undefined symbol 'onyx_version_suffix'
tcc: error: undefined symbol 'onyx_stat'
tcc: error: undefined symbol 'onyx_stat_filepath'
tcc: error: undefined symbol 'onyx_context_free'
tcc: error: undefined symbol 'onyx_version_build_time'
tcc: error: undefined symbol 'onyx_run_wasm_with_debug'
tcc: error: undefined symbol 'onyx_run_wasm'
tcc: error: undefined symbol 'onyx_event_count'
tcc: error: undefined symbol 'onyx_event_type'
tcc: error: undefined symbol 'onyx_event_field_str'
tcc: error: undefined symbol '__popcountdi2'
Compiling onyx auto-compiler
src/autocompiler_binding.c:154: warning: assignment makes integer from pointer without a cast
Compiling onyx_runtime.so
In file included from ./onyx_runtime.c:42:
./src/ort_processes.h:71: warning: assignment from incompatible pointer type
In file included from ./onyx_runtime.c:43:
./src/ort_os.h:268: warning: assignment from incompatible pointer type
In file included from ./onyx_runtime.c:43:
./src/ort_os.h:269: warning: assignment from incompatible pointer type
In file included from ./onyx_runtime.c:43:
./src/ort_os.h:270: warning: assignment from incompatible pointer type
In file included from ./onyx_runtime.c:43:
./src/ort_os.h:271: warning: assignment from incompatible pointer type
In file included from ./onyx_runtime.c:43:
./src/ort_os.h:272: warning: assignment from incompatible pointer type
In file included from ./onyx_runtime.c:43:
./src/ort_os.h:273: warning: assignment from incompatible pointer type
In file included from ./onyx_runtime.c:43:
./src/ort_os.h:274: warning: assignment from incompatible pointer type
In file included from ./onyx_runtime.c:48:
./src/ort_net_linux.h:122: warning: assignment from incompatible pointer type
In file included from ./onyx_runtime.c:48:
./src/ort_net_linux.h:124: warning: assignment from incompatible pointer type
In file included from ./onyx_runtime.c:48:
./src/ort_net_linux.h:141: warning: assignment from incompatible pointer type
In file included from ./onyx_runtime.c:48:
./src/ort_net_linux.h:208: warning: assignment from incompatible pointer type
In file included from ./onyx_runtime.c:48:
./src/ort_net_linux.h:226: warning: assignment from incompatible pointer type
In file included from ./onyx_runtime.c:48:
./src/ort_net_linux.h:246: warning: assignment from incompatible pointer type
In file included from ./onyx_runtime.c:48:
./src/ort_net_linux.h:318: warning: assignment from incompatible pointer type
In file included from ./onyx_runtime.c:48:
./src/ort_net_linux.h:341: warning: assignment from incompatible pointer type
In file included from ./onyx_runtime.c:48:
./src/ort_net_linux.h:364: warning: assignment from incompatible pointer type

I also attempted to build with clang which is successful but has the same error:

$ strace -f dist/bin/onyx build -r js /home/swee/Git/recaman/onyx-wasm/main.onyx 
execve("dist/bin/onyx", ["dist/bin/onyx", "build", "-r", "js", "/home/swee/Git/recaman/onyx-wasm"...], 0x7fffbd9f17e8 /* 60 vars */) = 0
arch_prctl(ARCH_SET_FS, 0x7f7779f9eb28) = 0
set_tid_address(0x7f7779f9ef90)         = 27330
brk(NULL)                               = 0x55a349259000
brk(0x55a34925b000)                     = 0x55a34925b000
mmap(0x55a349259000, 4096, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x55a349259000
mprotect(0x7f7779f9b000, 4096, PROT_READ) = 0
mprotect(0x55a32e86a000, 12288, PROT_READ) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7779eee000
mmap(NULL, 262164, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7779ead000
mmap(NULL, 16777260, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7778eac000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7778eaa000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7778ea8000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7778ea6000
mmap(NULL, 1048620, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7778da5000
mmap(NULL, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7778da0000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7778d9f000
mmap(NULL, 16777260, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7777d9e000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7777d9d000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7777d9c000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7777d9b000
mmap(NULL, 36864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7777d92000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7777d91000
stat("/home/swee/.onyx/core/builtin.onyx", {st_mode=S_IFREG|0644, st_size=19473, ...}) = 0
readlink("/home", 0x7ffd831dca00, 4067) = -1 EINVAL (Invalid argument)
readlink("/home/swee", 0x7ffd831dca00, 4072) = -1 EINVAL (Invalid argument)
readlink("/home/swee/.onyx", 0x7ffd831dca00, 4078) = -1 EINVAL (Invalid argument)
readlink("/home/swee/.onyx/core", 0x7ffd831dca00, 4083) = -1 EINVAL (Invalid argument)
readlink("/home/swee/.onyx/core/builtin.onyx", 0x7ffd831dca00, 4096) = -1 EINVAL (Invalid argument)
open("/home/swee/.onyx/core/builtin.onyx", O_RDONLY|O_LARGEFILE) = 3
lseek(3, 0, SEEK_CUR)                   = 0
lseek(3, 0, SEEK_END)                   = 19473
lseek(3, 0, SEEK_CUR)                   = 19473
lseek(3, 0, SEEK_SET)                   = 0
mmap(NULL, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7777d8c000
pread64(3, "package builtin\n\nuse runtime\n\n//"..., 19473, 0) = 19473
close(3)                                = 0
mmap(NULL, 163908, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7777d63000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7777d62000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7777d61000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7777d60000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7777d5f000
munmap(0x7f7777d5f000, 4096)            = 0
--- SIGILL {si_signo=SIGILL, si_code=ILL_ILLOPN, si_addr=0x55a32e7a35de} ---
+++ killed by SIGILL +++
Illegal instruction        strace -f dist/bin/onyx build /home/swee/Git/recaman/onyx-wasm/main.onyx

extra info

licorice:~/Builds/onyx$ uname -a
Linux licorice 6.18.20-0-lts #1-Alpine SMP PREEMPT_DYNAMIC 2026-03-27 07:17:40 x86_64 Linux
licorice:~/Builds/onyx$ lscpu
Architecture:                x86_64
  CPU op-mode(s):            32-bit, 64-bit
  Address sizes:             39 bits physical, 48 bits virtual
  Byte Order:                Little Endian
CPU(s):                      12
  On-line CPU(s) list:       0-11
Vendor ID:                   GenuineIntel
  Model name:                Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
    CPU family:              6
    Model:                   158
    Thread(s) per core:      2
    Core(s) per socket:      6
    Socket(s):               1
    Stepping:                10
    CPU(s) scaling MHz:      25%
    CPU max MHz:             4600.0000
    CPU min MHz:             800.0000
    BogoMIPS:                6399.96
    Flags:                   fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe sy
                             scall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni
                              pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_
                             deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb pti ssbd ibrs ibpb stibp tpr_shadow fle
                             xpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsa
                             veopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp vnmi md_clear flush_l1d arch_cap
                             abilities
Virtualization features:     
  Virtualization:            VT-x
Caches (sum of all):         
  L1d:                       192 KiB (6 instances)
  L1i:                       192 KiB (6 instances)
  L2:                        1.5 MiB (6 instances)
  L3:                        12 MiB (1 instance)
NUMA:                        
  NUMA node(s):              1
  NUMA node0 CPU(s):         0-11
Vulnerabilities:             
  Gather data sampling:      Mitigation; Microcode
  Ghostwrite:                Not affected
  Indirect target selection: Not affected
  Itlb multihit:             KVM: Mitigation: Split huge pages
  L1tf:                      Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable
  Mds:                       Mitigation; Clear CPU buffers; SMT vulnerable
  Meltdown:                  Mitigation; PTI
  Mmio stale data:           Mitigation; Clear CPU buffers; SMT vulnerable
  Old microcode:             Not affected
  Reg file data sampling:    Not affected
  Retbleed:                  Mitigation; IBRS
  Spec rstack overflow:      Not affected
  Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
  Spectre v1:                Mitigation; usercopy/swapgs barriers and __user pointer sanitization
  Spectre v2:                Mitigation; IBRS; IBPB conditional; STIBP conditional; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
  Srbds:                     Mitigation; Microcode
  Tsa:                       Not affected
  Tsx async abort:           Mitigation; TSX disabled
  Vmscape:                   Mitigation; IBPB before exit to userspace

Onyx file in question

use core {*}

recaman :: (this: js.Value, args: [] js.Value) -> js.Value {
        a := args[0]->as_int() ?? 0;
        r := 0;

        // Used for data
        rec: [..] i32;
        Array.init(&rec);
        defer Array.free(&rec);

        // Used for indexing
        rem := Map.make(i32, i32);

        for n in 0 .. a {
                if n != 0 {
                        if r - n > 0 && !Map.has(&rem, r - n) {
                                r -= n;
                        } else {
                                r += n;
                        }
                }
                rec->push(r);
                Map.put(&rem, r, 0);
        }

        res := js.Value.from(rec)?;

        return res;
}

main :: () {}

Compiles completely fine in Ubuntu via Distrobox

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions