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/
<Sphax> oh right. I was confused about what []const actually means but I think I get it now
ur5us has quit [Ping timeout: 260 seconds]
mahmudov has quit [Remote host closed the connection]
ur5us has joined #zig
layneson has quit [Ping timeout: 250 seconds]
darithorn has joined #zig
_Vi has quit [Ping timeout: 246 seconds]
layneson has joined #zig
marijnfs has joined #zig
marijnfs_ has quit [Ping timeout: 256 seconds]
nephele_ has joined #zig
nephele has quit [Ping timeout: 260 seconds]
Kingsquee has joined #zig
<fengb> Wow, watching some C++ videos, allocations are sneaky
<daurnimator> > andrewrk>TheLemonMan, do you think we should rename the arch from sparcv9 to sparc64? --> andrewrk: sparc64 was a specific processor. sparcv9 is the architecture of it.
ur5us has quit [Ping timeout: 260 seconds]
ur5us has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
joey152 has joined #zig
<shakesoda> illegal instruction on the pi zero trying to run that zig binary :(
<fengb> Program received signal SIGILL, Illegal instruction. -- 0x025bf470 in __ARMv7ABSLongThunk___libc_start_main ()
<shakesoda> yeah, that's the one
ur5us has quit [Ping timeout: 260 seconds]
layneson has quit [Ping timeout: 256 seconds]
casaca has quit [Remote host closed the connection]
_whitelogger has joined #zig
joey152 has quit [Ping timeout: 256 seconds]
darithorn has quit [Quit: Leaving]
MajorLag has joined #zig
tgschultz has quit [Ping timeout: 250 seconds]
MajorLag is now known as tgschultz
cole-h has quit [Quit: Goodbye]
FireFox317 has joined #zig
FireFox317 has quit [Remote host closed the connection]
ur5us has joined #zig
dermetfan has joined #zig
notjones has joined #zig
FireFox317 has joined #zig
<FireFox317> fengb, shakesoda will look into it. the `__ARMv7ABSLongThunk` is suspicious, it shouldn't be ARMv7
drvirgilio has quit [Remote host closed the connection]
doublej472 has quit [Ping timeout: 246 seconds]
doublej472 has joined #zig
drvirgilio has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
marijnfs has quit [Quit: Lost terminal]
dermetfan has quit [Ping timeout: 246 seconds]
marijnfs has joined #zig
_Vi has joined #zig
omglasers2 has joined #zig
<omglasers2> This snippet has the wrong output on windows https://pastebin.com/cfGktQ3u I'm on master. It replaces the first character in the outputted value with '!'. Is it a bug ?
<daurnimator> omglasers2: I'm able to replicate in wine.... investigating/.
Kingsquee has quit [Quit: Konversation terminated!]
<wilsonk> omglasers2: it works correctly on linux...also fails here on wine64
<FireFox317> i think its because it includes the '\r'
<FireFox317> you are reading until '\n' so buf will contain '<sometext>\r'
<wilsonk> omglasers2: yep, it works correctly if you just readUntil... \r
<FireFox317> omglasers2, probably should read until '\r\n' then
ur5us has joined #zig
<wilsonk> FireFox317: that function only allows a single char as the second arg...and if you change it to \r then the linux version fails, of course. Change for each OS? Or is there a version of readUntil that takes more than a single char?
<FireFox317> wilsonk, yeah we should probably have something in the stdlib that sets the line delimiter for a platform, so you can use that. However on windows you can also have files that just use the linux line endings
<wilsonk> ugh, windows is such a pain
<FireFox317> Maybe we should have a function that detects which line endings are used in a file or something
waleee-cl has joined #zig
<daurnimator> FireFox317: which file would that be?
<daurnimator> generally in other languages (which take it from C I assume): when you `open` you pass a flag indicating "text" mode or "binary" mode.
<daurnimator> where binary mode writes exactly what you tell it
<daurnimator> and "text" mode inserts \r on windows
<daurnimator> in languages that differentiate "array of u8" vs "string" they also usually have read() on files open in "text" mode return strings and while files in "binary" mode have read() return an array of u8
<wilsonk> I will check what the verdict is tomorrow :) ...off to bed. Night all
ifreund has joined #zig
TheLemonMan has joined #zig
<TheLemonMan> FireFox317, yo, lld was tricked into thinking you're targeting a v7 or greater arch
<TheLemonMan> check out the individual files build-attributes with `llvm-readobj --arch-specific <file>`
ur5us has quit [Ping timeout: 260 seconds]
<daurnimator> TheLemonMan: do I recall you mentioning something about the macho linker getting better recently?
<TheLemonMan> daurnimator, Apple decided to throw it away and restart from scratch
<daurnimator> TheLemonMan: in LLD?
<TheLemonMan> yeah
<daurnimator> And its getting upstreamed?
<TheLemonMan> yeah
<daurnimator> nice! expected to be done by LLVM 11?
<TheLemonMan> maybe 13 or 14
<daurnimator> ouch
mahmudov has joined #zig
wootehfoot has joined #zig
<FireFox317> TheLemonMan, llvm-readobj has no --arch-specific flag
zfoo has joined #zig
<FireFox317> but i'm sure you are correct about the fact that lld gets ticked somehow
FireFox317 has quit [Quit: Leaving]
FireFox317 has joined #zig
josch557 has joined #zig
RagingDave has joined #zig
RagingDave has quit [Client Quit]
riba has joined #zig
dermetfan has joined #zig
<TheLemonMan> FireFox317, worksforme with llvm-readobj-10
josch557 has quit [Ping timeout: 260 seconds]
dddddd has joined #zig
riba has quit [Ping timeout: 250 seconds]
<omglasers2> using readUntilDelimiterOrEof with '\r' works ok on windows so I guess I'll use that for now; another thing, how can I read an int from the cmd ? tried with readIntNative but it returns gibberish
<ikskuh> readIntNative reads a literal int value (as in 4 bytes for an u32) from the slice
<ikskuh> and interprets it with native endianess
<ikskuh> use std.fmt.parseInt instead
layneson has joined #zig
<omglasers2> thanks, it worked
recombinant has joined #zig
r4pr0n has joined #zig
<r4pr0n> Hey, I looked and the wiki and the issue page about it, but I'm still curious: Why does zig encourage spaces over tabs, especially since zig fmt isn't configurable and the cpp compiled doesn't allow hard tabs at all. I know having one convention for the language ecosystem is good, but why spaces? I know this is kind of a flamewar theme but when I looked into it, I saw much more arguments for tab
<r4pr0n> indentation, e.g. for accessibility or aesthetic reasons, so why chose zig to encourage spaces?
josch557 has joined #zig
<ifreund> i personally plan on switching to tabs if/when it becomes possible
<r4pr0n> yeah i'd also do that, but then i couldn't even use zig fmt
<ifreund> i think we'll see a fork of zig fmt that uses tabs once there is a compiler that supports them
<ifreund> if nobody else makes it i will
mattmurr has quit [Quit: ZNC 1.7.2+deb3 - https://znc.in]
mattmurr has joined #zig
cole-h has joined #zig
<companion_cube> the aesthetic reason is a subjective one, and I think andrewrk just picked something he liked to end discussions
mattmurr has quit [Remote host closed the connection]
mattmurr has joined #zig
<r4pr0n> companion_cube: well not really, because i think tabs are superior for aesthetics, because everyone can choose how he wants them to look
<r4pr0n> when with spaces, you force someone to look at the code how you want it to look
<companion_cube> r4pr0n: unless you have code that looks butt-ugly in 8 spaces (which is how it'll display in github and many other places)
<companion_cube> so it seems it works best for imperative, statement oriented languages, like Go and C, with very shallow indentation
<companion_cube> I've yet to see an expression based language use tabs successfully in a way that looks reasonable, all the ones I can think of are at most 4 spaces
<fengb> We should adopt fibonacci indents
<companion_cube> comptime indents
<shakesoda> space indentation denies the programmer agency
<shakesoda> I WILL HAVE MY FREEDOM FROM SUCH OPPRESSION
<shakesoda> also, hello
<companion_cube> :D
<ikskuh> there's only one reasonable way of life: tabs to indent, spaces to align
<ikskuh> but no editor supports this right
<ikskuh> they think they are smart by replacing "4 spaces with a tab" because that code is surely indented
<shakesoda> ikskuh: i agree, but have also mostly given up on trying to align
<fengb> Zig just zaps your alignment. It’s fine!
<shakesoda> also, 3-width tabs here
<ikskuh> yeah, true
<ikskuh> zig fmt makes it easy because you are not allowed to decide
<shakesoda> i don't hold the indentation so close to my heart that it matters much, but i'd rather i weren't forced into specific indent widths against my will
<companion_cube> I've seen 3 spaces in C code, it's funny
<ikskuh> i usually use 2 nowadays
<ikskuh> makes the code less broad
<fengb> I use 4
<fengb> Because zig fmt 🙃
Akuli has joined #zig
<shakesoda> companion_cube: i'd do that
<shakesoda> but i don't
<shakesoda> i'd have done so in zig, but zig fmt just changes it anyways, so whatever.
<companion_cube> 🤷
<fengb> Thanks to Vexu, we're down to <1000 issues again :P
joey152 has joined #zig
knebulae has quit [Quit: Leaving]
<jaredmm> Obviously zig fmt should be added as a pre-commit hook to remove all leading/trailing tabs and spaces and your IDE should reformat the code to your preferred silly spacing.
knebulae has joined #zig
ifreund has quit [Quit: WeeChat 2.8]
marijnfs has quit [Quit: Lost terminal]
ifreund has joined #zig
marijnfs has joined #zig
recombinant has quit [Ping timeout: 240 seconds]
wootehfoot has quit [Ping timeout: 260 seconds]
layneson has left #zig ["WeeChat 2.4"]
marijnfs has quit [Ping timeout: 258 seconds]
<shakesoda> just solve everything with infrastructure, infinite levels deep, until it's like you're actually working with java tooling that takes a hundred years to get any work done at all
<shakesoda> that's how you know zig is finally ready for the enterprise
<companion_cube> spring.zig
Ichorio has joined #zig
nairou has joined #zig
<fengb> Unfortunately, spring was actually peeling back layers >_>
<ikskuh> summer.zig
<ikskuh> because the sun always shines in zig land
<fengb> SUN?
wootehfoot has joined #zig
<ikskuh> with sparc!
cole-h has quit [Ping timeout: 256 seconds]
<ikskuh> hmm
<ikskuh> making "type" a top-level variable is quite annoying some time
<ikskuh> what are good alternatives for the word "type"?
<fengb> kind is used a lot in std
<fengb> I usually just use @“type” :P
<ikskuh> TokenKind?
<ikskuh> kind: TokenKind
<ikskuh> hm
<fengb> I see TokenId a bunch
<ikskuh> i wonder
<ikskuh> i have a token iterator that stores a []const u8
<ikskuh> i think i just update the slice every time i iterate
<ikskuh> instead of storing an index to it :D
<ikskuh> no one needs to go back!
<ikskuh> ah wait
<ikskuh> stupid me. i can use type as a field name :D
<ifreund> hey, so it looks like std.ChildProcess is supposed to inherit the environ of the calling process like execl(3) does
<ifreund> however, this doesn't seem to be working properly for an environment variable I set during runtime with setenv(3)
<ifreund> anyone else seen this behavior?
<ifreund> I guess I should probably open an issue
frett27_ has joined #zig
wilsonk has quit [Ping timeout: 260 seconds]
recombinant has joined #zig
recombinant has quit [Client Quit]
wilsonk has joined #zig
frett27 has joined #zig
FireFox317 has quit [Quit: Leaving]
frett27_ has quit [Ping timeout: 260 seconds]
performative has joined #zig
<r4pr0n> companion_cube: you can set it for github
<r4pr0n> and for many other places
<companion_cube> with spaces I don't have to setup anything :)
FireFox317 has joined #zig
<nairou> Regarding the zig build system, I'm currently using it for a non-zig (C) project. Works great. However, I have a list of cflags I pass to each addCSourceFile() call, and I want to conditionally add additional flags to that list depending on whether I've requested a debug build. From what I can tell, a debug build would be a separate build step, but in this case I'm using the same list. Is there a way to know, within the builder, what
<nairou> the sepected build was on the command line? I can't find any examples that do something like this.
marijnfs has joined #zig
cole-h has joined #zig
<nairou> sepected = specific
cole-h has quit [Client Quit]
cole-h has joined #zig
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<FireFox317> i'm not sure if you generated the build.zig file using `zig init-exe` but there is a `const mode = b.standardReleaseOptions();` in there. you can check which mode you are in by doing `if (mode == .Debug)` or something
<FireFox317> nairou ^^
<nairou> Ah nice. Mine was custom, patched together from examples, but I'll look into that. Thanks!
dddddd_ has joined #zig
daurnimator has quit [Remote host closed the connection]
dddddd has quit [Ping timeout: 240 seconds]
dddddd_ is now known as dddddd
frett27_ has joined #zig
frett27 has quit [Ping timeout: 258 seconds]
FireFox317 has quit [Ping timeout: 258 seconds]
nairou has quit [Quit: Leaving]
marijnfs has quit [Ping timeout: 256 seconds]
ur5us has joined #zig
josch557 has quit [Quit: ERC (IRC client for Emacs 26.3)]
Akuli has quit [Quit: Leaving]
performative has quit [Quit: Leaving]
wootehfoot has quit [Ping timeout: 250 seconds]
mixi has quit [Quit: quit]
mixi has joined #zig
cole-h has quit [Ping timeout: 265 seconds]
<joey152> has anybody else had a segfault when building the zig master branch
<joey152> it segfaults trying to build libzigstage2.a
marijnfs has joined #zig
<marijnfs> what is a good way to cast a ?*c_void to a useful type when dealing with c functions?
<shakesoda> marijnfs: perhaps @ptrCast(*T, whatever.?)
<marijnfs> i guess the issue is i want a []u8 out of it, or anything mem.copy accepts
<shakesoda> if you know the length you can cast it to a [*]u8 and then slice that
<marijnfs> shakesoda: if i do that ptrCast it does seem to pass through but mem.copy doesn't like that
<marijnfs> ah
<marijnfs> maybe thats it
<shakesoda> so cast to [*]u8, then foo[0..len]
<marijnfs> yeah that works, thanks
cole-h has joined #zig
daex has quit [Ping timeout: 256 seconds]
daex has joined #zig
FireFox317 has joined #zig
omglasers2 has quit [Read error: Connection reset by peer]
<ifreund> alright this seems dumb, how can I avoid duplicating all of the linking stuff for the test exe in my build.zig? https://github.com/ifreund/river/blob/master/build.zig
<FireFox317> fengb, shakesoda, would you like to try running zig on a rpi0/rpi1 again? andrewrk changed some stuff in the build project. the armv7_libc_start symbol is now gone. https://drive.google.com/file/d/1CGnmbMPBf78KSXFSwAfVumZZu9BglSzg/view?usp=sharing
<fengb> Sure
<shakesoda> giving it a go
<shakesoda> or at least i will, whenever drive lets me
<andrewrk> FireFox317, wow that was fast
<FireFox317> andrewrk, updated the build script manually after your first message :)
<andrewrk> nice
<shakesoda> good old super definitely fast sd card io
<shakesoda> FireFox317: this one runs!
<andrewrk> great, thank you both for figuring that out before the release
<fengb> Showoff!
<FireFox317> i probably should have done a clean run, but it looked like the caching system was working correctly because stuff was rebuilding. also the symbol libc_start symbol changed to `__ARMv5ABSLongThunk___libc_start_main`
<FireFox317> Nice shakesoda!!
<shakesoda> seeing if it successfully runs a hello world, too
<andrewrk> FireFox317, you shouldn't normally have to do a clean run. I just wanted to make sure the recent changes (not just the last one) to the build script worked
<FireFox317> yes makes sense
<shakesoda> it's taking its sweet time, but nothing seems to have gone wrong yet
<FireFox317> yeah first time will be slow for sure, zig has to build all the stuff for the first time :)
<fengb> Yeah I don't think I'll be using this Pi to build Zig code lol
<shakesoda> hmmm, bad alloc
* shakesoda tries again
<FireFox317> hmm, out of ram?
<shakesoda> yeah, code generation 327/1845 died
<fengb> $ ../zig-rpi0-rpi1/zig run blah.zig
<fengb> hello world!
<fengb> It works!
<shakesoda> yeah, it's absolutely eating all my ram
<shakesoda> working though
<shakesoda> hopefully it can survive this time without me throwing more swap at it
<shakesoda> nope!
<FireFox317> sad :(
<shakesoda> using more ram than the system has is a shame, but at least not hard to work around
<FireFox317> but fengb yours worked? probably one a rpi1 and shakesoda is testing on a rpi0?
<fengb> I'm on a pi0
<fengb> I spent a bit of time tweaking the memory profile earlier today though :P
<shakesoda> I'm on a pi zero (512mb ram, 100mb swap)
<andrewrk> goodness, how much ram does zig want for hello world?
<shakesoda> apparently a lot to build the initial cache
<andrewrk> that's compiler-rt and freestanding libc
<shakesoda> so hungry :(
<fengb> Do I need libc even without linking it in?
<andrewrk> llvm always generates calls to memcpy, memset, and a few others. that's what I mean by "freestanding libc"
<fengb> Ah
<FireFox317> i mean, this is the limitation of stage1 right? it is not optimized for devices with small memory.
<andrewrk> correct
<andrewrk> bootstrapping zig on a pi zero would be extremely painful, haha
<andrewrk> (but possible, in theory)
<fengb> I need to figure out how to give this a few gigs of swap
<fengb> Then I could try
<shakesoda> increased my swap to 512mb, this will be painfully slow but shouldn't run out anymore
<fengb> Hmm, it took around ~150MB of RAM on my box
<shakesoda> fengb: # dphys-swapfile swapoff; edit /etc/dphys-swapfile, dphys-swapfile setup; dphys-swapfile swapon
<fengb> Yeah but I don't want to use my crappy SD card as swap. It's already dying as is >_>
<shakesoda> (assuming you're running something about the same as my hardly altered raspbian)
<shakesoda> heh, this is running a lot faster now actually
<andrewrk> you could try running `zig fmt` and see how well that performs. that is self-hosted
<andrewrk> I mean with regards to memory used
<shakesoda> would it be possible to include a prebuilt initial cache for the native target for releases?
<shakesoda> that'd be handy on the really low power ones
<andrewrk> I don't think that's going to happen
<shakesoda> it's an edge case, just curious
<andrewrk> yeah it's definitely possible
<shakesoda> hopefully after this first build the regular ones run at a sensible pace
<shakesoda> if so, i can switch all my c code on the zero to zig
<andrewrk> you build C code using the zero?
<Snektron> Why not cross compile?
<shakesoda> I write and build on the thing, yes.
<Snektron> ouch, that must take a while
<shakesoda> not really.
<shakesoda> c builds of just a few files at any given time are no big deal
marijnfs has quit [Quit: Lost terminal]
Ichorio has quit [Ping timeout: 260 seconds]
<shakesoda> time for zig build run on hello world (with a nice warm cache) is... 41 seconds D:
<shakesoda> a few orders of magnitude slower than the c i've been building
<shakesoda> actual number: that project takes 7 seconds
<shakesoda> (5 seconds on second run)
<FireFox317> shakesoda, i'm a bit worried that the bootstrapped zig contains armv5 code instead of armv6, because now the libc_start symbol is: `__ARMv5ABSLongThunk___libc_start_main`. maybe that's why its so slow
<shakesoda> FireFox317: that could do it
<shakesoda> if true
<shakesoda> i'm happy that it works at all, really
<FireFox317> jup, that is definitely cool
<andrewrk> maybe v6 and v5 have the same thunk code?
frett27_ has quit [Ping timeout: 260 seconds]
<FireFox317> could be, i'm not sure. Time to get some sleep now :)
<fengb> Good night!
<andrewrk> night
layneson has joined #zig
FireFox317 has quit [Quit: Leaving]
<andrewrk> mikdusan, uploaded
_Vi has quit [Ping timeout: 246 seconds]
dermetfan has quit [Ping timeout: 260 seconds]
ifreund has quit [Ping timeout: 256 seconds]