ChanServ changed the topic of #zig to: zig programming language | | be excellent to each other | channel logs:
ur5us has quit [Ping timeout: 264 seconds]
jamii has joined #zig
<jamii> I'm very confused by the alignments produce by arrays inside packed structs -
<jamii> Can anyone explain this? I would expect them all to just be byte aligned.
<justin_smith> jamii: maybe I'm misunderstanding your question, but most CPUs do not allow arbitrary data offsets - eg. a 64 bit value must often be 8 byte aligned
notzmv has quit [Remote host closed the connection]
<justin_smith> you can store things how you like but this would mean a lot of extra work just to construct the value, instead of just being able to read / write the memory
notzmv has joined #zig
<justin_smith> oh but I see in your example the arrays are all arrays of u8...
<justin_smith> the alignment data might be there to ensure cast correctness?
<justin_smith> I'm sure someone else has the answer
<fengb> Packed structs are buggy
<leeward> I feel like we should put that in the channel topic.
<leeward> Be excellent to each other. | Packed structs are buggy.
<jamii> fengb: I was afraid that might be the answer :)
<jamii> I guess I'll have to do this the old fashioned way
<jamii> Here's a problem more closely related to what I'm trying to do -
<fengb> You might be able to get away with using an extern struct
<jamii> It seems like the (now poorly named) bytes field gets an unnecessary align(1) which then propagates into the element and makes all my code sad.
<jamii> fengb: That might work. I'll have to look up the abi rules. I'm trying to pack a tree branch into page. Might be easiest to just do this with pointer arithmetic for now.
leon-p has joined #zig
ur5us has joined #zig
a92 has joined #zig
hlolli has quit [Ping timeout: 246 seconds]
cole-h has quit [Ping timeout: 256 seconds]
leon-p has quit [Quit: leaving]
rslabbert has quit [Quit: WeeChat 3.0]
idxu_ has joined #zig
idxu has quit [Ping timeout: 260 seconds]
idxu_ is now known as idxu
jamii has quit [Remote host closed the connection]
lonjil has quit [Ping timeout: 246 seconds]
lonjil has joined #zig
earnestly has quit [Ping timeout: 246 seconds]
_whitelogger has joined #zig
a_chou has joined #zig
a_chou has quit [Remote host closed the connection]
a92 has quit [Quit: My presence will now cease]
lucid_0x80 has joined #zig
powerofzero has joined #zig
powerofzero has left #zig [#zig]
ur5us has quit [Ping timeout: 264 seconds]
ur5us has joined #zig
jj__ has quit [Remote host closed the connection]
jjsullivan1 has joined #zig
_whitelogger has joined #zig
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
a_chou has joined #zig
<companion_cube> <--- praise from a really strong hacker
remby has joined #zig
<andrewrk> Windows users: here's that surprise for you that I promised:
cole-h has joined #zig
ur5us has joined #zig
a_chou has quit [Quit: a_chou]
factormystic has quit [Ping timeout: 256 seconds]
rowbee has joined #zig
<rowbee> hi, is the if (fun()) |value| syntax customizable by user types, or does the language only permit it for optionals and errors?
xackus has joined #zig
sord937 has joined #zig
radgeRayden has joined #zig
<andrewrk> rowbee, the latter
<rowbee> gotchu
lucid_0x80 has quit [Remote host closed the connection]
lucid_0x80 has joined #zig
decentpenguin has quit [Read error: Connection reset by peer]
ur5us has quit [Ping timeout: 264 seconds]
remby has quit [Quit: remby]
decentpenguin has joined #zig
hlolli has joined #zig
dumenci has joined #zig
lucid_0x80 has quit [Ping timeout: 264 seconds]
wallyduchamp has joined #zig
wallyduchamp has quit [Quit: Leaving]
wallyduchamp has joined #zig
][_R_][ has quit [Quit: No Ping reply in 180 seconds.]
[RMS] has joined #zig
factormystic has joined #zig
wallyduchamp has quit [Ping timeout: 264 seconds]
moinstar has quit [Quit: Leaving.]
ur5us has joined #zig
cole-h has quit [Ping timeout: 240 seconds]
earnestly has joined #zig
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
ur5us has quit [Ping timeout: 264 seconds]
[RMS] has quit [Ping timeout: 272 seconds]
[RMS] has joined #zig
sord937 has quit [Remote host closed the connection]
sord937 has joined #zig
<betawaffle> does (or will) the zig build system allow users to bring their own stdlib, if they need to modify some aspect of it that isn't extensible yet?
<ikskuh> andrewrk: very neat!
<ikskuh> betawaffle: you mean the startup code? for alle other things, there isn't a requirement on the stdlib (except on std.builtin)
<ifreund> even the startup code isn't forced on you
<ifreund> you can export __start() yourself
<ikskuh> true
<ikskuh> only thing you need is the std.builtin part
<betawaffle> i suppose you're right, but does that really allow you to bring a _slightly modified_ version of std and have it work correctly?
<ikskuh> yeah
<ifreund> sure, copy paste the code to a new folder and call it mystd
<ikskuh> ^=
<ifreund> though I'd personally try to get whatever patch I needed upstreamed first
<betawaffle> for people writing kernels in zig, is it possible to support custom threading and threadlocal vars in freestanding?
marnix has quit [Ping timeout: 240 seconds]
marnix has joined #zig
<betawaffle> we definitely need some docs on all the various hooks you can put in your root module
<ikskuh> grep -rnIi '@import("root")'
<ikskuh> :D
<betawaffle> why don't i ever think of stuff like that
<betawaffle> ifreund: are you saying that if you don't import std, and you export the right symbol, it won't even include the start.zig file?
<ifreund> betawaffle: I'm saying that start.zig checks if you exported the proper symbol for the target and does nothing if you did
<betawaffle> oh i see, it doesn't do anything for freestanding or other
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
<rowbee> does zig have an LSP server or is one in the works?
<rowbee> thanks
sord937 has quit [Ping timeout: 240 seconds]
leon-p has joined #zig
sord937 has joined #zig
<dutchie> is there a better way to go from std.builtin.EnumField to the enum than @intToEnum(Enum, field.value)?
<ifreund> not that I know of, that doesn't seem to unwieldly IMO
<dutchie> mmm, it's not too bad, just feels slightly clunky when i'm already in an `inline for (@typeInfo(Enum).Enum.fields)`
dumenci is now known as lucid_0x80
marnix has quit [Read error: Connection reset by peer]
<rowbee> i went through the stdlib a bit but couldn't find anything that can help me split or tokenize a string, what's the best way to split a string by spaces?
<g-w1> std.mem.split
<g-w1> or std.mem.tokenize to split by multiple delims
<rowbee> i see, thanks
marnix has joined #zig
<dutchie> something about using void as a real type, not just a marker for no return value makes me think of great big gaping black holes in all my data structures
<dutchie> "ah yes, this is a map from string keys TO THE VOID"
<dutchie> i think there's a joke about set theory in there somewhere
<fengb> If it makes you better, Zig void is equivalent unit in type theory
<fengb> e.g. `()` in an ML
<dutchie> yeah, i think it's just the name. rust just uses () as void (and allows you to not write it in return types if it's all that's coming back)
<dutchie> isn't Haskell's Void type an empty enum though i.e. unreachable
cren has joined #zig
<fengb> We have an actual unreachable via `noreturn`
<fengb> I don’t think you can use that in a struct
sdixon has joined #zig
<sdixon> Hey folks, just installed zig! Very dumb question... where would the std lib be located if I installed via Ubuntu/snap? ZLS is saying it can't find it :(
dumenci has joined #zig
<ifreund> is there some way you can list the files installed by a snap thing?
<ifreund> Generally I'd recommend using a tarball from the website over snap...
<sdixon> i can which zig and see its located in /snap/bin/zig -- I know like nothing of snap haha
<sdixon> yeah coolio
<sdixon> I'll do that
lucid_0x80 has quit [Ping timeout: 260 seconds]
<ifreund> at a guess your lib is at /snap/lib/zig then
<betawaffle> how long do previous master builds survive in
<sdixon> no dice. but think I figured it out looks like /snap/XXX they store related files
<g-w1> i just found it
<g-w1> /snap/zig/weirdnumber/lib
<ifreund> betawaffle: a couple weeks, until andrew deletes them manually to save on AWS costs
<ifreund> g-w1: lol, of course
<sdixon> /snap/zig/current/lib/zig/std -- that was silly of me. thanks again for rubber ducking with me @ifruend stoked to start learning zig :)
<ifreund> snap being logical as usual :/
gpanders has joined #zig
lucid_0x80 has joined #zig
dumenci has quit [Ping timeout: 258 seconds]
<companion_cube> dutchie: void is a bit of a misnomer if it's actually just i0/u0/unit
<companion_cube> I think it's good to have a proper type and not C's void
<companion_cube> Much more uniform
<dutchie> oh yeah, 100% agree that it's way better than C's void
<cren> what's the difference between i0 and u0?
<betawaffle> when the package manager is in place, is std going to be available via that, such that we can have an up-to-date std with a slightly older zig compiler?
<fengb> i0 returns signed zeroes 🙃
ifreund1 has joined #zig
ifreund has quit [Ping timeout: 240 seconds]
<g-w1> betawaffle, I think std has to be in sync with the compiler or else bad things happen (from experience). some things like @TypeInfo are given by the compiler
<betawaffle> maybe that will change after 1.0. or perhaps the solution is to just have less in std, and make that stuff available as official packages
<g-w1> maybe other parts of std would work, but i think std.meta and std.builtin would have a 50% chance of breaking
<cren> fengb: how does that work?
<companion_cube> It does not, it's a joke
<betawaffle> g-w1: well, std doesn't break in every single master version
<companion_cube> 0 byte types are all the same
<g-w1> when i was working on stage2 1/10 times when I was using the tarball from the website to compile a slightly older stage2, the stdlib was mismatched and it didn't compile, so the solution was rebasing
ifreund1 has quit [Read error: Connection reset by peer]
<betawaffle> heh
ifreund has joined #zig
donniewest has joined #zig
<cren> companion_cube: then why are there different 0-byte types?
<companion_cube> Because they're special cases of general constructs?
<companion_cube> I mean, if you have in and un for every n, why not 0?
<cren> i guess
<cren> but why have them in the first place, actually? when would i need to use it?
<fengb> It's useful with generics
<companion_cube> Well it's important to have at least one zero sized type
<companion_cube> Several is just cherry on the cake I guess
jorangreef has joined #zig
<jorangreef> Hey everyone! Is there a way to iterate anonymous array literals, using for or while loops without running into "unable to evaluate constant expression"?
<jorangreef> I want to use Zig as a DSL for cluster config, and iterate these nodes to parse addresses:
<jorangreef> const nodes = .{ .{ .ip = "", .port = 3001 }, .{ .ip = "", .port = 3002 } };
waleee-cl has joined #zig
<ifreund> jorangreef: not yet, but there is an open proposal to allow that iirc
<jorangreef> Great, thanks ifreund
<ifreund> you could alternatively use zzz:
gpanders has quit [Read error: Connection reset by peer]
gpanders has joined #zig
gpanders has quit [Client Quit]
remby has joined #zig
seadragon-droid has joined #zig
<betawaffle> is anytype the new var, and is var just an alias for that?
<ifreund> betawaffle: anytype replaced var being used as a type, using var where a type is expected should no longer compile
<ifreund> var is still used for variables and you can't use anytype there
<betawaffle> the docs for 0.7 still have var in places
<ifreund> the stdlib docs?
<betawaffle> yeah
<ifreund> the language ref doesn't I hope
<ifreund> yeah the generated std lib docs are rather broken/incomplete
<ifreund> I recommend everyone to just read the source code (and get zls)
<betawaffle> but how does it result in `var` if that isn't actually the signature of format?
<betawaffle> does zig.vim use zls?
<g-w1> no
<ifreund> betawaffle: the stdlib doc gen falls back to var when it gets confused afaik
<betawaffle> i haven't figured out how to set up coc yet
<ifreund> you'll also find stuff that takes a []const u8 or something but the generated docs say it takes var
<jorangreef> ifreund going back to that earlier discussion, I saw that `inline for` also works to iterate anonymous array literals
<g-w1> betawaffle, do you use neovim, because coc might not work with regular vim, ive not tried
<ifreund> jorangreef: afaik that treats them as a tuple
<betawaffle> i use neovim, yeah
<ifreund> which is fine to iterate at comptime but not at runtime
<jorangreef> ifreund that's fine since I was wanting to iterate at comptime, thanks for the help
<g-w1> first make sure you have node, then use whatever plugin manager to install it, then type `:CocConfig` to get to the lsp config file and follow the instructions. this worked for me
<ifreund> jorangreef: no problem!
<betawaffle> "make sure you have node" is my main problem
<g-w1> neovim has some builtin lsp support that you could try
<g-w1> its beta so its kinda buggy ive heard, but its better than nothing
<companion_cube> I use LanguageClient in neovim 0.4
<companion_cube> it works well
<companion_cube> autozimu/LanguageClient-neovim more precisely
<betawaffle> honestly, i'd like proper docs ;) even just ones that let me navigate and look at the code
<betawaffle> if the language server can find definitions, i'd assume a doc generator could too
<ifreund> it's just waiting for someone to write it
<ifreund> the current old crappy docgen is C++ and quite bitrotted
<ifreund> we need a self hosted implementation at some point, but there are other priorities
<betawaffle> does zig have stuff for parsing zig and working with the ast?
<g-w1> std.zig
<ifreund> yes, std.zig
<betawaffle> nice
<g-w1> thats what zls uses
<ifreund> Yeah I honestly don't think it would be very hard to write a good docgen tool using std.zig, might be a fun project
<ifreund> personally my todo list is 10 miles long though :/
<betawaffle> i might experiment with that, we'll see
wallyduchamp has joined #zig
Akuli has joined #zig
Ashpool has joined #zig
hnOsmium0001 has joined #zig
notzmv has quit [Remote host closed the connection]
cole-h has joined #zig
notzmv has joined #zig
wallyduchamp has quit [Ping timeout: 260 seconds]
notzmv has quit [Remote host closed the connection]
notzmv has joined #zig
notzmv has quit [Remote host closed the connection]
notzmv has joined #zig
notzmv has quit [Remote host closed the connection]
notzmv has joined #zig
notzmv has quit [Remote host closed the connection]
Ashpool has quit [Quit: Leaving]
<andrewrk> jorangreef, that will let you iterate over a homogenous list too
<andrewrk> *heterogeneous
<jorangreef> P.S. Yes, we're writing an accounting database in Zig!
<andrewrk> hmm it doesn't look like you're taking advantage of comptime values in this loop
<andrewrk> oh I see you just wanted to not have to specify a type on `nodes`
<jorangreef> Yes, trying to explore Zig as a config DSL... but if we can use comptime in that loop that would be good.
preyalone has joined #zig
<andrewrk> yeah when you use `inline for`, it makes both of the captures comptime known within the loop
<preyalone> Hi! I am curious about using zig as a drop-in replacement for gcc/clang. How well does Zig support C17, C++17? What about compiler flags like -Wmost, -Weverything?
<andrewrk> preyalone, this feature of zig is powered by clang and lld
<preyalone> So... all of the above :) ?
<andrewrk> so the answer to the question is the same question as, what does clang 11 support
<preyalone> baller.
<andrewrk> what zig brings to the table on top of clang is (1) no system dependencies and (2) cross-compilation support with the -target option
<andrewrk> well and the handy binaries from :)
<andrewrk> jorangreef, this project looks ambitious - I'll be keeping an eye on it
<jorangreef> awesome andrewrk appreciate the pro-tips!
<preyalone> How stable is the Zig language, given its current, pre-v1.0 state? I got burned several times in Go and Rust before they hit 1.0
<andrewrk> very unstable. if you're concerned about getting burned you should wait a year or two
<g-w1> in this context, what does burned mean?
<andrewrk> your code bit rots because the language made breaking changes
<g-w1> ah
<preyalone> Hmm. I'd also like to see the `zig` CLI itself stabilize, so that I don't have to run back to my old C/C++ projects and make sure they still compile as the language progresses
<andrewrk> the `zig cc` / `zig c++` feature is determined by clang's CLI. so that's bound by the stability of clang CLI
<andrewrk> literally, we parse their table of CLI options and match it exactly
<preyalone> slick.
<andrewrk> are you mcandre on github?
<leeward> preyalone: The only good reason I have for writing code in Zig right now is to make Zig better. For projects I have to actually ship and support, Zig will be the wrong choice until it (and its standard library) stabilizes a bit more.
<preyalone> Bated breath for Linus to convert the kernel to Zig, Rust, D, something other than crusty ol C
<leeward> D is not going to happen. Rust looks like it's making inroads, at least in modules. Zig would be a really good fit once it hits 1.0.
<preyalone> As a Debian/Ubuntu user, does the zig package automatically install clang, or should I explicitly add this for `zig cc`, `zig c++` support?
<leeward> There's a zig package?
<preyalone> yeah, in a bintray third party repo
<g-w1> it doesn't install clang, its in the binary. it *is* clang
<preyalone> !
<andrewrk> preyalone, "what zig brings to the table on top of clang is (1) no system dependencies" ;)
<leeward> Huh, hadn't seen that one. Will have to try it out on systems where I don't need to build it.
<preyalone> Guessing that in the best case, many Zig applications will continue to import some native dependencies for some time, and end up needing xgo to manage these kinds of impure ports
notzmv has joined #zig
<preyalone> Is there a built-in flag to loop over ALL available ports? Or even a flag to list available target platforms?
<g-w1> im confused, the clang in zig can cross compile to any llvm-supported arch, iirc. is there a reason for a new tool?
<leeward> zig targets?
<preyalone> g-w1: Only in the case that a project depends on some non-pure Zig libraries
<g-w1> zig can just include c sources from the build.zig
<rowbee> i'm running doom emacs, whenever i save a file with zig-mode enabled, it seems to turn off lsp. should i create an issue on zig-mode repo?
<preyalone> Okay, `zig targets` is frankly impressive. Now how do I build for ALL of these targets in an automated fashion? Parse the output with `jq` and do a shell for loop?
<andrewrk> preyalone, zoom out a little bit, what are you trying to do?
wootehfoot has joined #zig
<preyalone> andrewrk: I have no ulterior motive. Let's say I want to port hello.c to as many platforms as physically possible. For the hell of it.
<andrewrk> I recommend to start with one target, then start adding more to an explicit list
<leeward> rowbee: sounds like it. I'm not having that problem with gnu emacs.
<preyalone> In the past I developed projects like goxcart, cartel, and tonixxx to manage cross compilation. I'm curious how I can use Zig to the same effect. Build all the ports!!!
<rowbee> leeward: this is also gnu emacs, just with pre-installed packages
<rowbee> let me see here
<g-w1> you can use std.Target to find it. its easy just to do a O(n**3) loop over everything to get all possible combos
<leeward> rowbee: hmm, let me check if there's anything newer in zig-mode than what I'm running.
<leeward> nope...sounds like a configuration issue
<preyalone> Does Zig work with Doxygen for generating HTML API docs?
<preyalone> ah, -fgenerate-docs
<ifreund> be aware that that flag is by no means production ready and quite bitrotted atm
<ifreund> it's waiting for someone to reimplement it in zig (currently its functionality is written in C++)
<leeward> Anyone who knows things about LLVM have a clue what I'm looking at here?
<andrewrk> leeward, "cannot select" basically means you hit a TODO panic in LLVM
<leeward> ahh
lucid_0x80 has quit [Ping timeout: 260 seconds]
<Nypsie[m]> ifreund: I noticed that the old wasm tests generate an error currently because codegen.zig does not yet support u64 and floats for constants. Would it be ok to disable 2 of the tests?
<Nypsie[m]> (This is for the current PR I opened for moving the wasm backend to codegen.zig)
<leeward> Thanks, andrewrk. That probably saved me hours of pointless digging. Back to linker scripts with me.
<andrewrk> leeward, it could mean the codebase needs an improvement, or it could mean a missing compile error because that target, with the selected CPU feature set, could not generate any code to match your zig
<andrewrk> s/codebase/LLVM codebase/
<andrewrk> given that it has to do with atomics, I think what happened is a missing compile error saying that this target cannot support usize atomics
<andrewrk> if you think that is a mistake then it's LLVM's instruction selection needing a patch
<leeward> I'm pretty confident it's that. I've gotten Zig to generate a .o file from that source file already.
<andrewrk> you are welcome to file a zig issue for LLVM bugs
<preyalone> Zig doesn't need separate header files like C for pure code, right?
<andrewrk> we track them until they are fixed
jorangreef has quit [Remote host closed the connection]
<leeward> Ooh, that's an idea. I'll do that.
<leeward> preyalone: Right.
<ifreund> Nypsie[m]: sure, do whatever makes sense
<preyalone> Thinking about how I want to structure my Zig projects. Might borrow the ./*.go, src/cmd/<name>/main.go convention and use .zig extension
<preyalone> er, ./cmd/<name>/main.go
<Nypsie[m]> ifreund: Thanks for confirming and the previous feedback you gave me :)
<ifreund> Nypsie[m]: are you planning on reverting your changes to how function indexes are handled or have you come up with something new that works and is better?
<preyalone> What's the significance of the Zig logo? Just looks cool?
TheLemonMan has joined #zig
<TheLemonMan> leeward, let me guess, msp430 uses 16bit integers?
<preyalone> cmd/<name>/main.zig is helpful for any projects with multiple distinct binaries, like how git is actually split up into a dozen binaries
<leeward> TheLemonMan: You got it.
<Nypsie[m]> ifreund: I couldn't come up with a strategy that accesses both the target declaration as well as the current declaration to append the target to the current declaration. I think the implementation I made is pretty sane, but I want to perform more testing before I'm confident in it. (Such as randomly inserting and removing functions all over the place).
<leeward> TheLemonMan: I ran into something like this when fiddling with avr support, but worked around it by linking manually. On msp430, gnu ld expects main to be in a section called .init9, and zig puts it in .text, so I was hoping that maybe I could skip the linker script but no.
<TheLemonMan> you should put a c_int where I used i32, that'd match the C definition for such targets too
<leeward> Ooh, ok, thanks.
<leeward> Same llvm error.
<TheLemonMan> link?
<leeward> Cannot select: 0x5557a03d9060: ch = AtomicStore<(store release 2 into %ir.6, align 64)> 0x5557a11de1d8:1, 0x55579fd2c9b0, Constant:i16<0>
osa1 has quit [Quit: osa1]
<preyalone> Can Zig allow semicolons to be omitted for simple procedural code? Many modern languages leave these out unless you are tightly expressing multiple statements within a single text line.
<leeward> filling out an issue on github...that'll probably be easier to talk about
osa1 has joined #zig
<ifreund> Nypsie[m]: what you have now hardcodes function indexes into the in-memory generated code. This means that whenever e.g. the function at index 0 is deleted ALL code needs to be regenerated
<ifreund> which kills incremental compilation
<ifreund> (unless I'm missing something)
<g-w1> no semicolon omission
<TheLemonMan> leeward, gimme a few minutes, I'll fetch a MSP430 manual
<karchnu> preyalone: I guess this will imply an ambiguous grammar, therefore slower compilation.
<TheLemonMan> it seems that either MSP430 or LLVM don't support atomics on `usize`-wide memory cells
<ifreund> it wouldn't necessarily be ambigous, but it would be inconsistent
<TheLemonMan> that's the bare minimum we need for the fallback atomics to work
<ifreund> and not very "one way to do things"
<Nypsie[m]> ifreund: That makes perfect sense. I'll revert it and give it another try to make it work
<ifreund> cool, sorry the comments/commit message didn't make it clear why things were the way they were :D
<preyalone> I see in the GH issues the syntax is fixed for now. It's just surprising, given how Google's Go and Apple's Swift have dropped semicolons for visual simplicity. Although Rust keeps the semicolon.
<ifreund> emulating Go/Swift isn't a goal
<ifreund> IMO semicolons make code more not less readable
<ifreund> like how proper punctuation makes english work much better
<Nypsie[m]> ifreund: No worries, I appreciate it
<ikskuh> <ifreund> IMO semicolons make code more not less readable <= this
<preyalone> Hmm.
<preyalone> The hello world example produces a compile error on my machine
<ikskuh> which version do you have?
notzmv has quit [Ping timeout: 246 seconds]
<ikskuh> that sounds horribly outdated
<ikskuh> what compiler version do you have?
<ikskuh> (use "zig version" to get it)
<preyalone> Ah, the Debian repo has Zig at v0.6.0
<TheLemonMan> leeward, have you tried setting `largest_atomic_cas_size` to zero for msp?
<ikskuh> don't use the OS packaged one, use the master tarball from the website
<andrewrk> preyalone, are you mcandre on github?
<preyalone> @ikskuh sure
<leeward> TheLemonMan: I have not.
<preyalone> @andrewrk yes
<leeward> But will!
myNameJeff has joined #zig
<andrewrk> preyalone, so far 4/4 of your issues are questions you could get answers for here, please try to keep the issues related to the zig codebase
<preyalone> sure
<preyalone> Is there a zvm yet?
<g-w1> zigup
<leeward> TheLemonMan: No change.
<ikskuh> preyalone: there are several out there
<ikskuh> i just use a stupid bash file for that
hlolli has quit [Ping timeout: 240 seconds]
<ifreund> I just build zig from source with whatever commit I want :D
<ikskuh> ^= or this
<preyalone> Link to zigup?
<TheLemonMan> leeward, I'll give it a spin, does passing `--single-threaded` make any difference?
<leeward> TheLemonMan: Nope, same result.
<TheLemonMan> can't try right now as the compiler is building and all my ram is occupied
<leeward> TheLemonMan: sounds like a familiar problem
<preyalone> Pre 1.0, with too old a version of the compiler in the Debian repo... Basically, I'm getting the same early days behavior with Zig as I had with Swift on Ubuntu. There, the thing compiled but segfaulted lol
<ikskuh> preyalone: yeah, zig is still in a very early phase
<ikskuh> but even now, it's more pleasure to work with zig than with C/C++
<ikskuh> it's less pain to write new libraries than using existing ones in their main language :D
<preyalone> You'll know we're blowing up when Microsoft creates yet another language clone instead of adopting it
<andrewrk> TheLemonMan, sorry about the CI failure - gonna try to push a quickfix to arch-gate kubkon's macho code signing thing only for aarch64 for now
<andrewrk> aarch-gate
<TheLemonMan> yeah, the patching logic is smart as is fragile :\
<preyalone> Zig claims it has no macros. So if one does choose to wrap native libraries, then how are we supposed to inform Zig, use *this* code for X platform and *that* code for Z platform? Anything like Go's build directives here?
<TheLemonMan> stupid apple and its stupid signed binaries
<companion_cube> preyalone: zig# ?
<companion_cube> that'd be fun
<ifreund> preyalone: comptime
<ikskuh> preyalone: switch(std.builtin.os.tag) { .windows => {}, .linux => {}, … }
<ifreund> there's an example of this on the homepage
<fengb> Comptime is a magic solution that replaces macros, templates, generics, metaprogramming, and cancer
<ikskuh> zig has compile time execution, you can select stuff at compile time and exclude other code
<ikskuh> without different syntax
<preyalone> cool
<leeward> fengb: It would be nice if we didn't come up with a new kind of cancer.
<companion_cube> I mean, it's rust whose mascot is a crab
<leeward> Though I can't argue about comptime sometimes forgetting how to die.
<preyalone> I feel dumb. How am I supposed to use comptime to distinguish between different platform-specific code?
<preyalone> Define some type synonyms when the build executes?
<fengb> Zig is very lazy, so things that are detected to be inactive at comptime will not be compiled
<leeward> preyalone: look at std.builtin.os.tag or std.builtin.arch, which are populated at build time.
<andrewrk> if (std.Target.current.os.tag == .windows) { a(); } else { b(); }
<preyalone> cool
<preyalone> Can I insert such conditionals in imports as well?
<ikskuh> you can insert them *everywhere*
<andrewrk> I encourage you to read through that language reference section I linked
<ikskuh> const SomeType = if(std.Target.current.os.tag == .windows) u32 else f32; // u32 in windows ;)
<leeward> const library = switch (std.Target.current.os.tag) { .windows => @import("windows_library"), else => @import("non_windows_library")};
<preyalone> Does Zig stdlib offer CLI flag parsing? Any third party docopt/getopt implementations?
<companion_cube> there's `clap` I think
<companion_cube> or you can bind getopt
<ikskuh> clap, zig-args
philtor has joined #zig
* ikskuh wants to advertise this:
wallyduchamp has joined #zig
<g-w1> how does the * person work. this has confused me for a while?
<ifreund> g-w1: /me
<g-w1> thanks
<ikskuh> /me is not amused
<ikskuh> =>
* ikskuh is not amused
<ikskuh> *grin*
<preyalone> getopt is okay in UNIX but a pain to integrate regarding Windows targets. So pure Zig is really helpful there!
<ikskuh> /say will make you say stuff literal, even if it starts with /say
* leeward /action is the same as /me
<ikskuh> my absolute favourite is /slap though
<leeward> That one's more client specific.
<fengb> Old school trout
* ikskuh slaps fengb around a bit with a large trout
<TheLemonMan> so many large trouts died for this
<ikskuh> ^= that is slap
<ikskuh> TheLemonMan: it's a tradition
<ifreund> weechat doesn't support this by default :/
<fengb> Our next generation IRC users won't understand trout references
<leeward> I haven't slapped anyone with a trout since the '90s with mIRC.
<preyalone> what's irc
<fengb> Just kidding, next gen won't use IRC 🙃
* TheLemonMan slaps ikskuh with a large slab of firm tofu
<preyalone> lelel
<leeward> fengb: s/next/this/
<preyalone> anyone in the Reddit zig cat? Gitter? Discord?
<preyalone> *chat
<ikskuh> Discord: ack, Reddit: sometimes
<leeward> The discord is pretty...high volume.
<TheLemonMan> reddit has.. a chat?
<ifreund> i think the new javascript site does
<preyalone> and mobile
<ifreund> i of course don't use the new javascripty site though so I'm not sure about the details
<fengb> It does?
<TheLemonMan> oh right, the new website
<ifreund> who uses the default mobile reddit app
<ifreund> its horrible
<fengb> Oh right, I switched off once it was spamming me to use the chat
<fengb> I remember now
<preyalone> reddit.{ios,android,winrt}.zig, do it
<TheLemonMan> I have a firefox extension to redirect me to
<Nypsie[m]> I should get that :o
<TheLemonMan> suck a large trout reddit, I won't use your shitty redesign
<earnestly> If that ever breaks there's also
<earnestly> (Which I use for the few times I look at reddit simply because it doesn't collapse any comments by default (which needs javascript and third-party scripts to function, even on old.)
<Nypsie[m]> Lovely, apparently you can also disable it in the settings itself on reddit. TheLemonMan: Thanks!
<andrewrk> the mobile reddit app, and the new reddit mobile website, are both slower than the old desktop website on a phone
wilsonk has quit [Ping timeout: 272 seconds]
ur5us has joined #zig
riba has joined #zig
<oats> if you must use reddit on a phone, slide for reddit is pretty good. FOSS and it's on f-droid
<TheLemonMan> I print a few pages off the frontpage and stuff them into a good old-fashioned binder
<TheLemonMan> no need for apps
<TheLemonMan> leeward, you can temporarily get rid of the problem by editing compiler_rt.zig, just remove the import of "atomics.zig"
<TheLemonMan> beware that some parts of the stdlib may need adjustments because of the 16bit usize
<leeward> TheLemonMan: Just read your comment on the issue. I'll try that.
<leeward> Well, all these u32s that are being used as usize should probably get fixed anyway.
<leeward> Though it would be nice if there were a register-sized type instead of just a pointer size.
<TheLemonMan> yeah, gotta check the libgcc definitions to see what's a c_int and what not
notzmv has joined #zig
<leeward> oof, there's some stuff in the math library that will probably be incorrect if I just naively replace u32 with c_uint...will look into that later
<leeward> Woot! A new error: "warning: unexpected LLD stderr: ld.lld: warning: cannot find entry symbol _start; not setting start address"
<leeward> I think this is related to the problem I've been having when linking manually.
<leeward> Yeah, it's not linking it.
<TheLemonMan> no _start?
<leeward> Yeah.
<leeward> That should be put in by...start.zig?
<TheLemonMan> yeah
moo has joined #zig
<leeward> objdump of what it generated:
<leeward> oh, hmm, never mind
<TheLemonMan> unless you're -freestanding
<leeward> that's not right
<leeward> I am -freestanding
<leeward> This is what it generated:
<TheLemonMan> then that's right, you gotta define/export it by hand
<leeward> That was an older version of the dump file that I had generated yesterday.
wootehfoot has quit [Ping timeout: 256 seconds]
<leeward> Oh, well I should have known that. It's just `export fn _start() noreturn { ...}`?
<TheLemonMan> `pub export fn _start() void`
<TheLemonMan> or noreturn, if you're feeling fancy
<leeward> Well, that's a new and interesting error message.
<leeward> I feel like there's something missing here. I should probably set up a stack.
nycex has quit [Ping timeout: 240 seconds]
<TheLemonMan> get the .o binary and run it trough objdump -dr, check what relocation is wrong
nycex- has joined #zig
<leeward> Do I need to do the C runtime style stuff like initializing the stack and clearing bss manually in freestanding?
<leeward> also: this is the objdump of the .o:
<TheLemonMan> yeah, but that's orthogonal to the linker error
<leeward> Huh, objdump put that R_MSP430_16_BYTE in indented without my help.
_whitelogger has joined #zig
<leeward> Yeah, it looks like it.
<leeward> The one I pasted is all the errors I get.
<leeward> I disabled the atomics import and fixed the errors in std/math/exp2.zig, then it's exactly the command line you see.
marnix has quit [Ping timeout: 256 seconds]
_whitelogger has joined #zig
<leeward> heh, cheating with -lc failed: "attempt to unwrap error: LibCInstallationNotAvailable"
<leeward> I guess I'll just copy the contents of crt0.S.
wootehfoot has joined #zig
moo has quit [Ping timeout: 256 seconds]
notzmv has quit [Remote host closed the connection]
notzmv has joined #zig
<leeward> TheLemonMan: <- the full patch to Zig sources that I'm using, in case it's causing differences
moo has joined #zig
<leeward> *gasp*
<leeward> It built something.
wootehfoot has quit [Ping timeout: 240 seconds]
<leeward> Oh, it didn't install the interrupt vector table.
<leeward> Is freestanding really supposed to come with 0 runtime overhead?
rowbee has quit [Remote host closed the connection]
rowbee has joined #zig
<leeward> Hmm, anyone know how to tell Zig to put a bit of data at a particular address? Comptime pointers?
<ifreund> I think you can @intToPtr the address and deref it?
<leeward> ifreund: Sure, but can I do that at comptime?
<leeward> Well, that's what I'm trying, anyway.
<ifreund> I'm not sure, I feel like I've seen code doing this somewhere but I can't recall where
wootehfoot has joined #zig
moo has quit [Ping timeout: 265 seconds]
<leeward> Maybe what I need is just an array and a linker script to locate it.
<leeward> But Zig doesn't seem to do linker scripts...
<leeward> Mmm, looks like I'm out of time for now. Might come back to this tonight.
<ifreund> I'm almost certian I've seen zig code in some repo setting up the interrupt vector table
<ifreund> but I can't find a link
radgeRayden has quit [Ping timeout: 272 seconds]
sord937 has quit [Quit: sord937]
notzmv has quit [Remote host closed the connection]
moo has joined #zig
wootehfoot has quit [Ping timeout: 258 seconds]
xackus has quit [Remote host closed the connection]
xackus has joined #zig
Akuli has quit [Quit: Leaving]
<leeward> Ooh, a hack that will work has been discovered!
donniewest has quit [Quit: WeeChat 3.0]
<leeward> It does work! Just setting main to `linksection(".init9")` lets me run gnu ld and have it put everything in place nicely.
moo has quit [Read error: Connection reset by peer]
radgeRayden has joined #zig
xackus has quit [Ping timeout: 256 seconds]
<preyalone> What happens in the zig build tool during `exe.install();` ?
<preyalone> Go tools are traditionally placed into $GOPATH/bin. Is there a similar location for Zig binaries?
<ifreund> preyalone: they go to the cache directory if no prefix is set with --prefix
<ifreund> if you set a prefix, they go to the prefix
<preyalone> gotcha
myNameJeff has quit [Ping timeout: 258 seconds]
<preyalone> I see some references to run_cmd, run_step in the build.zig file that zig generated for me. But I don't know how to properly trigger these tasks.
remby has left #zig ["Good Bye"]
<ifreund> zig build run
<ifreund> see also zig build --help
<preyalone> thank you, ifreund! i was confusing that with the `zig run` subtask
<g-w1> it actually calls zig run under the hood
<preyalone> makes sense
<ifreund> pretty sure it doesn't actually
<preyalone> I love that the build system is just 100% Zig code. More programming languages need to take heed.
<ifreund> just runs the artifact generated by the LibExeObject step using zig build-exe or whatever
<g-w1> oh huh I saw addSystemCommand and thought it did. nvm
DarkPlutonium has joined #zig
<preyalone> Mage works that way, too
<preyalone> Ended up writing my own half ass task managers, dale for D and tinyrick for Rust, to that effect
DarkUranium has quit [Ping timeout: 260 seconds]
DarkPlutonium is now known as DarkUranium
riba has quit [Ping timeout: 246 seconds]
<leeward> I may be the only person on the planet who wanted this, but...
<leeward> laters ziguanas
radgeRayden has quit [Ping timeout: 272 seconds]
<ifreund> andrewrk: I seem to recall you running into something about musl startup code not being run recently, I think I've hit the same issue
<ifreund> __progname which is used by mesa as a fallback on musl systems is never initialized when running with zig's start.zig startup code
<andrewrk> ifreund, that was for my PoC for a libc-agnostic binary that can open a window and use the system vulkan driver
<ifreund> right, so was the conclusion that there is musl startup code that isn't being run?
<andrewrk> preyalone, I'd appreciate if you'd ask around before opening all these issues that are just getting closed
<andrewrk> I've given you a 1 day timeout to show you than I'm serious about not spamming the issue tracker
<ifreund> so musl has this __init_libc() function here:
<ifreund> should we be duplicating more of this behavior in start.zig if linking libc?
<ifreund> I'm not even sure how this function gets called
cren has quit [Quit: cren]
<andrewrk> ifreund, I think you're hitting
<andrewrk> this is a musl-based linux distro right?
<ifreund> indeed, the person feeding me stack traces is runnind a musl distro
<andrewrk> yeah. zig is broken for such systems if they rely on dynamic linking musl - which any graphics based program does
<andrewrk> it may be possible to work around using the --libc parameter
<preyalone> Trouble doing basing loops. Help?
<andrewrk> ifreund, this is a rather glaring problem, I really should prioritize fixing it
<ifreund> andrewrk: that would of course be appreciated, it seems the NULL __progname is probably stopping river from getting to this point
<andrewrk> you really need full dynamic musl linking support to be correct
<ifreund> yeah I realize that
<g-w1> preyalone, try `inline for` since it is a tuple. I suspect that making it a regular array will make it work.
<ifreund> I wouldn't mind trying to fix #5364 myself, but I'm really not sure where to start
<preyalone> @g-w1: Like, convert this to an explicitly typed array?
<andrewrk> ifreund, I could help if you're interested in spending some time on it
<andrewrk> I think it's a 1-3 day project
<ifreund> I guess by reading how linking glibc works?
<andrewrk> nah musl is way simpler than glibc
<ifreund> oo, 1-3 days sounds like I could get it done before 0.7.1
<andrewrk> hmm yeah I'd be willing to call that a bug
<g-w1> yes, try to convert it to a typed array
<andrewrk> step 1 is build musl normally, and get a log of the commands the build used to produce the file
<preyalone> Is there a string type, or just an array of u8's?
<ifreund> preyalone: no builtin string type no
<andrewrk> there is no string type and there are closed issues you can go read to learn why
<preyalone> Eh, I'm used to Haskell's similar string type structure, where strings are, for the most part, simply arrays that happen to contain characters
<andrewrk> ifreund, you are right though - there are elements of how zig builds a dummy .so file for glibc that will apply to musl. but it will be much simpler for musl because we don't have to deal with abi versions
<andrewrk> in summary: find out what linker command the system compiler does on a musl-based system when you build hello_world.c and dyn link against system musl
ur5us has quit [Ping timeout: 264 seconds]
<andrewrk> that will tell you what crt files you need to grab from the musl repo. for example crtn.c or crt1.s or something like that
<preyalone> Are Zig strings null terminated?
<preyalone> I see. But where is the example for declaring a multidimensional array, so that coders can provide arrays of varying-length strings?
<ifreund> var foo = [_][]const u8{"this", "is", "it"};
<andrewrk> preyalone, did you try searching that document for "multidimensional array"?
<preyalone> Yes I did
<preyalone> ifreund's syntax works. I was trying things like [_][_]u8
<andrewrk> and what happened when you did that search?
<preyalone> The search yielded one short example for number matrices, whose syntax failed to compile when applied to u8 matrices of varying length strings
<ifreund> well arrays have fixed length as stated in the docs
<andrewrk> I see, you are asking about varying length strings
<ifreund> you might notice if you scroll down a bit more that there is a section on Slices
<ifreund> andrewrk: I think you've given me enough to get started, time for me to read code and learn a lot more about how linking works
<andrewrk> ifreund, the nice thing is you can play with it on the command line without writing any zig code. when it's time to write the patch, basically all you're doing is writing zig code that is doing the work a build system would normally do
<andrewrk> and trying to integrate it nicely with the cache system
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<ifreund> that's a very helpful perspective, thanks
<preyalone> I see slices, but no slices apparently featuring multiple distinct strings as members
<ifreund> preyalone: you can make an array or slice of anything, including slices
<preyalone> execve is mentioned in the API docs, but not actually documented itself;os
<ifreund> read the source, the generated docs are incomplete as I said earlier
<preyalone> +1
<preyalone> Unable to report further issues on GitHub. Not a good experience.
<ifreund> well, your issues haven't had a high signal to noise ratio, most of them would have been better as a message here
<preyalone> That's one opinion
<fengb> That’s more than one opinion
<preyalone> From my perspective, any language whose Hello World doesn't work out of the box is not off to a good start
<ifreund> it does
<ifreund> if you can can manange to match your version of zig the version of the docs you read
<ifreund> which isn't really too much to ask
<preyalone> The Debian release does not support the syntax. It's months out of date.
<ifreund> blame debian
<andrewrk> preyalone, would you like to participate in this community? you will have to be willing to listen to the feedback you are getting. I'm not interested in having an argument about it
<viashimo> i didn't think zig was in debian
<ifreund> yeah that suprised me to
<fengb> I mean... item that Debian’s MO: months out of date
<ifreund> i didn't think they had any software released in the past year :D
<viashimo> it doesn't seem to be in debian
<ifreund> probably some third party ppa then...
<ifreund> sigh
<preyalone> Could someone help me to locate the file where the std.os functions are defined in the zig source? I tried searching the whole project but get too many results unrelated
<ifreund> std/os.zig?
<ifreund> no that would be too obvious
<preyalone> Nested under lib, okay okay
<ifreund> also if your're really stuch you can always go to std.zig and follow the @imports()
<preyalone> good tip!