<daurnimator>
So that's a "no" on the release party I guess
daex has joined #zig
<andrewrk>
oh I just got discord set up and installed and running
<emekoi>
i'm ... a moron
<andrewrk>
this is the saddest release party ever, only 4 ppl in it
daex has quit [Ping timeout: 256 seconds]
daex has joined #zig
<foobles>
6 now :D
<fengb>
I have a crying toddler :(
daex_ has joined #zig
daex has quit [Ping timeout: 265 seconds]
daex_ has quit [Ping timeout: 265 seconds]
diginet_ has joined #zig
jaredmm_ has joined #zig
johnLate_ has joined #zig
bbrittain_ has joined #zig
andrewrk has quit [*.net *.split]
diginet has quit [*.net *.split]
johnLate has quit [*.net *.split]
bbrittain has quit [*.net *.split]
jaredmm has quit [*.net *.split]
diginet_ is now known as diginet
daex has joined #zig
darithorn has quit [Quit: Leaving]
layneson has quit [Ping timeout: 260 seconds]
foobles has quit [Ping timeout: 240 seconds]
<redj>
andrewrk: and now I wonder if designing a gui-editing ide would be a use case to consider for language stabilization
<emekoi>
my function pointers are off by 16 whenever i call a function
<emekoi>
is my stack aligned wrong or something?
<pixelherodev>
That was a nice release party :)
ur5us has quit [Ping timeout: 260 seconds]
<wilsonk>
I was taking a nap, or I would have been at the party...sort of just logged on to discord at the last minute, was reading logs, and missed it :P
nycex has quit [Remote host closed the connection]
nycex has joined #zig
wootehfoot has joined #zig
cole-h has quit [Quit: Goodbye]
dermetfan has joined #zig
<Snektron>
<andrewrk "this is the saddest release part"> Night in europe
dermetfan has quit [Ping timeout: 265 seconds]
nikki93 has joined #zig
dermetfan has joined #zig
_Vi has joined #zig
dddddd has quit [Ping timeout: 256 seconds]
dermetfan1 has joined #zig
ur5us has joined #zig
dermetfan has quit [Ping timeout: 246 seconds]
omglasers2 has joined #zig
<nikki93>
how reasonable / easy is it to compile zig compiler to wasm; so that you can write, compile and run zig code in the browser? seems like the hardest parts are llvm and wrapping syscalls zig compiler may make to assume eg. how modules are imported / found etc.?
Ichorio has joined #zig
<nephele_>
>If statically linked, Zig looks at the dynamic linker path of /usr/bin/env
<nephele_>
what would this do on android?
<pixelherodev>
I don't think running the compiler on android is supported yet
slowtyper has quit [Ping timeout: 260 seconds]
jjido has joined #zig
slowtyper has joined #zig
emekoi has quit [Remote host closed the connection]
<daurnimator>
nephele_: what would you suggest looking at instead?
_Vi has quit [Ping timeout: 265 seconds]
<daurnimator>
and why *wouldn't* you look at `/usr/bin/env`? is it not present on android?
return0e has joined #zig
<nephele_>
android (and haiku) don't have /usr at all
<nephele_>
there you would likely need /system/bin/env or so
return0e_ has quit [Ping timeout: 256 seconds]
<nephele_>
actually, i am not sure if android has /system/bin/env should check that..
<nephele_>
nope, don't see it, maybe because it uses so little sh :)
<nephele_>
it does have i.e /system/bin/cp or so though
squeek502_ has quit [Ping timeout: 265 seconds]
<daurnimator>
wow, /usr/bin/env is a pretty wide standard
<daurnimator>
nephele_: you'll have to just specify the abi and linker yourself
<nephele_>
well, pretty wide is debateable :)
<nephele_>
if you follow posix making portable scripts in the "just run it like ./script" sense is impossible :P
<shanrhyupong>
Congratulations to the Zig team for the 0.6.0 release!
<ikskuh>
haha oh no
ifreund[m] has joined #zig
<ikskuh>
but daurnimator: I'll maybe write an assembler emulator for my CPU in zig
<ikskuh>
it's much more emulator friendly with stuff like @addWithOverflow and perfect-fit-types
frett27 has joined #zig
frett27_ has joined #zig
<daurnimator>
I think it would be really cool
<daurnimator>
if you did it right it could work at comptime *or* runtime
<ikskuh>
yeah, true :)
marijnfs has joined #zig
<pixelherodev>
Sure but
<pixelherodev>
I'd counter that's not doing it right
<daurnimator>
pixelherodev: howso?
<pixelherodev>
Doing it right would mean maximal runtime support even if it comes at the expense of comptime
<pixelherodev>
For something that doesn't need to be comptime, it's not a good idea to support comptime if it harms runtime
<daurnimator>
what does maximal runtime support mean in this context?
<pixelherodev>
e.g. performance
<pixelherodev>
If there's a performance trick that boosts runtime, but breaks comptime entirely, should it be used?
<pixelherodev>
I'd say yes
<daurnimator>
I'd say that means comptime needs to be fixed then
<pixelherodev>
Sure, except for one problem
<pixelherodev>
Comptime performance is only *intended* to ever reach CPython levels
<pixelherodev>
Which isn't *bad*
<pixelherodev>
but again, for something *intended for runtime*, comptime should never be the goal
<ikskuh>
@TypeOf Supports Multiple Parameters §
<pixelherodev>
Comptime should not be an end in and of itself
<ikskuh>
this is a really nice addition
<shanrhyupong>
Hey guys, I have a basic question. Does Zig have copy semantics by default for the assignent operator? If so, is this guaranteed? Also, do we have something like move semantics?
<ikskuh>
zig has no move semantics, = will always perform a copy
<ikskuh>
not that if you assign a pointer, it will only copy the pointer
<shanrhyupong>
ikskuh, ah okay.
<shanrhyupong>
Hmmm... so we have aliasing by default, right?
BitPuffin has joined #zig
afontain_ has joined #zig
dtz has joined #zig
magejohn has joined #zig
alva has joined #zig
pmwhite has joined #zig
AlexMax has joined #zig
fengb has joined #zig
jorge-jbs has joined #zig
BaroqueLarouche has joined #zig
sammich has joined #zig
Snektron has joined #zig
hryx has joined #zig
D3zmodos has joined #zig
<shanrhyupong>
So maybe this is not a valid scenario, but if we had multiple aliases for a pointer, some of which we send to some other function, and we have a defer for freeing that pointer, will this be a problem (or not)?
<ikskuh>
good question, can you make a code example?
<ikskuh>
it will be a problem if you release the memory while still referencing it somewhere
<shanrhyupong>
ikskuh I will try... still a newbie to Zig! :-)
<shanrhyupong>
yeah... still going through the master documentation, had some questions pop up in my mind!
ur5us has quit [Ping timeout: 260 seconds]
<ikskuh>
:)
<shanrhyupong>
Thanks for your help, ikskuh!
<ikskuh>
you're welcome :)
slowtyper has quit [Ping timeout: 260 seconds]
slowtyper has joined #zig
squeek502 has joined #zig
jjido has joined #zig
shanrhyupong has quit [Quit: leaving]
FireFox317 has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
* nephele_
hopes LLVM adds Xtensa support... so that eventually lands in zig too, maybe
z0ltan has joined #zig
<z0ltan>
Hello, I had mentioned a scenario some time back today about how we could return pointers along with using deinit() on an allocator, and then have segmentation fault. Just wanted to know if this is the expected behaviour.
<z0ltan>
I have some sample code here:
<daurnimator>
nephele_: should be soonish. maybe 2 releases?
<daurnimator>
nephele_: I poked the xtensa devs back in jan which at least prompted them to push their WIP to github....
FireFox317 has joined #zig
z0ltan is now known as antaoiseach
<nephele_>
daurnimator, ah i saw that indeed the LLVM xtensa on github, maybe i should look up how often llvm releases stuff :)
<daurnimator>
nephele_: every 6 months. and zig's releases are scheduled to be a couple of weeks after each LLVM release
<daurnimator>
antaoiseach: what is your question?
<antaoiseach>
So this code segfaults (expectedly so according to me, but just want to make sure it is as per expectations) - if I remove the defer map.deinit() code, of course that's a memory leak, right?
<ifreund>
yeah, you probably want your allocator in your main
<antaoiseach>
In this case, even when I have deinit(), I can return a pointer back which segfaults.. this is expected, right?
<ifreund>
yep
<daurnimator>
yes.
<antaoiseach>
ifreund - that makes sense
<daurnimator>
you have a stale pointer
<antaoiseach>
Okay, cool. Thanks, guys!
<daurnimator>
apparently the preferred term is dangling pointer.
<antaoiseach>
Haha... yeah, that's the term I'm more familiar with... so this code example came about because i was discussing about copy vs move semantics in Zig
<FireFox317>
antaoiseach, also the part where you do an `if` on the pointer can be changed to use `try allocator.create()` then ptr will be an actual pointer instead and if the allocator fails the function would return.
<antaoiseach>
and I came to understand that Zig doesn't have move, but only copy semantics..
<antaoiseach>
Firefox317... yes, you're right! I realised that in hindsight... still a Zig newbie, working through the Zig master doc... haven't reached the memory part yet! :-)
<FireFox317>
ah no problem :) its the error handling in zig that is really cool using `try`
<daurnimator>
antaoiseach: the pointer is copied. the contents are not
<antaoiseach>
daurnimator: so if I pass a struct (or assign a struct), the compiler *may* optimize that to a pointer? Or would that always be copy?
<ifreund>
if you pass it as fn dothing(mystruct: MyStruct) void {} yeah the compiler may transparently optimize that to a pointer
<antaoiseach>
Ah, okay. Thanks, ifreund.
<ifreund>
parameters are immutable so theres no way for you to notice which one happens in practice
<antaoiseach>
Haha.. that's exactly what I was asking next!
<antaoiseach>
So the compiler does some magic so that we don't have to use pointer syntax from within the function, right:?
<ifreund>
you don't need special syntax for pointers in zig
<antaoiseach>
I mean something like mystruct.*.x = 100 instead of mystruct.x = 100?
<antaoiseach>
Inside the dothing function, for instance
<ifreund>
yeah you dont need the .*. generally
<antaoiseach>
Whoa... I didn't know that!
<ifreund>
only in a few cases with c pointers
<antaoiseach>
Interesting!
<antaoiseach>
That makes more sense to me nnow
<antaoiseach>
So this brings me to my last question then - so even if the mystruct object may be a pointer, changes from within dothing would not show up in the callee?
<daurnimator>
antaoiseach: it's const
<ifreund>
yeah you can't change it
<antaoiseach>
Oh, not just the pointer, but the contents as well? Got it... so that's consistent throughout
<antaoiseach>
Cool... I learnt a lot more in this session than a day of reading the documentatiopn.. haha
<FireFox317>
correct antaoiseach, if you want to change it you're function needs to accept a ptr: fn dothing(mystruct: *MyStruct) void {}
<antaoiseach>
Brilliant... I like the explicitness!
<ifreund>
oh you can modify whatever the pointer is pointing to, but you cant modify the variable storing the pointer
<antaoiseach>
ifreund.. ohh, that was my question.. suppose I do mystruct.x = 100, will this change reflect in the x field of the struct in main, say? Assuming I passed it as dothing(mystruct: MyStruct)
<ifreund>
that wont compile if mystruct is passed as fn dothing(mystruct: MyStruct) void
<antaoiseach>
Ah, okay
<antaoiseach>
Very interesting indeed
<antaoiseach>
In all fairness, I should be trying out all these scenarios myself :D ...
<ifreund>
and yeah learn by doing is the way to go, i was several hundred lines of zig into my project before i learned that you don't need the .*. everywhere :D
<antaoiseach>
ifreund: That makes perfect sense. Since `ptr` is `const`, I cannot change what it points to... if I wanted to change the pointee, I would have to declare it `var`, right?
<antaoiseach>
Hahaha
<ifreund>
antaoiseach: exactly
<antaoiseach>
Cool! So far I'm really liking it... took some time to get my head around the various error handling bits, but it's really nice now.
<antaoiseach>
Thanks, guys... this has been very helpful... I'll get back with a bunch of question once I've worked though the master doc. Cheers!
<pingiun>
btw I'm very new to Zig (and C development), I just have access to a power64le virtual machine and I heard the news about zig-bootstrap in the 0.6.0 release and I wanted to try it out
<FireFox317>
Hey pingiun, welcome to the zig community! I think you are the first person to try to build Zig for powerpc64le-linux-gnu. As you could see in the issue tracker andrew tried to build it for musl, but ran into different issues. It seems that the std library support for powerpc is not correctly implemented yet :(
<pingiun>
ah I see, is this something a newcomer could work on?
<FireFox317>
pingiun, yes for sure! I think best bet would be to start with getting to properly build zig and afterwards do the behavior testing. As you could see it correctly build zig0 (the cpp part of the zig compiler) but not yet zig itself (which is zig and cpp code linked together).
<pingiun>
so I need to add the parts of the standard library that the zig compiler itself uses?
<pingiun>
also just to be sure, is it a good idea to clone zig-bootstrap, work in the zig directory and if I make something work create a patch for the zig repo?
<FireFox317>
correct, as you can see in the first error message it is trying to reference os.mode_t, but that is not yet defined for powerpc. The file that you would have to create is in std/os/bits/linux/. In that dir all the linux defintions for stuff like mode_t is defined. You could copy for example mipsel and start with that
pingiun[m] has joined #zig
<pingiun[m]>
(this is just a test to see if my matrix configuration joined the irc channel correctly)
<pingiun[m]>
okay this works, now I can logoff from irc
<FireFox317>
pingiun[m], well at the end the stuff has to end up in the ziglang/zig repo, because that is where we develop zig
<pixelherodev>
That joke hasn't been funny for me in a while
<pixelherodev>
Heard it too often I guess
<nephele_>
Is there perhaps an example of zig beeing used with e.g libressl (libtls) or another tls library?
Aransentin has left #zig [#zig]
ifreund has quit [Quit: WeeChat 2.8]
ifreund has joined #zig
r4pr0n has joined #zig
SebastianM has joined #zig
SebastianM has quit [Client Quit]
dermetfan1 has quit [Ping timeout: 265 seconds]
kenaryn has joined #zig
<kenaryn>
Hello guys. Please what does the 'm' stands for in `-mcpu` parameter associated with `-target` option?
<daurnimator>
machine I think?
<kenaryn>
Thank you buddy!
<daurnimator>
Its a very old convention from other compilers
<kenaryn>
So there are still artifacts in 21th century? (joke inside)
<daurnimator>
kenaryn: why do you ask/why does it matter?
<kenaryn>
My second question wasn't serious but the first one is intended to help me understand the release notes.
<kenaryn>
Nevertheless, I didn't find the exact word in english, my dictionnaries purpose 'remains', 'remainders' or 'balance' but nothing in computer science context.
PC9801 has joined #zig
<pixelherodev>
The real answer for "what does -m stand for": GCC does it and if we use something else people will get angry
<fengb>
People get angry anyway
<kenaryn>
Allright, I agree with the need for conventions in common vocables.
<shakesoda>
as programmers we are honor bound to appreciate such things
<shakesoda>
daurnimator: every single time i see something about riscv i want more riscv hardware
BeardPower has quit [Read error: Connection reset by peer]
<shakesoda>
just realized i haven't upgraded to 0.6.0 yet
<shakesoda>
the time has come!
SebastianM has joined #zig
<kenaryn>
your computer may not support such power^^
<SebastianM>
Hey guys, I can't figure out a problem Hope you can help.
<SebastianM>
I'm using zig as ac compiler in Nim language, and i can create an executable with ./nim_1_3_1/bin/nim --cpu:arm -d:danger --cc:zig --passC:"-target arm-linux-musleabi" --passL:"-target arm-linux-musleabi" c ./hi.nim
<SebastianM>
but the following command to create executable for different architecture results in error with pretty big log:
<pixelherodev>
Okay, got my bugzilla account for LLVM :)
<shakesoda>
left already? argh
<pixelherodev>
Now I can file that reduction
<pixelherodev>
Wow that was fast
<shakesoda>
it looked like that wasn't invoking zig cc
<shakesoda>
just zig
<Snektron>
SebastianM: To compile c with zig, you need to use `zig cc`. The command you used invokes `zig`
<pixelherodev>
Pretty sure they're gone already
<shakesoda>
barely even two minutes!
<daurnimator>
shakesoda: I think nim has config to call `zig cc` when you pass --cc:zig
<shakesoda>
hmmm
<FireFox317>
Snektron, it ran `zig cc` as you can see at the bottom of his dump
<shakesoda>
so it did
<Snektron>
i see, soz
SebastianM has joined #zig
<FireFox317>
this looks like a mistake on Nim side? the zig c compiler is not able to compile the co code, because it is not valid? (warning: type specifier missing, defaults to 'int' [-Wimplicit-int])
<daurnimator>
SebastianM: where is `N_INLINE` defined?
<FireFox317>
daurnimator, i think that comes from the nim c code generator. That is how Nim compiles, it generates c code and that gets now compiled with `zig cc`
<daurnimator>
FireFox317: yes..... but from those error messages it looks like its not getting defined properly. which to me suggests a missing #include of some nim thing
nephele_ is now known as nephele
<SebastianM>
daurnimat: it looks like its defined in stdlib_system.nim that what the log says
<daurnimator>
SebastianM: and why are you using --passC/--passL instead of --zig.options.linker / --zig.options.always
<SebastianM>
daurnimat: well this worked for another user with arm, but i'll try your suggestion
<SebastianM>
daurnimat: thanksfor the link and advice, will read it carefully
<companion_cube>
wait, daurnimator, are you also a nim programmer?
<daurnimator>
companion_cube: nope
dermetfan1 has joined #zig
<fengb>
Only 2 cool clubs allowed
backwhack has quit [Ping timeout: 240 seconds]
<fengb>
He filled his quota with Lua
<shakesoda>
lua club though
JX7P has quit [Excess Flood]
r4pr0n has quit [Quit: r4pr0n]
backwhack has joined #zig
SebastianM has left #zig [#zig]
foobles has joined #zig
<fengb>
Too much cool for us D:
<foobles>
is it allowed to just, change the value of an IrInstGen during analysis? O_O
<oats>
congrats on 0.6.0 y'all :)
<oats>
I wish I had more time to poke around with zig, but it's been super fun watching from afar
<foobles>
:D
r4pr0n has joined #zig
<fengb>
o/
JX7P has joined #zig
<r4pr0n>
what is the WhileContinueExpr in the WhilePrefix actually for? couldn't you just put it in the normal expr block of the while?
<r4pr0n>
doesn't that go against the "you should only be able to do things one way" way?
<oats>
wait, `[]const u8` is automatically null-terminated now?
<r4pr0n>
oats: yes
<r4pr0n>
well no
<oats>
has that always been?
<r4pr0n>
the literals are
<oats>
ohh, literals
<oats>
does that mean you can't have a string literal with a null byte in it?
<oats>
oh nvm
<oats>
I just remembered that has length info in it :P
<r4pr0n>
well i guess you could technically, it still has a length
<r4pr0n>
yeah
<pingiun>
daurnimator: can you give me a hint about which files I should look at for this "TODO implement C ABI for this architecture. See https://github.com/ziglang/zig/issues/1481"?
<oats>
I guess it would just confuse any C stuff you passed it to
<r4pr0n>
yeah
<pingiun>
is implementing the C ABI necessary to build the compiler?
<daurnimator>
pingiun: sorry I can't help with that error much. how did you hit it?
<pingiun>
it's the only message I get now when compiling using the build script
<pingiun>
so far I only copied the files you pointed to and filled in the syscall numbers
<pingiun>
I'm quite sure that that is not the only thing I should do
<pingiun>
but I'm just puzzled that that is the only error message
<pingiun>
like of course I should also fill in the assembly parts for the syscalln functions
jjido has joined #zig
kenaryn has joined #zig
<kenaryn>
Please what does it mean 'v7a is considered baseline'? Is that a synonym for 'v7a is a CPU feature?'
<ikskuh>
v7a is the "minimum cpu"
<ikskuh>
for "arm"
<kenaryn>
baseline is also used by llvm for cpu and features detection, but I do not understand the word.
<kenaryn>
Ah thank you :)
<oats>
“If there is no type in the result location then an anonymous list literal actually turns into a struct with numbered field names”
<oats>
well that's freakin cool
<oats>
so tuples then, basically?
<nycex>
i think so
<ikskuh>
yep
<fengb>
Yes tuples
<nycex>
it would just be nice imo, when you could specify somehow that you want a tuple in a function signature
<fengb>
I have a hack I'm not proud of that does this in userland. It's really fugly
<nycex>
well you can of course just check if it's a tuple and if not do a compileError
kenaryn has quit [Quit: WeeChat 2.3]
<FireFox317>
pingiun, so you got past the messages you got before?
<r4pr0n>
what is the WhileContinueExpr in the WhilePrefix actually for? couldn't you just put it in the normal expr block of the while, doesn't that go against the "you should only be able to do things one way" way?
<fengb>
I suppose the argument could be made that `while (foo) : (foo += 1) {` is basically `while (foo) { defer foo += 1;`
<r4pr0n>
is that an argument for the syntax or against it?
<foobles>
Hoooray! I got optional comparison to work at comptime! Instead of generating an unwrap instruction, I should have just manually set the value already inside the provided instruction
<foobles>
:D now for runtime.......
<daurnimator>
pingiun: zig is lazy: it only compiles the code is tries to use
<daurnimator>
==> you can have completely broken code inside of a function if it never gets called (still has to be e.g. syntactically correct though)
<foobles>
i love my `const foo = [_]bar{1, "hello", (.{})} ++ (x - x - x);`
<foobles>
as long as you dont use `foo`, this will compile even if `x` and `bar` havent been defined either
<nephele>
the "zig" usage shows zig cc but not zig c++ in the list, is that intended?
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jjido has joined #zig
<daurnimator>
nephele: good (original) question! perhaps ask it on the issue tracker for posterity
<nephele>
Sadly, i don't have a github account to ask with
<nycex>
i'll do
pingiun has quit [Read error: Connection reset by peer]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<karrick>
Is this intentional? Sorry if it's already been discussed...
<fengb>
Probably not. The homepage has bitrot :P
<oats>
blame cosmic rays
zfoo has quit [Remote host closed the connection]
<nephele>
what did cosmic rays ever do to you
<oats>
eat my bits
<oats>
s/eat/flip
<r4pr0n>
we should write a new language where fixing cosmic rays are in scope
<r4pr0n>
they seems very problematic
<nephele>
Well, you can always use ECC ram.. and ZFS or btrfs etc :)
<fengb>
Why not just use lead shield
<fengb>
A mile thick should do the trick
<r4pr0n>
^ seems to be the best option
<r4pr0n>
but i'd say 2 miles
<r4pr0n>
just to be sure
Xavi92 has joined #zig
<oats>
ok, someone wanna throw together a pull request?
frett27_ has joined #zig
<oats>
I'll work on the unit tests
<karrick>
lul
<karrick>
s/u/l/
<karrick>
damn, I cannot type
<oats>
huh, is std.c new?
<oats>
what's in there?
<fengb>
Might be too hard to shield every device though. How about we just re-engineer stars to never emit these buggers
<r4pr0n>
just to be clear: do we use the vim or the sed syntax for s// in here? does s//g mean for all occurances in all lines or for every first in every line?
<karrick>
🍿
<oats>
since when does /g not mean every occurrance in all lines?
<oats>
or do I just not know sed that well
<r4pr0n>
since vim reversed the meaning of /g
<r4pr0n>
in sed it's like you think it is
<fengb>
/g has always applied only to "this line"
<karrick>
M-x query-replace-regexp
frett27 has quit [Ping timeout: 250 seconds]
<fengb>
Varying definitions of this
Patrice_ has quit [Ping timeout: 250 seconds]
<r4pr0n>
oh i'm sorry
<r4pr0n>
it just neovim being stupid here
<fengb>
It's the prefix to s/ that changes which lines
frett27 has joined #zig
<r4pr0n>
vim does what sed does
<fengb>
oats: it's Zig's shim to libc. We add some better typings to make it nicer in Zig
<fengb>
(Obviously doesn't work unless you explicitly link in libc)
<ikskuh>
hm, i still wonder about the freestanding libc :D
<ikskuh>
i should get me informed about this
zfoo has joined #zig
layneson has joined #zig
zfoo has quit [Read error: No route to host]
cole-h has joined #zig
<nephele>
Is zig c++ expected to work as a drop-in replacement for clang++? (I know cc is expected to be currently, but unsure of c++)
<oats>
if you want a function to "return multiple values", do you have to say it returns a `var` and then `return .{ true, "hi" }` kinda thing?
<companion_cube>
I think the syntax for tuple types is still in the works
<oats>
hmm, so gotta stick with named structs for now?
<fengb>
You can’t have var as the return type
<fengb>
You can use an unnamed struct or you apply a terrible hack that I don’t really want to share >_>
<fengb>
This works: `fn foo() struct{a: u8, b: u8} {`
FireFox317 has quit [Remote host closed the connection]
FireFox317 has joined #zig
<oats>
is that the terrible hack?
<oats>
that doesn't look bad at all
<oats>
kinda nice being able to name your returns
<nycex>
well but it's not a real tuple that, i guess you e.g. can't use it for std.fmt.format anymore and can't use indexing on it, right?
<foobles>
would you have to say `return .{ .a = foo, .b = bar };` in that case?
<foobles>
instead of just `.{foo, bar};`
<danyspin97_>
zig 0.6.0 has linking errors. does it need some llvm/clang option enabled? like polly
<fengb>
Yeah
<fengb>
That’s structs. You can get a tuple type but it takes a lot of effort. I guess I should post it
<fengb>
Unfortunately, anon structs / tuples converts comptime known values into comptime fields. The bitcast / as hack is the only way I figured out how to make them not comptime
marijnfs has quit [Quit: leaving]
<fengb>
But... I'd recommend waiting for declared tuples to be in the lang than using this
<companion_cube>
shakesoda: welcome to D
zfoo has joined #zig
nycex has quit [Remote host closed the connection]
nycex has joined #zig
<oats>
hmm, could you generate a tuple type with something called like this: Tuple(.{ u8, bool})
<companion_cube>
hopefully at some point `fn foo(): .{u8, bool}` will be supported? I think it's even in the release notes
<fengb>
oats: it's really hard to get that behavior because we don't have a way to build types at comptime. We can manually roll one but it's a really clunky implementation (especially on top of this horrible kludge): https://github.com/ziglang/zig/issues/2930#issuecomment-514037717
zie has left #zig [#zig]
layneson has quit [Read error: Connection reset by peer]
<oats>
oof
<fengb>
Oh that example is for building function args. Building a type would be somewhat similar
<foobles>
i got the comptime optional comparison to work!
<andrewrk>
nice
<foobles>
is it ever ok to just modify the value of an IrInstGen?
<foobles>
oh nice, i just checked the issue you linked
<foobles>
that does sound good
jjido has quit [Client Quit]
waleee-cl has quit [Quit: Connection closed for inactivity]
layneson has joined #zig
<r4pr0n>
is it even possible to set a output name for the executable in zig build-exe?
<r4pr0n>
i can't find a option to do that
<FireFox317>
r4pr0n, `--name`
<Snetry>
Hey, I'm having some trouble with the bootstrapper
<Snetry>
as far as I understand it I should be able to invoke build using native native
<Snetry>
but whenever I do that I end up with "System is unknown to cmake, create: Platform/Native to use this system, please post your config file on discourse.cmake.org so it can be added to cmake"
tgschultz has joined #zig
<r4pr0n>
FireFox317: thanks
<r4pr0n>
and is it possible to disable the creating of .o file or rather that they are stored in /tmp and deleted afterwards or whatever?
<andrewrk>
Snetry, ah, the build script made an invalid assumption there
<FireFox317>
r4pr0n, the zig compiler stores the .o files in a zig-cache directory. or are you talking about `zig cc`?
<tgschultz>
Hi everyone. I haven't been able to do anything with Zig in quite some time due to changes in life circumstances, but I wanted to drop by and say congrats on 0.6.0! Impressive work all around, and I'm excited in particular to see how many long standing issues I'd encountered are now resolved.
mahmudov has quit [Ping timeout: 256 seconds]
<fengb>
Hiya 👋
<andrewrk>
hi tgschultz
<pixelherodev>
Hello!
mahmudov has joined #zig
<r4pr0n>
FireFox317: no, when running zig build-exe file.zig, an file.o file is created in my cwd
<r4pr0n>
and an file executable
<FireFox317>
r4pr0n, ah yeah that is correct actually. `zig build` puts the object files in zig-cache. Not sure why `zig build-exe` isn't doing that actually.
mahmudov has left #zig ["Leaving"]
<r4pr0n>
but it's not disableable, is it?
Akuli has joined #zig
<ifreund>
you can delete the object files, the resulting binary doesn't depend on them
<ifreund>
i don't think zig build-exe is intended to be aware of directory structure, it just take path as input and outputs to the working directory
kenaryn has joined #zig
<kenaryn>
Hi again. Please what is the difference between a `comptime var` and a `const`?
jjido has joined #zig
<ikskuh>
kenaryn: hey!
<kenaryn>
:)
<ikskuh>
you can compute a comptime var at compile time
<ikskuh>
so, change it
<ikskuh>
but you cannot do that to a const
<kenaryn>
Ah, thank you, I will add your tip to my zig praecisus (it's like a brief memorandum).
<D3zmodos>
Hey, I've been waiting for stdlib network support in zig for a while so you can imagine I was excited when I saw earlier today that 0.6.0 was out! I have just the project to try the new functionality out on but upon trying to use it now, I'm running into issues just reading from stdin... Take this minimal example: https://paste2.org/OGV6J0ZZ My understanding (which could certainly be incorrect) is that the
<D3zmodos>
`readUntilDelimiterOrEof` should return as soon as I enter a newline in the console, however this isn't the case and stepping through in a debugger shows that it appears it's spinning on the OS call to read from the file descriptor until it has a full buffer's worth of data, which in this (default) case, is 4096 bytes! :O Am I doing something wrong here?
<kenaryn>
Dully noted, you're both kind.
<ikskuh>
btw, care to share your notes?
<ikskuh>
they can make a nice starting point for "Zig for beginners"
<ikskuh>
@D3zmodos: why using a buffered stream?
<ikskuh>
buffered streams improve I/O performance by reading a huge block of data
<ikskuh>
this should do fine for interactive input
<r4pr0n>
i don't think you would ever want to use bufferedinstream for real user input on stdin
<r4pr0n>
for piping in file contents e.g. on the other hand it would be useful
<kenaryn>
Thank you too Xavi92, I will read your code later because I can't stay for now, but you're sympathic too =)
<r4pr0n>
Xavi92: good example, but why are you using comptime var for this, you could just not use a comptime block and rather defined w and h at the block
<r4pr0n>
s/the block$/the block where they are returned
<D3zmodos>
@ikskuh @r4pr0n I was trying buffered streams because in my head things that are not buffered streams don't support higher-level concepts like "read a line" but taking another 2s to look at it now, this is obviously not true at the moment (independent of whether or not it was true in the past) -_- I'm in too much of a hurry to get to the networking clearly... thanks!
<ikskuh>
you're welcome
<ikskuh>
what platforms are you targeting with network code?
<foobles>
if I have a non-comptime variable defined in a function, and I run that function within a `comptime` block, the value of the variable is not considered comptime (i.e., op->value.special != ConstValSpecialStatic)
<foobles>
is that intended?
<D3zmodos>
ikskuh: Initially just linux but I'd like to expand to windows in the near future, I see in the release notes it was mentioned that the API isn't quite fully rolled out to other platforms yet
<ikskuh>
yeah, that's why i was asking
<ikskuh>
i'm writing a GUI library right now that needs networking and i'm building a network lib aside from zig std
<ikskuh>
i'll probably give that library a merge request to zig std one day, but i want it to mature a bit first
marijnfs_ has joined #zig
<ikskuh>
src is here right now, it even is documented a bit:
<ikskuh>
it's a tad higher level than pure OS abstractions
<ikskuh>
supports TCP server and UDP+multicast right now
<ikskuh>
haven't implemented connect() yet, but should be trivial
* ikskuh
searches for people to adopt this
<Xavi92>
r4pr0n: you're right, since in the end w = cfg.g and h = cfg.h, they can be only defined inside the comptime block, right?
<andrewrk>
foobles, currently, comptime scope only affects control flow and function calls
<foobles>
what do you mean by that? dont all functions called in a comptime block have to be evaulated at comptime too?
<foobles>
andrewrk
<andrewrk>
whether it should affect variables is a good question, and I would need to take some time to consider various examples and consider how to define the lang spec
<andrewrk>
oops, I'm incorrect, it also affects variable *declarations* but it does not affect reads and writes of runtime variables
<andrewrk>
yes, function calls within comptime blocks are evaluated at compile time
<foobles>
ok interesting
<foobles>
cool
<foobles>
but the variables declared in the function arent considered comptime?
<andrewrk>
they are, sorry I misspoke earlier
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<foobles>
so then why is the value.special not Static?
<foobles>
comptime testNullableIntEql(); <- variables declared in this function don't have the Static flag
<foobles>
but if I wrap the whole body of the function in a comptime block, they are
<andrewrk>
note that that function gets analyzed twice - once for the comptime call, and once because it still gets emitted, available to be called at runtime (what if you took a function pointer to it, and called it at runtime?)
<andrewrk>
you might be looking at the runtime-generated function
<foobles>
Yep, thats gotta be it.
<foobles>
thanks!
<foobles>
alright that makes sense to me
<foobles>
:)
<foobles>
also is it ever ok to just re-assign to the `value` of an IrInstrGen?
<foobles>
or should i make a copy and pass that around?
<andrewrk>
I think you might be looking for copy_const_val
<andrewrk>
and now that I'm thinking about it, should just be copy_val
<pixelherodev>
I wasn't telling you to google it :P
<pixelherodev>
It's google's future-gen OS
<marijnfs_>
let me fuchsia that for you
<marijnfs_>
there are some namepuns there
<pixelherodev>
They probably intend to use it as a replacement for Linux in e.g. Android
<marijnfs_>
if you really want them to know everything
<Snetry>
my question now is
<Snetry>
why is UNIX not defined when recompiling llvm with zig
<Snetry>
and why is it compiled when compiling llvm normally
<nephele>
more like they intend to replace android with fuchsia
slowtyper has quit [Ping timeout: 256 seconds]
<marijnfs_>
Snetry: maybe it has to do with the fancy cross compiling? Maybe it's doing that somehow
<Snetry>
maybe
<Snetry>
but cmake is in charge of setting the unix flag
<Snetry>
so idk
<marijnfs_>
I think it uses uname, don't know how that would change
slowtyper has joined #zig
marijnfs has quit [Ping timeout: 265 seconds]
<andrewrk>
Snetry, it's a mistake in the build script, if you remove both occurrences of -DCMAKE_SYSTEM_NAME="$TARGET_OS_CMAKE" it should work
<andrewrk>
looks like we might need some branching logic after all :)
<Snetry>
oh
<Snetry>
well
<Snetry>
guess that solves it
<andrewrk>
(I actually forgot to test using it natively, I only tested cross compiling, heh)
<andrewrk>
oh you know what, if you pass native-linux-native for the triple it might work
<Snetry>
I'll try and report back
<andrewrk>
err, native-linux-gnu or something like that
<andrewrk>
anyway, don't be afraid to edit the build script, it should be pretty clear how it works
<mikdusan>
so here I am trying to find a helper function to create a ZigValue from ZigValue.data.x_optional .. and wouldn't ya know it, the helper function is an assignment operator :P
<marijnfs_>
my poor single core server is trying to build it, i wonder if it makes it
<Snetry>
yeah native-<sys>-<abi> works like a charm
<Snetry>
thanks andrewrk
<companion_cube>
I have a raspberrypi (second generation I think), and cross compilation is more or less the only hope I have to get stuff on it :D
<pixelherodev>
Turns out my JIT code emitter wasn't bugged :D
<pixelherodev>
It was the *translator* that was bugged
<pixelherodev>
Was missing a `try self.emitter.And(Register.EAX, 0);`
<pixelherodev>
:)
<pixelherodev>
Which means I actually have a working code emitter for x64 in Zig
<r4pr0n>
andrewrk: is it possible to disable the cache with zig cc? when putting `--cache off` after cc, it says it's no clang option, and when i put it before, it says cc is unrecognized
tracernz has joined #zig
zie has joined #zig
ninjacato has quit [Ping timeout: 250 seconds]
foobles has quit [Remote host closed the connection]
r4pr0n has quit [Ping timeout: 240 seconds]
r4pr0n has joined #zig
Akuli has quit [Quit: Leaving]
xackus_ has joined #zig
xackus has quit [Ping timeout: 264 seconds]
klltkr has quit [Remote host closed the connection]
<fengb>
`error: option '-atomics,-bulk-memory,-exception-handling,-multivalue,-mutable-globals,-nontrapping-fptoint,-sign-ext,-simd128,-tail-call,-unimplemented-simd128' cannot be specified with '-target-feature'`
<pixelherodev>
JIT in Zig working with serial output
<wilsonk>
pixelherodev: sweet
<wilsonk>
pingiun[m]: you still around?
<pixelherodev>
The most annoying bug I have ever had to deal with:
<pixelherodev>
"Segfault at 0xfffe05b7"
<pixelherodev>
That's the virtual address, which implies it's jumping to it, except *nope*
<pixelherodev>
To translate from virtual address to physical, a `call` is generated to a translation function, which pushes the virtual address to the stack
<pixelherodev>
it pops it afterwards, but doesn't zero it
<pixelherodev>
I forget to generate a `return`, so it was flying through some nops then popping that address off the stack as the return address :(
Yardanico has quit [Read error: Connection reset by peer]
Xavi92 has quit [Remote host closed the connection]
ur5us has quit [Quit: Leaving]
ur5us has joined #zig
<wilsonk>
andrewrk: I just posted a somewhat complete powerpc64le diff (really just one error when building zig and the two missing /lib/std/os/linux files that can be mostly copied from musl sources) to the bootstrap issue #24. Since pinguin[m] posted that issue and you replied to it, I just wanted to post that incomplete so that not too much effort was duplicated.
zfoo has quit [Remote host closed the connection]
<shakesoda>
ppc64le...
<shakesoda>
makes me want one of those fancy talos workstations
<pixelherodev>
Got a workaround for the LLVM issue :D
<pixelherodev>
Uh, hm
<pixelherodev>
there's no way to call a stdlib function with an arbitrary CC, is there?
<wilsonk>
shakesoda: yeah, I wish I could pick one of those up :) I would work on ppc a bit more if I had access to a decent piece of hardware, but trying to work on a VM is just too painful!
ur5us has quit [Ping timeout: 256 seconds]
<pixelherodev>
Is Zig's calling convention documented?
nycex has quit [Remote host closed the connection]
<pixelherodev>
Hmm, am I going to have to link libc?
<pixelherodev>
I don't think I can get away with calling Zig functions within translated code
<pixelherodev>
So I need to use e.g. `std.c.write` instead of `std.debug.warn`
xackus has joined #zig
<Snetry>
Well this didnt go as expected
<Snetry>
Build Dependencies...lld: error: unable to find library -lclangARCMigrate
<Snetry>
how odd since ARCMT is explicitly enabled
xackus_ has quit [Ping timeout: 260 seconds]
xackus_ has joined #zig
foobles has joined #zig
xackus has quit [Ping timeout: 256 seconds]
frett27 has joined #zig
frett27_ has joined #zig
<fengb>
Unknown Clang option: '--libc'
<fengb>
Does zig cc not understand --libc?
frett27 has quit [Ping timeout: 240 seconds]
frett27_ has quit [Ping timeout: 240 seconds]
<r4pr0n>
why would it?
<r4pr0n>
if you want to specify the libc, you can do that in target
Yardanico has joined #zig
<r4pr0n>
and zig cc has to compile with a libc obviously, so that's no option
<fengb>
Because I'm trying to cross compile to a target that zig doesn't understand
<r4pr0n>
uhm - i don't think zig is able to do that, is it?
<fengb>
It is natively. You can toss it whatever libc you want and if LLVM supports it then it should work
<fengb>
Or rather, it is possible in both Zig and Clang separately. But I don't think this was exposed to zig cc
<fengb>
Ah I see. Adding --libc adds it to Clang, which gets angry. But removing it makes zig cc angry
<fengb>
I can probably patch this
<fengb>
(I'm trying to bootstrap Zig into wasm32-wasi if you're curious)
jjido_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<r4pr0n>
but wasm32-wasi is a tier 2 supported zig target
<r4pr0n>
why would you not be able to use -target for this?
<fengb>
There's no libc defined
<fengb>
One of the reasons it's tier 2 :)
<r4pr0n>
oh ic
<r4pr0n>
that makes sense, totally forgot that option
<fengb>
Only tier 1 guarantees full cross compilation
<r4pr0n>
yeah, saw that, that sentence of the tier 2 definition confused me: "One can link with libc or other libraries to fill in the gaps in the standard library."
neceve has quit [Ping timeout: 264 seconds]
jamii has joined #zig
<jamii>
How I use translate-c? If I just point it at a c file I get `'stdio.h' file not found` but I can't figure out how to tell it about includes etc.
<jamii>
Oh, I just copied all the arg from zig build run --verbose and that does the trick.
<r4pr0n>
that error sounds like a missing -lc
timl has quit [Remote host closed the connection]
Yardanico has quit [Read error: Connection reset by peer]