ChanServ changed the topic of #zig to: zig programming language | | be excellent to each other | channel logs:
_whitelogger has joined #zig
telemach has joined #zig
jjido has quit [Quit: Connection closed for inactivity]
hio has quit [Quit: Connection closed for inactivity]
shritesh has joined #zig
_whitelogger has joined #zig
neceve has quit [Remote host closed the connection]
develonepi3 has joined #zig
_whitelogger has joined #zig
<hryx> Looks like Cloudflare had an interesting side effect. Go to the docs page, view source, and search for "email"
<hryx> The really funny bit is that it detected ptr=i32@7f375d561020 as an email address
<hryx> Neat feature, but it did the wrong thing in this case, and is kinda a nuisance because it introduced a new network request and the use of JS to the docs
<torque> ah the old "parse email with regular expressions" trick
<torque> *email addresses
<hryx> code block: "hi, I'm an @ symbol with something on my left and something on my right"
<hryx> cloudflare: "REPLACE HIM"
andrewlm has joined #zig
<andrewlm> :q
andrewlm has quit [Client Quit]
andrewlm has joined #zig
_whitelogger has joined #zig
_whitelogger has joined #zig
andrewlm has quit [Quit: andrewlm]
_whitelogger has joined #zig
reductum has joined #zig
hio has joined #zig
tankf33der has quit []
_whitelogger has joined #zig
nullheroes has joined #zig
emekankurumeh[m] has quit [Remote host closed the connection]
slugmatt_ has quit [Remote host closed the connection]
dtz has quit [Read error: Connection reset by peer]
dtz has joined #zig
reductum has quit [Quit: WeeChat 2.4]
dewf has joined #zig
<l1x> :D
slugmatt_ has joined #zig
dewf has quit [Quit: Leaving]
slugmatt_ has quit [Remote host closed the connection]
dtz has quit [Read error: Connection reset by peer]
Flaminator has quit [Disconnected by services]
SimonNa has quit [Remote host closed the connection]
dtz has joined #zig
Zaab1t has joined #zig
fsateler_ has quit [Read error: Connection reset by peer]
fsateler has joined #zig
slugmatt_ has joined #zig
<develonepi3> ZipCPU: Good morning.
tracernz has quit [Ping timeout: 258 seconds]
tracernz has joined #zig
ShrewdSpirit has joined #zig
<ShrewdSpirit> Hello. Is Zig production ready?
return0e has quit [Remote host closed the connection]
scientes has joined #zig
ShrewdSpirit has quit [Ping timeout: 252 seconds]
<slugmatt_> hey, anyone know @typeInfo(my_type).Struct.fields is guaranteed to be in the same order declared when my_type is a packed struct?
<scientes> it should be
<scientes> and currently they are all in order IIRC
<scientes> slugmatt_, but there is planned a by-name API, and you should use that when it exists
<slugmatt_> <scientes "slugmatt, but there is planned a"> awesome. thanks
<scientes> what are you using this for?
<scientes> maybe I should work on was my bug
<slugmatt_> working on a minimal ECS type lib, I just want to ensure everything is updated in correct order
<scientes> what is ECS?
<slugmatt_> Entity component system
<slugmatt_> popular architecture for games at the moment but also useful elsewhere
<scientes> ahhh, so MVC for graphics
<slugmatt_> yeah pretty much
<slugmatt_> the issue is 'get-by-name api in TypeInfo #1439' ?
bheads__ has joined #zig
return0e has joined #zig
bheads_ has quit [Ping timeout: 246 seconds]
<scientes> yes
<scientes> but andrew spoke of what the api would look like in the logs
<scientes> @hasField
<tgschultz> Why do we need a special compiler builtin for by-name again? What's wrong with a std.meta implementation?
<scientes> tgschultz, O(1) lookup. enumerating all fields is (n)
<scientes> O(n)
<scientes> its stored in a hash table, so it can be O(1)
<tgschultz> it's comptime though, and the same argument could be made for a neigh infinite number of use cases. Why does this one deserve a language feature?
<scientes> yeah, sure
halosghost has joined #zig
<andrewrk> hryx, wtf this is horrible!
<scientes> I still think it deserves a language feature.
<andrewrk> tgschultz, there's also the problem of dependency loops. @typeInfo forces a full evaluation of an entire type; whereas if you just want to look at one name that allows more constructs to work
<andrewrk> for example look at the example in
scientes has quit [Read error: Connection reset by peer]
scientes has joined #zig
<andrewrk> hryx, the email thing is fixed now
<hryx> andrewrk: great to hear the Cloudflare issue was fixed. I meant to file an issue on the repo last night but fell asleep while searching for a solution :P
<andrewrk> it was just a toggle button in their control panel, with an unfortunate default
bheads__ has quit [Ping timeout: 245 seconds]
bheads___ has joined #zig
gonzus has joined #zig
wootehfoot has joined #zig
gonzus has quit [Quit: Leaving.]
gonzus has joined #zig
gonzus has quit [Client Quit]
<andrewrk> tgschultz, do you do anything with @typeInfo Definitions that isn't solved with @field and @hasField ?
<shritesh> I'm trying to build for wasm with `zig build-obj --release-small --target-arch wasm32 wasm.zig` but it's giving me "Invalid argument: --target-arch". Am I missing something?
<andrewrk> shritesh, -target wasm32-freestanding
<andrewrk> you can also try -target wasm32-wapi
<andrewrk> sorry, -target wasm32-wasi
<andrewrk> I've been meaning to do a basic verificationt of web assembly support now that we have llvm 8 but I haven't yet
Ichorio has joined #zig
<andrewrk> hopefully I can do that within 4 days
<shritesh> Thanks. I'm giving it a try right now.
<andrewrk> shritesh, I'm happy to provide guidance if you hit any problems
<andrewrk> see also this issue:
darithorn has joined #zig
<shritesh> andrewrk, thanks. There are many wasm-related issues that seem to have been fixed.
bheads__ has joined #zig
bheads___ has quit [Ping timeout: 244 seconds]
<andrewrk> who wants their zig project mentioned in the 0.4.0 release notes?
<andrewrk> paste links
Sahnvour has joined #zig
Flaminator has joined #zig
moo has joined #zig
wootehfoot has quit [Ping timeout: 246 seconds]
andrewlm has joined #zig
emekankurumeh[m] has joined #zig
<tgschultz> andrewrk, I'm not entirely sure what you mean, but with enum fields we have meta functions to search by value instead of name as well. This is used by TagPayloadType for example.
<andrewrk> yeah that's using the fields though - not the definitions
<andrewrk> having Definitions in @typeInfo sort of breaks the declarative nature of zig's top level declarations
<tgschultz> Oh, that's what you're going for. Well, meta does use them, let me see if all the ground is covered by @hasField/@field
<tgschultz> One thing that comes to mind is that @typeInfo/meta differentiates between field and definitions. I can't recall if @field(some_instance, "SomeInstanceStructDef") would work or not.
Ichorio has quit [Read error: Connection reset by peer]
<andrewrk> @field / @hasField operate the same way that field access does, so if the first arg is a type, you get the definitions; if the first arg is an instance, you get the fields
<andrewrk> it's equivalent to `a.b` except `b` is a comptime string
<tgschultz> ok. I may be misremembering but I think that was actually ambiguous at one time.
<tgschultz> Anyway, I don't see anything I've touched (meta, serializer, bitstream) that does definition stuff and wouldn't work with @hasField/@field.
<tgschultz> Although, if one wanted to list all the definitions of a struct, I guess that would go away
<tgschultz> Unless definitions just have a name in typeInfo and nothing else?
<tgschultz> Then you can always @typeInfo(@field(T, field)), so I don't think that'd be a big deal.
<tgschultz> The same could be said for fields. That might actually help cleanup TypeInfo in the long run.
<tgschultz> No wait, I'm wrong, because I can't use @field to get the field type easily, I'd have to create an instance.
<tgschultz> *field type from the type
<scientes> is there a way for me to rerun the azure devops test suite?
<scientes> this linux failure look spurious
<tgschultz> If you'd like I can run the CI tests on my own server and let you know what's failing.
<scientes> nah, i'll just bump the pull request
<tgschultz> well, I went ahead and did it anyway since my server is otherwise idling and it takes a while. If it errors again I can get you the info.
<scientes> ok thanks
<scientes> are you the one with the EPYX?
<scientes> although the test suite is single-threaded still.....
<tgschultz> No, my server is an old PowerEdge 2500 III. Free kit is best kit.
gonzus has joined #zig
<scientes> I run Linux
<scientes> I just like to keep hacking, instead of waiting for the test suite to run
<andrewrk> that's an alarming failure if it's unrelated to your changes
<scientes> I know
<andrewrk> how could std.os.Thread.getCurrentId fail with --single-threaded on?
<scientes> its just gettid()
<andrewrk> the first line of that test is if (builtin.single_threaded) return error.SkipZigTest;
<andrewrk> oh. this whole time it's not actually been passing --single-threaded
<andrewrk> so this is concerning because it was a non single threaded build that failed that test
<scientes> maybe its a shared system and it ran out of pids
<scientes> and returns EAGAIN
<scientes> *tids
<andrewrk> that's true it could be resource exhaustion. I should update the test to explain that if it happens. in which case it would actually be a spurious failure and not a bug
<scientes> ThreadQuotaExceeded
<scientes> and also SystemResources and OutOfMemory
<andrewrk> gettid is always successful
<andrewrk> and the error says "test failure" which means it's the expect() that was wrong
<scientes> no, but that test spawns a thread
<andrewrk> yeah but the thread spawning worked
<andrewrk> it didn't return from try os.spawnThread
<scientes> are you sure?
<scientes> oh its a race
<scientes> you have to create a mutex, and wait for the thread to write
<scientes> or call wait
<andrewrk> are you looking at the test? the wait() is right there
<scientes> oh it does that
<scientes> yeah i wasn't looking at the test
<scientes> maybe there is no explicit fence when the thread exits
<scientes> *implicit
<andrewrk> this is really important to fix or at least understand what's happening
<scientes> my guess is that we need a @flush(.Release);
gonzus has quit [Quit: Leaving.]
<scientes> at the end of the thread
gonzus has joined #zig
<scientes> or rather .Monotonic
<andrewrk> CLONE_PARENT_SETTID says Store the child thread ID at the location ptid in the parent's memory. The store operation completes before clone() returns control to user space.
gonzus has quit [Client Quit]
<andrewrk> so thread_id should be valid
<scientes> i'm talking about the getCurrentId in the child
<andrewrk> yeah sorry wasn't responding to you yet
<scientes> that write needs to be flushed
<scientes> the wait() doesn't do that
<scientes> that is my guess
<andrewrk> so why would that be a problem? because the thread_id.* = os.Thread.getCurrentId(); only updates the thread-local cache?
<andrewrk> is that even a thing? I don't think CPUs have thread local caches
<scientes> "The store operation completes before clone() returns control to user space." that is not clear. It doesn't say that a memory flush is issued or not
<scientes> <andrewrk> so why would that be a problem? because the thread_id.* = os.Thread.getCurrentId(); only updates the thread-local cache?
<scientes> yes, they only write when they get evicted
<scientes> at least thats how it works on arm
<scientes> the cache lines
<scientes> L1
<mikdusan> aliasing?
<scientes> this is better:
<scientes> its not a thread local cache, its a cpu-local cache, and the other thread was run on a differn't cpu
<andrewrk> so I wouldn't be able to reproduce this on my laptop because it only has 1 cpu
<scientes> well core
<scientes> most cpus have multiple cores these days
<andrewrk> oh right there are core-local caches. that makes sense. so a fence would make the memory observable to the other core
<Sahnvour> are you implying caches are incoherent between cores on ARM ? that would be very surprising
<scientes> and then only write when they are evicted, unless you issue a flush instruction
<scientes> Sahnvour, yeah thats how it works, x86 has exceptions when it comes to detecting self-modifying code
<andrewrk> ok I can reproduce this easily with
<andrewrk> thread_id=0 sometimes
<scientes> well, it should be 0xaa
<andrewrk> after about 1600 iterations on average it'll have the race
<scientes> why is it 0 instead of 0xaaaaaa
<Sahnvour> (what do you mean x86 has only "exceptions" ? From what I know all recent major x86 chips have coherent caches, hence false sharing for example)
<scientes> oh well i don't know much about x86
<scientes> i just know that is the way arm works
<Sahnvour> okay, TIL
<scientes> note that the flush instruction is only 16 bits, cause its thumb 2
<andrewrk> scientes, the memory for threads is mmapped directly
<scientes> I doubt AMD could release a 64-thread cpu without some cache coherancy model however
<andrewrk> and spawnThread does not write 0xaa to it
<scientes> ahh, only the stack is 0xaaaa
<andrewrk> 0xaa comes from 2 places: 1. assignment of undefined, writes 0xaa bytes. 2. std.mem.Allocator memsets 0xaa in create/alloc
<andrewrk> err, (2) is just (1). it's a for loop that assigns undefined
<scientes> oh ok
<andrewrk> assignment of undefined also has valgrind client requests by default so valgrind understand's zig's concept of undefined
<scientes> yeah i saw that
gonzus has joined #zig
<andrewrk> scientes, how do you know it's .release?
<mikdusan> don’t know if it helps - musl puts in `a_barrier()` in it’s pthread_join.c
<scientes> oh yes
<scientes> .Release
<scientes> i get those confused sometimes
<andrewrk> @fence(.SeqCst); does not fix the issue
<scientes> hmm, maybe you need it on both sides
<scientes> yeah, because that memory is already in the cache of the spawning cpu
<andrewrk> I need to understand this better
<scientes> me too
<Sahnvour> andrewrk did you build zig in debug mode on windows ? because I think the instructions to build llvm from source are incorrect for this usecase
<andrewrk> Sahnvour, I haven't built zig in debug mode on windows for a long time
<andrewrk> I was unable to figure out how to build llvm/clang in release mode and zig in debug mode on windows
<andrewrk> so zig in debug mode is really slow
gonzus has quit [Quit: Leaving.]
<andrewrk> on windows, because of llvm/clang being in debug mode
<Sahnvour> cmake/llvm's cmake defines the iterator debugging level differently on release that on debug target
<Sahnvour> and that makes it unable to link against a zig using a different definition
gonzus has joined #zig
<Sahnvour> thus I think `-DCMAKE_BUILD_TYPE=Release` in LLVM debug mode instructions is wrong and should be `Debug` instead
<Sahnvour> it's unfortunate not being able to mix debug/release between zig and llvm
<andrewrk> Sahnvour, you're talking about the wiki yeah? feel free to update it
<Sahnvour> yeah, wanted to check with you first
<Sahnvour> my cmake-fu is weak :p
<shritesh> FYI: building without `-DCMAKE_BUILD_TYPE=Release` has been failing for me with "unused function 'zig_libc_find_native_crt_dir_posix' [-Werror,-Wunused-function]"
<andrewrk> shritesh, ah, that probably happened in 5866dfe4d970ad10
<Sahnvour> looking at the code now shritesh, it should be #ifdef'd out on windows ?
<andrewrk> just need to shuffle some #ifdefs or functions around
<shritesh> I'm on a mac
Ichorio has joined #zig
<andrewrk> I can reproduce it. just a moment
<andrewrk> fixed
<Sahnvour> msbuild is also awfully slow, I wonder if we shouldn't instead advertise for ninja unless one wants to have a visual studio solution
<Sahnvour> but that's an additional dependency
<scientes> ninja is awesome
<scientes> i use it to build zig
<scientes> -GNinja
<scientes> I wish Linux switched to ninja
<andrewrk> scientes, I bet I know the problem
gonzus has quit [Quit: Leaving.]
<andrewrk> we're giving CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, and the same address for both. so if the child exits before clone returns, the child pid is already cleared to 0
<andrewrk> which actually is kind of awesome. maybe std.os.spawnThread should be able to return "I did it and the thread has already finished. no resources are allocated."
<scientes> woah, thats a cool feature
<scientes> it even does a futex wakeup
<andrewrk> what do you mean?
<scientes> read the docs for CLONE_CHILD_CLEARTID
gonzus has joined #zig
<andrewrk> yeah that's important, that's how wait() works
<scientes> but wait() does it in the kernel
<andrewrk> huh?
<scientes> man wait4
<andrewrk> the fact that CLONE_CHILD_CLEARTID does a futex wake is why wait() works at all and doesn't have a race problem
<scientes> oh I C
<scientes> it still has a pid reuse problem, but using FUTEX_WAIT would not
<andrewrk> what has a pid reuse problem?
<scientes> so maybe we should implement wait() with FUTEX_WAIT
<andrewrk> I'm literally telling you that's what we already do
<scientes> the wait4 syscall---it has its own syscall
<scientes> oh ok
<andrewrk> std.os.Thread.wait
<scientes> yeah that is pretty cool
<andrewrk> I think... I'm actually going to just document this behavior and say that it is correct
<scientes> that if it returns 0 the thread has already returned
<andrewrk> right
<scientes> thread.handle() returns 0 that is
<andrewrk> whatever pid it was could be recycled by now anyway
<andrewrk> this makes sense because if you do anything with the pid of a no-longer-existing thread it's a bug
<andrewrk> this is actually an anti-footgun
<scientes> its nice
gonzus has left #zig [#zig]
andrewlm has quit [Ping timeout: 250 seconds]
Zaab1t has quit [Quit: bye bye friends]
<mikdusan> would anyone here with linux be kind enough to this 1 liner test and pastie their stack trace?
<halosghost> sure
<halosghost> mikdusan: commented
<mikdusan> yup. i knew something smelled with my lldb. dammit.
* halosghost doesn't really know what's happening, and that's 0.3.0, not master or anything
<halosghost> so, I hope that was helpful :)
<mikdusan> i’m running a rather old lldb (it is from the last xcode for my macos version), and building a new lldb is not functional. so my stack traces are i think a little suspect.
<halosghost> ah, I see
<mikdusan> ie. pretty sure i should see “assertional failure” like your trace shows.
<halosghost> ah
<halosghost> fernuff
halosghost has quit [Quit: WeeChat 2.4]
<andrewrk> I'm drowning in release notes
<andrewrk> can everyone please stop being so productive around here
<andrewrk> (just kidding)
<andrewrk> so far I've made it through October 17, 2018 commit logs
<mikdusan> hey it’s one of those good problems to have.
<hryx> andrewrk: sorry but I want to do 2 more tiny zig fmt things for 0.4.0
<hryx> since we're on a roll
<hryx> issues incoming :>
Ichorio has quit [Ping timeout: 245 seconds]
MajorLag has joined #zig
Flaminator has quit [Disconnected by services]
darithorn_ has joined #zig
Flaminator has joined #zig
return0e_ has joined #zig
mikdusan_ has joined #zig
bheads___ has joined #zig
hio has quit [Quit: Connection closed for inactivity]
nullher0es has joined #zig
fengb_ has quit [Ping timeout: 255 seconds]
return0e has quit [Ping timeout: 255 seconds]
shachaf has quit [Ping timeout: 255 seconds]
so has quit [Ping timeout: 255 seconds]
hryx has quit [Ping timeout: 255 seconds]
tridactyla has quit [Ping timeout: 246 seconds]
nullheroes has quit [Ping timeout: 246 seconds]
allan0 has quit [Ping timeout: 246 seconds]
mikdusan has quit [Ping timeout: 246 seconds]
tgschultz has quit [Ping timeout: 246 seconds]
bheads__ has quit [Ping timeout: 246 seconds]
darithorn has quit [Ping timeout: 246 seconds]
redj has quit [Ping timeout: 246 seconds]
mikdusan_ is now known as mikdusan
MajorLag is now known as tgschultz
so has joined #zig
shachaf has joined #zig
<shritesh> Master is broken. I've submitted a pull request to fix it.
fsateler has quit [Read error: Connection reset by peer]
<andrewrk> shritesh, ah, thanks. I just responded to that
fsateler has joined #zig
<andrewrk> shritesh, thanks
<andrewrk> how's that web assembly stuff going?
<shritesh> There's already a pull request for that too ;)
<andrewrk> ah, here are the web assembly options:
<andrewrk> shritesh, what happens when you don't do --export-all?
<shritesh> extern functions don't get exported for some reason
<andrewrk> you mean export functions right?
<shritesh> yes my bad
hryx has joined #zig
<andrewrk> hmm. does it export any non-export functions when you use --export-all?
<shritesh> Nope
<andrewrk> ok. I think your PR is a good starting point, and we can tighten up handling of undefined symbols later
<shritesh> Yeah. I liked the `extern "wasm"` idea.
<andrewrk> is --relocatable no longer a thing?
<andrewrk> oh, that's a general linker option
<andrewrk> can you try --relocatable instead of --export-all --allow-undefined?
<shritesh> Sure.
<andrewrk> with build-obj and build-lib
<andrewrk> build-exe is the one where we would want everything to be resolved (but might be ok with --allow-undefined for now)
return0e_ has quit [Read error: Connection reset by peer]
return0e has joined #zig
<shritesh> andrewrk using only --relocatable doesn't produce a valid wasm file
<andrewrk> noted. OK I'm going to merge your PR, it's an improvement from status quo
<shritesh> nice
<Sahnvour> sometimes i miss macros
<andrewrk> confessions of a zig programmer
<scientes> uggggh, i don't miss macros
<scientes> comptime is way better
_whitelogger has joined #zig
darithorn_ has quit [Remote host closed the connection]
fengb has joined #zig
<emekankurumeh[m]> but can you do things like return functions that you built during comptime?
<andrewrk> yes
<emekankurumeh[m]> nim also has a relatively power macro system that allows async await to be built using the macro system.
<andrewrk> what you can't do is control flow
<emekankurumeh[m]> we can do that with zig?