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/
karchnu has joined #zig
<karchnu> I'm using std.heap.page_allocator and valgrind doesn't tell me that I did a memory allocation. In strace I see mmap and munmap. Is that normal?
<waleee-cl> I think you need to use the C allocator for valgrind to work
<waleee-cl> karchnu: ping ^
<justin_smith> that's my understanding as well, that might be the only one that maps to a malloc call (you also need the --library c flag)
ur5us has quit [Ping timeout: 258 seconds]
rslabbert has joined #zig
<ifreund> this is correct ^
<hlolli> I'm exploring around, and checking if it's possible to make a custom writer. The wall I'm hitting is that "type 'type' does not support field access", the type in question is the return of @TypeOf(struct_instance), called in std.fmt.format. So basically, is field access not possible from struct types?
ur5us has joined #zig
<justin_smith> hlolli: is this one of those type vs. typinfo things?
<justin_smith> hlolli: @Type(x) doesn't contain the fields as something you can enumerate, as I understand it, @typeInfo(x) does
<hlolli> not sure, I've not used much of the type values up to this point. The failing code is this https://github.com/ziglang/zig/blob/master/lib/std/fmt.zig#L376, and my writes is a struct, whereas the built in writer type is a function returning struct, it could be that it's nececcary?
<karchnu> oh, so to test my code and be sure that I don't have memory leaks, I need to use the C allocator and compile with --library c, right?
<justin_smith> hlolli: try using @typeInfo(@typeOf(x)) instead of @typeOf(x)?
<karchnu> I wonder if there is another way, I use valgrind, but maybe there is another tool
<justin_smith> karchnu: if you want to use a tool written for debugging C allocations, yes
<hlolli> to do that I'd need to override the built in function, if I were to want to use std.fmt.format with a custom writer? If it's possible to overridie builtins, I could do that.
<justin_smith> hlolli: oh I think I misunderstood your issue, my apologies
<andrewrk> karchnu, the GeneralPurposeAllocator from the zig standard library does leak checking
<andrewrk> you don't need libc or valgrind for that
<hlolli> justin_smith, all good
<andrewrk> you can try it out quickly using `zig test` and `std.testing.allocator`
<karchnu> Oh… that's nice! Thanks
<andrewrk> karchnu, it also provides heap safety
<andrewrk> it will exhaust the entire virtual address space before recycling pointer addresses
<karchnu> I'll try to create a memory leak just to check how this works, later.
<companion_cube> what did @typeof become?
mikdusan has joined #zig
<leeward> @TypeOf?
<leeward> I thought there was a zig fmt thing to translate that one.
<companion_cube> ah yes indeed.
wallyduchamp has quit [Ping timeout: 260 seconds]
<hlolli> companion_cube: I solve it, realizing that the Writer type is probably a compiletype where field access is possible, but simple type isn't. So I did the ceremony which was done here https://github.com/ziglang/zig/blob/master/lib/std/io/fixed_buffer_stream.zig#L28, I must admit, I'm slowly digesting the concepts here of comptime vs runtime in terms of types.
<hlolli> perhaps it was a random occourance that the exact same buzzwords were thrown out as I used related to my question, so not sure if this was related at all, well, so be it :)
<companion_cube> my question was unrelated :p
<companion_cube> I tried to translate-c some code a while ago, and was trying to update it
<companion_cube> it still fails because there's indexing with i32 (instead of usize)
<companion_cube> it's from somewhat gnarly C code…
a92 has joined #zig
rslabbert has quit [Ping timeout: 264 seconds]
mattnite has joined #zig
layneson has joined #zig
rslabbert has joined #zig
rslabbert has quit [Ping timeout: 260 seconds]
hlolli has quit [Ping timeout: 260 seconds]
<rowbee> what's the best way to open a file and get a File object? i found std.os.open but that seems to return the fd instead of a File.
<rowbee> i looked through the source code but couldn't find much
earnestly has quit [Ping timeout: 258 seconds]
<viashimo> rowbee: I struggled with that too. i have settled on: var fd = try std.os.open(filename, std.os.O_RDONLY, 0); var f = std.fs.File { .handle = fd };
<viashimo> it can probably be just online
<viashimo> one* line
<rowbee> i see...
<rowbee> would it be better to have std.fs.openFile(fname, mode, flags)?
<rowbee> there seems to be something called "openFileAbsolute" but i didn't quite get what it does
<rowbee> i guess you're supposed to use Dir.openFile https://ziglang.org/documentation/master/std/#std;fs.Dir.openFile
<rowbee> but that feels kind of clunky
<rowbee> since std.fs.cwd() also returns a Dir, i suppose you could do std.fs.cwd().openFile(fname, mode, flags); ???
<rowbee> again feels clunky but it's probably analogous to what people would expect from a high-level open function
<viashimo> yup, which is pretty much openFileAbsolute does, except there's an extra check for the absolute path
<rowbee> yeah but i don't want to open from an absolute file, i was looking for something analogous to python's open
<rowbee> absolute path*
layneson has quit [Ping timeout: 260 seconds]
<rowbee> what allocator should i choose if i'm just reading a file into a buffer? is page_allocator enough, should i get GeneralPurposeAllocator?
<rowbee> gotchu
rslabbert has joined #zig
a92 has quit [Quit: My presence will now cease]
<daurnimator> rowbee: yes you're meant to use `std.fs.cwd().openFile(`. that's how all modern OS file apis work: with a directory to be relative to.
<rowbee> that's fine, it was just a bit opaque looking at the source code and such
rslabbert has quit [Client Quit]
rslabbert has joined #zig
<karchnu> daurnimator: it's what I did to open files but I thought I hacked a bit the standard library…
<karchnu> good to know that's normal
Pistahh has quit [Ping timeout: 272 seconds]
<rowbee> what's the atoi equivalent in zig?
<andrewrk> std.fmt.parseInt
<rowbee> thank you
<rowbee> i will probably have to make a cheatsheet of this stuff... the stdlib documentation search is giving me a hard time
<rowbee> also it says the version is 0.6.0+commit hash when the current version is 0.7.0?
<andrewrk> rowbee, try this link instead: https://ziglang.org/documentation/0.7.0/std/
<andrewrk> master branch std lib docs are pretty outdated, the issue is https://github.com/ziglang/zig/issues/3402
<rowbee> thanks... master is older than 0.7.0? :S
<rowbee> aha i see
<andrewrk> I'll refresh it now at least
<rowbee> yeah master didn't even have ArrayList.pop
<rowbee> ah yeah that helps
<andrewrk> there's also the problem of lazy decls which I haven't given up trying to solve yet
dimenus has joined #zig
<andrewrk> mikdusan, long time, no see! good to see you around :)
<andrewrk> ...have you always been idling here and I just didn't notice?
<mikdusan> hey andrew just noticed qemu upstream released so doing a bump for linux testing to qemu-5.2.0
<mikdusan> haven't been lurking for a while. just stuff in life keeping me very occupied
<mikdusan> congrats on 0.7.0 :)
<rowbee> okay zig-mode is actually breaking stuff because of revert-buffer
<g-w1> tell me if you think I should make a proposal for this: zig check command which analyzes all the public decls in a file recursively. if given an exe it will check main and anything else public or that main references, but if given a lib it will analyze any public decl from the lib. this would be pretty useful when writing a standalone library to analyze it without writing a bunch of tests. for generic
<g-w1> functions, the semantic analyzer will do the best it can, but I feel like this would be a BIG help. what do you think, ive been thinking of this for a few days
<rowbee> my code just reverted to an earlier version
<andrewrk> mikdusan, appreciate the bump. hope you're doing ok out there buddy
<g-w1> I feel like I saw an gh issue on this once though, so I might be just regurgating from my sub concious
<andrewrk> g-w1, it's been proposed and in fact implemented and then reverted. it's unfortunately a pretty complicated topic
<g-w1> ah cool, so I was regurgating it, good to know. what is the relevant issue(s)/prs to get me caught up?
<andrewrk> hmm well there's this commit from 2017: af536ac343564e5120f99cbf3b7fc9efa984eb93
<g-w1> ok, thanks
<g-w1> is there anything I can read on why it is so complicated?
<andrewrk> rowbee, I updated https://ziglang.org/documentation/master/std/ to latest master. we don't have it hooked up to CI yet
<rowbee> aha i see, thank you
<rowbee> ArrayList documentation seems to be missing all the pop, remove etc. stuff? known bug?
<andrewrk> this is the lazy decls issue that g-w1 and I were just discussing. looks like pop and remove don't have test coverage :)
<andrewrk> hmm they do though, so that's worth investigating
<andrewrk> g-w1, have a look at this issue: https://github.com/ziglang/zig/issues/3028
<andrewrk> multibuilds is probably too complicated to get implemented but I think I at least explained the problem clearly there
<g-w1> ok tysm
<andrewrk> rowbee, to be clear: these generated docs are still experimental
<rowbee> i see
<rowbee> maybe it would be nice to have them categorized and have a preface to each category, like how python documentation has a description and examples at the start of each page
<rowbee> rather than just dumping them hierarchically
<andrewrk> if you want to experiment with that, the code is here: https://github.com/ziglang/zig/tree/master/lib/std/special/docs
<andrewrk> basically the compiler dumps a big json blob and this html/js code creates an interactive web page out of it
<rowbee> i see
<rowbee> would be nice to also have it generate a static site, for nojs support
<rowbee> i'll take a look cheers
<rowbee> what's the best way to iterate over a slice from a start index until the end? i tried doing for (slice[i..]) { but that's a syntax error
<rowbee> slice.len?
<rowbee> nevermind it works
<rowbee> i was missing the payload
<andrewrk> rowbee, my reasoning re: js is that we want search. in order to make search work we need js and we need all the data available at once. in this case we may as well embrace it and do everything with js rendering the site based on the data
<andrewrk> so it's kinda the simplest thing you can do if you want to have a search feature
<rowbee> with my approach, it would be category-by-category, perhaps reducing the need for search at all
<rowbee> so semantically grouping modules rather than just based on module hierarchy
<rowbee> search could be added on top of it
powerofzero has quit [Ping timeout: 258 seconds]
<daurnimator> for e.g. the lua docs, I just use Ctrl+F to search.... at least it works without JS
<andrewrk> I think the js is pulling a lot of weight with the auto generated std lib docs
<andrewrk> the good news is that third party projects can utilize this option: -femit-analysis[=path] Write analysis JSON file with type information
<andrewrk> then they can produce that single-page docs
<andrewrk> err non-js docs page, I mean
ur5us has quit [Ping timeout: 258 seconds]
<rowbee> how can i get the maximum value for a type, i.e. maximum value of i64?
<rowbee> nevermind
<rowbee> maxInt
rslabbert has quit [Ping timeout: 246 seconds]
remby has joined #zig
rslabbert has joined #zig
<rslabbert> quit
rslabbert has quit [Client Quit]
waleee-cl has quit [Quit: Connection closed for inactivity]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
mattnite has quit [Quit: Lost terminal]
dimenus has quit [Quit: WeeChat 2.9]
osa1 has quit [Quit: osa1]
osa1 has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
<rowbee> i cannot pass std.sort.asc as an argument to std.sort.sort
<rowbee> error: expected type 'fn(type,anytype,anytype) anytype', found 'fn(void, u32, u32) bool'
<rowbee> welp sort simply doesn't work
<rowbee> TODO implement inferred return types https://github.com/ziglang/zig/issues/447
<andrewrk> inferred return types probably won't make it into the language
<andrewrk> don't put `anytype` as your return type
<rowbee> i see... well, i was simply trying to do std.sort.sort(u32, numbers.items, void, std.sort.asc(u32));
<rowbee> but that fails with the first error
<rowbee> i had to write a wrapper function
<andrewrk> look at the function signature of std.sort.sort
<rowbee> hm... i don't quite get what i'm doing wrong here
<andrewrk> there are some examples of using asc in the test cases in that file
<rowbee> i see
<rowbee> ah, something like {} will do. okay
<rowbee> hmmm... now getting "error: unable to evaluate constant expression" with std.sort.sort(u32, numbers.items, {}, asc);
<rowbee> i moved it to a variable like in the tests however that didn't help
<rowbee> maybe i should move it to module scope
<rowbee> yeah that worked
<daurnimator> FYI I noticed the other day that the doccomment on std.sort.asc is out of date/incorrect
<daurnimator> and yes indeed there is a weird compile error if you don't evaluate it at compile time. I think that's a zig bug
<daurnimator> I never got around to filing either of them :/
radgeRayden has joined #zig
<rowbee> yeah i noticed too. what's context supposed to be? like an analogue to user pointers in C or something?
a_chou has joined #zig
a_chou has quit [Client Quit]
sord937 has joined #zig
decentpenguin has quit [Read error: Connection reset by peer]
decentpenguin has joined #zig
mgxm has quit [Ping timeout: 264 seconds]
sord937 has quit [Remote host closed the connection]
sord937 has joined #zig
squeek502 has joined #zig
lucid_0x80 has joined #zig
mgxm has joined #zig
Ashpool has joined #zig
cole-h has quit [Ping timeout: 265 seconds]
remby has quit [Quit: Konversation terminated!]
ur5us has joined #zig
xackus has joined #zig
<ifreund> rowbee: iirc you just need a comptime keyword: std.sort.sort(u32, numbers.items, void, comptime std.sort.asc(u32))
<rowbee> i see
<rowbee> yeah the docs need to be updated
lucid_0x80 has quit [Ping timeout: 264 seconds]
<ifreund> and yeah, that's exactly what the context is meant to be used for
<rowbee> hmm... maybe a 3-parameter sort would be nice? i'd guess that the actual use for a context variable is uncommon
<ifreund> maybe, though you can just just pass {}/void for it
return0e[m] has quit [Quit: Idle for 30+ days]
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
marnix has quit [Ping timeout: 246 seconds]
marnix has joined #zig
<rowbee> hm... {} is of type void, yeah?
<rowbee> what exactly is it? empty block?
<ifreund> yep, exactly
marler8997 has quit [Read error: Connection reset by peer]
sord937 has quit [Ping timeout: 240 seconds]
sord937 has joined #zig
wallyduchamp has joined #zig
waleee-cl has joined #zig
ur5us has quit [Ping timeout: 258 seconds]
wallyduchamp has quit [Ping timeout: 264 seconds]
<ikskuh> andrewrk: when linking against libsoundio on windows with zig i get the following error:
<ikskuh> lld-link: error: could not open 'libuuid.a': no such file or directory
earnestly has joined #zig
lucid_0x80 has joined #zig
Ashpool_ has joined #zig
Ashpool has quit [Ping timeout: 240 seconds]
Ashpool has joined #zig
Ashpool_ has quit [Ping timeout: 272 seconds]
Ashpool has quit [Ping timeout: 240 seconds]
marnix has quit [Ping timeout: 256 seconds]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
jjido has joined #zig
g-w1 has quit [Quit: WeeChat 3.1-dev]
g_w1 has quit [Quit: The Lounge - https://thelounge.chat]
g-w1 has joined #zig
lucid_0x80 is now known as dumenci
<ifreund> andrewrk: so, I think I've succeeded in making executeables that link musl dynamically, however this doesn't seem to have solved my issue runnning river as the musl startup code isn't being run
<ifreund> which as far as I can tell happens because we export our own _start symbol instead of letting libc call main
<ifreund> so maybe the real fix we need is to do more of the things musl does in its startup code in start.zig
<ifreund> I'm going to try that now and see if I can't get river running on my my musl install
jj__ has joined #zig
jjsullivan__ has joined #zig
jjsullivan1 has quit [Ping timeout: 258 seconds]
jjsullivan has quit [Ping timeout: 264 seconds]
TheLemonMan has joined #zig
<TheLemonMan> ifreund, musl crt should take over start.zig _start
<ifreund> hmm, that doesn't seem to be happening as I'm getting a segfault deep in mesa because __progname is NULL
<TheLemonMan> double-check the linking logic
<TheLemonMan> iirc you need rcrt1.c
<ifreund> looking at that file that would make sense
<ifreund> gcc only links Scrt1.o though not rcrt1.o
<TheLemonMan> that's the static crt1 iirc
<TheLemonMan> the naming is extremely confusing
samtebbs has joined #zig
<ifreund> huh, it's definetly creating a dynamically linked executeable
<ifreund> I'll try it with rcrt1.o and see what happens
<TheLemonMan> "Used in place of crt1.o when generating PIEs."
<TheLemonMan> that's Scrt1
<TheLemonMan> "A new crt start file, rcrt1.o, is provided for producing static-linked position independent executables (PIE)"
sord937 has quit [Ping timeout: 240 seconds]
powerofzero has joined #zig
sord937 has joined #zig
sord937 has quit [Remote host closed the connection]
sord937 has joined #zig
<ifreund> huh, so our `int main()` export in start.zig is getting called...
lucid_0x80 has joined #zig
<ifreund> and progname is even set properly, seems like I need to dig deeper into why river is crashing then
dumenci has quit [Ping timeout: 260 seconds]
<ifreund> oh, only when I do -fPIE though
<TheLemonMan> ..is this about dynamically-linked musl?
<ifreund> yeah
<ifreund> The end goal is to run river on a musl-based distro, which requires dynamic linking
<ifreund> now there's an odd backtrace: https://0x0.st/ihEx.txt
<ifreund> this is without -fPIE
<ifreund> pretty sure it's cause I'm still using Scrt1.o even when PIE is disabled
notzmv has quit [Read error: No route to host]
notzmv has joined #zig
radgeRayden has quit [Remote host closed the connection]
<ifreund> ok, so I've done something right because the example from #5364 works with -dynamic -fPIE
<TheLemonMan> progress!
frmdstryr has joined #zig
x0r19x91 has joined #zig
wallyduchamp has joined #zig
xackus has quit [Ping timeout: 240 seconds]
donniewest has joined #zig
xackus has joined #zig
a_chou has joined #zig
hnOsmium0001 has joined #zig
zippoh has joined #zig
samtebbs has quit [Read error: Connection reset by peer]
a_chou has quit [Remote host closed the connection]
cole-h has joined #zig
powerofzero has quit [Ping timeout: 240 seconds]
m4r35n357 has quit [Quit: Ex-Chat]
powerofzero has joined #zig
x0r19x91 has quit [Quit: Connection closed for inactivity]
commande1 has joined #zig
commande1 has quit [Client Quit]
sord937 has quit [Ping timeout: 240 seconds]
wallyduchamp has quit [Ping timeout: 260 seconds]
sord937 has joined #zig
txdv has joined #zig
cren has joined #zig
<andrewrk> ikskuh, zig can provide -luuid out of the box if you use the gnu abi. see also #6565
lucid_0x80 has quit [Ping timeout: 260 seconds]
wallyduchamp has joined #zig
<ikskuh> andrewrk: thanks
<ikskuh> i'll try
* ikskuh boots the windows machine
Akuli has joined #zig
<TheLemonMan> give it the boot!
<leeward> /kick the_windows_machine Booted!
<TheLemonMan> hello msp430man, got any more interesting problems to troubleshoot?
<leeward> hah, hi
<leeward> Actually, no interesting problems right now. I'm just assembling a minimal set of things needed to build msp430 code with Zig into a convenient place.
<leeward> Finding the license for these linker scripts at the moment. It's not in the files, but I'm pretty sure they're distributed as part of GCC so...GPL seems likely.
hlolli has joined #zig
<leeward> Soon I get to actually start working on the project I wanted to build with this.
Pistahh has joined #zig
kenran has joined #zig
* dutchie sees people running into trouble with std.sort.sort before
<dutchie> was ust th
<dutchie> whoops
<dutchie> was thinking earlier today about whether the language should know to try to evaluate comptime args at comptime
<dutchie> `std.sort.sort(u32, arr, {}, std.sort.asc(u32))` didn't work when i tried
<dutchie> is there a bug for that already?
ur5us has joined #zig
<TheLemonMan> hmm, did that actually work in some previous release?
ur5us has quit [Remote host closed the connection]
<dutchie> i'm not sure
<TheLemonMan> if you have a small snippet compiler-explorer is your friend
<leeward> Alright, time to generate some random numbers.
<TheLemonMan> 3
<TheLemonMan> here you go
<leeward> Bzzt. Wrong. It was 4.
<dutchie> hard to say if it's a regression because the signature is different in 0.6.0
<leeward> Or was that the ISO one? I use IEEE random numbers.
layneson has joined #zig
<dutchie> https://godbolt.org/z/bTa95z looks good
layneson has quit [Client Quit]
ur5us has joined #zig
<andrewrk> TheLemonMan, with #7372, why not let @atomicRmw emit a compile error for invalid ordering?
<andrewrk> isn't the userland check redundant?
<dutchie> lol, thanks vexu for turbo-closing as dupe of https://github.com/ziglang/zig/issues/5672
<dutchie> might be a fun first dip into the code for me if i get a chance over the weekend
wootehfoot has joined #zig
<andrewrk> ir.cpp might be a rough first dip
<ikskuh> if the editor can support it :D
<andrewrk> ifreund, what do you have the linker line down to so far?
<TheLemonMan> andrewrk, the orderings are valid but won't do what people want, LLVM will happily compile them
<andrewrk> I see
<andrewrk> well should we change the builtins?
<ifreund> andrewrk: here's where I'm at, compiling and running on a musl based distro: https://0x0.st/ihlw.txt
<ifreund> only works with -fPIE, but I haven't figured out why yet
<TheLemonMan> *shrug* no strong opinion on that, doing the checks in Zig is much nicer than hacking on ir.cpp heh
<andrewrk> fair enough, I'll leave it be for now
<andrewrk> ifreund, how is libc.so produced?
<andrewrk> also do you have handy the linker line that the native do you have handy the linker line that th enative tooling uses? you can get it pretty easily with `strace -f -e trace=execve cc -o hello hello.c`
<ifreund> basically just the same as libc.a but with LinkMode set to Dynamic
tdeo has quit [Ping timeout: 240 seconds]
tdeo has joined #zig
<ifreund> here's the execve call: https://0x0.st/ihlE.txt
<andrewrk> hmm looking at the diff I think the libc.so is the culprit
<andrewrk> well... maybe it could be ok
synaps3 has joined #zig
<ifreund> oh maybe it's getting built as PIE when it shouldn't be
<ifreund> I didn't check that yet
<andrewrk> we build the glibc .so files very differently
<ifreund> yeah I saw :D
<ifreund> this seemed like a good thing to try first though
<andrewrk> well maybe not that differently
<andrewrk> but I'm not sure build_crt_file should be repurposed for dyn linking
<andrewrk> you probably need a soname in there too
<ifreund> isn't it unversioned though?
sord937 has quit [Quit: sord937]
<synaps3> hey all, I am new to zig any fun projects to look around ?
<ifreund> river is pretty fun :P https://github.com/ifreund/river
<andrewrk> ifreund, check your system-installed libc.so using `readelf -d`
<andrewrk> for glibc it's libc.so.6
<andrewrk> yeah alright, no soname
<ifreund> and it's just /usr/bin/libc.so
<ifreund> er /lib not /bin
<andrewrk> oh here's something to try
<fengb> Zig is for work, no fun allowed 🙃
<synaps3> thanks ifreund
<synaps3> danke
<ifreund> bitte :P
<andrewrk> ifreund, take your first linker line the one that's not working, and put `zig` in front of it
<andrewrk> from https://0x0.st/ihlw.txt
<andrewrk> you need a zig after master branch commit 391d81a3802e48f59d804746eedc396d60ad3820
<andrewrk> zig ld.lld ...
<andrewrk> replace the libc.so with your system one, and see if that fixes it
<ifreund> indeed it did
<ifreund> what does that tell us?
<ifreund> libc.so is messed up?
<andrewrk> ok so we have narrowed the problem down to how we are generating libc.so
powerofzero has quit [Ping timeout: 272 seconds]
<ifreund> hold up, I may have made a small typo let me check this
* TheLemonMan roots for ifreund
<andrewrk> I just built musl locally, and here is the command it used to link libc.so: https://clbin.com/ItP8x
<ifreund> zig is building on the musl machine...
<andrewrk> I'm guessing -Wl,-e,_dlstart is the issue
<ifreund> ld.lld --help doesn't show a _dlstart option
<andrewrk> it's the -e option
<andrewrk> -e _dlstart
<ifreund> oh yeah duh
<andrewrk> here's another topic: with dynamic musl we have 2 options: (1) stub out the functions to produce a libc.so more quickly, or (2) build libc.so based on libc.a which will produce a fully viable libc.so but take longer on first run
<andrewrk> we don't currently support overriding the entry point symbol in link.zig so that will have to be added
<andrewrk> whether to expose it to the cli is a separate issue
marnix has quit [Ping timeout: 256 seconds]
<andrewrk> also linked into libc.so are obj/ldso/dlstart.o obj/ldso/dynlink.o
<andrewrk> we might also want to consider those other -Wl args, such as --dynamic-list
cren has quit [Quit: cren]
<ifreund> looks like I have a lot of stuff to try now, thanks
<ifreund> by the way I know why it was working with -fPIE earlier, I was actually building libc.a but calling it libc.so because I forgot to pass link_mode along somewhere
<andrewrk> oops, lol
<ifreund> kinda cool that that SDL example somehow worked :D
<andrewrk> hmm I think you actually can't re-use the same libc.a from static linking because we need PIC objects for libc.so
<andrewrk> so in this case I would suggest option (1) - stubbing out all the functions with a similar strategy that we do with glibc libc.so
<TheLemonMan> oh no, more stubs
<andrewrk> for musl it can just be a pre-made .s file since we aren't trying to support multiple versions
<TheLemonMan> ...as long as it's autogenerated it's fine
<andrewrk> yep, just one more step added to https://github.com/ziglang/zig/wiki/Updating-libc#musl
factormystic has quit [Quit: The Lounge - https://thelounge.chat]
<andrewrk> welp that was a fun distraction from #7308. now let's see where was I...
<ifreund> build with `-e _dlstart` failed with "cannot find _dlstart" but the fact that I'm not linking a thing called dlstart.o yet gives me a hint where that comes from :D
<ifreund> thanks for giving me some time andrewrk that was very helpful and I should be good on my own now for a while :)
factormystic has joined #zig
xackus has quit [Ping timeout: 260 seconds]
<andrewrk> :)
kenran has quit [Quit: leaving]
Akuli has quit [Quit: Leaving]
<justin_smith> is there a recipe somewhere (or a function I didn't find yet) to consume stdin by lines?
<justin_smith> I could use readAllAlloc and iterate the result, but for my use case it would be nice to just consume a line at a time
<ifreund> justin_smith: well get a Reader from stdin and then use readUntilDelimiterAlloc() or similiar
<justin_smith> ifreund: readUnitDelimiterAlloc is what I was looking for (already have that reader) - thanks much
<ifreund> no problem!
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<justin_smith> quick follow up: if I am using readUntilDelimiterAlloc to create a series of strings that go into an ArrayList, is there a shorthand to tell the ArrayList that its cleanup should involve freeing each of those strings?
<justin_smith> probably not, its just a small for loop anyway
<ifreund> nope, there isn't
<fengb> Toss them into a single arena
<ifreund> that works too, but isn't always ideal
<justin_smith> fengb: that makes sense, then just let the arena go
<andrewrk> you can avoid allocating if you put a comptime known upper bound on the line size of your file format
<andrewrk> otherwise, fundamentally the problem you're being forced to deal with is, "what if the user makes a file with a really long line?"
<fengb> Can you invoke UB and slap the user?
<andrewrk> I think invoking UB is the user slapping *you*
<ifreund> I saw a rougelike once with segfault traps and other such fun things
<justin_smith> hmm, I do have a predictable line length, maybe instead of returning an ArrayList of lines I can just take a function that is called on the line...
<ifreund> :D
<justin_smith> ifreund: nethack has a signal handler that gives you the max possible score if you can make it crash irrecoverably (or so I hear, I've never hit it)
<ifreund> I really want to write a game in zig sometime, but there are so many other things that need doing
<justin_smith> I like the "arbitrary execution chamber"
<ifreund> yeah that's really good
<justin_smith> I once built for a mud that had a scripting language for rooms/mobs that couldn't do math
<justin_smith> I created a series of rooms that acted like registers, and objects that could be dropped in the rooms
<justin_smith> basically a cross between a register machine and an abacus for doing math in my mob scripts
<justin_smith> (end goal was very simple, a gambling bot that would double your money or eat it)
<andrewrk> josh's open source work is really inspiring, I wish he would quit ok cupid and try to hack it as a donation funded open source person
<karchnu> talking about projects, I want to do a QML-like UI system based on zig and *probably* opengl, that's a kinda big application
<andrewrk> neat
<karchnu> and I never used opengl, so… :D
<karchnu> I'll (almost) dedicate the next 6 months on that I think
<ifreund> heh, I'd really love to see a simple UI toolkit in zig
<andrewrk> imgui seems like a possible contender
<ifreund> retained mode, I wouldn't be using it for games
wootehfoot has quit [Read error: Connection reset by peer]
donniewest has quit [Quit: WeeChat 3.0]
<karchnu> I want to separate the model and the controller, having an application able to get QML-like data and handling only the UI, sending notifications to the controller on user input.
<karchnu> Creating UI would be easy for everyone after that, as HTML did but in a way less broken way.
<justin_smith> karchnu: so basically a data-driven UI server?
<karchnu> justin_smith: data-driven I'm not sure, but yes an UI server.
<justin_smith> karchnu: what I mean by "data driven" is that the interaction would happen via events / messages rather than mutating a shared state (maybe that's my prejudice sneaking in)
<karchnu> I want single-page applications inside browsers in WASM so I can finally make UI without any HTML code or broken layout or even worse, javascript.
Snetry has quit [Ping timeout: 260 seconds]
Snetry has joined #zig
<karchnu> But I don't want it to be "just" for web applications, that would be silly, once you have an UI server you can make it work everywhere (or at least it _should_ be possible).
<fengb> Adobe tried that with Air
<justin_smith> karchnu: there's a cool open source app, "open stage control", which lets you use drag and drop to create UIs that are variations on an audio mixer or synth, then lets you register each control to communicate with a data channel
<justin_smith> the UI editor emits a json file, the app runs it in an electron window
<justin_smith> (the data channels are OSC, which many audio apps support)
<karchnu> on principle, that's nice, until the electron part :D
<karchnu> OSC?
<justin_smith> karchnu: OSC is like midi crossed with http - different signals have heirchal paths, and it uses the network
<justin_smith> (and it allows data types other than 7 bit ints)
wallyduchamp has quit [Ping timeout: 260 seconds]
<justin_smith> karchnu: right, the model sounds close to what you are talking about to me, even if the UI engine it uses isn't up to your standard
<karchnu> yes, that's kinda close, but I want to implement layout, property bindings and maybe a few other cool things we can find in QML
wallyduchamp has joined #zig
<karchnu> in the end, we should be able to create websites and (probably) any kind of graphical application (even maybe a compositor for wayland, using only the layout part)
<karchnu> it's at least the things I have in mind right now, let's see what happen within the next months :D
LanceThePants has quit [Read error: Connection reset by peer]
LanceThePants has joined #zig
LanceThePants has quit [Read error: Connection reset by peer]
LanceThePants has joined #zig
dominikh has quit [Ping timeout: 272 seconds]
ur5us has quit [Ping timeout: 260 seconds]
wallyduchamp has quit [Ping timeout: 260 seconds]
wallyduchamp has joined #zig
wallyduchamp has quit [Ping timeout: 264 seconds]
powerofzero has joined #zig