<Cadey>
specifically, in zig/lib/std/special/start.zig `wasm_freestanding_start` is calling `callMain` but discarding the return code
<msiism>
andrewrk: Ok, I just can't, well, I can't really put into words how exactly i don't understand that... I mean I (think I) understand what a data type is, like an integer value of 1 or the return type of a function. But then, a command, like `break` is “not data”, is it? That's why I can't really imagine what, e.g., `break` having a type would really mean.
<andrewrk>
Cadey, ah yes. wasm32-freestanding does not provide a way to deal with the error code. your OS does, so wasm_freestanding_start is not the correct entry point. give me a sec I have a diff for you to try
<Cadey>
:=1:
<Cadey>
:+1:
<andrewrk>
Cadey, can you try this diff? https://clbin.com/ygcoZ -> 2 things: (1) olin os package should export _start and call main (2) your target should be `wasm32-other`, not `wasm32-freestanding`
<andrewrk>
msiism, "noreturn" is a type that means "not data"
<Cadey>
andrewrk: from the os package, how do i call main()?
<Cadey>
just `main()`?
<andrewrk>
you can look at the file that diff patches as an example
<andrewrk>
hm maybe the std lib should expose that callMain function
<msiism>
andrewrk: Hm... ok. And what then is the rationale behind having a data type that has the meaning of ”not data”? (If that's already explained somewhere, a link will do.)
<pixelherodev>
That's what I'm saying - wait - you mean it's *supposed* to be?
<pixelherodev>
... mine isn't...
<pixelherodev>
Was the OS layer changed?
<andrewrk>
I don't think so
<pixelherodev>
I think that's wrong then
<andrewrk>
pixelherodev, Indomitable has it in a system struct too
<pixelherodev>
... wait I do?
<andrewrk>
yeah I sent you that PR
<pixelherodev>
Ah, okay
<pixelherodev>
Ah - `pub const system = if (@hasDecl(root, "os") and root.os != @This()) root.os.system`
<pixelherodev>
That does root.os.system instead of root.os
<pixelherodev>
Which now that I think about it makes sense
<pixelherodev>
But doesn't solve the issue
<andrewrk>
Cadey, I'm not sure why that error would be happening, can you double check stuff on your end? e.g. that the changes are getting picked up or whatever
<andrewrk>
which line is giving the compile error?
<Cadey>
/home/cadey/prefix/zig/lib/zig/std/os.zig:202:11: error: container 'std.os.system' has no member called 'abort'
<andrewrk>
make sure your application file has `pub` on your `os`. in the example you provided it is correct, but the panic function is not
<Cadey>
i do
<Cadey>
assuming `pub const os` is the right order
<andrewrk>
yeah that should be fine
<andrewrk>
let me try to reproduce
<andrewrk>
both my zig checkouts have dirty working trees, good thing I have a third checkout
<Cadey>
i'm almost at the level of making a fresh zig environment in a docker container lol
traviss has quit [Remote host closed the connection]
<pixelherodev>
andrewrk, if you have a third, then "both" isn't entirely accurate now is it? :)
<andrewrk>
🤔
<pixelherodev>
Oh, and regarding the earlier " there's --emit llvm-ir"
<pixelherodev>
I know, that's what I used to produce the test files
<pixelherodev>
(along with --strip for good measure)
<pixelherodev>
But if the goal is to remove LLVm
<pixelherodev>
LLVM*
<pixelherodev>
and my real goal is to support a backend to *Zig*, not *LLVM*...
<pixelherodev>
Then I'm going to need to switch the input source :P
<pixelherodev>
I was going to ask actually: is the goal to remove LLVM completely? Or just as a mandatory dependency for native compilation?
waleee-cl has quit [Quit: Connection closed for inactivity]
<andrewrk>
pixelherodev, my eventual goal is to make it an optional dependency of self-hosted
<pixelherodev>
And remove it entirely for stage2?
<pixelherodev>
Real question:
<pixelherodev>
Will stage2 be able to generate LLVM IR?
<andrewrk>
the zig language specification will not mention LLVM
<pixelherodev>
Right but practically
<pixelherodev>
Will LLVM be an alternative to e.g. x86?
<andrewrk>
the ability to output llvm ir will always be an "extension" or "implementation defined" feature
<pixelherodev>
Is that true of e.g. ARM also?
<pixelherodev>
And practically
<andrewrk>
that's a good question, how architectures fit into it
<pixelherodev>
I'd support having LLVM IR as a backend, even if the dependency on LLVM as a library is removed
<andrewrk>
still not quite sure what you're trying to figure out. I feel like I probably can answer it but haven't understood the question yet
<pixelherodev>
With `-target`
<andrewrk>
oh I see
<pixelherodev>
Sorry, starting over:
<pixelherodev>
Basically, will there be an alternate to `-emit llvm-ir` in stage2?
<pixelherodev>
e.g. `-target llvm-ir`?
<andrewrk>
you're suggesting a use case of LLVM IR (or bitcode) as a target, not necessarily with the actual LLVM project as a dependency
<pixelherodev>
Right
<pixelherodev>
That's why I was interested in the idea of a Zig-specific IR, but I feel like LLVM as a target is a better option that trying to stablize a Zig-specific IR
<andrewrk>
I'll have to think about how that might work. it wouldn't really be an architecture, because if it was then every sub-architecture would be all the other architectures
<pixelherodev>
Oh, that reminds me
<pixelherodev>
Is there a way to override the LLVM target to a custom definition for Zig?
<pixelherodev>
stage1
<pixelherodev>
Right now I'm using i386-freestanding since that's the closest match
<pixelherodev>
But it's not fully accurate, and if I want to try targeting e.g. z80 I need more customization
<andrewrk>
Cadey, ok I can reproduce
<Cadey>
\o/ my environment isn't as insane as i thought it was
adamkowalski has joined #zig
<andrewrk>
oh, this is happening when building zig's freestanding memcpy/memset/ other libcalls like that
return0e has quit [Ping timeout: 250 seconds]
<pixelherodev>
https://git.sr.ht/~pixelherodev/llvm_parser - a simple `make` will build the parser and two test files, one for the LIMN architecture (an ISA designed for the LIMNstation Fantasy Console - disclaimer: not by me :) and one for x86 (though since I haven't actually implemented the x86 backend or some needed instructions, the x86 backend is just a basic freestanding code being partly translated into x86 asm)
<pixelherodev>
Warning: code is *very* ugly
<pixelherodev>
That'll be fixed soon enough
<andrewrk>
Cadey, there's still room for improvement here, but this is an improvement over status quo: https://clbin.com/xUkuC
<andrewrk>
should get you past the abort() not found thing
<andrewrk>
the error was correct; what was not clear is that it was happening when we were building our freestanding libc functions from source
<pixelherodev>
Don't expect it to work on basically anything yet
<pixelherodev>
Very rudimentary, I was focused on the core
<pixelherodev>
Now that the general proof-of-concept works, I can actually flesh it out and add broad LLVM support :)
adamkowalski has quit [Quit: Lost terminal]
<pixelherodev>
std.os.is_overridden idea: That way, instead of checking `if freestanding or other`, it allows overriding the code even when targeting supported systems, and doesn't result in accidentally checking only freestanding or other
<andrewrk>
pixelherodev, I do want to make the self-hosted compiler have a straightforward way to add backends to it. idea bing you can add a minimal amount of data to an ISA database and then the compiler gains support for it as a backend
return0e has joined #zig
<Cadey>
andrewrk: how do i import `lib/std/special/start.zig`?
<andrewrk>
I want to make this data format flexible enough to even support e.g. a C code backend, potentially lllvm ir
<pixelherodev>
You might be interested in ddevault's cozy idea
<daurnimator>
frmdstryr: remind me tonight and I can go over mine with you if you want?
<frmdstryr>
I can take a look if you have it somewhere
<andrewrk>
fengb, I see. we should use a constant from bits instead of 4 then
ur5us has joined #zig
<daurnimator>
frmdstryr: it's in a git stash somewhere on my home desktop
<fengb>
Ah okay, would it make sense to put `pub sockaddr_alignment = 4` into all the other os bits?
<fengb>
And set sockaddr_alignment = max_align_t for wasi
muffindrake has quit [Ping timeout: 276 seconds]
muffindrake has joined #zig
<fengb>
I'm also getting a weird issue where initUnix just pops into existence and errors out the compiler. Deleting the method fixes the compile error so I'm not sure why it's being built
<frmdstryr>
daurnimator: Just got error.FileDescriptorAlreadyPresentInSet
<daurnimator>
frmdstryr: great; I'm not the only one!
<daurnimator>
frmdstryr: would be fantastic to get that debugged/fixed
<frmdstryr>
It doesn't really make sense, I'm only using one connection
<daurnimator>
it seems to happen when an epoll wait gets picked up in another thread
<frmdstryr>
Were you reusing frame pointers?
<frmdstryr>
It started when I tried doing that and doesn't happen if I don't
<daurnimator>
'reusing'?
<andrewrk>
fengb, yes I'm ok with this. we may benefit from putting it in the sockaddr struct, since that namepsace is sort of "unclaimed" in terms of posix
<andrewrk>
actually I think it should just be @alignOf() whatever the union type is
<andrewrk>
there's a type that is supposed to be allowed to be pointer casted to any sock addr type
<andrewrk>
that type should be properly aligned, and then we can use @alignOf() on it
Sargun has joined #zig
<Sargun>
Is there a zig style guide
<pixelherodev>
Thought experiment: second else clause to if/else statements
<pixelherodev>
Not necessary though, there's a number of ways to accomplish the same thing already
<pixelherodev>
I just find the idea of a second else clause amusing
<daurnimator>
pixelherodev: when would it run?
<fengb>
andrewrk: I think that's where the align(4) came from. The base struct (sockaddr) is partially built and thus has a natural alignment of 2. It really should be the max of (sockaddr_in, sockaddr_in6, sockaddr_un)
<fengb>
Wasi is apparently the only one that aligns the common struct correctly >_>
<andrewrk>
yeah, can we fix by aligning the common struct correctly for the other systems?
<fengb>
Sure, I can add an explicit alignment in the same style
<pixelherodev>
fengb, I'd argue that it should return an error even without the bug
<pixelherodev>
Because it's not out of the question that someone might try using it even though it's unsupported
<mq32>
hey
<mq32>
what is the current state of the AVR backend?
<mq32>
i remember it being "you can compile objects, but do not link"
<pixelherodev>
I was planning on debugging it, but...
<pixelherodev>
Well, first there were some IRL problems, then I had to rebuild LLVM with support for it, then Zig was annoyed because LLVM=10 but Clang=9 so now I need to rebuilt Clang...
<Pistahh>
Snektron: this template based fizzbuzz.. it is.. it is.. no words. :P
<Snektron>
i like the private member access even more, though i didn't come up with it
<mq32>
Snektron: you can write a turing machine emulator with that => undecidable
<mq32>
:D
<Snektron>
I think there was actually a template function to check wether an expression is undecidable
<Snektron>
Because if a constexpr function in c++ errors or cannot be calculated, it'll defer to runtime
<Snektron>
so all you have to do is check wether that function is evaluated
<Snektron>
also, mq32, there is a maximum template depth so its pretty much guaranteed to error at some point
marmotini_ has quit [Remote host closed the connection]
ltriant has joined #zig
ltriant has quit [Client Quit]
marmotini_ has joined #zig
marmotini_ has quit [Remote host closed the connection]
marmotini_ has joined #zig
marmotini_ has quit [Remote host closed the connection]
<daurnimator>
you can get pretty far with plain C too
<daurnimator>
the secret to stupid hacks in C is that ternarys can return different types
<daurnimator>
(for each branch)
dimenus has joined #zig
<dimenus>
Snektron: you said you have vulkan experience, yeah?
return0e_ has joined #zig
return0e has quit [Ping timeout: 250 seconds]
<frmdstryr>
daurnimator: I'm trying the h1 branch again, getting the error error: no member named 'ensureCapacity' in struct 'std.io.BufferedInStreamCustom(4096,std.fs.file.File)'
<aperezdc>
I am trying to rewrite an existing C project, piecewise, for the fun
<frmdstryr>
thanks will give it a try
<daurnimator>
frmdstryr: it seems to randomly get stuck all the time...
<daurnimator>
and if I push it hard with `wrk` then it fails with that EEXIST error
<aperezdc>
I feel like the way argc/argv are forwarded to the foo_main() functions (which are still in C) is unnecessarily complicated. As I am a total Zig newbie, comments and suggestions are super welcome :)
<frmdstryr>
yeah I noticed wrk seems to close and reopen connections periodically
<daurnimator>
that should be fine...
<daurnimator>
aperezdc: why do I know your name?
<frmdstryr>
I think it's trying to read before the previous handle is removed
<daurnimator>
aperezdc: hmmm... arcan?
<aperezdc>
mmh, Lua mailing list?
<daurnimator>
aperezdc: that would work too
<daurnimator>
aperezdc: some misc notes: make use of null terminated pointers: `[*:0]` instead of `[*]`
<aperezdc>
I posted Arcan PKGBUILDs to package it for Arch Linux, too
<aperezdc>
oh, I hadn't noticed the null-terminated pointers in the manual (still reading through as I try things), neat
kristoff_it has joined #zig
<daurnimator>
aperezdc: `if (......) else unreachable` is weird
<aperezdc>
daurnimator: FWIW, I've been a fan of lua-http for quite some time :-D
<aperezdc>
ah, the “else unreachable” probably I am going to change into some kind of print error + exit
<aperezdc>
unreachable is more of an assertion, then, isn't it?
<daurnimator>
aperezdc: C assertion yes. (lua assertion no)
<daurnimator>
aperezdc: I assume the applets are going to be somewhat dynamic? otherwise I'd suggest making an enum of them
<daurnimator>
aperezdc: also, run `zig fmt` over your code :)
<daurnimator>
aperezdc: no need to use argsAlloc: just use std.process.ArgIterator
<frmdstryr>
daurnimator: Did you push to github?
<daurnimator>
frmdstryr: yes. my h1 branch.
<aperezdc>
mmh, the applets are a fixed set, I suppose an enum makes more sense, yeah
<frmdstryr>
It says last update 5 days ago?
<daurnimator>
frmdstryr: I amended. it keeps the old author time (but updates the commit time)
dddddd has joined #zig
<frmdstryr>
Yeah it works now
<frmdstryr>
For whatever reason the original test file I had was segfaulting
<aperezdc>
mmh, zig fmt is neat <3
<frmdstryr>
It was using 85% cpu?
adamkowalski has joined #zig
<daurnimator>
frmdstryr: oh I see one stupid mistake of mine (unrelated)
<frmdstryr>
Also I'm interested to see what the raw http parser benchmarks at
<fengb>
glibc should be linked in, but if not that might be Zig using musl instead
<nofmal>
oh you meant the compiler. gotcha, wait a sec
<nofmal>
it says statically linked
<fengb>
Er not the compiler, the binary you built
<nofmal>
oh, in that case, libc is linked in
<nofmal>
and so is libargon2
<fengb>
Hmm, I'm out of ideas :/
<nofmal>
ehh it's fine. thank you anyway
<daurnimator>
nofmal: what version of glibc do you have?
<daurnimator>
IIRC it was absent in 2.24
<nofmal>
mine is 2.29
<nofmal>
i'd checked the symbol table thing and it is there
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 245 seconds]
<andrewrk>
ugh I'm tired of debugging corrupt unions in c++. wish I had zig's "use of inactive union field" safety
wootehfoot has joined #zig
kristoff_it has quit [Ping timeout: 276 seconds]
adamkowalski has joined #zig
<fengb>
Does any other language allow you to use any union field but also error checks it?
<mq32>
andrewrk: what about std::variant?
<Cadey>
it looks like the tests on master are failing, i'm gonna look into it and see if i can fix them
<mq32>
it's the c++ way of "tagged union" with pain
adamkowalski has quit [Ping timeout: 265 seconds]
<daurnimator>
misc note before I go to bed: in mid January I'll be at Linux.conf.au. I'd love to be able to give a demo of writing a kernel module in zig. There's a backlog of related items at https://github.com/ziglang/zig/projects/5
<andrewrk>
daurnimator, that's a great motivating use case
<andrewrk>
Cadey, it's just a timeout on the aarch64 server, tests running too long
<andrewrk>
it's a crime really, they're giving us like 60 cpus and we're using 1 for 2 hours and getting timed out
<Cadey>
ah, when is the master release updated?
<andrewrk>
you are correct that the failing ci blocked the download page from getting updated
<Cadey>
ah, lol, makes sense
<daurnimator>
andrewrk: oh shit; I forgot: I think that arm box on packet.net is still running?
<andrewrk>
daurnimator, I'm not personally using it, although I believe we gave access to several other community members, including LemonBoy and markfirmware
<daurnimator>
ah okay. as long as its in use
<fengb>
Is it a physical aarch64 box?
<andrewrk>
daurnimator, we should probably advertise that it is available for community members to experiment with
<daurnimator>
fengb: yes. a very very beefy one
<andrewrk>
idk maybe on the wiki or reddit announcement or something
<daurnimator>
andrewrk: how do you want to manage access?
* daurnimator
isn't familiar with nix tooling
<andrewrk>
btw anyone else want to mod /r/zig? right now it's just me, and what if I die
<daurnimator>
andrewrk: sure. same username
<Cadey>
i'm a somewhat avid redditor, /u/shadowh511
<mq32>
andrewrk: and what if I die
<andrewrk>
daurnimator, I think we can get away with "if you ask for it, you get a user account" for now
<daurnimator>
andrewrk: though if you die... I think the bus factor is still 1
<mq32>
then i don't think zig will ever get awesome again!
<daurnimator>
andrewrk: I more meant: how are you deploying keys onto the box
<andrewrk>
asking people for their pub keys, manually creating user and copying the pub key in there
<daurnimator>
Cadey: I know how to *get* keys. the question is how to create a user account and populating things
<daurnimator>
oh I thought there was nix magic around that sort of thing
<andrewrk>
would be happy to hand off admin of this box to someone else
<daurnimator>
mq32: any chance you'll be going past brussels soon?
<daurnimator>
(or anyone else?)
<mq32>
brussels?! :D
<aperezdc>
FOSDEM?
<mq32>
ah, i think you told here already some time
<aperezdc>
I usually go, but can't make it thus time due to $LIFE
<mq32>
i just know the name, but i have no idea what FOSDEM is
nofmal has quit [Remote host closed the connection]
<aperezdc>
It's a conference, two days, usually first weekend of February
<daurnimator>
aperezdc: actually I just want someone to pick up beer for me :P
<mq32>
ah
<mq32>
nah, i'm not the conference guy
<aperezdc>
Well, it's more of a huge gathering of free software people
FireFox317 has joined #zig
<aperezdc>
With lots of talks, because conference, too
<aperezdc>
For me it's more of a social event
<aperezdc>
;-)
dddddd has quit [Ping timeout: 250 seconds]
<mq32>
yeah, doesn't sound that appealing to me, sorry :D
deesix has quit [Ping timeout: 268 seconds]
<mq32>
i'm more the demoparty guy ^^
<aperezdc>
Oh, I like those when they're the real deal, with actual demoscene competitions
<aperezdc>
Not the ones which have devolved into LAN-parties
* aperezdc
should try to attend Assembly sometime
<andrewrk>
daurnimator, invite sent
<andrewrk>
there is nix magic probably for user accounts. I don't really know anything about nixos beyond setting up my personal dev environment
<daurnimator>
/bed
<daurnimator>
5:20am and I have to get up in.... 3 hours
<andrewrk>
goodness
<fengb>
Good night
<aperezdc>
Ouch, make the most of the sleep time, daurnimator !
<Cadey>
has anyone made a cgi library in zig yet?
<andrewrk>
fengb, can you help Cadey get the CI green in #3891 ? what's happening is that we're trying to call wasi.abort() which doesn't exist. it was working before because it used raise() but you showed me that they removed raise from wasi
<andrewrk>
so basically, what should be the impl of std.os.abort() for wasi?
<andrewrk>
it would be nice if there was just a single-page list of wasi syscalls
<mq32>
aperezdc, come to UNC at 27,28th december in darmstadt!
<Cadey>
the /metrics thing is a lie, but otherwise it works
<andrewrk>
sweet!
<andrewrk>
I'm almost done merging your PR
qbradley has joined #zig
<andrewrk>
I added into the branch, un-special-casing the start code from the compiler
<andrewrk>
so you'll have to change std.special.start.callMain to std.start.callMain
<Cadey>
:+1:
<Cadey>
sounds good to me
<andrewrk>
but the cool thing is that std/start.zig no longer has any special casing in the compiler, it's just another std lib file like everything else
<Cadey>
oh wow
<andrewrk>
`comptime { _ = start; }` in std/std.zig makes it get analyzed; then the comptime block in start.zig has all the start logic of what symbols if any to export
<Cadey>
lol
GrooveStomp has joined #zig
<Snektron>
What if you @import std from another source file though?
<Snektron>
Wouldnt that also import the bootstrap code
<andrewrk>
Snektron, start code is always unconditionally analyzed for all builds