<andrewrk>
don't be jealous, stage1. you've had your time to shine
<fengb>
LLVM errors always look so scary
<andrewrk>
this is what I get for writing... *checks notes* 26 files changed, 2867 insertions(+), 1723 deletions(-) ... over a perido of 5 days without testing
<andrewrk>
hmm seems to be a bug with breaking out of a block with defers in scope
<andrewrk>
alright, after 10 hours of looking at compile errors I have something built. now on to the debugging phase!
<foobles>
im scared because i started messsing with basic blocks and now im getting "assertion failed" with no other info ;D
<foobles>
comptime works like a charm tho!
bheads has quit [Remote host closed the connection]
racoon has joined #zig
aerona has joined #zig
ur5us_ has joined #zig
daex_ has quit [Ping timeout: 246 seconds]
_whitelogger has joined #zig
slice has joined #zig
slice has quit [Client Quit]
waleee-cl has quit [Quit: Connection closed for inactivity]
daex has joined #zig
xackus has joined #zig
_whitelogger has joined #zig
slice has joined #zig
cole-h has quit [Quit: Goodbye]
<marler8997>
what's the simplest cpu arch that zig can compile to?
<hermier>
Hi, I'm trying to compile zig on my distro and it fails to "CommandLine Error: Option 'mc-relax-all' registered more than once!"
<hermier>
Due to distro, I have to use: -DZIG_PREFER_CLANG_CPP_DYLIB=Yes -DZIG_STATIC_LLVM=True if that has some importance
<hermier>
I also have a *minor* issue with git, for some reasons deps/SoftFloat-3e/*.txt get line ending borked on checkout
mokafolio has joined #zig
<ifreund[m]>
hermier: what distro? when I updated the package for void i was getting the same error, but disabling `-DZIG_PREFER_CLANG_CPP_DYLIB=Yes` fixed it
<hermier>
frugalware
<hermier>
infortunatly I can't disable that, because I only have libLLVM.so or all the *.a
ifreund has joined #zig
<ifreund[m]>
so you're probably running into the same fiasco that is messing up the homebrew package for mac users
<cren>
I'm getting ./main.zig:12:5: error: expected token ';', found ','
<cren>
(that's the first comma in the array)
Stephie has joined #zig
xackus has joined #zig
<ikskuh>
cren: string literals are not arrays anymore
<ikskuh>
they are pointer-to-arrays
<cren>
so it's the type of the array that's wrong?
<ikskuh>
there's also a semicolon missing at the end
<ikskuh>
but it's a syntax error
<alexnask>
Well the type is wrong too but the `= {` is the issue
slurpie has quit [Ping timeout: 265 seconds]
<ikskuh>
oh yeah
<ikskuh>
that'S a code block, not an array literal
<alexnask>
`const hangman_pics = [_][]const u8 {` is what you want
<alexnask>
Or &[_][]const u8 if you only need a slice
<cren>
oh yeah
<alexnask>
In the future `.{` will work there too but it is a compiler todo atm
_Vi has joined #zig
<cren>
why is the syntax different for an array compared to that for a normal type? I think of arrays as being just a special case of type with a more complex literal syntax
<ikskuh>
they aren't
<ikskuh>
the syntax for type construction in zig is 100% equivalent for all types:
<ikskuh>
T { }
<ikskuh>
for arrays, T is an array type
<ikskuh>
[3]T { }
<ikskuh>
for structs, you use your struct type: Point { }
<ikskuh>
and so on
<cren>
ah so the []u8 in an array of u8 is part of the construction and not the type declaration
<alexnask>
Yes it is part of the array literal
<cren>
what is the difference between [] and [_] when you construct an array
<alexnask>
[] is invalid, you need to specify the size with [N], [_] just means the size is inferred from the initialization list
<ikskuh>
Names that begin with either ‘is’ or ‘to’ followed by a lowercase letter may be used for additional character testing and conversion functions. See Character Handling.
<ikskuh>
the heck?!
<ikskuh>
total() and tolerance() are reserved names
<ikskuh>
in C
<Amun_Ra>
how to assing to x in: for foo |x| { …; } I can't seem to find it
<daurnimator>
Amun_Ra: you can't. its const
<Amun_Ra>
uhm, thanks
<daurnimator>
Amun_Ra: `for (foo) |*x|` might be what you want?
<Amun_Ra>
that's it, thanks
<hermier>
ifreund[m]: fixed the issue, I need to understand the situation now
rzezeski has joined #zig
<ifreund>
hermier: nice!
<ifreund>
i don't really understand it either tbh, i just tried some things and it turns out that the simplest option worked for void
<hermier>
ifreund: I think the issue lies down to the fact that the embded Find*.cmake are broken, by producing incomplete *_LIBRARIES
<hermier>
ifreund: Do you know why the official llvm/clang ones are not used ?
<hermier>
ifreund: My issue was related to the fact that I missed the clang package dev/static libraries. It resulted in an invalid combo at compiletime resulting in alink issue detected at compiletime
cren has quit [Ping timeout: 245 seconds]
cren has joined #zig
kradnoel has joined #zig
waleee-cl has joined #zig
<cren>
Hello. I'm learning Zig. Can I make an array of strings of different lengths?
<ifreund>
cren: what you want is an array of pointers to the strings
<ikskuh>
you can use slices for this
<ifreund>
objects in an array must all have the same size
<cren>
ah I see. Sorry if the answers to my questions seem obvious, I'm coming from Python so I'm not used to a language with so many limitations :p
<ikskuh>
a slice is pretty much an array with variable size (and you need a memory for backing the storage)
<ikskuh>
cren: strings in zig are also only slices/arrays
<ikskuh>
so
<afontain_>
you can do like in C where there is a `**char`. [3][:0]char = { "hi", "hello", "goodbye" }
<ikskuh>
"a" is a pointer to an array of 1 element + NUL-terminator
<afontain_>
in my example, it works because the strings are null-terminated. With slices, it works because the size is stored in each element.
<afontain_>
that's two ways of doing that
<ifreund>
to explain why all objects in an array must be of the same size, an "array" is really just a pointer to a block of memory containing evenly spaced elements
<cren>
That makes sense
<ifreund>
to access an element of the array, you just add the index of the element to your pointer
<cren>
Yes, I was reading The C Programming Language and C pointers/arrays seem to work the same
<ifreund>
so if the items weren't all the same size it wouldn't work at all :P
<ifreund>
yeah all real arrays work the same way in the end
<ifreund>
afaik python wraps literally every object in a ref-counted heap-allocated thing
<ifreund>
and so a python lists are actually lists of pointers as well
<afontain_>
but if the elements of the array are pointers, and you know you can keep reading until you find a 0, or a pointer + a size, and you know you should keep reading for this size; it works!
<ifreund>
but it abstracts it all away so you don't have to worry about the details, for which you then pay a hefty performance penalty
<cren>
I'm trying to change the array of arrays to an array of slices, but I can't figure out what the syntax is for a slice
<cren>
(type of a slice I mean)
kradnoel has quit [Remote host closed the connection]
<ifreund>
[]u8
<ifreund>
or probably []const u8 in your case
<cren>
so for an array of strings, `[_][]const u8` to infer the length of the array?
<ikskuh>
yep
<cren>
compiler is complaining about that. "Expected type `[]const []u8`, found `[14][]const u8`
<ifreund>
try &[_][]const u8
<ifreund>
or wait no, that won't work
<ifreund>
you need to mutate these strings?
<cren>
no
<ifreund>
eh, well try what i put then it'll probably work
<ifreund>
the & will take the address of the array which coerces into the slice the compiler wants
<cren>
It doesn't :p : "Expected type []const []u8`, found `*const [14][]const u8`
xackus has quit [Read error: Connection reset by peer]
xackus has joined #zig
<cren>
`[]const []u8`, found `*const [14][]const u8`
<cren>
I mean
<ifreund>
yeah, so the problem is that []const u8 cant coerce into []u8
<ifreund>
maybe you could paste the code somewher?
<fengb>
I didn’t realize the spiral also pertained to const
<cren>
Does Zig copy values when you pass them to a function, like C?
<ikskuh>
cren: that is unspecified
<alexnask>
Arguments are all const, so the compiler decides what to do
<ikskuh>
zig allows the const-pointer optimization
<fengb>
Zig decides how the best way to pass args. Sometimes it’s by value and sometimes it’s by const reference
<cren>
what's the const-pointer optimisation?
<ikskuh>
when it's more efficient to allow passing a const pointer, the compiler may do this
<cren>
okay
<fengb>
It’s undefined behavior to rely on the address of an argument
<alexnask>
You only need to explicitly pass by pointer when you want to modify the input
<ifreund>
or compare by pointer
<fengb>
It means Zig is choosing the fastest way to pass the data around
<alexnask>
gotta go fast
<cren>
I saw ifreund use syntax for string formatting (like printf stuff) in an example a minute ago but I have since closed that tab, can someone put the syntax up
<ifreund>
cren: std.debug.warn("{}", .{mything});
<cren>
thanks
xackus has joined #zig
<cren>
Okay here's a question. Can I add new characters to the end of a string if the string is mutable?
<ikskuh>
no, not directly
<ikskuh>
you have to track the memory of the string
<ikskuh>
if you allocated it yourself, you can use std.mem.concat
<ikskuh>
that allows you to allocate a "sum" of two or more slices
dingenskirchen has quit [Quit: dingenskirchen]
<cren>
Is there a better way to make a string that is the same character repeated `n` times where `n` is known only at runtime?
dingenskirchen has joined #zig
<ifreund>
you can allocate an array of size `n` and memset it
cole-h has joined #zig
<cren>
okay that looks hard so I'm gonna take a break now. Thanks for all your help everyone
<andrewrk>
cren, maybe look into using std.ArrayList
kradnoel has joined #zig
<ifreund>
yes, an ArrayList(u8) is probably closer to the resizeable python strings you're used to
<cren>
I'm practising Zig by translating a Python program into Zig, so it doesn't translate terribly well.
<ifreund>
though the allocation + memset isn't that scary `const n_times_a = try myalloc.create([n]u8); std.mem.set(u8, n_times_a, 'a');`
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen has joined #zig
<andrewrk>
ifreund, probably would be myalloc.alloc(u8, n)
<andrewrk>
if your n is runtime known
<andrewrk>
if it is comptime known you could do [1]u8{'a'} ** n
alexnask has quit [Ping timeout: 256 seconds]
<ifreund>
andrewrk: that makes sense, the length of the array is definitely part of the type
<andrewrk>
It's looking like I'm going to be at a point in a few hours where I can do a live stream and I'll be sure to promote this
<fengb>
🎉
FireFox317 has joined #zig
<kristoff_it>
nice, let us know at what time you're going live, so I can raid you if I'm still online.
<dimenus>
andrewrk: I just got here but it might depending on the platform. eg I have a weird bug with alignment on aarch64 that goes away if I inline all of the calls
knebulae has quit [Ping timeout: 260 seconds]
<dimenus>
this with qemu emulating a raspi3
knebulae has joined #zig
<FireFox317>
dimenus, did you install expection handlers? So you can see if an alignment exception is actually generated. Aarch64 is really strict about alignment
<foobles>
does anyone who knows how 2nd-pass IR is validated take a look at my PR? It's generating basic blocks that apparently cause assertion errors. I think it has to to with me not properly communicating that they are not supposed to correspond to matching IrInstSrc instructions
<foobles>
since they are just generated during the 2nd apss
<foobles>
s/apss/pass
<dimenus>
Firefox317: no not yet. excellent point though
<FireFox317>
dimenus, also did you properly setup the target using zig cpu features? that might also make a difference
<dimenus>
Just targeting a cortex_a53 right now, no specific features
<ifreund>
been thinking about doing my first actual blog post on it too after reading about people trying to write them in rust
<andrewrk>
kristoff_it, what do you think about lowering the minimum even more? 10-30min, so that way it feels less like a big pressure to do a whole thing
<andrewrk>
short presentations can be quite enjoyable as well
<FireFox317>
dimenus, looks good! It might help to enable the cpu feature "strict_align", i think that forces llvm to have everything properly aligned. Might not be optimal for performance tho
<ifreund>
i could definitely fill a 15 minute slot, not really sure how much I have to say tbh
<dimenus>
FireFox317: it only happens with the flat binary, not the elf file - but good to know
<kristoff_it>
andrewrk: I'm fine with lowering the time limit, although in my experience 10min talks are harder than 20min talks, but from an organizational point of view, I have zero issues with either
<FireFox317>
dimenus, that is a good hint. In a elf file everything (code, data) is page aligned, and when you ask a flat binary it is all smashed together so alignment might be wrong indeed
<fengb>
ifreund: rant about how bad X11 is 🙃
<ifreund>
fengb: my experiance with X11 programming is literally starting to read the docs, then going "oh, may i should switch from i3 to sway and see if wayland is nicer"
<ifreund>
turns out working with wayland is a lot of fun
<kristoff_it>
ifreund: I have no idea what a wayland compositor is, so you already have 1 person interested in your talk :) if it ends up being 10 mins long it's perfectly fine!
<fengb>
Sounds like my experience with Rust :P
<ifreund>
kristoff_it: alright, yeah if i'm giving a brief intro to wayland as well i can do 30 minutes, and it sounds like i should do that :D
<dimenus>
i would highly recommend Drew Devault's wayland book as well, he changed the license recently.
<ifreund>
kristoff_it: submitted the form, do you have a sense of when this is going to happen yet?
<kristoff_it>
Let's say teantively next month. My plan is to get a few submissions and then work with the speakers to find a date that works for them
<ifreund>
cool, sounds good to me
<ifreund>
i wonder how much I can mature my project in another month
knebulae has quit [Ping timeout: 246 seconds]
<fengb>
Times are not great :(
<ikskuh>
damn you, global communities!
<fengb>
We need to be on galactic standard time
<ikskuh>
UTC is enough
<fengb>
Is it really universal though?
<fengb>
Should be called global instead 🤔
slice has quit [Quit: zzz]
dimenus has quit [Quit: WeeChat 2.8]
dimenus has joined #zig
knebulae has joined #zig
wootehfoot has joined #zig
dimenus has quit [Quit: WeeChat 2.8]
dimenus has joined #zig
<dimenus>
has anyone done any xml parsing in Zig?
fraktor has quit [Quit: WeeChat 2.6]
<fengb>
Have you tried regex? 🙃
* companion_cube
slaps fengb around with a large trout
<dimenus>
negative, haven't tried anything yet
<companion_cube>
bind to a C library? :p
<dimenus>
yeah, i spose reinventing the wheel in xml parsing isn't a good idea when libxml exists :P
<fengb>
RIIZ
<dimenus>
i started out wanting to build a wayland vnc client in zig, and then i decided i wanted to parse wayland's xml files myself instead of relying on wayland-client
FireFox317 has quit [Remote host closed the connection]
FireFox317 has joined #zig
FireFox317 has quit [Quit: Leaving]
FireFox317 has joined #zig
<ifreund>
i think tdeo may have
wootehfoot has quit [Ping timeout: 265 seconds]
slice has joined #zig
<andrewrk>
anyone want to play around with readelf/objdump and figure out why this small ELF binary is giving EINVAL when I try to execve it?
<companion_cube>
even "é" can be a composite unicode char, so yeah
frmdstryr has joined #zig
<fengb>
Only emojis: where I can be a black man with blonde hair 👱🏿, but I still can't be asian
<alexnask>
Sure, I know about the diacretics/composites, just didnt expect it to be the case in emoji
<alexnask>
idk why
<ikskuh>
it's quite ingenious to use ligatures for combining such features :D
<ikskuh>
if it's ligatures :D
<ikskuh>
but yeah, you can merge multiple people into a family :D
<alexnask>
lol
<ikskuh>
and with backspace, you delete persons from the family 😱
<ikskuh>
👩👩👧👧
<companion_cube>
it's below the level of ligatures, afaik
<companion_cube>
you combine codepoints to make a grapheme
<andrewrk>
ok I'm for sure going to be able to stream today
<andrewrk>
18:00 my time zone. that's in 1.5 hours from now
<alexnask>
🎉
<oats>
alexnask: you're in NYC, right?
<oats>
er, *andrewrk
<andrewrk>
both of us are I believe
<oats>
heh, ok then
<alexnask>
nah :P
<companion_cube>
ah, the move to CA was delayed because of covid?
<oats>
andrewrk: looking forward to it!
<ikskuh>
andrewrk, i'm so getting no sleep tonight :D
<alexnask>
EU life
<andrewrk>
alee didn't get into santa cruz :( so another year in NYC it is
<oats>
time zone buddies \e/
<andrewrk>
I used to say "EST" but then I realized that the time zone doesn't stay constant for daylight savings. the *TIME ZONE CHANGES* rather than the time changing. so you have to look up what time zone you are in every time you want to tell someone a time, which is ridiculous
<oats>
yeah, we're in "EDT" :P
slice has quit [Quit: zzz]
<andrewrk>
but you can't say EDT either. one day you will be wrong
<andrewrk>
I suppose I could say NYC time zone
<alexnask>
^
<ikskuh>
andrewrk, just announce times in UTC
<oats>
could just do UTC :P
<oats>
let everybody else figure it out
<alexnask>
Hah europeans mad /s
<andrewrk>
that's not rigth either though
<ikskuh>
let *everybody* figure it out :D
<andrewrk>
because your local municipality can change its time zone and then your UTC date is wrong
<ifreund>
man i've been building up stream hype for 3 days now :P
<companion_cube>
that sounds amazing
<andrewrk>
the truest way to tell someone a time is with a tuple (geographical_location, local_time)
<kristoff_it>
I think you can say ET to be daylight-savings-agnostic
<companion_cube>
just imagine a local city of 20k habitants, with its own timezone
<oats>
andrewrk: start a campaign for timekeeping reform and I will happily jump on the bandwagon :P
<alexnask>
Yes, we just need a new standard
<companion_cube>
or a bot with a counter
<companion_cube>
"stream in 1.5h"
<companion_cube>
durations are sometimes easier than datetime
<andrewrk>
I also decided to play my new favorite game in the ~10 min while waiting for ppl to join
<andrewrk>
"Getting Over It with Bennett Foddy"
<ikskuh>
alexnask: i still wonder about europe removing DST
<alexnask>
Im generally favorable to it but I havent really given it much thought :P
<ikskuh>
yeah
<ikskuh>
it will break a lot of embedded devices though :D
frmdstryr has quit [Ping timeout: 260 seconds]
<fengb>
UTC would be correct if you're talking about "instant in time", but not necessarily about future scheduled times
<fengb>
So if it's an hour away, broadcast in UTC :P
<sjm>
on windows i get ".\main.zig:13:56: error: expected type '*[98302]u8', found '*[260]u8'"
* redj
will miss the stream
<redj>
:(
<sjm>
my guess is that certain stdlib functions expect the path to be a certain length that's incompatible with PATH_MAX but i'm a noob so it's probably just that i'm missing something
<ikskuh>
use std.fs.MAX_PATH_BYTES instead of PATH_MAX
<andrewrk>
sjm, there is also fs.realpathAlloc which might be easier to use
Akuli has quit [Quit: Leaving]
<andrewrk>
also consider that you might be able to get away with using dir fds rather than realpath, which could have nicer semantics
<ikskuh>
btw, i successfully hooked up Zig and BearSSL to connect a TLS1.2 socket stream :)
* ikskuh
is a bit proud
<andrewrk>
nice
<sjm>
andrewrk: which function(s) would i use to do that?
<andrewrk>
sjm, everything in std.fs.Dir
<andrewrk>
so you'd start with std.fs.cwd() and then go from there
<andrewrk>
I'm not sure what your use case is for realpath, maybe this is not helpful advice
<sjm>
andrewrk: it's all good. i'm just messing around experimenting trying to wrap my head around the language. doesn't help that i've probably forgotten most of the system programming stuff i'd learned while teaching myself c years ago.
<FireFox317>
andrewrk, in the binary you send i see twice the program header LOAD, where one has flags rx and the other only has the r flag. Is that correct?
<andrewrk>
FireFox317, I got the problem worked out - it was the .got section not having an aligned file offset
<FireFox317>
Ah nice! Looking forward seeing you demo this on stream :D
dnmllr has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]