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/
bwb_ is now known as bbrittain
ltr- has quit [Quit: leaving]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 268 seconds]
bbrittain is now known as bwb_
laaron has joined #zig
kristoff_it has joined #zig
Ichorio has quit [Ping timeout: 264 seconds]
kristoff_it has quit [Ping timeout: 248 seconds]
curtisf has joined #zig
ltriant has quit [Ping timeout: 272 seconds]
dimenus has joined #zig
<dimenus> anyone having issues building zig (master) on mingw64?
<dimenus> getting a bunch of undef references to z3_* libclangStaticAnalyzerCore
<dimenus> even with Z3 installed
<daurnimator> dimenus: 2965 and 2958 were recently merged.... does it work from before they were merged?
<scientes> we don't need maskedLoad or maskedStore
<scientes> you can just use | and & and let the optimizer figure it out
<daurnimator> scientes: I don't think that fits zig's philosophy
<scientes> daurnimator, we could just put it in std lib
<scientes> we only need @gather and @scatter
<daurnimator> scientes: e.g. if you have half of a vector next to something with PROT_NONE: i'd want to be using a masked load.
<scientes> daurnimator, ahh unaligned loads?
<daurnimator> scientes: not unaligned. but when you *do not* want to read from memory
<scientes> the optimization should just be guaranteed
<scientes> daurnimator, yeah, but it will always be 16-byte aligned, so PROT_NONE is impossible
<daurnimator> howso?
<scientes> it has to be page aligned
<daurnimator> 16-byte aligned can still go over a page long if your vector is > 16 bytes.....
<scientes> and thus is simd aligned
<scientes> again, you just have to guarantee that the optimization is wrong
<scientes> optimization is right
<scientes> LLVM has already annonced that these instructions will be deprecated too
<scientes> I feel its a bug in LLVM
<daurnimator> whats a bug?
<scientes> if it isn't getting optimized to a maskedstore/maskedload
<scientes> if you use | and &
<daurnimator> why should it be?
<daurnimator> | and & can be much slower than a masked store/load
<scientes> its equilivent
<daurnimator> no its not
<scientes> the optimizer would figure it out
<daurnimator> from http://llvm.org/docs/LangRef.html#llvm-masked-load-intrinsics > Other targets may support this intrinsic differently, for example by lowering it into a sequence of branches that guard scalar load operations. The result of this operation is equivalent to a regular vector load instruction followed by a ‘select’ between the loaded and the passthru values, predicated on the same mask.
<daurnimator> a sequence of branches guarding loads is for sure slower than plain `|` and `&`
<scientes> oh I see
<scientes> uggh, its still code smell to me
<scientes> they could add a optimization attribute
<daurnimator> scientes: from the zig side: if I didn't have @maskedLoad: how would I indicate that I want to load half a vector without reading the other half?
<scientes> I only see that it could cause problems if the pointer was unaligned
<daurnimator> it's not about alignment
<scientes> daurnimator, how do you specifiy that you only want to read one bit?
<daurnimator> you don't. a byte is called a byte because its the smallest addressable quantity
<daurnimator> however a vector is more than a byte.
<daurnimator> (at least, most of the time... I guess we can have vectors of u1 )
<scientes> and those get bit-packed
<daurnimator> right
<daurnimator> but imagine a 64 byte vector
<daurnimator> split across two pages
<scientes> it would be two vector loads
<scientes> oh, x86 is weird in that way...
<scientes> and also supports unaligned
<daurnimator> a 64 byte vector only needs to be aligned to 16 bytes.
<scientes> daurnimator, https://lwn.net/Articles/793455/#Invented%20Loads
<scientes> the compiler can load whatever the hell it wants
<scientes> it just can't modify it
<daurnimator> ??
<daurnimator> the whole point of a maskedload is to tell it it can't load whatever it wants
<scientes> well two things 1) I still think an instruction is not necessarily, but could be an attribute flag, 2) it seems like using a hammer to solve a edge condition
<daurnimator> > Edge cases matter.
<scientes> like it would be faster to test if you are at a boundary
<scientes> yes of course
<scientes> but the compiler doesn't know where the boundries
<daurnimator> exactly!
<scientes> so it generates ship code
<daurnimator> which is why it needs to be a builtin
<scientes> *shit
<scientes> it would be easier to have a check before doing the load/store
<scientes> and only then use this expensive one
<scientes> which wouldn't have to then be implemented this way
<daurnimator> `x | mask` -> may or may not access masked off bits: don't care, do whatever is fast. `@maskedLoad(x, mask)` -> do *not* access masked off bits
<scientes> well, I guess this would be OK, like on power 8 there is a load/store that takes a length
<scientes> but then you would have to do a ctz + clz + popcount
<scientes> instead of just one clz or ctz depending on where the border was that you were avoiding
<scientes> i doubt they would have the optimization to avoid that
<scientes> and see how the mask was generated
<scientes> and you could instead just use differnt length vector types
<scientes> like use a 61-byte vector
<scientes> LLVM is deprecating these instructions too
<scientes> daurnimator, how is your use-case not solved by generating a llvm type that is the length you want?
<scientes> zig can't do that well right now, but LLVM is working on it
<scientes> basically you would just page align your vector loads/stores
<scientes> by splitting them
<scientes> <daurnimator> but imagine a 64 byte vector
<scientes> <daurnimator> split across two pages
<scientes> <daurnimator> it's not about alignment
<scientes> yes it is
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
<scientes> you can't split pages if you are naturally aligned
<scientes> and page alignment is not relevent here
<scientes> *stack alignement is not relevent
ltriant has joined #zig
laaron has joined #zig
dimenus has quit [Ping timeout: 272 seconds]
<daurnimator> scientes: yes you can
<scientes> a 4k stack means the bottom 12 bits are zeros
<daurnimator> scientes: e.g. an avx-512 loads can be 64 bytes. yet it only needs to be 16-byte alignerd
<scientes> daurnimator, a 64-byte vector might have alignOf of 16 bytes
<scientes> yes, we were thinking the same thing
ltriant has quit [Ping timeout: 245 seconds]
<scientes> but that's not natural alignment
<daurnimator> ??
kristoff_it has joined #zig
<scientes> natural alignment has a strict definition
<scientes> that there is only a single bit in the size
<daurnimator> oh okay; I didn't know that definition
<scientes> maskedLoad just seems very x86 specific to me, and kindof a hack, and doing the optimizations to make it possible to use right on ppc for example, I doubt those have been done
<scientes> but yeah with the way avx-512 has 16-bit alignOf, maybe it is necessary
<scientes> *128-bit
kristoff_it has quit [Ping timeout: 245 seconds]
<daurnimator> scientes: it probably defaults to the series of branches lowering I quoted above
<scientes> even though on vsx it doesn't need to, but the optimizations would be difficult
<scientes> and the programmer would probably not generate the mask right for that either
<scientes> even though C11 would allow such a zombie read
<daurnimator> scientes: though also: doesn't llvm allow arbitrary vector sizes?
<scientes> inside of the page
<scientes> daurnimator, yes it does, but not variable length
<scientes> the lowering of those is also quite bad right now
<scientes> but it does work
<daurnimator> scientes: e.g. I could have a @Vector(8, u32768) for a vector of pages.
<scientes> lol, I don't have enough RAM to compile that
<daurnimator> huh?
<daurnimator> Why would that take lots of ram to compile?
<daurnimator> it's just 8*4KB.
<scientes> well I did 1MB
<curtisf> while it's kinda neat that zig (theoretically) supports integers that large, I question how reasonable it is to support numbers that require compiling loops to do things like addition
<scientes> also clang has a more sane max
<scientes> I was using gcc
<scientes> d.c:2:36: error: vector size too large
<scientes> typedef int badass __attribute__ ((vector_size (1024*1024)));
<scientes> daurnimator, yeah that is too large for clang
<daurnimator> curtisf: not different to targetting a 8bit microcontroller and adding u32s...
<scientes> yeah clang's max is 1024 vector_length
<curtisf> there's a difference of scale, having 4 instructions unrolled is totally different from having hundreds
NI33_ has quit [Ping timeout: 245 seconds]
<curtisf> you'd probably not want to have addition of u32768 be unrolled, which is odd
<daurnimator> curtisf: my immediate thought is of https://en.wikipedia.org/wiki/Zero_one_infinity_rule
<scientes> yeah the gcc 1MB simd multiplication is still compiling
<daurnimator> scientes: you had to pick multiplication :P
<curtisf> I agree, there's no good place to put the limit. This is more like a "please don't do this" feature
<daurnimator> scientes: try e.g. a XOR instead. which isn't completely unreasonable for some cryptography algorithms.
<scientes> daurnimator, oh wow, it just turned it into a loop!
<scientes> without and simd at all
<scientes> oh, that is because its xor with itsself
<daurnimator> xor with itself should just give you a zero vector :P
<scientes> yeah with optimizations it used memset()
<scientes> d.c:3:8: note: The ABI for passing parameters with 1048576-byte alignment has changed in GCC 4.6
<scientes> lawl
<scientes> yeah, not enough RAM
<daurnimator> scientes: can you share your sample. I want to try for myselfd
<scientes> it would be easy to do in zig too
<scientes> i'm just lazy
<scientes> and i wanted to try gcc
ltriant has joined #zig
<daurnimator> scientes: https://godbolt.org/z/I2ulBM works
<scientes> but it doesn't generate a loop
<scientes> because we are abusing it
<scientes> daurnimator, aww yeah https://godbolt.org/z/rGLdw0
_whitelogger has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 272 seconds]
darithorn has quit [Quit: Leaving]
Sahnvour has quit [Ping timeout: 245 seconds]
Sahnvour has joined #zig
curtisf has quit [Remote host closed the connection]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 248 seconds]
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #zig
jjido has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
hio has joined #zig
ltriant has quit [Quit: leaving]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 246 seconds]
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #zig
talin has joined #zig
marijnfs has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 258 seconds]
laaron has quit [Remote host closed the connection]
laaron has joined #zig
avoidr has quit [Quit: leaving]
kristoff_it has joined #zig
commande1 has joined #zig
commander has quit [Ping timeout: 244 seconds]
laaron has quit [Remote host closed the connection]
laaron has joined #zig
shachaf has quit [Ping timeout: 245 seconds]
shachaf has joined #zig
marijnfs has quit [Ping timeout: 245 seconds]
omglasers2 has joined #zig
kristoff_it has quit [Remote host closed the connection]
NI33_ has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 245 seconds]
knebulae has quit [Ping timeout: 248 seconds]
rappet has quit [Quit: -]
rappet has joined #zig
marijnfs has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Remote host closed the connection]
mattmurr has joined #zig
kristoff_it has joined #zig
GoorMoon has joined #zig
SimonNa has quit [Ping timeout: 246 seconds]
SimonNa has joined #zig
GoorMoon has quit [Quit: rcirc on GNU Emacs 25.2.1]
GoorMoon has joined #zig
SimonN has joined #zig
SimonNa has quit [Ping timeout: 268 seconds]
GoorMoon has quit [Quit: ERC (IRC client for Emacs 25.2.1)]
dimenus has joined #zig
<gonz_> Hmm, is subsystem detection broken?
dimenus has quit [Remote host closed the connection]
<gonz_> Having `WinMain` and not `main` seems to still give `windows.subsystem == .Console`
FireFox317 has joined #zig
FireFox317 has quit [Remote host closed the connection]
NI33_ has quit [Ping timeout: 272 seconds]
omglasers2 has quit [Quit: leaving]
omglasers2 has joined #zig
NI33_ has joined #zig
halosghost has joined #zig
andersfr has joined #zig
<Tetralux> What's a good example of how to use .format on your type so that you can print it with warn?
darithorn has joined #zig
<Tetralux> Nvm - figured it out :)
andersfr has quit []
sammich has quit [Quit: No Ping reply in 180 seconds.]
sammich has joined #zig
knebulae has joined #zig
omglasers2 has quit [Quit: leaving]
Akuli has joined #zig
laaron has quit [Remote host closed the connection]
tracernz has quit [Ping timeout: 252 seconds]
tracernz has joined #zig
tracernz has quit [Ping timeout: 245 seconds]
tracernz has joined #zig
samtebbs has quit [Quit: leaving]
marijnfs has quit [Ping timeout: 272 seconds]
omglasers2 has joined #zig
kristoff_it has quit [Ping timeout: 244 seconds]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 272 seconds]
emekankurumeh[m] has joined #zig
<emekankurumeh[m]> dimenus: it seems like I introduced a regression
kristoff_it has joined #zig
omglasers2 has quit [Quit: Leaving]
kristoff_it has quit [Ping timeout: 246 seconds]
omglasers2 has joined #zig
omglasers2 has quit [Client Quit]
omglasers2 has joined #zig
kristoff_it has joined #zig
darithorn has quit [Quit: Leaving]
kristoff_it has quit [Ping timeout: 272 seconds]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 258 seconds]
wootehfoot has joined #zig
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 244 seconds]
Akuli has quit [Quit: Leaving]
Hourglass has joined #zig
kristoff_it has joined #zig
<Hourglass> Hello, I'm having trouble building clashos (https://github.com/andrewrk/clashos) with zig
kristoff_it has quit [Ping timeout: 245 seconds]
<Hourglass> I'm using zig 4.0 and the host machine is a 64bit debian
<scientes> Hourglass, you should use master for now
<Hourglass> the actual compilation seems to work fine but then the build script stalls when using objcopy
<Hourglass> so i'm not sure swithing to master will do any good
<Hourglass> specifically objcopy complains that the input file format is not recognizable
<Hourglass> I've checked with hexdump and it looks like a regular ELF file (and readelf agrees also)
<nrdmn> Hourglass: what does readelf -h say about it?
<emekankurumeh[m]> @dimenus: i'm not getting any build errors...
<emekankurumeh[m]> are you static linking or dynamic linking?
<nrdmn> Hourglass: I mean, what's the exact output
<Hourglass> En-tête ELF:
<Hourglass> Classe: ELF64
<Hourglass> Données: complément à 2, système à octets de poids faible d'abord (little endian)
<Hourglass> Version: 1 (current)
<Hourglass> Magique: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
<Hourglass> OS/ABI: UNIX - System V
<Hourglass> Version ABI: 0
<Hourglass> Type: EXEC (fichier exécutable)
<Hourglass> Machine: AArch64
<Hourglass> Version: 0x1
<Hourglass> Adresse du point d'entrée: 0x0
<Hourglass> Début des en-têtes de programme : 64 (octets dans le fichier)
<halosghost> LC_ALL=C might be useful for some folk
<nrdmn> Hourglass: does your objcopy support AArch64?
<Hourglass> nrdmn: good question, I don't know. How can I check that ?
<nrdmn> objcopy --info
<Hourglass> nrdmn: good catch, it doesn't. I suppose its logical since my host computer is x86_64 and I'm trying to target arm64. I'm a bi new to this cross-compilation stuff
<Hourglass> *bit
<nrdmn> hmm, there seems to be no way to create a File with an outStream() method that returns an OutStream with a custom OutStream.stream.writeFn
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 272 seconds]
Ichorio has joined #zig
<nrdmn> which makes it difficult to support platforms where stdin, stdout, stderr aren't files
jjido has joined #zig
<emekankurumeh[m]> daurnimator: can you point me to some implementations or header files that define `sockaddr_any`?
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kristoff_it has joined #zig
jjido has joined #zig
omglasers2 has quit [Quit: Leaving]
FireFox317 has joined #zig
<FireFox317> gonz_: I found the issue for the subsystem detection. You have to declare the WinMain function as a pub function. In the example that andrewrk gave this wasn't specified and that caused the issue.
<FireFox317> Maybe we should add the same restriction that the 'normal' main function has. Namely the fact that the main function needs to be pub.
Hourglass has left #zig [#zig]
<FireFox317> Not sure how to properly solve this
<gonz_> Indeed, that was the reason
<gonz_> `pub export` seems to do the trick
<FireFox317> I will make a issue to track this.
wootehfoot has quit [Read error: Connection reset by peer]
<gonz_> In retrospect it's somehow obvious
knebulae has quit [Ping timeout: 268 seconds]
<FireFox317> Yeah it is, but the detection should be polished a bit
<gonz_> The annoying thing is it half-working without the `pub`, yes
<gonz_> If it didn't, you might just try adding it and end up where you needed to be
halosghost has quit [Quit: WeeChat 2.5]
FireFox317 has quit [Remote host closed the connection]
knebulae has joined #zig
kristoff_it has quit [Remote host closed the connection]
darithorn has joined #zig
kristoff_it has joined #zig
jmiven has quit [Quit: reboot]
jmiven has joined #zig
reductum has joined #zig
kristoff_it has quit [Ping timeout: 272 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<andrewrk> how does one order a pinebook pro?
<andrewrk> gonz_, it's a bug, pub should not be required if the function is exported
<THFKA4> i think you need a forum account that's older than a month
<THFKA4> which you then use to get a coupon code during checkout
<andrewrk> I found a support email address. I sent them a description of my use case, hopefully they let me buy one
<bwb_> woah, they are way cheaper than I expected
ltriant has joined #zig
Ichorio has quit [Ping timeout: 264 seconds]
<fengb> Wow that's cheap
<daurnimator> andrewrk: FWIW I have a box from works-on-arm. it's a beast of a machine
<daurnimator> we'd be allowed to use it for zig if we wanted
<daurnimator> just give me a daemon to run on it to run CI jobs
<daurnimator> which I guess is where gitlab CI might come in
<andrewrk> daurnimator, I believe that's what https://github.com/ziglang/zig/pull/2978 is
<daurnimator> because you can run your own runners.
<daurnimator> andrewrk: ah yes. "Andrew could also set up an official gitlab mirror, and then just authenticate the arm64 CI runner"
<daurnimator> andrewrk: I think that would be a good way forward for a lot of platforms where existing CI providers don't exist
<andrewrk> agreed
kristoff_it has joined #zig
<daurnimator> andrewrk: if you set up the gitlab account I'm happy to start the runner
<daurnimator> the box is a https://www.packet.com/cloud/servers/c2-large-arm/ --> 32 cores; 128GB RAM; 20GBit net connection...
kristoff_it has quit [Ping timeout: 244 seconds]
<bwb_> I might have a spare cavium around here...
<bwb_> lemme check
hio has quit [Quit: Connection closed for inactivity]
<andrewrk> daurnimator, nice, let me try setting that up now