ChanServ changed the topic of #zig to: zig programming language | | be excellent to each other | channel logs:
Ashpool has joined #zig
tomku has quit [Quit: Lost terminal]
tomku has joined #zig
tomku has quit [Ping timeout: 260 seconds]
tomku has joined #zig
Ashpool has quit [Quit: Leaving]
xackus has quit [Quit: Leaving]
CommunistWolf is now known as CapitalistWolf
CapitalistWolf is now known as lupine
lupine is now known as CommunistWolf
<v0idify> CommunistWolf, what is that supposed to mean? lol
<CommunistWolf> I was just grouping a new one, don't mind me
SimonNa has quit [Remote host closed the connection]
SimonNa has joined #zig
<kandinski> any nix/nixos user here? I could use some help debugging a cImport/cIinclude issue
<kandinski> I was working on this last October, at 0.6, and could run `impls/zigzug$ zig test -lc -lpcre2 re.zig` and it would work, but now I upgraded my channels, got zig 0.7 and I see this error: Could any of you with zig and nix experience give it a look-see?
mokafolio has quit [Quit: Bye Bye!]
gazler_ has quit [Read error: Connection reset by peer]
gazler has joined #zig
mokafolio has joined #zig
gpanders has quit [Ping timeout: 264 seconds]
gpanders has joined #zig
<kandinski> hmm, found the solution for now at least. Posting it here so people find it when googling
kbd has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
kbd has joined #zig
jsb has quit [Quit: .]
jsb has joined #zig
<kandinski> I don't know whether this is a nix issue or a zig issue that changed search paths, but I solved it by using pcre2-config like sebonirc recommended yesterday and then passing options by hand:
<kandinski> or, more portably: zig test -lc $(pcre2-config --cflags) $(pcre2-config --libs8) re.zig
<kandinski> kbd: asnwering your question: I'm working on a pcre2 wrapper. Definitely not std-worthy, but maybe contrib-worthy at some point.
<kbd> very cool. I was wondering what it would take to use pcre from zig.
<kandinski> I can show you someone using pcre too
<kandinski> I've decided to wrap pcre2 because I don't want to copy code, I'm trying to learn
* kandinski rummages...
<kandinski> kbd ^
<kbd> just import and use 🤯
<kbd> thanks for the example!
<kandinski> nw
<kandinski> kbd: I looked at it briefly, you can just use it if you don't mind writing c-style zig
<kandinski> I don't know C and I thought this would be a good opportunity to learn about C calling conventions but also write myself a higher level API
<kbd> good call on the learning project 👍
<kandinski> I'd be happy to receive any criticism or advice
<kandinski> (not asking for pull requests yet, because that would preempt the "learning" goal)
<kandinski> current Yak is to write myself enough of the equivalent of Python's findall() that I can move on with the rest of MAL
<kandinski> but eventually I guess a pcre2 wrapper would be useful to other Zig users
<kbd> I don't know C well either, and I'm still learning Zig. In fact I wanted to ask you a basic question -- how does zig find the header&implementation files when you include pcre.h?
<kandinski> haha
<kandinski> that's what I've spent 24h finding out, because apparently it changed recently
<kandinski> so...
<kbd> haha
<kandinski> I've still to look at the build script
<kbd> because I've messed with using c stdlib stuff in zig but I don't know how to use with a library.
<kandinski> but for running `zig test`, `zig run` etc, just scroll up, just before I answered your question
<kandinski> and I'm answering mine
<kandinski> (for search engines to find)
<kandinski> in fact, maybe someone else can suggest how to add the pcre*-config calls to build.zig so it builds correctly. I have a linkSystemLibrary call, but I'm pretty sure that I want a static linkage, especially given I'm on Nixos
kbd has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
tracernz_ has joined #zig
tracernz has quit [Ping timeout: 256 seconds]
casaca has quit [Ping timeout: 256 seconds]
tracernz_ is now known as tracernz
via has quit [Ping timeout: 256 seconds]
via has joined #zig
nvmd has joined #zig
_whitelogger has joined #zig
ur5us_ has joined #zig
_whitelogger has joined #zig
<sebonirc> hi all! i think ive found a bug in the zig stage 1 compiler. i dont have a github account so if someone else wants to open an issue for it that would be appreciated. code to replicate the bug is here: this appears to be broken on both 0.7.1 and master
<sebonirc> (i havent tested this on the self-hosted compiler, so i don't know if that's also affected)
neptunepink has quit [Ping timeout: 246 seconds]
waleee-cl has quit [Quit: Connection closed for inactivity]
neptunepink has joined #zig
<sebonirc> yeah, that bug seems very similar. i think my example still shows some new things, notably the miscompilation and the zig compiler not being able to handle the error (the github issue doesnt have the miscompilation tag)
_whitelogger has joined #zig
kbd has joined #zig
casaca has joined #zig
ur5us_ has quit [Ping timeout: 264 seconds]
cole-h has quit [Ping timeout: 246 seconds]
tracernz has quit [Ping timeout: 246 seconds]
kwilczynski has quit [Ping timeout: 258 seconds]
tracernz has joined #zig
kwilczynski has joined #zig
kbd has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
<mikdusan1> directly increasing `slice.len += 1` is dangerous, is this a thing the language will continue to permit? (ie. mutation of .len field)
dom96 has quit [Ping timeout: 256 seconds]
dom96 has joined #zig
v0idify has quit [Remote host closed the connection]
v0idify has joined #zig
squeek502 has joined #zig
Ashpool has joined #zig
_whitelogger has joined #zig
<sharpobject> hello, I'm trying to use wz which requires me to import hzzp, it seems like I should do this by passing --pkg-begin at the command line, but I'm not sure which file in hzzp is the "root package file"
<sharpobject> oh, I just messed up and did not check out the right branch of hzzp
<sharpobject> this seems to work to run wz tests now: zig test main.zig --pkg-begin hzzp ../../hzzp/src/main.zig --pkg-end
Ashpool has quit [Quit: Leaving]
nycex has quit [Ping timeout: 240 seconds]
nycex has joined #zig
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
midgard_ has quit [Ping timeout: 264 seconds]
midgard has joined #zig
gpanders has quit [Quit: ZNC -]
gpanders has joined #zig
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
mokafolio has quit [Client Quit]
mokafolio has joined #zig
mokafolio has quit [Client Quit]
mokafolio has joined #zig
mokafolio has quit [Quit: Bye Bye!]
mokafolio has joined #zig
v0idify has quit [Remote host closed the connection]
v0idify has joined #zig
inet56 has joined #zig
inet56 has left #zig [#zig]
l1x has joined #zig
<sharpobject> is there some example of using openssl? currently I am finding that -I/opt/homebrew/Cellar/openssl@1.1/1.1.1i/include successfully includes openssl headers but -L/opt/homebrew/Cellar/openssl@1.1/1.1.1i/lib does not successfully link openssl
<ifreund> don't know of any yet, there is a BearSSL binding though:
<ifreund> and an experimental TLS implementation:
<sharpobject> I mean uses openssl, but I am not sure how to get it to build xd
<ugla> I was using openssl without trouble, but not on mac.
<ugla> Well, there was one (1) issue of macros not being translated, so I had to add some C functions that would just call the macros.
<ugla> How does linking fail?
<ifreund> sharpobject: built for me just fine on linux too
<sharpobject> with the above options, Undefined symbol: /Users/sharpobject/.cache/zig/o/c6c151e8e49487d5ebd3ffa11eaf42e0/main.o: _SSL_read_ex and a dozen other symbols
<ifreund> just cloned and zig build, no errors for me
<sharpobject> with -lcrypto -lssl, ld64.lld: error: Unable to find library for -lcrypto
<ifreund> ok, well that's the problem
<ifreund> how do you link openssl on macos in a C Makefile for example?
ifreund1 has joined #zig
ifreund has quit [Disconnected by services]
ifreund1 is now known as ifreund
<sharpobject> ah, it was sufficient to pass -L/opt/homebrew/Cellar/openssl@1.1/1.1.1i/lib -lssl -lcrypto
<sharpobject> I now must just find a _stderr symbol and then I will be all set (?)
<ifreund> -lc
<ifreund> this begs the question why homebrew/macos is like this though, that's ugly
<sharpobject> that doesn't seem to do it, maybe because my target is not in the list of targets in zig/lib/libc/include
<sharpobject> not sure!
<ifreund> could you paste the full error somewhere?
<sharpobject> my line above is speculation based on this issue and the fix to it
<ifreund> are you using zig master or 0.7? master should have proper libc support for macos
<sharpobject> master
Akuli has joined #zig
<sharpobject> ah yeah it is called aarch64-macos-gnu and it's there
<mikdusan1> which version of macos is your host
<sharpobject> macos 11.1
<mikdusan1> what is the output from `zig targets | grep -A 1 native`
<sharpobject> "native": {
<sharpobject> "triple": "aarch64-macos.11.1...11.1-gnu",
<mikdusan1> `zig version`
<sharpobject> 0.8.0-dev.992+1f65828ec
<mikdusan1> i thought we forced native linker on big sur?
<mikdusan1> one of your errors "ld64.lld: error: Unable to find library" i think implies lld linker is used
<mikdusan1> oh. `export ZIG_SYSTEM_LINKER_HACK=1`
<ifreund> mikdusan1: yes, I think direct mutation of slice ptr and length fields as well as slicing beyond lenght with foo[0..end] syntax will continue to be supported
<ifreund> see the current implementation of std.ArrayList, these features are necessary for its nice api
<sharpobject> thanks! this successfully made it use the system linker, and the system linker pointed out that the use of _stderr was actually in the ssl.zig that I had cribbed from ziget, so I just got rid of it
<mikdusan1> ifreund: ok there's some ability for us to detect this in comptime. I have a 1 liner that replaces a stage1 assert with decent log message.
<mikdusan1> sharpobject: see #7715 if you want to do that hack automatically in build.zig
<sharpobject> I should definitely learn how to use build.zig
<ifreund> yeah it is fairly easy to cause UB or leak memory if you're not careful when doing these operations on slices
<mikdusan1> sharpobject: oh n/m then. thought you were already
<ifreund> but I think doing the operations themselves should always be valid, zig shouldn't get in your way here
<mikdusan1> ifreund: yeah i get why ArrayList does that. saves passing around a second slice of full capacity to slice from. That's exactly why I was doing it doo.
<ifreund> slices are just data like any other pointer or struct
<mikdusan1> ifreund: wiat.. slicing beyond length? that's bounds-checked
<ifreund> nope
<ifreund> only for arrays where the lenght is comptime-known
<mikdusan1> uhm... we do runtime bounds checking in debug/safe
<ifreund> no we don't, otherwise std.ArrayList wouldn't work
<ifreund> we only do bounds checks for arrays and slicing arrays, not slicing slices
<mikdusan1> a bounds check is done on slicing. --> but .len += 1 is not slicing
<mikdusan1> that should be qualified. .ptr is an unknown number of items.
<mikdusan1> when you slice a slice, or an array, it is bounds checked
<ifreund> ah, yeah I see
<mikdusan1> anyways small point. I think .len manip is ok but this would be safer: `slice = slice_storage[0..slice.len + 20]` but means u need to have access to slice_storage for the checking to happen
<ifreund> true, that way you don't dodge the bounds checking
jokoon has joined #zig
cole-h has joined #zig
xackus has joined #zig
<sharpobject> I am pleased to announce that I have connected to some websocket API and sent a json blob and received a json blob back
<sharpobject> that's basically the whole app at this point
<ifreund> \o/
tane has joined #zig
koakuma has joined #zig
waleee-cl has joined #zig
<Biolunar> Question: When I do _ = async foo(); that function frame lives on the stack and will vanish when the surrounding block of that statement ends?
<ifreund> es
<ifreund> *yes
<Biolunar> I was confused when I had: var frame = async foo(); and printed out @frame() from inside foo(). Turns out @frame() and &frame are equal in this case.
<ifreund> that's right yeah
<Biolunar> I would’ve expected them to have different addresses but that is indeed not true. Optimized
<ifreund> they can't be different, that wouldn't make any sense
<ifreund> the memory is only in one place
<ifreund> usually you want to put your frames on the heap though in real-world use cases
<Biolunar> I was under the impression that 1st) async foo() creates a function frame and call that function, 2nd) upon suspend or return of foo() that frame will be assigned to whatever is left of that assignment operator
<Biolunar> Yes, that is one unnecessary step. That’s what I thought
di-wu has left #zig ["Bye."]
<ifreund> the frame needs to be stored somewhere before the function can be started
mikdusan1 is now known as mikdusan
<Biolunar> Yeah. In hindsight I’m not really sure what I was thinking
cole-h has quit [Remote host closed the connection]
dom96 has quit [Ping timeout: 256 seconds]
m6w6 has quit [Ping timeout: 256 seconds]
m6w6 has joined #zig
dom96 has joined #zig
datalus has joined #zig
<v0idify> wait so, if the frame disappears before the function the frame represents end that is undefined behaviour no?
<ifreund> yup
<v0idify> good to know
<ifreund> well, only if the function gets resumed or is currently being executed by another thread or something
<ifreund> if the function is never continued it doesn't matter if the frame is gone
<koakuma> So, if I run zig build test-behavior it'll print lines like these
<koakuma> 64/997 behavior.async_fn.test "behavior-native-Debug-bare-multi calling an inferred async function"... OK
<koakuma> How do I find the place(s) where those tests are defined?
jensln has joined #zig
<v0idify> ifreund, so where would the things of the function itself (variables, etc) be stored?
<ifreund> v0idify: that's what the frame is
<ifreund> koakuma: those are in test/stage1/behavior
<koakuma> Thanks!
wootehfoot has joined #zig
jensln has quit [Ping timeout: 246 seconds]
Akuli is now known as {}__`__{}
{}__`__{} is now known as Akuli
CommunistWolf is now known as CapitalistWolf
CapitalistWolf is now known as CommunistWolf
jensln has joined #zig
Ashpool has joined #zig
<mikdusan> ooh 0.8.0-dev.1000+3562edf13
Gliptic has joined #zig
xackus_ has joined #zig
xackus has quit [Read error: Connection reset by peer]
<Gliptic> hey, I'm having an issue with the wasm32-freestanding target. "export" functions don't seem to be exported from the .wasm
<Gliptic> tried master and 0.7.1 versions
<ugla> Gliptic: maybe related to this issue
<Gliptic> not exactly, that's about exported tables, but maybe it affects that too
<Gliptic> seems "zig build-lib -target wasm32-freestanding -O ReleaseSmall src/main.zig" works, sort of
<Gliptic> it seems to not really build it as ReleaseSmall
jensln has quit [Ping timeout: 260 seconds]
hnOsmium0001 has joined #zig
zags has joined #zig
<zags> I agree with some of the concerns about loop syntax there
<zags> Anything that'll be adressed, or are he/I thinking about it the wrong way?
<Nypsie[m]> Don't think there will be any further changes to how the while loop works in Zig
<zags> I see
<ifreund> The point about the else being required on `while (true)` is a good one, I can't really see any of the other details changing though
<ifreund> what he should have used there is `else unreachable` though
<zags> Yeah, I think his main point is that this is a surprising part of the language, I had the same feeling, so was just wondering if any changes were planned
<fengb> Maybe while(true) can be detected and assume else unreachable?
<fengb> We probably won’t get sugar for assign/check/iter though
<Nypsie[m]> It does make it more readable tho. Makes it explicit that it shouldn't be able to be reached and if it does, it's most likely a developer error.
<zags> Good point. Is this channel bridged with the discord server, or should I join there as well?
<Nypsie[m]> Nope, it is not bridged, so feel free to join :)
kbd has joined #zig
<ifreund> I just started a discussion of this on the discord since specs_guy is there
a_chou has joined #zig
<zags> his user name checks out :D
<ifreund> It's actually spex_guy but he's earned the other nick :P
<zags> :D
a_chou has quit [Quit: a_chou]
<ifreund> dammit, I broke the compiler:
<Nypsie[m]> Yikes
wootehfoot has quit [Ping timeout: 264 seconds]
Ashpool has quit [Remote host closed the connection]
Ashpool has joined #zig
datalus has quit [Ping timeout: 256 seconds]
<ifreund> have a minimal reproducer for 0.7.1, building master now
jokoon has quit [Quit: Leaving]
kbd has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
datalus has joined #zig
zags has quit [Quit: leaving]
<datalus> cls
<datalus> haha, woops
<datalus> that was for cmd.exe ;)
l1x has quit [Quit: Connection closed for inactivity]
riba has joined #zig
jensln has joined #zig
<ifreund> now that's a fun crash :D
squeek502 has quit [Ping timeout: 272 seconds]
jensln has quit [Read error: Connection reset by peer]
squeek502 has joined #zig
fritchie has quit [Remote host closed the connection]
fritchie has joined #zig
<ikskuh> ifreund: did someone miss a zero terminator?
<Nypsie[m]> Hell yeah have if/else working for wasm backend
<ikskuh> wooot?!
<ikskuh> nice work!
<fengb> Does it generate if/else opcodes?
<Nypsie[m]> Yes
<Nypsie[m]> Currently Zig uses the same condBr instruction for both loops and if/else constructs, so I'm playing around and seeing what works best in a generic way
<Nypsie[m]> Loop instruction exists too tho, but it's just a list of instructions with the first being the condBr
<fengb> Most compilers seem to ignore if/else and go straight to nested blocks
<Nypsie[m]> Aaah yeah that was what I had initially
<Nypsie[m]> But wanted to atleast give this a try and see how it works out
<Nypsie[m]> Will just use blocks with jumps to block labels
<Nypsie[m]> As that seems to work for both loops and if/else expressions
<fengb> How does it work with loops? You can’t jump backwards without a loop opcode
ur5us_ has joined #zig
<Nypsie[m]> It doesn't :P
<Gliptic> loop is just a block with the label at the start instead of end
<Nypsie[m]> Hence I'm changing it back to what I had
<fengb> Right, but wasm doesn’t have arbitrary gotos
<fengb> >_>
<fengb> Okay I wasn’t sure I missed something
<Nypsie[m]> Emit loop opcode, handle condition, at end of body 'break' to loop label
<Nypsie[m]> Just trying to figure out how it will work with while loops that also have an 'else' branch
<Nypsie[m]> Hence me playing with if/else opcodes as well
<Gliptic> need another block that stretches past the else, I imagine
<Gliptic> which break uses
<Gliptic> but the loop condition uses the inner block
<Nypsie[m]> Yeah that's what I had in mind as well
<Nypsie[m]> Ok makes sense, just have to implement it now xD
riba has quit [Ping timeout: 260 seconds]
ur5us_ has quit [Ping timeout: 264 seconds]
ur5us_ has joined #zig
midgard_ has joined #zig
midgard has quit [Ping timeout: 256 seconds]
Cadey has quit [Quit: WeeChat 3.0]
Akuli has quit [Quit: Leaving]
Xe has joined #zig
Xe is now known as Cadey
jmiven has quit [Quit: reboot]
<ifreund> ikskuh: nah just printing stack memory like a boss
<ifreund> (after returning from the function
cole-h has joined #zig
v0idify has quit [*.net *.split]
nycex has quit [*.net *.split]
ur5us_ has quit [Ping timeout: 264 seconds]
kbd has joined #zig
ur5us has joined #zig
nycex has joined #zig
v0idify has joined #zig
<ikskuh> ifreund: oh, okay
<ikskuh> :D
<ifreund> I now have my minimal zero-allocation arg flag parser thing working :)
<ifreund> I love comptime
<ikskuh> cool :)
<ikskuh> how do you do it?
<ifreund> well, not supporting windows helps :D
<ifreund> ikskuh: if you're curious:
<ifreund> oh that second for doesn't need to be inline...
<ifreund> also using std.cstr annoys me, I use sentinel termintated type pointers cause that's what the OS gives me not because I want to talk to see
<ifreund> s/see/C/
<ifreund> std.mem needs a better eql function
<ifreund> the second for actually does need to be inline unless I use a tagged union in the flags array
wootehfoot has joined #zig
tane has quit [Quit: Leaving]
ur5us has quit [Ping timeout: 264 seconds]
<shachaf> Chet out my flag parser in C:
<shachaf> It's not quite minimal but I like the API I ended up with.
<shachaf> I wonder how much that would change in a different language. It certainly felt like C wasn't quite expressive enough for it.
ur5us has joined #zig
<ifreund> Mine's a bit more minimal and flexible yeah, looks like a pretty nice API for C though
<shachaf> Flexible how?
<shachaf> More comptime things certainly help here.
<ifreund> doesn't force you to use the classic short/long option conventions for one
<ifreund> and doesn't do any help/usage text for you
<shachaf> Ah, sure. I should add a long-only option mode.
<ifreund> mine doesn't have a way to handle grouping of short options like -odp or whatever
<shachaf> Right. I just wanted a nicer replacement for getopt.
<ifreund> I prefer single hyphen long options personally for more featureful CLIs
st4ll11 has quit [Ping timeout: 256 seconds]
wootehfoot has quit [Read error: Connection reset by peer]
st4ll11 has joined #zig
nycex- has joined #zig
nycex has quit [Remote host closed the connection]
marijnfs_ has quit [Quit: WeeChat 2.8]
ur5us_ has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
nycex- has quit [Remote host closed the connection]
nycex has joined #zig
mixi has quit [Quit: quit]
Ashpool has quit [Remote host closed the connection]