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/
KIMI_0881 has quit [Remote host closed the connection]
frett27_ has quit [Ping timeout: 272 seconds]
joaoh82 has quit [Remote host closed the connection]
joaoh82 has joined #zig
a_chou has joined #zig
joaoh82 has quit [Ping timeout: 256 seconds]
a_chou has quit [Remote host closed the connection]
cole-h has joined #zig
hsh has quit [Quit: Connection closed for inactivity]
hlolli_ has joined #zig
hlolli__ has quit [Ping timeout: 272 seconds]
joaoh82 has joined #zig
a92 has quit [Remote host closed the connection]
a92 has joined #zig
joaoh82 has quit [Ping timeout: 264 seconds]
a92 has quit [Ping timeout: 240 seconds]
moinstar has quit [Quit: Leaving.]
moinstar has joined #zig
xackus_ has joined #zig
joaoh82 has joined #zig
joaoh82 has quit [Remote host closed the connection]
joaoh82 has joined #zig
hlolli_ has quit [Ping timeout: 272 seconds]
<andrewrk> marler8997, with the latest commit to zig-window it is additionally working on musl based linux distros
tetsuo-cpp has joined #zig
xackus_ has quit [Ping timeout: 240 seconds]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
xackus_ has joined #zig
cole-h has quit [Ping timeout: 246 seconds]
Iolen has joined #zig
Iolen has quit [Quit: Leaving]
dumenci has joined #zig
joaoh82 has quit [Ping timeout: 240 seconds]
gpanders has quit [Ping timeout: 265 seconds]
gpanders has joined #zig
joaoh82 has joined #zig
gpanders has quit [Ping timeout: 246 seconds]
joaoh82 has quit [Ping timeout: 264 seconds]
gpanders has joined #zig
gpanders has quit [Ping timeout: 240 seconds]
srgpqt[m] has quit [Quit: Idle for 30+ days]
frett27_ has joined #zig
koakuma has joined #zig
<ikskuh> andrewrk: can i somehow use Builder.addWriteFile to create a Package?
<koakuma> Excuse me, I'm having some weird issues with floating point values on sparc64
<koakuma> Found out that FP values would compile down to wrong constants in assembly when compiled natively on a sparc64 machine, but compiles down correctly when cross-compiled using an x64 machine
<koakuma> For example: https://pastebin.com/yavW4p9s
<koakuma> I'm still not very familiar with the compiler's internals, can anyone help me with directions so that I can start debugging this?
<koakuma> Oh, the issue is observable in the generated LLVM IR too
mmohammadi9812 has left #zig ["User left"]
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
gpanders has joined #zig
rzezeski has quit [Quit: Connection closed for inactivity]
TheLemonMan has joined #zig
<TheLemonMan> koakuma, that's weird, only the upper part is corrupted
notzmv has quit [Ping timeout: 256 seconds]
joaoh82 has joined #zig
notzmv has joined #zig
lucid_0x80 has joined #zig
dumenci has quit [Ping timeout: 256 seconds]
benjamin-l has quit [Quit: WeeChat 2.9]
joaoh82 has quit [Ping timeout: 246 seconds]
gpanders has quit [Ping timeout: 240 seconds]
<koakuma> Yeah
<koakuma> All the corruptions seem to happen in the first 12 bits
<koakuma> In f32 and f64
<TheLemonMan> 12... that's the sign+exponent for a f64
<TheLemonMan> I bet for f32 it's the upper 9 bits
<koakuma> Lemme check
<koakuma> -10.05 compiles down to 0xf7a0cccd here
<koakuma> So yeah, nine bits
<koakuma> Some sort of parsing or codegen bug, maybe?
<TheLemonMan> check out gen_const_val
<TheLemonMan> break there with a debugger and check if the const_val->data.x_f32 (or x_f64) values are ok
<TheLemonMan> if they are already fucked up the problem is with Zig
marnix has quit [Ping timeout: 272 seconds]
marnix has joined #zig
frett27_ has quit [Ping timeout: 272 seconds]
gpanders has joined #zig
gpanders has quit [Ping timeout: 260 seconds]
marnix has quit [Ping timeout: 264 seconds]
marnix has joined #zig
<koakuma> TheLemonMan: const_val->data.x_f32 is also wrong
<koakuma> -10.05 becomes 0xf7a0cccd there too
<TheLemonMan> cool, it's Zig corrupting the values then
joaoh82 has joined #zig
<TheLemonMan> the next stop is ir_gen_float_lit, if the bigfloat value is corrupted there we have a lead
xackus_ has quit [Ping timeout: 265 seconds]
xackus_ has joined #zig
gpanders has joined #zig
<koakuma> Okay, lemme check there too
joaoh82 has quit [Remote host closed the connection]
<koakuma> It seems that it represents the literal using 128-bit softfloat?
<koakuma> *node->data->float_literal.bigfloat is where the float value is stored, right?
<TheLemonMan> yep
<TheLemonMan> it then calls bigfloat_to_f64 to get the value you see in x_f64
<koakuma> The content is {4643001868805052825, 11068046444225751414}
<koakuma> Not sure how to interpret/convert it to floating value notation
<TheLemonMan> ask gdb `p bigfloat_to_f64(your bigfloat ptr)`
<koakuma> $10 = 6.5228229285343777e+33
<koakuma> So still wrong here
<TheLemonMan> ok, let's backtrack some more... now break on end_float_token
<TheLemonMan> that calls bigfloat_init_buf that in turns calls parse_f128
<TheLemonMan> and the latter is something you don't want to debug
<TheLemonMan> oh, there are a few pieces that assume the target is LE
<koakuma> Ah
<TheLemonMan> scrap that, it does check __BYTE_ORDER (is that correct for your build?)
<TheLemonMan> if that's where the numbers are corrupted you will need some patience and a good debugger
<ikskuh> oh man. we definitly need to reduce the number of "notes" the compiler prints
<ikskuh> 1030 lines of messages for a single error is just way too much
<TheLemonMan> 1030? that's a noteworty record!
<ikskuh> :D
<ikskuh> "HGLRC was already declared. Referenced here:"
<ikskuh> and then 300 lines of code where it was referenced
<ikskuh> problem:
<ikskuh> my terminal only has 1000 lines backlog
<ikskuh> → i couldn't read the error without grepping for it
<ikskuh> there was an issue about reducing clutter, right?
<TheLemonMan> iirc yes
<ikskuh> 6999
<ikskuh> 6673 as well
<koakuma> After running bigfloat_init_buf, t->cur_tok->data.float_lit's content is again {4643001868805052825, 11068046444225751414}
<koakuma> So it's really parse_f128 that's returning the wrong value
<TheLemonMan> ok, the f128 number you see is *drumroll* +6.52282e+33
<koakuma> If __BYTE_ORDER is __BIG_ENDIAN then it will trigger an error
<koakuma> Is this intentional? If so, why did the stage1 build succeeds anyway?
<TheLemonMan> what compiler are you using to build the stage1?
<koakuma> clang
<TheLemonMan> uhhh, what does `clang -x c /dev/null -dM -E |& grep ENDIAN` print?
<TheLemonMan> I fear the answer
<koakuma> #define __BIG_ENDIAN__ 1#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__#define __ORDER_BIG_ENDIAN__ 4321#define __ORDER_LITTLE_ENDIAN__ 1234#define __ORDER_PDP_ENDIAN__ 3412
<koakuma> #define __BIG_ENDIAN__ 1
<koakuma> #define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
<TheLemonMan> and `grep ORDER /usr/include/bits/endian.h`
<koakuma> #ifndef __FLOAT_WORD_ORDER
<koakuma> # define __FLOAT_WORD_ORDER __BYTE_ORDER
<koakuma> #if __BYTE_ORDER == __LITTLE_ENDIAN
<koakuma> #elif __BYTE_ORDER == __BIG_ENDIAN
<koakuma> Only those
<TheLemonMan> are you sure that's /usr/include/bits/endian.h and not /usr/include/endian.h ?
<koakuma> Yes
<TheLemonMan> the former should define __BYTE_ORDER
<koakuma> There's only two ORDER-related lines in my /usr/include/endian.h
<koakuma> # define BYTE_ORDER__BYTE_ORDER
<koakuma> # if __BYTE_ORDER == __LITTLE_ENDIAN
<TheLemonMan> the question now is, where is __BYTE_ORDER defined?
<koakuma> A recursive grep says that it's defined in /usr/include/bits/endianness.h
<TheLemonMan> yeah, I had just found https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/sparc/bits/endianness.h
tetsuo-cpp has quit [Ping timeout: 264 seconds]
<koakuma> Ah I think I know why
<koakuma> Zig uses strict -std=c99 to compile files, and it, for some reason, makes sys/types.h not include endian.h
<koakuma> So we don't get the endianness macros
<koakuma> It just probably happen to work on LE machines because, for reasons that I don't know why, the lack of macros results in the #if in parse_f128.c to take the LE branch
<TheLemonMan> does it pick the correct macros if you explicitly include it?
frett27 has joined #zig
rzezeski has joined #zig
<koakuma> If I explicitly include endian.h, then yes, the macros seem to be picked correctly
<TheLemonMan> oh dog, undefined macros default to zero
<TheLemonMan> that's why `__BYTE_ORDER == __LITTLE_ENDIAN` is always taken
wootehfoot has joined #zig
<koakuma> It seems to parse correctly now
<koakuma> I'll prepare a PR for this
gpanders has quit [Ping timeout: 256 seconds]
gpanders has joined #zig
wootehfoot has quit [Ping timeout: 256 seconds]
gpanders has quit [Ping timeout: 246 seconds]
<koakuma> Wait, seems like BSD doesn't have an endian.h?
wootehfoot has joined #zig
<TheLemonMan> its sys/endian.h there iirc
jpe90 has joined #zig
riba has joined #zig
<koakuma> Ah, thanks
rhencke has joined #zig
<rhencke> the documentation for the zig build system mentions that it can help with "surfacing build configuration as comptime values by providing a file that can be imported by Zig code." does anyone have any examples of what such a file would look like?
<ifreund> rhencke: the file is created automatically when you call addBuildOption()
<rhencke> ifreund: ah! thank you!
<ifreund> you can then import and access the options with @import("build_options")
<rhencke> i thought i was the one who had to provide the file, haha
<ifreund> yeah, documentation is far from complete for the build system :/
<rhencke> appreciate the help :)
waleee-cl has joined #zig
oats is now known as grogu
<ifreund> no problem!
jpe90 has quit [Quit: WeeChat 2.9]
grogu is now known as oats
cole-h has joined #zig
koakuma has left #zig [#zig]
jpe90 has joined #zig
Akuli has joined #zig
lucid_0x80 has quit [Ping timeout: 240 seconds]
lucid_0x80 has joined #zig
dumenci has joined #zig
lucid_0x80 has quit [Ping timeout: 256 seconds]
Pistahh has joined #zig
riba has quit [Ping timeout: 240 seconds]
cole-h has quit [Ping timeout: 256 seconds]
g-w1 has quit [Ping timeout: 256 seconds]
g-w1 has joined #zig
frett27 has quit [Ping timeout: 272 seconds]
remby has joined #zig
moo has joined #zig
Jeanne-Kamikaze has joined #zig
moo has quit [Client Quit]
wootehfoot has quit [Quit: Leaving]
hnOsmium0001 has joined #zig
dumenci has quit [Ping timeout: 264 seconds]
rhencke has quit [Remote host closed the connection]
_whitelogger has joined #zig
Jeanne-Kamikaze has quit [Ping timeout: 240 seconds]
hlolli_ has joined #zig
jpe90 has quit [Quit: WeeChat 2.9]
remby has quit [Quit: remby]
ur5us has joined #zig
hlolli__ has joined #zig
hlolli_ has quit [Ping timeout: 260 seconds]
remby has joined #zig
dddddd has quit [Quit: dddddd]
jjsullivan1 has joined #zig
jpe90 has joined #zig
dddddd has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
reductum has joined #zig
<remby> all current documentation is on the site at the Documentation link?
<ifreund> there's also https://ziglearn.org
<ifreund> and doc comments in the std
radgeRayden has joined #zig
<TheLemonMan> you can easily grep the docs
<TheLemonMan> grep "what you're searching for" /dev/null
<TheLemonMan> replace /dev/null with /dev/urandom if you want the nightly docs
<remby> heh :P
<remby> I'm trying to find out some more about linking in zig
<remby> does it use its own linker?
<TheLemonMan> no, it uses LLD
<g-w1> it uses lld but soon (TM) it will have its own linker
<remby> ok, that's fine with me
<pixelherodev> It has its own linker already
<pixelherodev> It's just not used by default yet ;)
<g-w1> could it be used with stage1, or is it too tightly integrated with stage2?
<pixelherodev> ... I mean, it probably could
<pixelherodev> Not necessarily a great idea though
<andrewrk> you can try the self-hosted linker with -fno-LLD
<andrewrk> looks like I forgot to add it to the usage text. adding now
<g-w1> I get a segfault (in the compiler) with `pub fn main() void {}`. i guess it doesn't work with stage1 yet
<andrewrk> there's a lot of code to link with that - all of start.zig and the default panic handler too
marnix has quit [Ping timeout: 256 seconds]
<g-w1> ah, makes sense
<andrewrk> you must be using a release build too - a debug build has more helpful output: https://clbin.com/j7ToV
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
Akuli has quit [Quit: Leaving]
remby has quit [Quit: remby]
a_chou has joined #zig
riba has joined #zig
riba has quit [Ping timeout: 240 seconds]
nrdmn0 has quit [Quit: The Lounge - https://thelounge.chat]
radgeRayden has quit [Ping timeout: 272 seconds]
remby has joined #zig
radgeRayden has joined #zig
<hlolli__> I'm getting a bit tripped out with struct consts. I feel it's a happenstance that expression like ''const s: S = S{.a: ?u8 = null,}; s.a = 1;'' throws ''error: cannot assign to constant''. If a pointer to a struct is a const, does it mean that its fields are immuteable?
<ifreund> no, but you don't have a pointer to a struct there you have a struct value
<andrewrk> hlolli__, in this code example, the storage provided by `s` is immutable
<hlolli__> andrewrk, good to hear, that's how I'm understanding const. So to be more concrete in the current error Im fighting, I have a setter function, wich I wall from a struct concretion which is a const pointer.
<ifreund> hmm, I wonder if this is my fault or not, happens on musl but not glibc: https://github.com/ifreund/river/pull/159#issuecomment-735472711
<hlolli__> https://pastebin.com/GKwU3Act something like this
<ifreund> hlolli__: there you have a constant pointer
<ifreund> const foo: *u8 is not the same as const foo: *const u8
<ifreund> you would have to use `self: *Self` there
<hlolli__> if I change ''self: *const Self'' to ''self: *Self'' the caller which is a const pointer fails, because it's a const. I mean I can change it all to var, but it would be a lot of refactoring.
remby has quit [Quit: remby]
<daurnimator> hlolli__: refactoring that probably needs to happen if you're trying to modify things you declared as `const`?
a_chou has quit [Quit: a_chou]
<hlolli__> the pointer, which is the address in memory where the struct is stored isn't changing by setting a field?
<ifreund> no, the pointer isn't changing but the data being pointed to is
<ifreund> which is what the const there is refering to
<ifreund> the pointer itself is implicitly const as function parameters are always const
ur5us has quit [Ping timeout: 264 seconds]
<hlolli__> good to know, so I understand it correctly, that when I declare a const like this ''const s: S = S{.a=0}'', the field .a is from this concrecion immutable?
<ifreund> the entire struct is immutable and stored as a value in s
<ifreund> there is no pointer involved there
<hlolli__> this differs from c then, in that there isn't a place in memory for the whole struct?
<ifreund> structs are semantically values in C as well
<ifreund> arrays are where zig and C differ in that regard
earnestly has quit [Ping timeout: 240 seconds]
<hlolli__> sizeof(Struct) is always allocated in c afaik. So then I modify let's say field foo.bar, the address of foo[0] is the same but the value of foo[0] + offsetTobar is changed.
<hlolli__> anyway, I was never good in C, so I may be wrong here :). Just tripping me out. Especially doing a lot of javascript. Where 'const a = {}; a.b = 2' is totally fine.
ur5us has joined #zig
<hlolli__> but at the same time ''const a = {}; a = "no";'' fails.
<ifreund> yeah that's not how C works unless I misunderstand what you're saying
<ifreund> and I have no idea how javascript works so I'll take your word for it :P
<hlolli__> is there a lot of optimization I'd lose in using vars instead of const?
<ifreund> const isn't guarenteed to be any faster at all
<andrewrk> zig works best if you treat local variables as mostly SSA, with a few mutable stuff thrown in
<ifreund> and that's besides the point really, if you need to modify something it needs to be mutable
<hlolli__> of the small amount of documentation/tutorial material I read, vars seem to be discouraged, but this nuance isn't pointed out. Perhaps it's just javscript developers that this trips out :)
<ifreund> well, you should use const when you can, but often you'll need to mutate something
<hlolli__> true, but the fact that const is all encompassing on the value, and not just the top level. Like var value within const, in most langugaes I use there's something like that.
<ifreund> that's how it works with pointers
<ifreund> i.e. ''const foo: *u8'' is a constant pointer to a mutable u8
<hlolli__> ''const foo: *const u8'' is just the same as ''const foo: *u8
<hlolli__> ?
xackus_ has quit [Ping timeout: 264 seconds]
<ifreund> no, the first is a constant pointer to a constant u8
<ifreund> the second is a constant pointer to a mutable u8
<hlolli__> ahhhhhhh, THERE IT IS :D finally
<hlolli__> ok that's where I'm doing things wrong. And I felt I was using const pointer all time on variable content.
<hlolli__> ok ok, thanks!
<ifreund> no problem!
earnestly has joined #zig
reductum has quit [Quit: WeeChat 2.9]