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/
<daurnimator> andrewrk: 501(c)(3) status is a lot of filing.... which is time not coding
<andrewrk> that's what the 5,000 USD is for
<daurnimator> thats to get there
<daurnimator> once you're there there's constant ongoing work
<daurnimator> the other thing to consider is international things.... e.g. I was talking to the SFC people about accepting deductible donations from anyone *outside* the US
<daurnimator> setting that up is a huge undertaking which I don't consider within the capabilities of e.g. a zig org
<andrewrk> Yeah that is the main reason to favor joining SFC or similar umbrella org
<daurnimator> andrewrk: aside from essentially having lawyers on retainer that would be able to e.g. solve the connectFree issue for us?
<fengb> What would you give up joining SFC?
<andrewrk> I'm not sure there is even an issue there, but regardless - that's just it. We don't really have them on retainer, we would be asking for pro bono work and hoping they care enough or have the time to spend
<andrewrk> Consider we don't even have an offer to join. My application was ignored for 6 months. SFC means relying on an unreliable partner to get things done
<daurnimator> fengb: the only thing is some percentage of donations go to the SFC (to pay admin/lawyers/outreach/etc). I think its 15%?
<andrewrk> We would be giving up autonomy
<daurnimator> andrewrk: FWIW I know the reasons for that. They put a stop on accepting new applications; all existing members had full service.
<andrewrk> That sounds promising
<daurnimator> andrewrk: infact they still have a stop on accepting new applications... I had a chat to them and got an exception for us...
<andrewrk> Yeah! Nice work on that for sure
epmills has joined #zig
<andrewrk> here's the bottom line though: we already have missed some opportunities that would have been available with an org. SFC has not accepted the application. Do we wait and hope, or take matters into our own hands?
<daurnimator> andrewrk: SFC has not accepted it? didn't you only send it yesterday?
adamkowalski has quit [Remote host closed the connection]
<andrewrk> I applied many months ago, but you apparently unlocked the "real" application
<daurnimator> Correct
<andrewrk> I received no response or timeline from them
<andrewrk> Which is fine, but im just making the point of autonomy
<fengb> andrewrk used public application. It’s not very effective...
<andrewrk> I think we may be in a position to take in substantial amounts of income to the org, get contributors paid for their time, maybe even get people jobs, and do some good in the world for once rather then trying to line the pockets of stock holders
rankao has joined #zig
<andrewrk> I want to prove that a non profit is a better way to run a business than a for profit company
<rankao> I think it can be.
<rankao> zig is a c compiler is a pretty lovely feature. I was going to start playing with someones AOE II implementation in C99. Got it running, but then realized it relies on the original CD release. So that plan kind of disappeared. But I appreciate the work you did on that andrewrk. It was really simple.
<lupine> abolish capitalism \o/
<daurnimator> andrewrk: have you had offers of funding? from whom?
rankao has quit [Remote host closed the connection]
<andrewrk> yeah, the company that ran the ETE conference that I gave that talk at
<andrewrk> there were a couple other things which I can't remember at the moment
<andrewrk> I'm happy to continue this conversation tomorrow; I'm off to spend my friday evening playing an arcade game with friends
<daurnimator> k. I'm on a 2 hour journey delayed by rain :P
<fengb> Have fun
<andrewrk> someone tell rankao if they come back they can probably find AOE II CD rip on the pirate bay
<fengb> But you’d never support anything so illicit!
<andrewrk> I'm pretty sure it's legal if you own the CD, and who doesn't own the CD, right? they probably just lost it ;)
rankao has joined #zig
<rankao> I'm sure it's in storage somewhere
<frmdstryr> we used to have AOE lan parties in high school. everything was on one network
<frmdstryr> the librarians didn't like it though
<tane> E=mc² trooper ..
<frmdstryr> how do you turn this thing on
<tane> isn't this a bazooka sportscar?
<frmdstryr> Was there two cars? I only knew about the cobra
<tane> hm, I only remember this one
<keegans> is there a way to convert integers to []const u8 (strings) in the Zig standard library?
waleee-cl has quit [Quit: Connection closed for inactivity]
rankao has quit [Ping timeout: 260 seconds]
<daurnimator> keegans: look in std.fmt
<keegans> thanks
<mikdusan> andrewrk: if PR builds clean, I'd like to again try for cmake merge and watch for need to revert if it doesn't give all passes. If you'd rather I hold off please let me know.
<mikdusan> pr #4215
swoogan has joined #zig
tane has quit [Quit: Leaving]
epmills has quit [Remote host closed the connection]
return0__ has quit [Read error: Connection reset by peer]
return0e has joined #zig
<terinjokes> my first (currently backburnered) zig project was to implement new executables for my favorite old DOS/Win9x games. Drop the binary in the same directory as the assets and you're good to go
<terinjokes> then i remembered I know how to make servers, not games :p
BaroqueLarouche has quit [Quit: Connection closed for inactivity]
<fengb> I’d expect a lot of people here are not doing what they’re comfortable with. Learning is fun!
kristoff_it has quit [Ping timeout: 272 seconds]
<daurnimator> lunamn: non-exhaustive enums should make your std.net.dns PR nicer :)
<lunamn> daurnimator: oh damn it got merged, nice
<fengb> Enum all the things
karrick has quit [Read error: Connection reset by peer]
karrick has joined #zig
leeward has quit [Disconnected by services]
<hryx> mikdusan: I woke up in the middle of the night and figured a way out of the #4155 problem. Now, instead of no compile error, we get a different (but legitimate) compile error. I think it might be ok in this case though, with andrew's blessing -- I'll finish implementation when I get home tonight
kristoff_it has joined #zig
<hryx> after one more night of studying ir.cpp, I think my comments in that PR are a little naive in retrospect. each day I understand one new thing about the zig IR pipeline
<mikdusan> oh mine too. but that's ok
<mikdusan> I said "and can this be forced comptime". it is only comptime - never gets out of IR analysis .
<fengb> I just hope I can absorb knowledge through osmosis in here
tracernz has quit [Ping timeout: 272 seconds]
tracernz has joined #zig
<mikdusan> just merged a cmake fixup (2nd try) previous one broke linux; if anyone has issues building zig like `Unable to find zig lib directory` let me know and I'll in shame revert it again
epmills has joined #zig
kristoff_it has quit [Ping timeout: 272 seconds]
<wilsonk> mikdusan: seems to build fine on linux for me (two different machines), just so you know
return0e has quit [Read error: Connection reset by peer]
return0__ has joined #zig
<mikdusan> wilsonk: good to know thanks
mahmudov has quit [Ping timeout: 260 seconds]
dddddd has quit [Remote host closed the connection]
<wilsonk> is @sqrt still supposed to work with Vectors? This program used to work (https://gist.github.com/travisstaloch/2bddc2645002e91507cb364ea2502321) but now it fails at line 137 with a broken llvm module -- both operands to FCmp instruction are not the same type
epmills has quit [Remote host closed the connection]
<daurnimator> wilsonk: broken LLVM module is a bug either way
<daurnimator> but I would expect its meant to work
<wilsonk> yeah, I was more wondering if I missed some recent change that would trigger this. I will file an issue
_whitelogger has joined #zig
<andrewrk> daurnimator, you have my partial, divided attention, but I can help with then next step of linking thing
<daurnimator> andrewrk: sure
<andrewrk> for starters, try adding abort() to lib/std/special/c.zig. It can probably just call std.os.abort()
<daurnimator> andrewrk: so last thing we hit was missing symbols without -lc, and hitting an unreachable with -lc (as the -lc paths only really handle linux from my reading)
<andrewrk> I thought we were doing -lc -target riscv64-freestanding-musl
<daurnimator> okay so going down the -lc route?
<daurnimator> 06:38 <daurnimator> adding -lc gives: Assertion failed at /home/daurnimator/src/zig/src/link.cpp:1484 in get_libc_crt_file. This is a bug in the Zig compiler.
<andrewrk> go up the stack a bit, we have to figure out what the linker line should be for this target
<andrewrk> no libc start files maybe?
<andrewrk> that's probably right. so go up the stack to where it's trying to put start files on the linker line, and make an exception for freestanding, to not do that
<daurnimator> andrewrk: so I have a file crt0-vexriscv.S, I had just compiled it into my object fies
<daurnimator> *files
<andrewrk> where does that come from?
<andrewrk> it sounds like a freestadning libc is being provided by a third party?
<daurnimator> sort of I think? I think I'm meant to download newlib?
<daurnimator> I'd like to not use their if I can...
<andrewrk> can you remind me of the context here?
<andrewrk> what are you working on?
<daurnimator> andrewrk: its a FOMU: its an FPGA that fits inside a USB-A port. it comes with a riscv core installed. they include examples of targetting it with C and Rust. I want to use zig.
<andrewrk> I'm sure you could follow the example substituting zig for rust here. But I suppose the question is whether we could take advantage of zig's freestanding libc rather than using whatever solution they have put together
mahmudov has joined #zig
<daurnimator> andrewrk: they seem to use some toolchain that generates C defines given the FPGA stuff: with @cImport we can take advantage of that. not so much if we use the rust base
<andrewrk> the way I would think about this is to break it down into sort of "dependencies". what actually needs to happen to make this stuff work?
<daurnimator> andrewrk: okay so my goals for now are: follow the C tutorial except swap in the gcc and newlib dependencies for zig ones
<andrewrk> that sounds like a productive goal
<daurnimator> I... feel underprepared here
swoogan has quit [Ping timeout: 260 seconds]
return0__ has quit [Read error: Connection reset by peer]
return0e has joined #zig
marmotini_ has joined #zig
marmotini_ has quit [Remote host closed the connection]
<daurnimator> andrewrk: I don't know what I should be doing next
<andrewrk> on the riscv thing?
MaiDouH has joined #zig
<MaiDouH> Hi everyone!
<MaiDouH> Just got started zig-ing last night!
<MaiDouH> pretty excited!
<gonz_> MaiDouH: Welcome! :)
<MaiDouH> Thank you!
metaleap has joined #zig
<metaleap> morning all! 2 questions on `zig_cache` dir: can a different name be specified in my `build.zig`, and does it also cache intermediate files for "outside deps" incl zig stdlib? i assume so, noticing that there's no `zig_cache` in $ZIGPATH/lib/zig/std/
tane has joined #zig
<gonz_> It caches c imports, yes, but if you have straight up source deps it'll bake them into your artifacts, AFAIK
<gonz_> The C imports it has to translate into usable files, etc., so they are stored in the cache directory to not be rebuilt again.
<gonz_> `rm` your cache dir and do a single build to see exactly what one build actually entails.
<metaleap> oh i thought its also for incremental (zig) build logic, regardless of C. thx
<metaleap> like caching semantic-analysis intel, to be picked up for unchanged files or some such
<MaiDouH> I have a question regarding zig's `switch` statement. As a background, I am making a chip8 emulator as a learning project. I currently implementing the instruction decoding using a big `switch`statement. In case you don't know, instruction are 16bits, big endian numbers, and they use 4 4bits numbers to encode instruction. For example, a jump
<MaiDouH> instruction would be `0nnn` where `nnn` is the 12bit address of the intruction to jump to. A mor e interesting example would be adding 2 register, `8xy1` does `vx = vx + vy`, where `x`and `y` are refers to register the register "id" (v0...vF). The question is: is there a way to express this kind of rules in a single `switch`, or should i go the
<MaiDouH> same route a C with nested `if`s while gradually decoding the instruction? Thanks for your time, i hope i am clear with my question.
<MaiDouH> I have a question regarding zig's `switch` statement. As a background, I am making a chip8 emulator as a learning project. I currently implementing the instruction decoding using a big `switch`statement. In case you don't know, instruction are 16bits, big endian numbers, and they use 4 4bits numbers to encode instruction. For example, a jump
<MaiDouH> instruction would be `0nnn` where `nnn` is the 12bit address of the intruction to jump to. A mor e interesting example would be adding 2 register, `8xy1` does `vx = vx + vy`, where `x`and `y` are refers to register the register "id" (v0...vF). The question is: is there a way to express this kind of rules in a single `switch`, or should i go the
<MaiDouH> same route a C with nested `if`s while gradually decoding the instruction? Thanks for your time, i hope i am clear with my question.
<MaiDouH> Oops. sorry for double posting
kristoff_it has joined #zig
<mq32> hey MaiDouH
<mq32> it looks like the chip8 is using nibbles to encode it's instruction?
<MaiDouH> mq32 It does yes.
<mq32> one approach would be using a packed struct, but those are currently a bit broken
<mq32> so i'd go with this approach right now:
<mq32> or you can probably say something like "0x0000 ... 0x0FFF => …," and switch over the whole instruction as one
<mq32> but i don't think this will create efficient code
<MaiDouH> Thank for the response. I'm currently using the approach '0x0000 ... 0xFFF', but couple of instruction are identified by the first AND last nimble, which means i have overlaping range ('0x8001 ... 0x8FF1' for OR, `0x8002 ... 0x8FF2` for ADD etc.). I think i will follow your recommended approach. It does look like a packed struct would do the trick
<MaiDouH> though, looking forward to them being fixed soon!
MaiDouH has quit [Ping timeout: 260 seconds]
<daurnimator> andrewrk: yes on the riscv thing
<metaleap> muh goto! i cant think of a succinct way to put this use-case into a goto-less form cleanly & concisely. ugly non-solution with multiple duplicate/identical "failure"(but-not-err) branches: https://gist.github.com/metaleap/57ce1abacb28ac755d891b9df0ee2f9f --- comment below: how it would be with `goto`
<metaleap> simple example, real world would have even more diverge-to-"fault"(but-not-err)-handling-path points. cant "call into" a labelled block either afaik. and the handling would usually also have more than just one statement.
<daurnimator> metaleap: `defer if (not ok) mem.free(bytes)`
<daurnimator> though really, instead of returning `null` on invalid bytes it might make more sense to `return error.OutOfRange` or something
<daurnimator> then you can just use `errdefer`
<daurnimator> would be nicer for your users too
<metaleap> nah in this usecase it's to be an optional
<daurnimator> why?
<metaleap> & thx btw daurnimator. now wait, unlike go, in defer the evaluation of ok and mem and bytes would be not when calling defer but when it eventually runs?
<daurnimator> metaleap: correct
<daurnimator> metaleap: `defer` takes a block or a statement to defer.
<metaleap> good to know! the reason as to "why" is that it is a test of the nature of the unknown incoming list, it's not an error case and I prefer to not "reuse" the `error`s enums facility, neat as it is, for handling "business logic" variants/enumerants/state-space =)
<daurnimator> metaleap: you're already returning an error.
<metaleap> yeah for alloc
<metaleap> because that _is_ an error :D
<daurnimator> metaleap: but also, errors are recoverable for a reason. e.g. ENOENT turns into a zig error. but sometimes missing files just mean you have to make a new one
<metaleap> sure thing. in my current world-view, errors signal invalid faulty inputs (or lower-level/machine/kernel/hardware faults), but optionals signal "is a thing or not" testing on inputs ;D in this situation otherwise the user would have to switch-on/dissect the error and sorta "recover unless its mem-alloc error or cosmic rays", now they can `const myopt = try foo()` then proceed after the try. anyway will see how defer goes here now
<daurnimator> metaleap: lower level machine/kernel faults should be panics. errors are for recoverable things :)
dddddd has joined #zig
<metaleap> well ok fair enough but still i dont foresee my code "recovering" from allocator errors for the foreseeable future.
<daurnimator> metaleap: e.g. imagine you're writing a library; and a http server decides to use your library: it should return 503: not crash the whole servr
<daurnimator> (in the case of low memory)
<metaleap> my lib doesnt crash :D if there's an error it goes to the caller. if it's a server consuming it, it shouldnt crash, whereas my current-stage dummy non-daemon-y fire-and-forget local console apps absolutely must :D
kristoff_it has quit [Ping timeout: 258 seconds]
<daurnimator> metaleap: I don't love your lack of braces
<metaleap> daurnimator: the ok/defer pattern helps smoothen this situation decently thx again! i didnt consider it as my `defer` conception was precolored by go
<metaleap> tricky topic , braces. as long as zigfmt keeps working as nicely as it currently does, i'm not currently seeing potential foot-guns here yet.. but then I'm blind in infinite ways (compared to the total amount of knowledge & truth in the universe, which must be exactly 1 infinity).
mahmudov has quit [Ping timeout: 268 seconds]
return0__ has joined #zig
return0e_ has quit [Ping timeout: 268 seconds]
<daurnimator> Is there a way to put two enums together?
<daurnimator> huh... where are all the ENSR constants from?
tane has quit [Quit: Leaving]
<betawaffle> is there a way to write a "naked" function that takes arguments in specific registers?
<betawaffle> such that llvm wont attempt to use those registers, fucking everything up
<betawaffle> i've been trying to write my x86 kernel _start function, and having a hard time reading out EAX and EBX, while also setting ESP
<mq32> betawaffle, there is a way to do this
<betawaffle> mq32: ok, some questions, one of which is unrelated to my original question
<daurnimator> wow some zig files have gone through a lot of renames
<betawaffle> 1. i see that a section isn't being given explicitly for `kernelStack`, is that because `= undefined` implies the .bss section?
<betawaffle> 2. I see it's using global variables to store those values. is there no way to tell LLVM "hey, just bind this name to the register"
<mq32> betawaffle, i tried to bind it to registers, but i had reasons not to do it
<mq32> i think it didn't work at this position
<mq32> i recommend using inline assembler if the registers are relevant
<mq32> and to 1: it's undefined because i pretty much don't care for the contents
<betawaffle> k, not a big deal, i think this can work
<mq32> and thanks for the inspiration for a thing!
<betawaffle> what did i inspire?
<mq32> it would be cool if zig would introduce not only .bss but also .uninitalized
<mq32> because on microcontrollers or similar it can make a difference if you have to initialize code or not in the bootstrap environment
<betawaffle> oh, .bss is defined as zero filled, and .uninitialized would be defined as literally uninitialized?
<betawaffle> what is responsible for the mapping of section names to the semantics that go with them (by convention)?
<mq32> it depends on the loading process
<mq32> on microcontrollers, it's "you"
<mq32> you have to code your bootstrap environment yourself
<mq32> on Linux/Windows, it's the ELF loading in the OS
<betawaffle> eventually i'd like to get into firmware with zig
<betawaffle> like, run zig code right from the reset vector
<daurnimator> Assertion failed at /home/daurnimator/src/zig/src/ir.cpp:28963 in ir_analyze. This is a bug in the Zig compiler.
<daurnimator> Assertion failed at /home/daurnimator/src/zig/src/analyze.cpp:5553 in type_has_bits. This is a bug in the Zig compiler.
<daurnimator> ^^ hit while playing around with non-exhaustive enums. No time to investigate right now
<betawaffle> do people normally put /path/to/zig/build/bin in their PATH, or is there a nicer way to use master zig?
<mq32> betawaffle: i have zig in ~/software/zig-current
<betawaffle> the repo, or the build dir?
<mq32> and an updater script that will create a new folder in ~/software/zig-0.5.0-sodhffd and will update the symlink what is in PATH
<betawaffle> hmmm, i just switched from 0.5 to master, and i'm getting this:
<betawaffle> ./src/main.zig:12:8: error: invalid token: 'Symbol'
<betawaffle> export nakedcc fn _start() noreturn {
<betawaffle> at the `nakedcc`
<betawaffle> what am i doing wrong?
<betawaffle> oh i see, changed to `callconv(.Naked)` ?
mahmudov has joined #zig
<mq32> yeah i think the calling conv thing was changed
<betawaffle> arg, looks like the vscode plugin isn't completely compatible with master
epmills has joined #zig
<betawaffle> is there a way to control the location of the tag in a packed union?
<betawaffle> i need it to directly precede the data
<mq32> betawaffle: i think you have to do it manually then
<mq32> struct { tag: TagType, value: union { } }
<betawaffle> the packed union won't try to add its own tag somewhere?
<mq32> if it's a union without tag, yes
<betawaffle> oh i see, they are different things
<betawaffle> sorry i forgot that
<mq32> you can use extern union and get a classic C union
<betawaffle> is there a difference between a C union and a packed union?
<metaleap> `zig build` doesnt seem to directly consume "compiler options" from `zig --help` such as `-fdump-analysis`. does everyone who wants this need to tweak every project's `build.zig` to read those in and set up the Builder, or is there some automatic-args-propagation way?
<mq32> metaleap: the idea of zig build is that you specify a certain set of compiler flags in build.zig and make those flags that are *reasonable* to modify as a compiler switch to zig build
<metaleap> gotcha, thx!
<betawaffle> how can i add explicit padding to a packed struct?
<mq32> betawaffle: "padding0: u3"
<mq32> just introduce padding fields
<betawaffle> oh of course, i was thinking arrays of bools
<mikdusan> does this work? const Foo = `struct { a: Something, _: u3 }`
<mikdusan> does this work? const Foo = `struct { a: Something, _: u3, }`
<mq32> mikdusan: i don't think _ is allowed as a field name
<mq32> last time i tried, it was not accepted as "padding field"
<mq32> although i remember a proposal for that
tane has joined #zig
mahmudov has quit [Ping timeout: 240 seconds]
epmills has quit [Remote host closed the connection]
<betawaffle> how do i get the type of a struct field as an expression?
BaroqueLarouche has joined #zig
epmills has joined #zig
<mq32> std.meta.field probably
<metaleap> aargh, you do `[][]u8{ "foo", "bar" }` and compiler says "error: index of single-item pointer" (arrow hinting at "foo")
<metaleap> whatever I'm doing wrong, to newcomers the message might be reworked :D
metaleap has quit [Remote host closed the connection]
metaleap has joined #zig
mahmudov has joined #zig
<betawaffle> is it possible to set a struct field's default value based on the value of other fields?
<metaleap> man can this not be auto-coerced? wth! make a simple `const hello: []u8 = "hallo";` and compiler barfs "error: expected type '[]u8', found '*const [5:0]u8'". ok lets say i omit the type... i do `const foo = "foo";` and `const bar = "barbaz";`. now to pass these differently typed (former `*const [3:0]u8` and latter `*const [6:0]u8` I gather) to a func accepting merely a slice-of-strings aka [][]u8 --- someone puleeze show me the freakish gymnastics required
<metaleap> for that (or I am just too stupid and must golang back =)
<fengb> `const hello: []const u8 = “hallo”`
<fengb> That’s the first error. Although you should be able make a variable literal with `var hello`
<metaleap> ok i got it.. slice all the things `const hello = "hallo"; const wurst = "wurst"; const both: []const []const u8 = ([_][]const u8{ hello[0..], wurst[0..] })[0..];` .. idk so much noise tho
<fengb> You can make an array of strings with `[_][]const u8{ “hello”, “world” }` and convert that into a slice of strings by pretending &
<fengb> And those types can be inferred so you shouldn’t need the redundant manual declaration
<fengb> `const both = &[_][]const u8{ “hallo”, “wurst” }`
<metaleap> fengb: thought i'd tried that , but this time around it works so I messed up somewhere back then. merci
<fengb> That technically isn’t a slice of strings but it should work just the same
<metaleap> i'll find out =) so "technically" then.. it's a "pointer to the start of a 2-len arr of whatWeCallStrings", right?
<fengb> Yes, and array pointer auto coerce to slices
<metaleap> ack
dddddd has quit [Ping timeout: 265 seconds]
<metaleap> yay ran into my first "broken LLVM module found: Call parameter type does not match function signature!"
dddddd has joined #zig
kristoff_it has joined #zig
<metaleap> ok my "broken LLVM module found: Call parameter type does not match function signature!" was setting "somePtr.Field = mem.alloc(Foo, 2);" and resolved by "somePtr.Field = try mem.alloc(Foo, 2);". andrewrk: and others involved in the compiler: guess the type-checker should catch that before feeding LLVM. it does correctly remark that "This is a bug in the Zig compiler" =) issue needed, or issue known? (also my zig is 1 week old so might be fixed already)
kristoff_it has quit [Ping timeout: 268 seconds]
<mq32> metaleap, that bug is pretty well-known already :D
<metaleap> ok then i'm soothed =)
Akuli has joined #zig
GrooveStomp has joined #zig
<GrooveStomp> Hello
<mq32> hey GrooveStomp
<GrooveStomp> Good morning!
<GrooveStomp> I just started seeing a weird Zig build failure for my program.
<GrooveStomp> Build failed. The following command failed:
<mq32> execute that "following command" to see more error messages
<GrooveStomp> Sorry, tried to paste it all; but it got truncated in hexchat.
<GrooveStomp> OK
<GrooveStomp> The following command terminated unexpectedly: (...)
<GrooveStomp> Output: "Killed"
<mq32> huh
<GrooveStomp> I just started working on trying to build a simple program to reproduce the behavior; the current program is not succinct.
<GrooveStomp> /snap/zig/890/zig build-exe /home/aaron/code/private/gschip8/src/main.zig --library c --library GL --library X11 --cache-dir /home/aaron/code/private/gschip8/zig-cache --name gschip8 -isystem /usr/include/libdrm -isystem /usr/local/include -isystem /usr/include/x86_64-linux-gnu -isystem /usr/include --library-path /usr/local/lib --library-path /usr/lib/x86_64-linux-gnu --library-path /usr/lib --library-path /lib/x86_64-linux-gnu --cache off
<GrooveStomp> Killed
<GrooveStomp> I just tried turning cache off; it also dies with cache on - although I'm sure that's unsurprising.
<GrooveStomp> (Also just realized why the command didn't make it through. :-) )
<GrooveStomp> I'm using Zig 0.5.0
<GrooveStomp> I guess I could try using master and see if it still occurs
<mq32> hm
<mq32> current recommendation is to always stay close to master
<mq32> as this keeps the number of changes to your code low
<GrooveStomp> Aye; I just relatively small bursts of programming time; so I don't want to have to spend that time keeping up with upstream changes. My workflow vastly favors sticking to a specific version. :-) Granted, now I have *this* problem.
kristoff_it has joined #zig
<GrooveStomp> Hmm. master _also_ fails to build. OK, gotta build a succinct sample program it looks like.
kristoff_it has quit [Ping timeout: 260 seconds]
<GrooveStomp> Unrelated - I recall Zig does dead code removal, but there's a way to force Zig to parse all code anyway -- how would I do that?
<mq32> there's a "reference all stuff" item, but that only works for top-level declarations
<mq32> look in the stdlib tests
return0e has quit [Remote host closed the connection]
<gonz_> Has anyone looked into making 4coder work with zig?
<mq32> what is 4coder?
<metaleap> some editor. gonz_: is it LSP compatible?
<gonz_> Indeed, it's just an editor. metaleap: As far as I know, it's not.
<gonz_> It's very customizable in the same way Emacs is, but uses native code instead.
<mq32> ah :)
<GrooveStomp> mq32 Thanks for the pointer. Unfortunately I'm not really sure what I'm looking for. I'm browsing the std files looking at the tests but nothing is jumping out at me; ie: https://github.com/ziglang/zig/blob/master/lib/std/json.zig
<mq32> i'm sticking with VS Code right now
<gonz_> Yeah, I'm using VSCode as well, but I'd still like to write extensions in zig
<GrooveStomp> Thank you
<mq32> but i'm not fully happy with VSCode as well
<mq32> eats too much resources for my taste
<mq32> one day i'm going to write my own code editor :D
<gonz_> Having your extensions in a shared library and access to a GL context, etc., is a nice idea.
<betawaffle> what does CallingConventionInterrupt do?
<mq32> betawaffle, its a calling convention required on most platforms to implement interrupts
<betawaffle> but where can i find what it means specifically?
<mq32> i think it's pretty new
<betawaffle> so, my confusion is github search doesn't seem to show how it gets mapped back to LLVM
<betawaffle> is that just because github search sucks?
<mq32> callconv doesn't even has docs right now
<betawaffle> i'm talking about the zig code
<betawaffle> (the compiler)
TheLemonMan has joined #zig
<TheLemonMan> betawaffle, it only works on AVR/MSP430 and x86/x64
<TheLemonMan> and if you want to know what it does you can also refer to rust docs :) https://os.phil-opp.com/handling-exceptions/#the-interrupt-calling-convention
<TheLemonMan> or, if you prefer some examples in C, there's https://lists.llvm.org/pipermail/cfe-dev/2015-September/045171.html
<mq32> TheLemonMan: i wonder what the GCC attribute((interrupt)) does…
<TheLemonMan> kill your firstborn?
<mq32> probably
<TheLemonMan> that's an attribute that instructs the compiler to produce the correct prologue/epilogue sequence
<TheLemonMan> and sometimes you need a whole different calling convention because the system does something...weird?
<TheLemonMan> like x86 passing arguments to your handler
<mq32> TheLemonMan, do you know if zig supports that prologue/epilogue generation for arm atm?
<TheLemonMan> for IRQ handlers?
<mq32> yeah
<TheLemonMan> nope
<TheLemonMan> I mean, LLVM knows what to do, it's Zig that has no way to specify a given function is an interrupt handler
<TheLemonMan> BaroqueLarouche, I've implemented a neat Thumb1 clzsi that compiles down to 56 bytes o/
<mq32> so in order to create an interrupt handler for arm i have to write that code myself?
<BaroqueLarouche> TheLemonMan: nice!
<BaroqueLarouche> I am not yet at a stade that I need interrupt handling on GBA
<TheLemonMan> mq32, yep, but it's not that much code (plus, afair, you still have to get down to the asm level if you want nested interrupts)
GrooveStomp has quit [Ping timeout: 258 seconds]
marijnfs has joined #zig
<metaleap> what a journey, one runs into the funkiest issue playing with zig ... comptime mutex-acquire failure :D https://user-images.githubusercontent.com/22109/72667612-07a67200-3a1e-11ea-82d4-482762ac621f.png posted at #4224
<TheLemonMan> even without that it'd fail sometimes later
<metaleap> Argh and now I recall that `@compileLog` exists :D
marijnfs_ has joined #zig
marijnfs has quit [Ping timeout: 272 seconds]
marijnfs has joined #zig
marijnfs_ has quit [Ping timeout: 240 seconds]
epmills has quit [Remote host closed the connection]
adamkowalski has joined #zig
marijnfs_ has joined #zig
marijnfs has quit [Ping timeout: 268 seconds]
<marijnfs_> how do i choose an install path using zig build install?
return0e has joined #zig
return0e has quit [Remote host closed the connection]
return0e has joined #zig
marijnfs_ has quit [Ping timeout: 268 seconds]
marijnfs has joined #zig
<metaleap> trying to determine at comptime whether a type is string. to cover both literals and classic (runtime) `[]const u8` slices i trial-and-errored-out this concoction: https://gist.github.com/metaleap/151dc7fbcf73f7073800af189ebdfc85 is this generally how one would do it, or is there a smoother / smarter / shorter / sounder way. works for the current use at hand but still feel a bit clumsy & bumbling playing with this new comptime world
<metaleap> could produce a "false positive" for a pointer-or-optional-of-u8, annoyingly
<metaleap> nvm i'm the only caller anyway, meh
epmills has joined #zig
epmills has quit [Remote host closed the connection]
epmills has joined #zig
epmills has quit [Remote host closed the connection]
epmills has joined #zig
epmills has quit [Client Quit]
kristoff_it has joined #zig
_Vi has quit [Ping timeout: 240 seconds]
kristoff_it has quit [Ping timeout: 240 seconds]
marijnfs has quit [Remote host closed the connection]
ur5us has joined #zig
zfoo has joined #zig
ur5us has quit [Quit: Leaving]
ur5us has joined #zig
<betawaffle> TheLemonMan: are you LemonBoy on github?
<betawaffle> i've got a packed struct inside a packed struct
<betawaffle> get_abi_size_bytes(field_type->size_in_bits, g->pointer_size_bytes) = 4
<betawaffle> but LLVMStoreSizeOfType(g->target_data_ref, element_types[gen_field_index]) = 5
<betawaffle> (it's supposed to be a 32 bit struct, and i've got a comptime assertion that it is
<fengb> One of the many packed struct bugs
<betawaffle> what is LLVMStoreSizeOfType doing?
<fengb> Are the packed structs a multiple of 8 bits?
<betawaffle> the one that's hitting the assertion is. let me check if the outer one is
<fengb> I also remember the compiler falling over if any of the fields span across a byte boundary
ur5us has quit [Read error: Connection reset by peer]
<betawaffle> ah, yeah definitely a multiple of 8 bits. it's 116 bytes + 4 padding bytes (this may be the problem?)
<betawaffle> lemme gist the whole thing, sec
<betawaffle> the failure is on the `flags` field
<betawaffle> and it goes away if flags is a u32 instead
<fengb> Unused is u19
<fengb> You’ll have to manually unroll that
<betawaffle> ahhh, ok cool
<fengb> Split it into chunks that divide up properly
<betawaffle> fixed!
<fengb> 👍
<betawaffle> wow, so glad i asked
<betawaffle> is there a way to set the alignment of a whole packed struct, rather than setting the alignment for the first field's type?
<metaleap> i run into the weirdest segfaults.. ah to be a newb again, feels young again! https://github.com/ziglang/zig/issues/4228
epmills has joined #zig
AndroidKK is now known as AndroidKitKat
Akuli has quit [Quit: Leaving]
<metaleap> i mean i slightly shift some bits of code around while absolutely preserving logical meaning and bam, no more segfault. or move them back, segfault again. same logical meanings i swear! feels flaky as feck
epmills has quit [Remote host closed the connection]
jjido has joined #zig
natrys has joined #zig
natrys has quit [Quit: natrys]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 258 seconds]
return0e has quit [Read error: Connection reset by peer]
return0e has joined #zig
<TheLemonMan> betawaffle, yep
BaroqueLarouche has quit [Quit: Connection closed for inactivity]
kristoff_it has joined #zig
BaroqueLarouche has joined #zig
return0e has quit [Read error: Connection reset by peer]
return0e_ has joined #zig
kristoff_it has quit [Ping timeout: 268 seconds]
metaleap has quit [Quit: Leaving]
metaleap has joined #zig
epmills has joined #zig
kristoff_it has joined #zig
adamkowalski has quit [Remote host closed the connection]
marijnfs has joined #zig
kristoff_it has quit [Ping timeout: 258 seconds]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
epmills has quit [Remote host closed the connection]
jjido has joined #zig
epmills has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tane has quit [Quit: Leaving]
<andrewrk> mikdusan, nice work on getting the cmake thing figured out
<andrewrk> that looks like it was tricky
<TheLemonMan> cmake is tricky by definition
<andrewrk> metaleap, TheLemonMan implemented your proposal
<daurnimator> TheLemonMan: not sure if you browse the channel logs, but I ran into a couple of non-exhaustive-enum related bugs/asserts last night
<TheLemonMan> daurnimator, yup, did #4222 solve your problem?
<daurnimator> TheLemonMan: not sure. only just back at the computer now. going through all my emails. I did see that PR so need to give it a try. However its probably not it: I didn't have an empty enum I think?
<metaleap> TheLemonMan: andrewrk: wowzers! can i peek at the PR (which #id?) to get a feel for what it took
<metaleap> ah got it, #4220 nice will peek
<TheLemonMan> daurnimator, you didn't show any code :(
<TheLemonMan> I tried to find the problem and managed to crash the compiler heh
<daurnimator> TheLemonMan: indeed. They happened when I changed getErrno to return an enum and ran the stdlib test cases. didn't have time to narrow down even which test yet
<TheLemonMan> andrewrk, do we want assembler-optimized versions of some builtins?
<andrewrk> TheLemonMan, yeah generally we want the best possible implementation of all the builtins that fulfills the ABI
<andrewrk> the non-assembler versions are convenient because they work for all architectures, but if you know of a way to provide an arch-specific override that improves things, go for it
<betawaffle> is zig always going to use llvm for release builds, or is there some far-off plan to not depend on llvm at all in the future?
TheLemonMan has quit [Read error: Connection reset by peer]
<andrewrk> in the far off plan we have fast-to-compile non-llvm debug builds, and llvm for release builds still
<betawaffle> ok, that's what i thought
<daurnimator> Is there some nice way to do: `if (x==0) x else y` inline without writing `x` twice?
<daurnimator> cota: you'll need to tell us the error you're getting
<cota> it's at the top of the file
<andrewrk> it's at the top in comments
<fengb> slice = letter[0..1];
kristoff_it has joined #zig
<daurnimator> andrewrk: ah. /me blind
<fengb> That’s setting slice to a stack variable no longer in scope
<fengb> Line 30
<fengb> Ah it’s probably putting “letter” in the same space in memory
<fengb> So you always get the same pointer per loop
<andrewrk> that sounds like a good guess
<daurnimator> We should really get some escape analysis :P
kristoff_it has quit [Ping timeout: 258 seconds]
epmills has quit [Remote host closed the connection]
<cota> fengb: makes sense, thanks
kristoff_it has joined #zig
<metaleap> in the far off plan we have fast-to-compile non-llvm debug builds, and llvm for release builds still
<metaleap> meant to quote :D
<metaleap> comment on this: "far off" would mean after self-hosting-compiler done&solid?
<andrewrk> yes
traviss has joined #zig
<metaleap> good. would suggest that number of contributors might rise further with zig-compiler-in-zig in place. i'm not the only one who won't touch c/c++ but finds zig most affable, in stark contrast
<metaleap> s/not/probably not
kristoff_it has quit [Ping timeout: 260 seconds]
<daurnimator> How did we end up solving enums where multiple things have same unmber?
<daurnimator> *number
<andrewrk> it's allowed for extern enums
<traviss> wilsonk, that error you reported earlier 'broken llvm module' i believe is caused by using @setFloatMode(.Optimized) without --release-fast or --relase-small