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/
atkh has quit [Ping timeout: 265 seconds]
atkh has joined #zig
<LewisGaul> Ok, created https://gist.github.com/LewisGaul/d5b303da9c03bf95f778c64e12ef1c5e! Lots of posts I hadn't come across before actually. Should/Could the Community wiki be edited to link to this?
<LewisGaul> The exclamation mark got munged into the URL, should've been https://gist.github.com/LewisGaul/d5b303da9c03bf95f778c64e12ef1c5e
LewisGaul has quit [Ping timeout: 240 seconds]
ed_t has joined #zig
fputs has joined #zig
decentpenguin has quit [Ping timeout: 246 seconds]
decentpenguin has joined #zig
rowbee is now known as rohb
nvmd has quit [Quit: Later nerds.]
Ren_V has joined #zig
ur5us_ has quit [Ping timeout: 264 seconds]
brzg has joined #zig
Ren_V has left #zig [#zig]
<jah> Is there an idiomatic way to add signed/unsigned integers together (eg. u16 + i16)? I'm currently casting up to a larger signed int width (i32), adding, bitCasting (u32), and truncating down to original int width (u16). Am I'm missing something obvious?
ur5us_ has joined #zig
tomku has quit [Quit: Lost terminal]
osa1 has quit [Ping timeout: 260 seconds]
tomku has joined #zig
brzg has quit [Quit: leaving]
sebonirc has quit [Quit: sebonirc]
_whitelogger has joined #zig
texno has joined #zig
<jah> andrewrk: yes, thank you. that's much more concise
texno has quit [Ping timeout: 260 seconds]
texno has joined #zig
<andrewrk> g-w1, yep. posted a review
<andrewrk> g-w1, btw how's your elf thingie coming along?
<g-w1> very nice, im writing a blog post too! see a draft here https://github.com/g-w1/blog/blob/master/_drafts/2021-3-08-elf-linux.md
<g-w1> trying to learn about negative numbers in x64 to write some jumps for the loops in brainfuck. then im done
xackus has quit [Ping timeout: 256 seconds]
xackus has joined #zig
zags has quit [Ping timeout: 246 seconds]
xackus_ has joined #zig
<andrewrk> ooh that's really neat how you can do the elf header in nasm
<g-w1> yeah, it helped me understand it a lot
xackus has quit [Ping timeout: 264 seconds]
<g-w1> andrewrk: it seems they are already tested in tokenizer.zig:1744
<andrewrk> brilliant, then we can delete all those files
<andrewrk> and the corresponding line in behavior.zig
<g-w1> ok cool
mshockwave has quit [Quit: Lost terminal]
redj has quit [Read error: Connection reset by peer]
redj has joined #zig
<g-w1> andrewrk: stage2 fails to parse test/stage1/behavior/syntax.zig:26:1: error: expected ';' or '{', found 'fn'
<g-w1> is this a regression, or just a weird/outdated case?
<andrewrk> time to consult the spec
<g-w1> the spec likes it, so ig its a regression
<andrewrk> let me double check with martin on this one, I recall discussing possibly introducing a rule to simplify the grammar here
<andrewrk> e.g. maybe you need parens on the return type when it's a complex expression like this
<g-w1> ah, I will make the pull request anyways (I had to make a new one since I force pushed, and I can always delete that test case)
leon-p has quit [Quit: leaving]
texno has quit [Ping timeout: 260 seconds]
texno has joined #zig
suhashebbar[m] has joined #zig
<andrewrk> thanks!
ur5us_ has quit [Ping timeout: 264 seconds]
terinjokes has quit [Quit: ZNC 1.8.1 - https://znc.in]
xackus_ has quit [Ping timeout: 264 seconds]
terinjokes has joined #zig
a_chou has joined #zig
a_chou has quit [Remote host closed the connection]
craigo has joined #zig
earnestly has quit [Ping timeout: 260 seconds]
texno has quit [Ping timeout: 256 seconds]
voldial has quit [Quit: WeeChat 1.0.1]
earnestly has joined #zig
sundbp has quit [Ping timeout: 260 seconds]
osa1 has joined #zig
<mikdusan> andrewrk: I'd like to commit #8194 now that 12.0.0-rc3 is out. ok?
sord937 has joined #zig
ur5us_ has joined #zig
dyeplexer has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
<andrewrk> mikdusan, yep
johannes has joined #zig
johannes is now known as kenran
tnorth has joined #zig
kenran has quit [Remote host closed the connection]
johannes has joined #zig
<mikdusan> closing #8130. perhaps update https://bugs.llvm.org/show_bug.cgi?id=49401
<mikdusan> actually I'll let you close #8130 once upstream bug report is closed.
decentpenguin has quit [Quit: ZNC crashed or something]
decentpenguin has joined #zig
greaser|q has quit [Changing host]
greaser|q has joined #zig
greaser|q is now known as GreaseMonkey
johannes has quit [Ping timeout: 246 seconds]
ur5us_ has quit [Ping timeout: 264 seconds]
kevinsjoberg has joined #zig
chivay has quit [Remote host closed the connection]
chivay has joined #zig
kevinsjoberg has quit [Quit: Ping timeout (120 seconds)]
kevinsjoberg has joined #zig
sundbp has joined #zig
<daurnimator> andrewrk, jah: `@as(i32, the_u16) + the_i16` that should be `%+` rather than `+`
kevinsjoberg has quit [Ping timeout: 240 seconds]
<andrewrk> daurnimator, I don't think so - why?
kevinsjoberg has joined #zig
<daurnimator> andrewrk: 0x7fffffff + 5 ==> will happily fit in the result of a u32; but with your code from before would have an overflow error
<daurnimator> oh wait, you upcasted to i32 not i16
<daurnimator> doh
<daurnimator> I thought this was a case of https://github.com/ziglang/zig/issues/7416
forgot-password has joined #zig
<forgot-password> Is there any case in which it is safe to return a stack allocated buffer from a function?
<daurnimator> forgot-password: yes.... when its called at comptime
txdv has joined #zig
kevinsjoberg has quit [Quit: Ping timeout (120 seconds)]
kevinsjoberg has joined #zig
<forgot-password> Thanks :)
<daurnimator> which is quite dangerous :(
<txdv> pub fn(buf: [36]u8) void { buf[0] = 'a'; }  //cannot assign to c onstant, how do I tell the compiler that this is should be not const?
<txdv> I am passing 36 bytes by value I guess, need to pass it by ref
<Nypsie> parameters are constant by default, you'll have to pass a pointer to it
duck2 has joined #zig
nycex- has joined #zig
nycex- has quit [Remote host closed the connection]
nycex- has joined #zig
nycex has quit [Ping timeout: 268 seconds]
cole-h has quit [Ping timeout: 245 seconds]
ur5us_ has joined #zig
snamber has joined #zig
ur5us_ has quit [Ping timeout: 264 seconds]
snamber__ has joined #zig
snamber__ has quit [Client Quit]
snamber has quit [Ping timeout: 264 seconds]
snamber has joined #zig
detha has joined #zig
ubert has joined #zig
kevinsjoberg has quit [Quit: Ping timeout (120 seconds)]
ubert has quit [Remote host closed the connection]
FireFox317 has joined #zig
snamber has quit [Quit: Leaving...]
<txdv> Can i cross compile win32 apps on macosx ?
<txdv> I just did zig c++ -target x86_64-windows-gnu main.cpp and it just compiled
<ikskuh> yes.
<txdv> We need more andrews to code software like this
<ikskuh> you can also build macos software from windows :)
FireFox317 has quit [Quit: Leaving]
forgot-password has quit [Ping timeout: 276 seconds]
<txdv> Calling objective C might be difficult
<ikskuh> true
zags has joined #zig
txdv has quit [Quit: Connection closed]
txdv has joined #zig
forgot-password has joined #zig
forgot-password has quit [Ping timeout: 256 seconds]
txdv has quit [Quit: Connection closed]
forgot-password has joined #zig
txdv has joined #zig
midgard_ has quit [Ping timeout: 264 seconds]
snamber has joined #zig
snamber has left #zig [#zig]
snamber has joined #zig
midgard has joined #zig
craftinglinks has joined #zig
snamber has quit [Quit: Leaving...]
zags has quit [Quit: leaving]
craftinglinks has quit [Ping timeout: 240 seconds]
FireFox317 has joined #zig
Kiori has joined #zig
<forgot-password> When I alloc a list of an optional type, are all values automatically initialized to null?
<g-w1> no
<forgot-password> That makes sense to me, but when I print all elements I get null for every single index
<ifreund> forgot-password: try it in a safe build mode
<g-w1> it *could* be null, but it does not have to be i think
<forgot-password> Isn't debug supposed to be a safe build mode?
<g-w1> yes
<ifreund> indeed, how are you allocating?
<ifreund> the memory you get back from any allocator is undefined
<ifreund> in safe build modes I think it should be therefore initialized to 0xaa
<forgot-password> I have to admit. I had a different implementation yesterday, which has since changed.
<forgot-password> However, I am at the same point as yesterday and decided to ask.
<forgot-password> But I just used `try allocator.alloc(?f32, n);`
<g-w1> maybe 0xaa is just interpreted by the printer as a null value?
LewisGaul has joined #zig
LewisGaul has quit [Quit: Connection closed]
Kiori has quit [Ping timeout: 276 seconds]
TheLemonMan has joined #zig
snamber has joined #zig
<TheLemonMan> marler8997, I think I fixed the problem with the terminal clearing, give it a spin when you have some time
<FireFox317> if marler8997 isn't here, i'm currently on windows too
<TheLemonMan> cool! then give #8174 a try
<FireFox317> also hey TheLemonMan! You have also access to that aarch64 32-core server right? Are you able to use sudo on that? (sourceware.org is not being resolved somehow, and i want to add a entry to /etc/hosts xd)
<TheLemonMan> hmm let me check
<FireFox317> i guess the dns server that is configured somehow doesnt like sourceware, i'm able to ping to the ip, however all the glibc stuff use sourceware.org in their scripts
<TheLemonMan> sudo is asking for a password so I guess I can't use that
<FireFox317> indeed, had the same problem
<TheLemonMan> I really hate nixos on this server :\
<FireFox317> TheLemonMan, well thanks for trying xd
<FireFox317> yeah i'm not used to nixos either
<mikdusan> i know right!
<FireFox317> brb, switching os's
FireFox317 has quit [Quit: Leaving]
<g-w1> nixos doesn't use /etc/hosts, it uses networking.extraHosts in /etc/nixos/configuration.nix
FireFox317 has joined #zig
<FireFox317> g-w1, oh well, but then im probably still not allowed to change that
<TheLemonMan> FireFox317, the only two users with sudo powers are andrewrk and daurnimator
<dimenus> trying to get LLVM on Serenity so we can get Zig on Serenity
<dimenus> time to learn a few things
<FireFox317> dimenus, oh nice, that was on my todo list too (in the far future lol)
<dimenus> this is my first time working with LLVM, so no promises. but there are examples online of people adding targets for new oses (same platform of course)
<g-w1> serenity uses elf right?
<dimenus> yep
<dimenus> should be fairly straight forward
<FireFox317> dimenus, well llvm is a pretty annoying beast to build, maybe zig-bootstrap can help you with it
<dimenus> good point
<FireFox317> TheLemonMan, https://pastebin.com/R0LXa78c
<FireFox317> tldr: integer overflow -> const fill_chars = window_width * (window_width - @intCast(windows.DWORD, info.dwCursorPosition.Y - info.srWindow.Top)) -
<FireFox317> this is powershell btw
<TheLemonMan> ... the second window_width should be window_height
<TheLemonMan> that's what you get when you test stuff with square terminals
<FireFox317> cmd works fine
<FireFox317> okay let me try that
<TheLemonMan> wait what the fuck have I committed
<FireFox317> i dont know xd
<TheLemonMan> welp try now
qbit has quit [Quit: leaving]
<FireFox317> TheLemonMan, integer overflow here: lib\std\Progress.zig:217:58
<FireFox317> it works
<FireFox317> but
<FireFox317> it panics when the terminal is 17 columns width
<FireFox317> bigger works
<FireFox317> on powershell btw
<TheLemonMan> damn it, I only tested that with cmd.exe
<FireFox317> sorry :( cmd works indeed
<FireFox317> TheLemonMan, maybe the cursor somehow stays offscreen?
<TheLemonMan> one sec, powershell is somehow installing between one UAC popup and another
qbit has joined #zig
gazler has joined #zig
<TheLemonMan> weird, no overflow here
<qbit> :D "lib/libc/include/aarch64-macos-gnu/AvailabilityInternal.h | 10 +--" oh boy
<FireFox317> TheLemonMan, debug build?
<TheLemonMan> yep
<FireFox317> hmm, sometimes it works
<TheLemonMan> I'm running Progress.zig test.exe
<FireFox317> okay it works fine, somehow my powershell session was borked
<FireFox317> except for another unreachable :(
<FireFox317> at Progress.zig:293
<FireFox317> apparantly SetConsoleCursorPosition can fail xd
<FireFox317> and the height can be 0 too, which causes another bug at Progess.zig:213
<FireFox317> but overall it works fine now :)
<TheLemonMan> let's ship it™ then
<TheLemonMan> what a shitty API :(
<FireFox317> Yup indeed
<txdv> FireFox317 are you coding win32 apis with zig on windows?
<FireFox317> txdv, nah, i was just helping a friend ;)
<txdv> what friend
<FireFox317> TheLemonMan xd
<sundbp> TheLemonMan, I've got my glibc-2.33 multi build done. About to start trying to get all the files included.
<TheLemonMan> sundbp, great! the missing files are a constant source of problems when cross-compiling
<sundbp> TheLemonMan, any guidance to where the logic for not missing files needs to be changed? process_headers.zig ?
<TheLemonMan> good question, where's the sysdep folder located?
<TheLemonMan> FireFox317, when you shrink too much the powershell window the .Top property becomes greater than the .Bottom one
<TheLemonMan> that's why we can't have nice shit in Detroit
<sundbp> TheLemonMan, in terms of the glibc git repo, the sysdeps dir is at the root. However, in the multis/install/glibc tree there is none at all
mikdusan has quit [Quit: WeeChat 3.0.1]
<sundbp> TheLemonMan, so just the stupid instinct knowing nothing about glibs suggests that the build-many-glibcs.py would be at fault as the input that the zig stuff has to work with has no sysdeps. Or the assumption of that that script gives is incorrect from the zig end at least.
<FireFox317> sundbp, that script is not the problem
<sundbp> FireFox317, ok - so then the zig side has bad assumptions, right? e.g. the search-path given to process-headers is a dir that for sure has no sysdeps
<TheLemonMan> sundbp, the sysdeps folder is not installed _but_ we need some bits and pieces from there
<TheLemonMan> namely the crt*.S files and their dependencies
<TheLemonMan> process_headers seems to be focused on the include-able and stuff that's installed
<sundbp> TheLemonMan, gotcha. ok, so then it's starting to look like process-headers needs to take another arg to somewhere where it has a chance to pickup required sysdeps pieces from?
<TheLemonMan> yep
<TheLemonMan> sundbp, keep an eye on start_asm_path in src/glibc.zig
dimenus has quit [Quit: WeeChat 3.0.1]
<sundbp> under the multis dir the location of sysdeps is multis/src/glibc/sysdeps - nothing on a per arch in that dir that I can find
forgot-password has quit [Ping timeout: 264 seconds]
<FireFox317> you also ran this command right? ´python3 ~/glibc/scripts/build-many-glibcs.py . glibcs´
<sundbp> FireFox317, yep
<TheLemonMan> the install command may filter the sysdeps files to leave out only the ones related to the target architecture
<TheLemonMan> what's the content of that folder? can you paste it somewhere?
<sundbp> which folder? src/glibc/sysdeps?
<TheLemonMan> yep
<FireFox317> i guess TheLemonMan means multis/src/glibc/sysdeps
<FireFox317> or thats the one we are talking bout
forgot-password has joined #zig
FireFox317 has quit [Quit: Leaving]
FireFox317 has joined #zig
<sundbp> if I check e.g. x86_64 I see crti.S and crtn.S
<TheLemonMan> looks good
forgot-password has quit [Ping timeout: 264 seconds]
<FireFox317> yeah that seems similar to what is currently in lib/libc/glibc/sysdeps
<FireFox317> looks*
<FireFox317> but it also seems like that all the files in lib/libc/glibc havent been updated since 2.31
<FireFox317> all the folders*
<sundbp> do we understand how the selection of files in lib/libc/glibc/sysdeps was made?
<FireFox317> sundbp, i guess you can just copy all the folders from src/glibc into lib/libc/glibc
sawzall has quit [Read error: Connection reset by peer]
<sundbp> FireFox317, that doesn't make sense to me - that'd bring a TON of stuff compared to what is in that dir at the moment
<FireFox317> oh hmm
<TheLemonMan> sundbp, check glibc.zig
<sundbp> check the pastebin and you see what I mean
<TheLemonMan> check start_asm_path callsites
<TheLemonMan> that gives you the base set of files you need
<TheLemonMan> then start adding all the #include'd files that are only present in the sysdeps folder
<TheLemonMan> and voilá
sawzall has joined #zig
<FireFox317> TheLemonMan, but what about the folders in zig/lib/libc/glibc ? These probably have to be updated too?
<TheLemonMan> yep, but let's start from sysdeps
<sundbp> TheLemonMan, when you say #include'd - included from where?
<TheLemonMan> from the handful of files you've collected in the first step
forgot-password has joined #zig
<sundbp> TheLemonMan, you're going a bit fast for me I'm afraid :) First step being? (there's a lot of steps..)
<TheLemonMan> 1) open src/glibc.zig
<sundbp> yep. looking at that. buildCRTFile refers to some files - you mean those? I'm guessing that's the endgame build requiring the crti.S and friends
<TheLemonMan> 2) read start_asm_path and its 3-4 callsites
<TheLemonMan> that's your base set of sysdeps files
signop has quit [Quit: Quit.]
<TheLemonMan> now collect a list of #include from those files
<sundbp> TheLemonMan, gotcha.
signop has joined #zig
<TheLemonMan> do that recursively until the queue is empty or you find something better to do :P
<sundbp> TheLemonMan, my goal is to automate this - will be slightly more complex zig code than I had in mind :)
<TheLemonMan> this list doesn't change that often (if ever), I wouldn't bother automating everything
<sundbp> it's a different chain for each arch
txdv has quit [Ping timeout: 240 seconds]
<sundbp> I might cheat and write a little tool in clojure to produce the list of files - will likely take me ages in zig coming in with about 0 lines :)
<TheLemonMan> nothing you can cobble together with some grep and bash
forgot-password has quit [Ping timeout: 245 seconds]
<sundbp> I'm not a fan of writing anything non-trivial in bash. It always seems like it'll be quick and then I waste hours on really simple stuff in the end.
<sundbp> but I guess it would have the benefit of being something that can be committed. I guess these steps already require python, unfortunately not a language I've used. bash it is I guess..
<TheLemonMan> keep in mind that andrewrk will rewrite it in Zig while you're not looking heh
<companion_cube> have you never heard of oil shell? 🙃
forgot-password has joined #zig
<sundbp> TheLemonMan, I'd be very happy with that :)
notzmv has quit [Ping timeout: 256 seconds]
forgot-password has quit [Ping timeout: 256 seconds]
blackpawn has joined #zig
<ifreund> companion_cube: bash compatibility is not something I'm looking for in a replacement scripting language
<ifreund> you have to break from the legacy to get something simpler and better
<g-w1> ifreund: the ci fail on my pr is on purpose, andrewrk is looking into if it is correct zig; see the irc link i posted
<ifreund> companion_cube: my hopes for sane scripting lie in https://github.com/stitchlang/stitch
signop has quit [Quit: Quit.]
<ifreund> g-w1: I see, guess I didn't read your PR description :P
<companion_cube> looks like a lisp-ish thing
signop has joined #zig
<ifreund> not really, there are no macros or quoting
<companion_cube> shoulda said tcl
<companion_cube> anyway
<companion_cube> I find fish much ncier as a language than bash, but I still don't script in it
<ifreund> yeah it's meant for interactive usage primarily
<ifreund> stitch explicitly isn't
<companion_cube> the line editor is super cool
<ifreund> anyhow, #stitch if you want to continue this discussion :P
<vent> companion_cube: Holy crap, I've been looking for something like Oil. I love shell scripting, but hate the language. Never heard of Oil before. It even has braces!
<companion_cube> vent: ahahah the author is very vocal about it on HN and lobsters
<companion_cube> ifreund: is that _your_ project? :)
<tnorth> Hey there, playing with function pointers now. Any hints on why Zig can't infer the parameter type here: https://zig.godbolt.org/z/boaK6P ?
<ifreund> companion_cube: marler8997's, I'm responsible for bouncing some ideas
<fengb> "stitch's primary purpose is to call other programs, when this is not the primary purpose of a script, another language like Python is better suited." :o
<fengb> Finally, a shell language that realizes the point of a shell language
<ifreund> tnorth: you'd need to make Foo.bar() take anytype as well
<ifreund> fengb: my thoughts exactly
<companion_cube> but often you need a bit of control flow … :/
<fengb> I'm mostly annoyed at new shells that try to be better Bash but they turn into worse Python
<fengb> Like PowerShell >_>
<tnorth> ifreund: thanks. Still a bit confused: "error: parameter of type 'fn(anytype) anytype' must be declared comptime" not sure how to do that?
<ifreund> comptime func: fn (anytype) void,
<ifreund> what I really meant though was this: https://zig.godbolt.org/z/d7rYhe
<ifreund> generic functions (those that take an anytype paramerter) have some special rules that aren't well documented. I wish they worked more normally
<tnorth> ifreund: that's a way more generic func argument :) Cool that it works... doesn't tell why my version doesn't, but that's fine, it covers all cases
<ifreund> well you can't have a pointer to a generic function at runtime
<ifreund> you can only have a pointer to a function with a specific signature
forgot-password has joined #zig
<tnorth> yes, I thought that the compiler would follow the calls and find out which print function to generate at compile time
<ifreund> it probably could if it were smarter
<marler8997> yeah I actually think Python is great for the space it's in. However, there seems to be a space where sometime Python is a bit overkill, when you just want to call other programs and "stitch" them together. That's what BASH is for and now stitch as well
<ifreund> this part of the langauge is underspecified so far IMO
<TheLemonMan> FireFox317, I think I've fixed the remaining problems (beside the unreachable one I couldn't reproduce)
<tnorth> ifreund: ok, thank you very much again!
<ifreund> no problem!
yyp has joined #zig
leon-p has joined #zig
forgot-password has quit [Ping timeout: 245 seconds]
notzmv has joined #zig
snamber has quit [Quit: Leaving...]
<yyp> Is there a tutorial or somewhat extended documentation on binding C functions and structs into Zig? I know there's "C" section in the docs but sadly, it doesn't apply to libraries
<g-w1> what do you mean binding?
<g-w1> they should Just Work, but heres a guide https://ziglearn.org/chapter-4/
<yyp> I want to include a C library (say, OpenSSL), how to link it together in build.zig or whatever and then export functions from it as a package?
<yyp> There's @cImport thing but it doesn't seem to work when you're targeting a library (.addStaticLibrary instead of .addExecutable)
<g-w1> exe.linkSystemLibrary("libssl")
<g-w1> @cImport should work anyways
<ifreund> yyp: are you writing a zig library exporting a C API or a zig package exporting a zig api?
<yyp> A zig library exporting C API
<ifreund> should work fine then, what error do you get?
<ifreund> yyp: you need to link libc
<yyp> I actually do .linkLibC() in my build.zig
<yyp> This doesn't seem to help
<ifreund> can you paste your build.zig?
<yyp> It's basically default from zig init-lib
<g-w1> still the same error?
<ifreund> yyp: and do you get the error when building the lib or the main_tests thing?
<ifreund> because you aren't linking libc into the tests
xackus_ has joined #zig
<yyp> Ah, that was the issue. Thanks!
<yyp> I thought tests step would inherit configuration from the library
nvmd has joined #zig
<Nypsie> ifreund, small nitpick and not really part of your IO_Uring PR but from what I can tell `submitted` can be const instead of `var`, right?
tnorth has quit [Ping timeout: 260 seconds]
<yyp> Agree, it doesn't need to a var
<ifreund> Nypsie: sure, might as well fix that while I'm there
<Nypsie> Sweet, thanks! My mind is relaxed now :P
<TheLemonMan> annnd the LLVM Xtensa backend is going to be upstreamed too https://lists.llvm.org/pipermail/llvm-dev/2021-March/149090.html
<FireFox317> TheLemonMan, nice!
<sundbp> TheLemonMan, think I'm giving up on automating it. Gotta have the knowledge of the include path of the compiler to actually be able to find things properly, without that one ends up missing stuff or needing heuristics etc. shame.
<TheLemonMan> told you :P
notzmv has quit [Ping timeout: 256 seconds]
<sundbp> TheLemonMan, indeed you did. at least I did an attempt in clojure first instead of banging head on bash. made it clearer to me quicker.
dimenus has joined #zig
<dimenus> LLVM, Y U need so much space to link
<dimenus> mem / swap
<TheLemonMan> dimenus, -DLLVM_PARALLEL_LINK_JOBS=1
<TheLemonMan> and -DLLVM_USE_LINKER=gold gives a small speed-up too
cole-h has joined #zig
<dimenus> TheLemonMan: thanks
<TheLemonMan> sundbp, find . -regex '.*/\(crt[in]\|start\).S' -exec grep '#include' "{}" \; | sort -u
FireFox317 has quit [Quit: Leaving]
yyp has quit [Quit: disconnected]
kevinsjoberg has joined #zig
<sundbp> TheLemonMan, yeah, figuring out the "1 step" results is easy. It is then resolving those "level 2" files into actual paths to then find level 3 etc, that's where it gets icky.
<sundbp> (without knowing include paths)
<kevinsjoberg> I'm doing some Ziglings and currently doing exercise 38. The exercise asked me to check what happens if I don't create the second character. On my machine I get the output 2863311530, 170, 2863311530 for the types u32, u8 and u32. Are these numbers arbitrary?
sord937 has quit [Quit: sord937]
<TheLemonMan> sundbp, most of the interesting ones are prefixed with sysdeps/
<Nypsie> They look like 0xaaaaaaaaa to me
<Nypsie> (undefined)
<g-w1> yep in python do hex(2863311530) and its 0xaaaaaaa
<ifreund> so yeah essentially arbitrary, try a release-fast or release-small build
<mipri> "In Debug mode, Zig writes 0xaa bytes to undefined memory. This is to catch bugs early, and to help detect use of undefined memory in a debugger."
<g-w1> in release they are just what was on the stack before
<kevinsjoberg> Makes sense. Thanks for clarifying. I thought it had to be undefined, but wasn't entirely sure. :)
<sundbp> TheLemonMan, it's the "most" part that makes this whole thing a massive pain in the a** :)
Akuli has joined #zig
<ifreund> sundbp: you should try the musl update sometime to compare, it's SOOO much easier
<ifreund> makes me motivated to swtich to a musl based distro
<fengb> Doesn't Void offer musl?
<kevinsjoberg> Why dl we
<kevinsjoberg> Oops, fat fingered. Why don't we have to dereference a pointer to a struct to access its fields?
<ifreund> fengb: indeed, though when I did this install I had not yet implemented dynamic linking support for musl so river could only build on glibc
<TheLemonMan> to avoid the . vs -> duality
<ifreund> kevinsjoberg: because the pointer can't be null
<ifreund> dereferencing it is safe
dyeplexer has quit [Remote host closed the connection]
<kevinsjoberg> So it's basically dereferencing it for us? Sorry if that question is stupid, but I'm new to Zig (my first day) and low-level languages in general. I'm coming from a Ruby background.
<ifreund> note than when dereferencing [*c] pointers zig requires foo.*.bar
<ifreund> kevinsjoberg: yeah you can think of it as sugar for foo.*.bar
<g-w1> not stupid
<ifreund> and welcome to zig!
<kevinsjoberg> ifreund thanks! Make sense.
<kevinsjoberg> *waving* glad to be hear. Having a lot of fun already.
mikdusan has joined #zig
<kevinsjoberg> Am I right in understanding that variable names are snake_case, functions camelCase and structs and enums are PascalCase?
<TheLemonMan> types in general are PascalCase
<TheLemonMan> 9beside the builtin ones)
<Nypsie> Enum tags are snake_case
<kevinsjoberg> Gotcha!
<ugla> PascalCase also for functions that return types (anything with return type of `type`)
<kevinsjoberg> "One way to do this is to THREATEN IT with the 'orelse' statement." I really enjoy the writing in the Ziglings.
<kevinsjoberg> Am I right in believing that b.zig is equivalent to a.zig? See https://gist.github.com/kevinsjoberg/46b9a0351aae49ce77dcb7692876ab55.
<kevinsjoberg> a.zig was provided as the example, b.zig was my "rewrite" of the example. Both seem to pass.
<g-w1> yes
<ifreund> b.zig is much nicer :)
<ifreund> though this code looks kinda weird tbh
Kiori has joined #zig
<kevinsjoberg> are all built-in functions prefixed with @?
<ifreund> yes
<kevinsjoberg> Such a wonderful decision. Love it.
<tdeo> yeah. they're not really functions necessarily because they can do some special things that functions can't
<tdeo> like @field can be assigned to
<oats> could they be thought of as "compiler directives" then?
<g-w1> a lot of them are llvm intrinsics too
<kevinsjoberg> tdeo: I see. In any case, it's nice having distinction.
waleee-cl has joined #zig
<ifreund> "builtins" is what I'd call them, drop the "function" part
hexaflex has joined #zig
<hexaflex> I am having some issues wrapping my head around what happens here: `fn zero() T { return comptime T.init(0); }` The comptime bit tells me that init() is called at compile-time. and whatever is returned by it, is stored in the programs data section and then simply returned whenever zero() is called?
<hexaflex> If that's the case, than two invocvations of zero() should yield the same instance of T. But comparing pointers shows me that is not true
<hexaflex> actualy, now that I read it.. the returned values are copies, since zero() doesnt return a pointer. I am an idiot.
<hexaflex> Still curious if my interpretation of comptime here is correct
<ifreund> yep, that matches my understanding of the current semantics
<hexaflex> I just tested it by making zero return a pointer. It's still not showing two invocations to return the same object
<g-w1> iirc its stored on the stack, not sure though
<hexaflex> mm if that's the case, Im not sure how the comptime bit is relevant there. Since the stack is unique to each invocation of zero()
<ifreund> hexaflex: https://0x0.st/-Ztu.txt
<ifreund> works for me
<ifreund> is your pointer const?
<kevinsjoberg> I've just completed the ziglings. What would be a good next step? I'm thinking a small project or something but not really what to build or where to start.
<hexaflex> Nope. I'll try that
<g-w1> kevinsjoberg: I always like to make projects based on what I am curious about or what annoys me, maybe you could do the same? a cli tool is pretty easy and fun
<ifreund> yeah, just pick something you're interested in and roll with it
<ifreund> hexaflex: sorry, I pasted the wrong thing: https://0x0.st/-Ztj.txt
<hexaflex> hah I was getting a bit confused by that first one
<kevinsjoberg> g-w1 that's not bad idea. I might try port some Ruby CLIs to Zig.
<g-w1> they will be faster :)
<hexaflex> ifreund: ok, that helps understand things a bit more.
<kevinsjoberg> g-w1I sure hope so.:)
ur5us_ has joined #zig
notzmv has joined #zig
<hexaflex> Is there a convention when it comes to the location of tests? Should they be in a separate file or in the same file as the code they cover?
<g-w1> usually near the code they cover for maximum readability
<hexaflex> ok
timmydo_ has quit [Quit: leaving]
xackus__ has joined #zig
xackus_ has quit [Ping timeout: 256 seconds]
dimenus has quit [Quit: WeeChat 3.0.1]
dimenus has joined #zig
<ifreund> for unit tests yeah
<ifreund> though that doesn't really make as much sense for larger test suites testing doing something closer to integration testing
kevinsjoberg has quit [Quit: Connection closed]
<hexaflex> I'm guessing when mockup types have to be created for tests, it is ok to use separate files? Mixing that code together in the same scope feels icky.
<hexaflex> Also, is there a stdlib function to test for float equality? testing.expectEqual just does a straightup a == b test on floats, which is not really ok
txdv has joined #zig
<txdv> hi guys
<g-w1> hexaflex: why is it not ok?
<TheLemonMan> hexaflex, there's math.approxEq{Abs,Rel} and expectWithinEpsilon and expectWithinMargin
<TheLemonMan> read the docs to understand the small differences between them
<hexaflex> TheLemonMan: ah great
<g-w1> oh, I guess I just don't know how floats work, ignore me
<TheLemonMan> exact comparison is asking for trouble
<hexaflex> g-w1: if you have some spare time, it's worth reading up on. Especially on why floating point comparison can be a bit of a hassle, It's a rabbit hole though.
<hexaflex> Bring cokies and coffee
<g-w1> ok, cool; i dont really know how floats work so that will be interesting
<hexaflex> and cookies
txdv has quit [Quit: WeeChat 1.6]
evs-chris has joined #zig
<evs-chris> was just watching the jt learns zig stream
<evs-chris> can I motion to rename detectable illegal behavior to detectable aberrant behavior, or dabbing?
ur5us_ has quit [Quit: Leaving]
<fengb> bruhavior
<evs-chris> even better
<oats> does the default expression for a struct field need to be comptime?
<g-w1> yes
<ifreund> hexaflex: you can probably put your test types in your test blcok
tomku has quit [Quit: Lost terminal]
craigo has quit [Ping timeout: 260 seconds]
tomku has joined #zig
kevinsjoberg has joined #zig
ur5us has joined #zig
<mikdusan> andrewrk: in `clang_options_data.zig` how is it decided if both pd1/pd2 = true ? for example .name="shared" has .pd1=true, .pd2=true
sebonirc has joined #zig
<mikdusan> was that gleaned from .td ?
<hexaflex> How can I get something like a `[2]f32` type to play nice with std.mem.eql ? I tried the slice operator [0..] and I tried the addres-iof operator. neither seem to work/
<ifreund> they should both work, could you paste code?
<hexaflex> Let me whittle it down to the essentials. sec
kevinsjoberg has quit [Quit: Connection closed]
<hexaflex> mm weird. if I declare the arrays as standalone values, it works fine with the slice operator. In my code though, the arrays are part of a struct.
<hexaflex> when passing them to mem.eql, the compiler gives "error: expected type '[]const f32', found '*align(1) const [16]f32'"
<hexaflex> Used as: expect(std.mem.eql(f32, c.values[0..], m.values[0..]))
<ifreund> the align(1) is the problem there, where is that coming from?
<ifreund> alse testing.expectEqualSlices(f32, a, b)
<hexaflex> not sure where that's coming fromn. The struct is packed. But removing the packed keyword doesnt remove the align bit
<hexaflex> actually, it does.
<hexaflex> Seems to be that the packed struct changes the types of the fields
<dimenus> god damn does llvm run a lot of tests in cmake
<tdeo> yeah, the compile error you're getting is there for a reason, in c you'd just have silent undefined behaviour
<tdeo> not sure how to compare unaligned values in zig though
<fengb> Yeah packed forces all the fields to be align(1)
<ifreund> yes, making a struct packed will definitely have an impact on the alignment of the fields
<mikdusan> dimenus: probe city :)
<dimenus> mikdusan: working on Zig for SerenityOS
<dimenus> but LLVM wants a lot of things
<mikdusan> python3
<g-w1> does cmake work on serenity?
<dimenus> g-w1: yes there is a port for cmake
<g-w1> nice
<hexaflex> So I'm guessnig there is no convenient way to get an aligned array to behave like a slice?
Techcable has quit [Quit: ZNC - https://znc.in]
Techcable has joined #zig
cole-h has quit [Ping timeout: 245 seconds]
<TheLemonMan> for one don't compare floating point numbers using mem.eql
<TheLemonMan> you can compare the two slices by writing a for loop
<TheLemonMan> there's also mem.sliceAsBytes
<hexaflex> handy
hexaflex has quit [Quit: Going offline, see ya! (www.adiirc.com)]
sundbp has quit [Remote host closed the connection]
sawzall has quit [Read error: Connection reset by peer]
sundbp has joined #zig
<fengb> You can coerce it into []align(1) f32, but these helpers don't allow you to change the alignment
sawzall has joined #zig
<sundbp> TheLemonMan, just getting back to my glibc. outside of sysdeps in the lib/libc/glibc lib - what are all those files and do they not also need updating for new versions?
<TheLemonMan> yes, those are some special-cased files that provide some symbols not exported by the libc .so
<sundbp> TheLemonMan, do I dare ask if there's any logic there? how did the list of files get collated the first time around?
ur5us has quit [Ping timeout: 264 seconds]
<TheLemonMan> some object files are linked together and are statically linked against every program
<TheLemonMan> those files produce the symbols in that library
<TheLemonMan> (grep the makefiles for static-only-routines)
<sundbp> hm. this is starting to feel very error prone.. the chance I'll get this correct in an ad-hoc manner seems pretty slim.
clee has quit [Ping timeout: 240 seconds]
evs-chris has quit [Ping timeout: 240 seconds]
ur5us has joined #zig
<TheLemonMan> updating the glibc files is a form of art
ur5us has quit [Ping timeout: 264 seconds]
<g-w1> TheLemonMan: someone on discord is reporting a regression on m1 silicon with the progress https://i.imgur.com/TrhFsk7.png
<TheLemonMan> that doesn't tell me much, what terminal emulator are they using?
<g-w1> its on the default apple terminal
<TheLemonMan> no idea if Terminal.app supports DECSC/DECRC
<g-w1> ah, i think they are going on to irc now
hoesglad has joined #zig
hoesglad has quit [Client Quit]
<g-w1> nvm
<TheLemonMan> ah I think I've found the problem
clee has joined #zig
Akuli has quit [Quit: Leaving]
notzmv has quit [Ping timeout: 264 seconds]
sundbp has quit [Ping timeout: 264 seconds]
<TheLemonMan> g-w1, #8229
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
notzmv has joined #zig
<dimenus> zig-bootstrap really is magical