<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: https://termbin.com/y09z. Could any of you with zig and nix experience give it a look-see? https://github.com/candeira/mal/tree/zigzug-wip
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: https://gist.github.com/candeira/bd2e38e36adc3d0519ae4d24583ff0e8
<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>
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
<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: https://termbin.com/n4ir 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]
<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]
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
<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?
<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>
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
<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
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 :)