ChanServ changed the topic of #zig to: zig programming language | https://ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
daurnimator has quit [*.net *.split]
mmx87 has quit [*.net *.split]
jzelinskie has quit [*.net *.split]
companion_cube has quit [*.net *.split]
guan has quit [*.net *.split]
jzelinskie has joined #zig
companion_cube has joined #zig
mmx87 has joined #zig
daurnimator has joined #zig
darithorn has joined #zig
<scientes> congrats
tracernz has quit [Ping timeout: 252 seconds]
tracernz has joined #zig
edr has quit [Quit: ZNC 1.6.5 - http://znc.in]
<dimenus> why would a build.zig generated by 'init-exe' not build an exe (without calling the run step)?
<dimenus> is there an extra call that must be made?
marijnfs__ has joined #zig
mawaldne has joined #zig
curtisf has joined #zig
marijnfs_ has quit [Ping timeout: 268 seconds]
<Tetralux> I could be wrong, but I may actually make the exe, and put it into zig-cache. If so, I believe you can pass `--prefix dir` to `zig build`.
dimenus has quit [Remote host closed the connection]
dimenus has joined #zig
<Tetralux> I could be wrong, but it may actually make the exe, and put it into zig-cache. If so, I believe you can pass `--prefix dir` to `zig build`.
qrpnxz has joined #zig
<qrpnxz> hello lads. Does zig have a stdlib?
<scientes> @import("std")
<scientes> but its static-linking only
<qrpnxz> okay, sorry, real question was where can I find the docs for the zig stdlib
<scientes> there are none
mawaldne has quit [Ping timeout: 260 seconds]
<qrpnxz> :(
<scientes> only the language has docs ATM
<qrpnxz> alright
<qrpnxz> thanks
<Tetralux> qrpnxz: Best you can do is search the std directory.
<Tetralux> It will have docs at 1.0.
<qrpnxz> oh, i have that. Will do
<Tetralux> I forget if it's planned before then or not.
<qrpnxz> hard to get feedback if on it before 1.0 without docs tho, no?
<Tetralux> You can grep for fn, or for vague things you're looking for.
<scientes> 1.0 is years away
<Tetralux> There's also some comments here and there.
<Tetralux> Zig is decent to read though, so it's not too hard to read through.
<Tetralux> But yeah
<Tetralux> This may also help you.
<qrpnxz> that's true. It looks pretty interesting so far so I wanted to make something with it but most important checkout the IO story. Go does IO very well
<Tetralux> std.fs has the filesystem stuff.
<Tetralux> Opening a file gives you a `File`
<Tetralux> `File` has .inStream()
<Tetralux> That gives you an InStream
<Tetralux> `InStream`s have things like `readFull`
<qrpnxz> i see
<qrpnxz> thanks
<Tetralux> There's also readAllAlloc if you just want act like you're in a GC langauge for a moment xD
<qrpnxz> haha
<Tetralux> Or readAllBuffer if you're more sane and have a place to write it into.
<qrpnxz> well, I guess I'll come back when it's further along
<Tetralux> (A buffer is basically a null-terminated byte array that auto-expands.)
<qrpnxz> alright
<qrpnxz> thanks again
<Tetralux> Welcome. Look forward to seeing you back at some point.
qrpnxz has left #zig [#zig]
qrpnxz has joined #zig
qrpnxz has left #zig [#zig]
<Tetralux> It occurs to me that we never asked them what they feature they wanted to see it have. :'D
<companion_cube> I hope there will be a nice IDE by 1.0, too
<Tetralux> What kind of experience you looking for?
<Tetralux> @companion_cube
<curtisf> a language server for vscode highlight-to-get-type and member completion would be great
<companion_cube> completion, type hint, jump to def
<companion_cube> auto format and errors on save are already there, which is neat.
<companion_cube> (also, get the docs of a function when you highlight it, etc.)
<companion_cube> interestingly rust isn't there yet, and their tooling is clearly harder to do
fengb has joined #zig
<fengb> error: incompatible types: 'i32' and 'u8': track -= res.duration;
ltriant has quit [Ping timeout: 245 seconds]
<fengb> Shouldn't this be coerceable?
avoidr has joined #zig
<fengb> -target wasm32-freestanding-musl "TODO implement C ABI for this architecture."
<fengb> I thought wasm32 musl was a thing now
<fengb> Oh one of my functions doesn't conform. That's a deceptive error
ltriant has joined #zig
qazo has quit [Remote host closed the connection]
ltriant has quit [Ping timeout: 258 seconds]
<fengb> Nope... I've no idea why this is happening
ltriant has joined #zig
ltriant has quit [Ping timeout: 248 seconds]
ltriant has joined #zig
<dimenus> andrewrk: how does one just generate an exe with build.zig or is it expected that you use build-exe instead?
<zie> dimenus it's my understanding the build implies you are using build.zig and the zig build system.
<dimenus> hmm, linking a c library without linking libc causes a SIGSEGV
ltriant has quit [Ping timeout: 245 seconds]
ltriant has joined #zig
<dimenus> fegb: thanks, it was just the setOutputDir
<dimenus> **fengb
<mikdusan2> dimenus: build.zig does generate an exe for you; it's just in the zig-cache folder, and you can create an install artifact to have the exe installed in a place of your choice. set install dir to "." and "./bin" will be used iirc
<andrewrk> I'm about to make "install" the default "zig build" step
<andrewrk> sorry I know it's been pretty counter-intuitive for a couple months
ltriant has quit [Ping timeout: 246 seconds]
<fengb> andrewrk: why is the build failing on wasm32-freestanding-musl? I thought that was added
<andrewrk> `zig targets` lists them and yeah it's in there. i'll take a look, is this a regression?
<fengb> I'm not sure. I'll test out the merge where it was added
<fengb> Trying to port my C project
<fengb> So finally got to a point where it's sorta buildable
<andrewrk> file a bug report. I just tested `pub fn main() void {}` with `zig build-exe test.zig -target wasm32-freestanding-musl --library c` and it worked fine
<andrewrk> lots of bugs to go through on the issue tracker, and I'm sure there will be some regressions reported over the next few days that I'll try to take care of
<fengb> I think it's one of the functions I'm invoking
<fengb> It works fine if I comment out all the C includes
<fengb> Alright, I'll probably do some hunting tomorrow thanks
return0e has quit [Read error: Connection reset by peer]
return0e has joined #zig
fengb has quit [Remote host closed the connection]
return0e_ has joined #zig
return0e has quit [Ping timeout: 258 seconds]
fengb has joined #zig
<fengb> Also, congrats on copy elision!
<andrewrk> thanks! sorry for the inevitable regressions, but I assure you it will be worth it
<andrewrk> zig's asm codegen on godbolt in debug mode might actually be reasonable now
<fengb> I'm just happy that it's here! Been lurking for a few months now, and it seems like a lot of previous effort is paying off
<andrewrk> I'm relieved because I literally tried and failed to do this during the 0.4.0 release cycle. spent ~3 months working on it and then abandoned the branch
<andrewrk> (actually ended up using a fair bit of the code in this third attempt though)
<fengb> I watched the 0.4.0 status video. 3rd time's a charm huh?
<fengb> It wasn't failure. It was learning to do it right!
avoidr has quit [Quit: leaving]
ltriant has joined #zig
dimenus has quit [Ping timeout: 248 seconds]
fengb has quit [Ping timeout: 260 seconds]
hryx has joined #zig
<curtisf> is there a way to make zig test build a 32 bit executable on windows? It looks like the gdb I have installed only works on 32 bit exes
<andrewrk> the 32 bit windows target needs some attention to be useful
<andrewrk> it doesn't pass all the tests
<andrewrk> the short answer is yes, you can pass -target i386-windows
laaron has joined #zig
<curtisf> ah, thanks for that, but it doesn't compile afterall
<curtisf> Time to learn Visual Studio :)
<andrewrk> I have a Project1.sln with no files in it. I right click the project, properties, debug info. put in the exe and the cwd, then hit the big green "play" button
<curtisf> I seem to have it working, but I'll need to learn a lot to figure out what's wrong. I _think_ Zig is miscompiling something in this inline for loop
<andrewrk> ah that's a bummer
<andrewrk> curtisf, are you aware of @compileLog ?
<curtisf> Yes, not sure how I could use it here, because I'm not sure where something is actually going wrong yet
<curtisf> based on my debug prints it looks like the iterating variable in the for loop is going backwards somehow
<andrewrk> it's for inspecting comptime values, so you'd use it like printf debugging at compile time
<curtisf> right, I want it for orienting myself in the runtime debugger
<curtisf> so that I can see which iteration of an unrolled loop I'm in, for example
<andrewrk> you can still print comptime values at runtime
<andrewrk> just can't print runtime values at comptime
<curtisf> yea, that's what I'm doing
<curtisf> Oh, I could probably just write `var foo = mcomptimevar` and it will hopefully not delete it in a test build?
<andrewrk> yeah
<curtisf> I think it'd still be nice to have them in the debugger window for free :) but this is also the first time i've opened visual studio so maybe not the best person to request debugging features
<andrewrk> in theory the new result location code should give them to you for free. but it appears that either llvm is not emitting good PDB/DWARF or gdb/msvc is not good enough to understand
<andrewrk> whatever the problem it will require an upstream/downstream patch
<andrewrk> I have yet to open an issue for that. feel free to do that in case I forget
knebulae has quit [Read error: Connection reset by peer]
brakmic has joined #zig
brakmic has quit [Remote host closed the connection]
brakmic has joined #zig
return0e_ has quit [Ping timeout: 252 seconds]
return0e has joined #zig
<curtisf> It definitely seems like it's not doing the right thing... Maybe this is a symptom of the comptime var in runtime if compile error I hit yesterday, since this is the same loop that I'm working around that in
return0e_ has joined #zig
return0e has quit [Ping timeout: 258 seconds]
darithorn has quit [Quit: Leaving]
<hryx> Regarding today's earlier conversation about dictation software, for what it's worth: I have a friend who temporarily lost the ability to use his hands. he used dictation to program (and ship) at least one video game during that period. so it can be done and is important for some people. I wonder if/how variable naming affected the experience
<andrewrk> 443 open issues in the 0.5.0 milestone @_@
<hryx> lordy
<andrewrk> hmm that's only 4.3 per work day until the release though
<andrewrk> good night
<andrewrk> pull requests tomorrow :)
<hryx> good night!
<emekankurumeh[m]> nice
ltriant has quit [Quit: leaving]
curtisf has quit [Ping timeout: 260 seconds]
Hejsil_ has joined #zig
brakmic_ has joined #zig
Hejsil has joined #zig
brakmic has quit [Read error: Connection reset by peer]
Hejsil_ has quit [Client Quit]
Hejsil has quit [Remote host closed the connection]
brakmic has joined #zig
brakmic_ has quit [Ping timeout: 252 seconds]
steshaw has quit [Quit: Connection closed for inactivity]
<BitPuffin> andrewrk: lmao thanks for the playtest :D very happy about the reaction vid
Hejsil has joined #zig
marijnfs__ has quit [Ping timeout: 246 seconds]
return0e_ has quit [Read error: Connection reset by peer]
return0e has joined #zig
avoidr has joined #zig
<samtebbs> andrewrk: Re: call for projects to test with copy-elision. I may have accidentally sent a reply to the email thread from my work address. Will resend from my personal account.
knebulae has joined #zig
edr has joined #zig
avoidr has quit [Quit: leaving]
laaron has quit [Remote host closed the connection]
laaron has joined #zig
rsdimenus has joined #zig
utzig has joined #zig
brakmic has quit [Ping timeout: 252 seconds]
brakmic has joined #zig
samtebbs has quit [Read error: Connection reset by peer]
Flaminator has joined #zig
<Flaminator> Is it normal for build.exe to crash whenever you use a @compileLog or have an error in your code somewhere?
<Cadey> Flaminator: what version of Zig are you using?
<Flaminator> I think it was a master release from a few days ago.
rsdimenus has quit [Remote host closed the connection]
<Flaminator> Downloaded zig-windows-x86_64-0.4.0+3c914c63.zip just now and it still pops up a build.exe has stopped working window. But atleast it isn't showing the build.zig traceback anymore which was the main reason I asked this question.
<Cadey> Flaminator: run it from a command prompt?
<Cadey> paste output to https://gist.github.com
bheads has quit [Quit: bheads]
rsdimenus has joined #zig
bheads has joined #zig
bheads has quit [Client Quit]
bheads has joined #zig
squiddlebit has joined #zig
<Flaminator> https://gist.github.com/Flaminator/a589531c410f592ac98f42d40fb033f5 This was from a master release a few days ago, I don't get the traceback with zig-windows-x86_64-0.4.0+3c914c63.zip but it still crashes build.exe.
fengb has joined #zig
<fengb> Flaminator: @compileLog always crashes the compiler
samtebbs has joined #zig
<BitPuffin> it shouldn't crash the compiler
<Flaminator> I know but I don't expect http://aeug.eu/p/8624.jpg to happen.
<BitPuffin> it should just emit an error
<fengb> I think "zig build" executes a different process for "zig build-exe" which returns error code = 1
<fengb> Which it interprets as a different failure and panics
<Flaminator> Using zig build-exe .\src\main.zig doesn't crash build.exe.
<fengb> So I think "zig build" always crashes if the build failed
<fengb> Here's the panic that happens
<fengb> I think the fix would be change the panic to an exit passing through the underlying error code
<fengb> Can you open a Github issue?
<Flaminator> Yes going to make an issue about it.
<Cadey> 👍
<rsdimenus> should 'addSystemLibrary' in build.zig automatically pull in libc?
<rsdimenus> sorry, **linkSystemLibrary
gamester has left #zig ["Leaving"]
<Tetralux> rsdimenus: I don't believe so.
<Tetralux> Maybe be wrong though.
<rsdimenus> yeah that's a good point. There seems to be a discrepancy between zig build and build-exe though
halosghost has joined #zig
laaron has quit [Remote host closed the connection]
laaron has joined #zig
<andrewrk> rsdimenus, no it's possible for c libraries to not depend on libc (although unlikely)
Akuli has joined #zig
<rsdimenus> yeah, that makes sense. zig build-exe complains as expected
<rsdimenus> but zig build compiles and just SIGSEGVs on the run step
mikdusan3 has joined #zig
mikdusan2 has quit [Ping timeout: 272 seconds]
<BitPuffin> andrewrk: does your arcade game os depend on any unikernel type thing or is it completely standalone?
<andrewrk> BitPuffin, completely standalone
<andrewrk> it is its own bootloader
<BitPuffin> nice!
<andrewrk> (the project is not very far along though)
<BitPuffin> I've been thinking about implementing my website in zig as its own os
<BitPuffin> or maybe running inside a unikernel
<andrewrk> although MarkFirmware just submitted a pull request to get the framebuffer working
<andrewrk> woah, as a novelty thing?
<samtebbs> BitPuffin: O.o
<BitPuffin> kind of yeah
<samtebbs> Please explain
<Akuli> hmm, zig for web dev?
<andrewrk> Akuli, that's a nearly unrelated topic :)
<BitPuffin> Well it's kind of just a counter reaction to the piles and piles of layers we have in the status quo of web dev
<BitPuffin> I don't really think the healthiest compromise is to necessarily go this far to the other end :P
<BitPuffin> although the unikernel thing certainly makes sense, since many of our deployements these with web are just OSs or dockers running a single program
<BitPuffin> so if there is a bunch of unnecessary code then it is not a bad idea to get rid of that surface area that could have bugs or security vulnerabilities
<fengb> Containerization without the OS layer?
<Tetralux> Sounds perfectly reasonable to me.
<BitPuffin> fengb: yeah you could even use a vm as the "container"
<BitPuffin> idk I got inspired by many things :P
<Tetralux> I suspect that containing an _entire_ OS within a container is just a artifact of terrible organisation, and is massively overkill for what it is, _just_ so you can make an environment that's sane.
<BitPuffin> one of them was just thinking through the complexity of things like having an ORM that does a bunch of magic because we typically store things in an external database which sometimes breaks
<Tetralux> I haven't looked much at it, but NixOS might do a better job at that aspect of it honestly.
<BitPuffin> Tetralux: yeah I mean something like rumprun would be good
<BitPuffin> cuz then you still save the work of implementing drivers
<Tetralux> What is that?
<Tetralux> Like
<Tetralux> A very thin OS-like layer?
<Tetralux> ie a kernel.
<Tetralux> And that's it?
<Tetralux> Or is there more to it?
<BitPuffin> well afaik it doesn't have kernely things like a scheduler
<BitPuffin> it's more something you could run a kernel inside of
<BitPuffin> I think
<andrewrk> Akuli, I didn't mean to shut you down - I was hinting that for recommended web dev you would certainly not put your web server on bare metal
<BitPuffin> and get re-use of the drivers
<andrewrk> although the project is intriguing
<BitPuffin> it's kind of a kernel
<fengb> I've wondered whether a database should be an OS since it reimplements a lot of OS level stuff already
<Tetralux> So essentially, it's the hardware layer for your OS essentially.
<bheads> we run web servers on bare metal
<bheads> cabelas had 8 64G boxes
<Tetralux> fengb: I have a suspicion that a database itself is a little overkill. Like, you don't need something that complicated for that.
<Tetralux> Even for a site.
<Akuli> yeah i know it's not the best way to do stuff :D
<BitPuffin> I suspect most websites don't need dbs
<bheads> you crazy
<BitPuffin> maybe we're a bit scared of serialization for probably good reasons
<Tetralux> Most sites seem to use dbs as just a key-value hashmap.
<Tetralux> In which case...
<Tetralux> ...optimized HashMap anyone?
<bheads> lol, not e-commerce
<fengb> Once you start persisting it, it starts looking like a NoSQL database
<Tetralux> ..Except probably faster and cleaner xD
<fengb> Redis
<fengb> Doubtful
<bheads> the last site we made was NoSql, we have to copy the whole site into memory to handle complex relationships
<bheads> was not a win
<fengb> Yeah I don't recommend NoSQL since you'd reimplement schemas poorly
<bheads> so use the right tool
<bheads> dont just pick nosql or KV cause its hip
<BitPuffin> I mean my assumption was that literally most websites are fairly simple
<BitPuffin> I wouldn't go as far as saying that DBs are never the right tool
<bheads> well it depends on what you measure
<bheads> volume of traffic wise you are hitting dbs more often
<bheads> url wise, most sites dont need one
<Tetralux> My suspicion is that anywhere you'd consider a DB, you could actually just use a few standard, fairly simple data structures, and you're done.
<Tetralux> Like - it really isn't that complicated, so far as I can tell.
<bheads> depends on scale
<BitPuffin> oh yeah, high profile websites that store ridiculous amount of data probably need a db
<bheads> multiple instances, multiple regions, backend services?
<Tetralux> Except a DB is really nothing more than load balancing + data structures.
<bheads> sure, you can roll your own "DB"
<Tetralux> Well - a _DB_ and load balancing are different things ofc
<Tetralux> But you get my point.
<bheads> I am just say, dont generalize a field :) use the right tool for the job
<Tetralux> Anything that uses string parsing to issue commands... *shudders*
<BitPuffin> I mean another thing that seems trendy these days is premature microservicefication
<BitPuffin> in web
<bheads> ugh
<bheads> microservices are a nightmare
<Tetralux> See, I think that could be alright... if it's designed to be debugged like a program, and uses a memcpy interface.
<Tetralux> ie. shared memory.
<BitPuffin> like yay we don't have a need for this kind of scale but now we need to synchronize these separate threads running on different computers
<bheads> even worse is when its someone elses microservices
<Tetralux> I haven't looked into that though.
<fengb> Once you add persistence and multiple servers, the DB layer starts getting really complicated
<Tetralux> BitPuffin: I suspect---though don't know if---you could use lockless stuff to deal with that.
<bheads> nothing like building a page and having 1 of 7 microservies fails...
<Tetralux> Ugh.
<BitPuffin> maybe
<Tetralux> I really want to use cmpxchg for something to get a better feel for it at some point.
<Tetralux> That seem really damn promising honestly.
<Tetralux> I feel like more things should use that.
<Tetralux> (that currently use locks instead.)
<BitPuffin> yeah I really need to get into the lockless stuff at some point
<Tetralux> That reminds me - I need to look up just how much more efficient strong vs weak cmpxchg is.
<Tetralux> Cause what little looking at x64 instructions I've done did not show anything about strong or weak.
<bheads> if only cmpxchg worked on larger blocks of memory
<Tetralux> Can cmpxchg a pointer though. :p
Hejsil has quit [Remote host closed the connection]
rsdimenus has quit [Remote host closed the connection]
thm has joined #zig
<thm> hi. just found zig and tried "./zig build-exe --c-source hello_world.c --library c -target x86_64-linux", but it crashes with "posix_spawn failed: No file descriptors available"
<Tetralux> If you're trying to compile to native, you shouldn't need to specify it.
<Tetralux> I'm not sure that would cause that problem though.
<andrewrk> thm, what is the output of `ulimit -n` for you?
<andrewrk> that tells you the number of file descriptors that you are limiting processes to
<thm> 1024
dimenus has joined #zig
<andrewrk> mine is set to 99999. I think it's reasonable to raise this limit. see a related issue: https://github.com/ziglang/zig/issues/2280
<andrewrk> thm, what OS are you on?
<thm> ok, setting it to 9999 works. is it really necessary to hold all the file descs?
<andrewrk> I need to try bnoordhuis's suggestion about raising the soft limit to the hard limit
<thm> I'm using Fedora 30 on x86_64
<andrewrk> it's to avoid a race condition with cache eviction
<andrewrk> issue remains open to address this. for now the solution is "please have a higher file descriptor limit"
<thm> ok, thx
<andrewrk> we could solve it by not having cache eviction...
<thm> another q: in order to cross compile, I need the target libc?
<thm> ah wait, targets tells me what libcs are available
<andrewrk> it's planned to provide libc for all targets: https://github.com/ziglang/zig/issues/514
<daurnimator> andrewrk: :( about the http.headers PR. Could you explain your idea more? A http header structure really needs to be universal for a language to be useful
<thm> ... but while it lists aarch64-linux-musleabi, I actually have to specify aarch64v8-linux-musleabi - that's a bit confusing
<andrewrk> daurnimator, any http structure should be built on a lower level streaming API
<andrewrk> which is the first step
<daurnimator> andrewrk: that's not possible for HTTP2
<andrewrk> why not?
<daurnimator> because in HTTP2 you have to decompress headers as the stream goes; but you can't *use* them until later. so you have to buffer them somewhere
<andrewrk> thm, I agree. that should be a bit less confusing with 516b5e6 which I just pushed
<daurnimator> also, if you have a 'request' object, you need a http headers object inside of it.
fengb has quit [Ping timeout: 260 seconds]
<andrewrk> no that can still be streaming
<daurnimator> andrewrk: how?
<andrewrk> what is this, gzip? bzip? both of those have streaming decompression
<daurnimator> andrewrk: HTTP/2 headers have their own compression called HPACK
<daurnimator> andrewrk: the approach I *think* you're suggesting is only really usable for a HTTP/1 server. not for a client; and not for HTTP/2..
<andrewrk> daurnimator, what I'm saying is that I am going to read this spec and come up with an API simply because I wish to be involved in this particular std lib API. you've got a head start on me, and I'm sure you'll have some good ideas in your implementation, but I wish to also do this
<andrewrk> I see that my intuitions about how the protocl worked were wrong
<dimenus> why would a shared library in linux not have a hash table?
<dimenus> ElfHashTableNotFound
<companion_cube> (I don't have any context, but would translating curl to zig be a good start?)
<andrewrk> daurnimator, let me consider more, I think we can both get what we want
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
<thm> andrewrk: one remark to the # of filehandles problem: it gives the error, but finally segfaults. is that expected?
<andrewrk> no, segfaulting is never expected, always a bug
laaron has joined #zig
<thm> made a comment in 2280
<andrewrk> thm, that segfault is https://github.com/ziglang/zig/issues/398 or more in general improving debug info support for optimized builds
<andrewrk> daurnimator, are you comfortable with the idea of using zig std lib to create prototype http stuff, since nobody but you is working on it right now, knowing that it's all up for being completely changed when I start looking into the use case?
<andrewrk> one reason for this push back is that http related code is under unusually high scrutiny from outside communities. the context that it's "in-progress" or "prototype" is lost and the reputation of the project becomes under question
mawaldne has joined #zig
dimenus has quit [Remote host closed the connection]
squiddlebit has quit [Ping timeout: 276 seconds]
bheads has quit [Quit: bheads]
bheads has joined #zig
marler8997 has joined #zig
<marler8997> quick question, is there a way in the standard library to chain multiple iterators?
<daurnimator> marler8997: what do you mean? can you not just call .next on the parent iterator within *your* iterator?
<marler8997> I want to iterate over multiple iterators
<daurnimator> andrewrk: I'm not sure.... I'd be happy to explain to you all the "whys" of my design for it. I wouldn't like if you came through at a later point and changed everything without knowing the reasons behind a certain architecture
<marler8997> Looking for something like this: https://pastebin.com/pCM1xmaN
dimenus has joined #zig
vexu has joined #zig
<daurnimator> andrewrk: the idea for the http.headers PR was that once it was merged, someone could work on a HPACK module
<daurnimator> once that was done; then you could start work on a http2 framer
<daurnimator> once that was done... hopefully the socket library has been rewritten on top of coroutines, and you can implement the rest
<daurnimator> s/you/someone/
<marler8997> oh nice, now there's one global directallocator
<dimenus> do I need to specify something extra to the c linker in order to generate a hash table for a dynamic library>?
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #zig
<dimenus> zig libs work out of the box, but c libs error with ElfHashTableNotFound
avoidr has joined #zig
<dimenus> ah, it's a GCC thing. GCC only generates GNU_HASH where as clang generates both
fu5ha has joined #zig
<dimenus> andrewrk: should zig support HASH & GNU_HASH?
<andrewrk> probably
<andrewrk> as of today you are now more knowledgable about it than I am
<dimenus> i'm appreciating error traces atm ;)
<andrewrk> :)
<andrewrk> daurnimator, I can appreciate the situation you're in, you've already done a bunch of work, you've read the spec, you have some working code with tests
<andrewrk> I'm willing to let you lead the charge on http stuff in the std lib, but you have to be willing to accept it is something that I will personally be involved in (probably once coroutine rewrite is done) and that I may decide to take the API in a different, possibly breaking, direction
<andrewrk> if you are ok with this, I'll walk back my decision on your PR and merge it (once the tests are passing)
<daurnimator> andrewrk: I guess I'm okay with it.... it's better than the alternative of nothing
<daurnimator> andrewrk: are you able to see why the tests are failing? I've been really confused by it
<andrewrk> I'll take a look
<andrewrk> daurnimator, I'm running the tests locally now. BTW, I think working on single-threaded HTTP stuff will be a good investment for when async/await is available
<daurnimator> andrewrk: I've been wanting to build a commmand-buffer socket abstraction as a base for zig. IMO it's both the nicest to use architecture, and the fastest
<daurnimator> I've got a bit of a prototype on my desktop; but haven't had time to work on it further. Coroutines working will help a lot of the open questions in my design though
vexu has quit [Read error: Connection reset by peer]
vexu has joined #zig
<daurnimator> andrewrk: any luck with those tests?
<scientes> so types get resolved between the two passes?
<scientes> the build and analyze passes?
<andrewrk> types are resolved in the analyze pass
<scientes> can i build new nodes in the analyze pass then?
<andrewrk> no
<andrewrk> indirectly that happens for other functions
<andrewrk> scientes, what are you trying to do?
<scientes> array access on vectors
<scientes> it can't use GEP->LoadPtr, instead needs ExtractElement
<andrewrk> sounds like that's going to happen in the analyze pass, and output different instructions for codegen.cpp
<andrewrk> potentially that change could only be made in codegen.cpp
<scientes> still have to add an extract instruction
<scientes> and then fall back to GEP->LoadPtr
fu5ha has quit [Remote host closed the connection]
<andrewrk> daurnimator, I'm getting all tests passing. what issue were you seeing?
<daurnimator> andrewrk: nothing locally; but they fail in CI
<andrewrk> what issue did you see in the CI?
<daurnimator> seems to run out of memory
<andrewrk> they run valgrind clean too
<daurnimator> andrewrk: heh. I think closing the PR deleted the CI logs.
<daurnimator> andrewrk: yeah I couldn't figure it out. I think it might have been caused by a memory leak *elsewhere* and the http.headers tests finally made the box run out of memory
<andrewrk> ok, i'm just going to merge it and then troubleshoot it if it fails
<daurnimator> 👍
fu5ha has joined #zig
<scientes> I don't see how i can do it only in codegen.cpp when its two instructions->>one
<andrewrk> scientes, let's back up for a second. how is this code supposed to work? `my_vector[1] = 1234;`
<andrewrk> or should that be a compile error
<scientes> yes
<scientes> my_var = my_vector[1], and my_vector[5] = 223
<scientes> but i was going to do the first first
<scientes> its quite straight-forward in the IR, the problem is we don't know the types until too late, so it makes it more complicated
<andrewrk> foo(&my_vector[1])
<andrewrk> this is a lot like pointers to packed struct fields
<scientes> you are not allowed to take the address of a vector element
<scientes> you would have to convert to an array
<scientes> you CAN take the address of a vector however
<scientes> which is kinda weird
<scientes> this is how it works in C and I think it is OK
<andrewrk> that's what makes it a lot like packed struct field pointers - your pointer points to some "base address" and the pointer type has extra data that tells what value is actually being referred to
<andrewrk> if we took this approach with vectors, it would mean that the index would always have to be comptime known
<scientes> llvm doesn't require that
<andrewrk> so the current problem to resolve is that zig exposes this concept of a pointer to a vector element, and that is a broken concept
<scientes> nor does C
<scientes> yeah, so I was going to add a Extract instruction, which then lowers to GEP->LoadPtr
<scientes> for array accesses (of rvalues)
<scientes> similar for lvalues, but not quite the same
<scientes> and if you took the address of a extract instruction it would have to lower it
<scientes> the issue is that you don't have enough type information to lower in stage1, so it kinda requires a third stage
<daurnimator> andrewrk: okay thanks I see the http.headers module is merged now.
fu5ha has quit [Remote host closed the connection]
<daurnimator> andrewrk: a "good+complex first issue" for someone might now be to write a http.hpack module. Should I make an issue on github?
<andrewrk> yes
<scientes> doesn't that require TLS?
<andrewrk> I'll mark it contributor friendly if you are willing to mentor whoever wants to work on it
<daurnimator> scientes: no. HPACK is the http/2 compression algorithm
<thm> how would the file system layout for a system-wide installation of zig look like?
<scientes> daurnimator, i was saying that IIRC http/2 requires TLS
<daurnimator> scientes: it does not
<daurnimator> scientes: browsers only support http/2 over TLS. but servers/proxies/client libraries support it over normal TCP.
<andrewrk> thm, it would look like unzipping the linux tarball to /usr/local or /usr, except zig binary would go in bin/ rather than root
<andrewrk> I don't recommend doing that, but that's what it would look like
<andrewrk> you can, in fact, override the default cmake install directory
<daurnimator> scientes: in any case, HPACK is only the compression algorithm: you can implement it before you even touch the socket layer
<thm> was just contemplating on creating a Fedora rpm
<daurnimator> andrewrk: please tag #2772 with userland, enhancement, contributor friendly
jjido has joined #zig
<andrewrk> thm I believe all you need to do is specify the install directory in the cmake command
<thm> andrewrk: yes, that mostly seems to work. interestingly it installs also a bunch of .a files somewhere else.
<andrewrk> what files
<thm> zig_cpp/libzig_cpp.a and zig_cpp/libembedded_lld_*.a
<thm> that looks like a bug
<andrewrk> I believe this issue is fixed in master branch. I'm guessing you're looking at 0.4.0
<thm> yes
<andrewrk> thm, here's a commit to backport: 40fe6afdad1a8676b5d3a5dd23d6d50d6ea9f059
<andrewrk> oops, there is more
<andrewrk> 81767a658d07219a402384f98a7553abcbbd2e70 and 40fe6afdad1a8676b5d3a5dd23d6d50d6ea9f059
<andrewrk> I just want to give you a warning, there are 717 commits to master since 0.4.0, many of them large breaking changes
<thm> ok
<andrewrk> any user using a 0.4.0 zig package will quickly discover that they want a newer version
<thm> are you planning a 0.5.0 soon?
Tetralux has quit [Ping timeout: 272 seconds]
fu5ha has joined #zig
Tetralux has joined #zig
<andrewrk> September 30, 2019
<thm> ups, did a make -j. that killed by gnome-shell.
<thm> s/by/my
<andrewrk> daurnimator is advocating for an earlier release
Akuli has quit [Quit: Leaving]
<andrewrk> daurnimator, std.debug.global_allocator shouldn't be used in std lib tests - that's the issue
<thm> building stage2 of 1ccf6a2c fails with a panic
fu5ha has quit [Remote host closed the connection]
<daurnimator> andrewrk: oh? it gets used in heaps of tests
<andrewrk> yeah that's why we ran into this issue
<daurnimator> andrewrk: like... see std.PriorityQueue, or LinkedList
<andrewrk> not your fault, you were following my example
<BitPuffin> can I reference the value of another field of a struct in its initialization
<BitPuffin> I ended up making a block now that assigns a const right before so that I can use the same value in two places
<daurnimator> BitPuffin: create a block and do it in there
<andrewrk> that's somewhat related to https://github.com/ziglang/zig/issues/2765
<daurnimator> BitPuffin: const foo = blk: { var tmp_foo: Foo = undefined; tmp_foo.a = 42; tmp_foo.b = tmp_foo.a * 2; break :blk tmp_foo; };
<BitPuffin> yeah that's basically what I'm doing daurnimator
<scientes> so I'm wondering if I should add a third pass, I think that is the cleanest way to do this, instead of duplicating a bunch of stuff
<andrewrk> scientes, I doubt it
<scientes> oh yeah, the solution I thought of before, is to build the backup stuff
fu5ha has joined #zig
<scientes> and then use it if its needed
<daurnimator> andrewrk: so what should we be using in std lib tests instead?
<andrewrk> daurnimator, just a moment, I have a fix to push but ran into an issue
<BitPuffin> http://dpaste.com/0TS6MSY like this
<andrewrk> it's effectively the same thing; just reserves upfront the amount of memory needed for these tests only
<BitPuffin> will it always be the case that const fields of a struct have to be accessed like TypeName.constant
<BitPuffin> it's a bit strange when member functions are allowed to be referenced without, but I guess maybe that's only the ones that take a self ptr or something
<andrewrk> const fields? that's not a thing yet but it's planned
<BitPuffin> hmm? You can put const things in structs though
<andrewrk> I have allowed stage2 to regress until #2377 is solved
<andrewrk> nobody uses stage2 for anything yet
<thm> ok
<andrewrk> BitPuffin, fields are a: i32, b: f32, etc
<daurnimator> andrewrk: I feel like there should be a global 'test_allocator' then
<daurnimator> andrewrk: possibly it should hook into the test framework and verify that everything is freed after each test
<andrewrk> that's not a bad idea
<BitPuffin> andrewrk: right, but what should I call the constants I put in a struct namespace
<andrewrk> declarations
darithorn has joined #zig
<BitPuffin> alrighty
<dimenus> how do I make a cstring?
<andrewrk> dimenus, std.Buffer might be of interest
<andrewrk> BitPuffin, do you know about usingnamespace?
<BitPuffin> yes, but I've only ever used it in a toplevel decl
<BitPuffin> but I guess if modules are structs
<BitPuffin> then I can use them on any struct
<andrewrk> top level is actually inside a struct - every file is a struct
<andrewrk> you can also alias structs to shorten the namespace for yourself
<BitPuffin> just by doing const F = Foo, I suppose?
<andrewrk> daurnimator, I think my general purpose debug allocator will be a good candidate for the test allocator, since it has leak detection and good debugging facilities
<andrewrk> we can call "detectLeaks()" after every individual test
<companion_cube> could you create a fresh sub-allocator for every test? if it isn't empty by the end of the test you get a leak?
<andrewrk> that's reasonable too, completely deinitialize it, initialize a new one for every test
<Sahnvour> both are interesting, by keeping a single allocator for many tests you also test it for free, but at the cost of having its eventual errors invading other tests
<andrewrk> I think it would be reasonable to add a flag to `zig test` to toggle that behavior
mawaldne has quit [Remote host closed the connection]
marler8997 has quit [Remote host closed the connection]
marler8997 has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
vexu has quit [Quit: WeeChat 2.5]
<dimenus> one more stupid question hopfully. How do I get from a compile time known length array (eg [10]u8) to a []u8?
andrewrk has quit [Ping timeout: 245 seconds]
<companion_cube> a[0..] I think
<dimenus> hmm, in this case its a string literal
jjido has joined #zig
fengb has joined #zig
darithorn has quit [Quit: Leaving]
<Tetralux> I think you'll want std.mem.copy into an allocated slice. Unless anyone else has a better suggestion?
<fengb> If you can guarantee only literals, you can change []u8 to []const u8 and it'd work seemlessly
<fengb> Otherwise, you can assign it to a const and pass it via slicing
<fengb> Hmm... you could also assign via slice too: const foo = "abc"[0..];
<companion_cube> it'd be cool to have a playground, like rust's, for such code samples :)
<fengb> Oh I see, it's complaining about the const-ness. Yeah you need to mark it []const u8 because the compiler doesn't know you're not changing it
<fengb> var foo: []u8 = "abc"[0..]; foo[1] = 'z';
<tgschultz> Something I did recently because of namespaces being structs was to create a single-file version of a package by pasting the text of each file into a global const struct declaration and removing the related import lines. Probably won't work in every case because of naming conflicts, but useful none the less.
brakmic_ has joined #zig
brakmic has quit [Read error: Connection reset by peer]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
SamTebbs33 has joined #zig
<SamTebbs33> I need some an opinion peeps
andrewrk has joined #zig
<SamTebbs33> If I try to align some address by an alignment of 0, should 0 or the original address be returned?
<SamTebbs33> What makes most semantic sense?
<andrewrk> dimenus, a string literal is constant data so it can't be casted to a mutable slice
<dimenus> yeah that makes sense now, i didn't realize []u8 was mutable - i just thought it had non-comptime known length
<SamTebbs33> If it was being aligned by 1 byte then of course the original address should be returned as all addresses are 1-byte aligned
<fengb> SamTebbs33: what's alignment 0 supposed to mean? It feels like a divide by 0 error
<andrewrk> companion_cube, I looked into making a wasm-based playground (*taps forehead* can't break out of a playground if it's running on your own computer). got stuck because emscripten can't build llvm yet
<SamTebbs33> fengb: Yeah it doesn't really make much sense, so perhaps an assertion should be added to stop that case
<andrewrk> align 0 is invalid, if 0 was passed to any alignment function it should be `unreachable`
<marler8997> SamTebbs33: sounds like an interesting question...I'd have to think about that one. Do you have a use case in mind, might help provide some insight
<companion_cube> andrewrk: wow, neat idea.
<SamTebbs33> I'm referring to this issue btw https://github.com/ziglang/zig/issues/2774
<companion_cube> could even serve for a local REPL.
<andrewrk> SamTebbs33, I thought you meant the address was 0 in that issue
<SamTebbs33> andrewrk: I did originally write the issue as it being about andresses and alignments being 0 but I realised my mistake and edited to only be alignment
<SamTebbs33> andrewrk: Just saw your comment, will add add to the doc comment
<fengb> Hmm, what's alignBackward of addr 0?
<SamTebbs33> fengb: That should be 0
<SamTebbs33> Since it uses unsigned ints
<fengb> But alignForward should be 0
<scientes> ok, now i am having a problem where it tries to analyze the backup IrInstructions
<daurnimator> also 0 is aligned to everything already ;)
<scientes> can i add them only in the second stage?
<marler8997> I don't see the `Chain` and `OneItemIterator` types anywhere in zig standard library. Should I add them? and if so, where would they go?
<daurnimator> marler8997: new module 'std.iterator'?
<marler8997> that was my first thought
<fengb> Oh yeah I'm just confused. Please ignore :P
<andrewrk> scientes, what you're working on is really difficult. I don't think I'm going to be able to help without trying to solve the problem myself
<andrewrk> let me try to stabilize zig a bit after the merge of result location, then I'll look into that
tgschultz has quit [Ping timeout: 245 seconds]
halosghost has quit [Quit: WeeChat 2.5]
<BitPuffin> is it because I'm passing structs?
<andrewrk> BitPuffin, what's your target? the related issue is https://github.com/ziglang/zig/issues/1481
<BitPuffin> should just be x86_64 I think
<BitPuffin> linux
fengb has quit [Remote host closed the connection]
<andrewrk> your options are: make the function not-extern, make the structs be in one of the checked boxes in that linked issue, or make the structs be non-extern
<andrewrk> or submit patch to zig to fix C ABI for that category of structs :)
andrewrk has quit [Quit: Leaving]
<scientes> or even better, a patch to LLVM to implement the C ABI in LLVM
<scientes> PPC does that
andrewrk_ has joined #zig
andrewrk_ is now known as andrewrk
<BitPuffin> Can I @cInclude everything except one thing without writing huge wall of text? andrewrk
<andrewrk> if you need to hack around @cInclude output, best bet is to copy the generated .zig code into your repo, and then make your edits
<andrewrk> you can use --verbose-cimport to see the file name
Sahnvour has quit [Quit: WeeChat 2.4]
Sahnvour has joined #zig
<BitPuffin> yeah so there is no way to overwrite the usingnamespace thingy
<BitPuffin> hmm the filename? not the source itself?
<BitPuffin> I think I need to set it in the build.zig instead of on command line somehow
<andrewrk> zig build has --verbose-cimport
FireFox317 has joined #zig
<BitPuffin> ahh it worked I think
brakmic_ has quit []
<FireFox317> Yo guys, I'm working on #2062, adding the function-sections flag to LLVM. Should this be enabled by default for all the output files, or only for libraries for example? What is the way to go here? Maybe we should also considering to add the data-sections flag
<FireFox317> Or maybe as a flag to the zig compiler
<FireFox317> Or maybe only for the compiler_rt library file?
<andrewrk> FireFox317, I think it should be a CLI flag -ffunction-sections. off by default. link.cpp will enable it for compiler_rt and libc
<andrewrk> don't forget to add it to the input parameters cache hash
<FireFox317> andrewrk: Okay thanks, i'm gonna try that. And regarding the LLVM flag which is located in the TargetMachine::Options, should I set it in `ZigLLVMTargetMachineEmitToFile` or somewhere else? What is the most logical location for this in the zigs codebase, because I don't know the structure of the cpp files that well
<BitPuffin> hmm making it non extern didn't help bcause then it doesn't allow me to call the function
<BitPuffin> or ah wait
<andrewrk> FireFox317, yes expose it as an option to ZigLLVMTargetMachineEmitToFile. there's only 1 callsite in codegen.cpp and there you can read the value from `g` (the CodeGen * instance)
darithorn has joined #zig
<BitPuffin> maybe I didn't change the signature
<BitPuffin> no the signature is ok
<BitPuffin> dangit
<BitPuffin> not allowed with calling convention ccc
<FireFox317> andrewrk: So I added a entry in the CodeGen struct and at the top it says 'check if it should be added to the hash computation in build_with_cache', is this the input parameter cache hash you were talking about?
fu5ha has quit [Read error: Connection reset by peer]
fu5ha_ has joined #zig
<andrewrk> yes
FireFox317 has quit [Remote host closed the connection]
jjido has joined #zig
fengb has joined #zig
jjido has quit [Client Quit]
fengb has quit [Ping timeout: 260 seconds]
ltriant has joined #zig
SamTebbs33 has quit [Quit: Lost terminal]
<dimenus> andrewrk: someday I'd like to see you and gingerBill go back and forth :P
<dimenus> Error traces seem really darn useful. They're not as "you deal with it" as something like exceptions
<andrewrk> we now have @import("root") available which will import the root source file (the one with pub fn main). it's available in every package. this combined with @hasDecl which is also a recent addition is a particularly interesting combination
<andrewrk> thanks emekankurumeh[m] for the PR
<marler8997> @import("root") could open up some interesting semantics
<andrewrk> it can also be abused. use with care
<marler8997> if (@hasDecl(@import("root"), "defaultAllocator")) ...?
<andrewrk> yeah something like that is a good use case
<marler8997> allowing root to declare logging mechanisms may also be another one
<mikdusan3> root context for the win
<marler8997> this is something I've wanted to have in other languages but never have, excited to explore it
<andrewrk> ah yes marler8997 did you see my log proposal?
<marler8997> I haven't, I'll look it up
<marler8997> seems like the info/warn/err/fatal functions should call a common function, which could also be configured by root
<andrewrk> that's in there
<marler8997> oh woops
<marler8997> I see it now :)
<marler8997> seems like a good start
<marler8997> logging is a very hard problem in general
dimenus has quit [Read error: Connection reset by peer]
bheads62 has joined #zig
<bheads62> Q: If given an array of types ( comptime []type ) is it possible to make a struct/union/enum of those types?
<Tetralux> Q: readFn/writeFn vs comptime trait.hasFn("read")/trait.hasFn("write") ?
poshix has joined #zig
<bheads62> only way I can think of so far is to make a void pointer array ( [types.len] *void ) and use the types list to find the index
poshix has left #zig [#zig]
fu5ha_ has quit [Remote host closed the connection]
dimenus has joined #zig