<daurnimator>
which is to ask: what feature do we depend on that was introduced in 3.16?
<lunamn>
is it expected to have compiler crashes from wrongly using @typeInfo and @typeOf?
<daurnimator>
lunamn: the compiler should never crash: that would be a bug
<lunamn>
daurnimator: thanks! so I'd assume its best to write an issue for it?
<daurnimator>
lunamn: yep. just do a search to make sure it's not already supported. include a minimal test case if you can.
<daurnimator>
uh s/supported/reported/
athaudia has joined #zig
<tgschultz>
I've run Zig on a 2.6 kernel before (as a test after we started distributing statically compiled binaries). I don't remember anything breaking but I didn't exactly push it.
<scientes>
that won't work after arm64 was merged
<scientes>
well, 2.6 is a huge amount of time, so maybe the later ones
<scientes>
But I don't really see a use-case for that
<scientes>
Unless you really want 2.4, which is a much smaller kernel
<scientes>
yeah, noone is support 2.4 either
<daurnimator>
scientes: RHEL 6 uses 2.6.32
<scientes>
yeah but rhel 8 was released
<daurnimator>
which is still a common distro for many enterprise users
<scientes>
and rhel6 doesn't even have systemd
<daurnimator>
RHEL 6 is supported until 2020; and most gov/telecom companies will remain on it until then
<scientes>
it does have cgroups however
<daurnimator>
the question is: is there any reason zig wouldn't work on that kernel?
<daurnimator>
and if so, why does our support table only say linux 3.16+
jevinskie has joined #zig
<scientes>
I just don't think we should work like that
<scientes>
software goes forwards
<daurnimator>
scientes: I'd love to be able to use zig in a work context. but this is the sort of thing that potentially stands in the way
<scientes>
if there is a business case, someone can always backport stuff
<scientes>
thats the way Red Hat works
<daurnimator>
that only works when *you* are the red hat customer
<daurnimator>
it doesn't work when you're contracted to write software to run under redhat
<scientes>
daurnimator, well, the language will never depend
<scientes>
and the stdlib needs alot of work, this is the least of its problems
<scientes>
so bring this up when you actually have a problem
<scientes>
google runs all their software at HEAD
<scientes>
clinging to old version is just not productive
<emekankurumeh[m]>
i considered it, but ended up getting distracted by other stuff
<emekankurumeh[m]>
if you decide to do so, i would get andrewrk to check it first
<bgiannan>
i'm in no way qualified to do so, was just wondering if something was being worked on
jjido has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jjido has joined #zig
rivten has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<mikdusan>
re: issue #2481. i am not a windows user, but in this blog they talk about WSL 2 which actually uses linux kernel code and will soon be released. it seems that will solve the issue of missing linux kernel syscalls
<euantor>
mikdusan: I believe they're going to support WSL 1 for a while. It sounds like WSL 2 uses Hyper-V to run, which makes it a non-starter for people who have to use tools like VMWare I believe as you can't run 2 different hypervisors on the same system. I certainly saw some people in comments complaing they'd be stuck on the current version
Zaab1t has joined #zig
rivten has quit [Ping timeout: 256 seconds]
rivten has joined #zig
Zaab1t has quit [Quit: bye bye friends]
xtreak has joined #zig
scientes has joined #zig
jevinskie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
xtreak_ has joined #zig
xtreak has quit [Ping timeout: 268 seconds]
Xe has joined #zig
<Xe>
i've successfully moved to montreal now \o/
<Xe>
once my home gets internet/a table/a desk I'm gonna work on the zig+olin PR
halosghost has joined #zig
xtreak_ has quit []
ryanworl has joined #zig
ryanworl has quit [Quit: Page closed]
<kristoff_it>
where can I learn more about alignment? I'm in this weird situation where I - mostly - understand the basics (i.e. ~ word-aligned operations run faster) but I don't know enough to make my program do what I want (or, actually, if what I want is reasonable). More precisely in my cuckoofilter program I want to support different bucket sizes (think of it as a hash map if you're not familiar with the concept) and I think that good alignment for
<kristoff_it>
these buckets might improve performance, but I don't know how to make that happen. So right now I have a struct field that - via generics - can be [][4]u8, [][4]u16, or [][2]u32, but I'm forced to declare it as [] align(1) T
<kristoff_it>
so my question is: am I trying to do wrong things? if now, where can I learn how to do it?
<kristoff_it>
my init function takes a []u8 and uses @bytesToSlice
<kristoff_it>
I'm doing that because I assumed I could hide the knowledge of what a bucket is from the user
<tgschultz>
that was going to be my next question.
<kristoff_it>
and now that you're making me say it, the two things kinda seem at odds
<kristoff_it>
haha
<tgschultz>
yeah, if you take []Bucket, you can ensure proper alignment with the allocator: allocator.alloc(Bucket, num_of_buckets);
<tgschultz>
or even the stack: var buckets: [100]Bucket = undefined;
<kristoff_it>
ok understood. So I should make an init that takes an allocator, and one that can accept a slice, but it has to be of Buckets. Makes sense, one is standard, while the other is a more advanced interface. I was originally not trying to make use of an allocator because after the initial one, no other allocations need to happen
<andrewrk>
kristoff_it, you can also annotate your function that takes bytes like this: []align(@alignOf(Bucket)) u8
<kristoff_it>
I tried going that route
<kristoff_it>
but then I don't know how to proceed to make @bytesToSlice produce what I want
<kristoff_it>
or something along those lines
<andrewrk>
@bytesToSlice and @sliceToBytes should preserve alignment
<tgschultz>
you don't need to make an allocator version of init, you can let the user handle it. Expose Bucket within the returned struct (pub const Bucket...) and the user can just call allocate with that type.
<kristoff_it>
tgschultz: understood, thanks. I'll try to fiddle a little more with the other thing, just out of curiosity, and maybe post here the point where I get stuck, but then I'll probably go with your suggestion
<andrewrk>
this is yet another example of how system dependencies are problematic
<donpdonp>
c.read returns an isize, and I've checked it for being >0. how can I get a usize? @intCast doesnt want to convert it
<tgschultz>
@intCast should convert it as long as it is >=0. What doesn't it like about it?
rivten has quit [Ping timeout: 256 seconds]
avoidr has joined #zig
wootehfoot has joined #zig
<donpdonp>
hmm i guess its something I did. I went to look at the error again and it compiles now
<kristoff_it>
uhmm, exposing Bucket makes initializing memory ugly, is there a better way than this?
<kristoff_it>
var memory = []cuckoo.Filter8.Bucket{cuckoo.Filter8.Bucket{0, 0, 0, 0}} ** 256;
<tgschultz>
var memory: [256]cuckoo.Filter8.Bucket = undefined; if don't care about it being zeroed. If you do, then: for(@sliceToBytes(&memory)) |*b| b.* = 0;
<tgschultz>
an alternative is to add a function to the struct that returns [1]cuckoo.Filter8.Bucket set to 0: var memory: cuckoo.Filter8.Bucket.zero() ** 256;
qazo has joined #zig
<tgschultz>
or even one that returns a whole array if given a comptime length: var memory = cuckoo.Filter8.Bucket.array(256); I suppose it depends on how often you expect to need to do that as to how convenient you need that use case to be.
wilsonk|3 has joined #zig
scientes has quit [Ping timeout: 245 seconds]
wilsonk has quit [Ping timeout: 246 seconds]
kristoff_it has quit [Ping timeout: 268 seconds]
kristoff_it has joined #zig
<kristoff_it>
tgschultz: thanks for the suggestions. not sure how trivial this stuff seems from your PoW, but I had a hard time in the past trying to explain people how to use correctly cuckoo filters, and now that I have the opportunity of coming up with a decent interface, I want to make it as easy as possible to do the right thing
<kristoff_it>
a function that takes a comptime number seems great actually, I'm not (fully) thinking with portals yet haha
<kristoff_it>
I've also found another way: I can create for each bucket type a uN in type with @IntType(), have the user create a slice out of it and then do in my init @bytesToSlice(@sliceToBytes()) and get the right alignment.
<kristoff_it>
your way is less convoluted though
<kristoff_it>
uN int type with*
meheleventyone has joined #zig
lunamn has quit [Quit: leaving]
<kristoff_it>
question: [] align(4) u8 means that the pointer of each element in the slice is aling(4), not just the first one right? It then also means that there are 3 bytes of padding between each element to ensure that, right?
Tetralux has joined #zig
meheleventyone has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
lunamn has joined #zig
<tgschultz>
no, [] align(4) T means that the pointer to the first T is aligned to a multiple of 4
<tgschultz>
align follows the thing it is aligning: *align(x) T aligns the pointer
DutchGh0st has joined #zig
<tgschultz>
I don't think there is currently a way to express what you describe other than padding a struct.
<DutchGh0st>
hiii
<DutchGh0st>
Im getting an error: "expected type 'builtin.TypeId', found 'type' "
<tgschultz>
DutchGh0st, is that unexpected?
<DutchGh0st>
while Im switching on the typeinfo , it happens with the Struct case
<tgschultz>
@typeInfo returns a union(TypeId)
<tgschultz>
so you're switching on the TypeId, not the type
<tgschultz>
I believe that particular return type magic was Hejsil's.
<tgschultz>
but if you work with the metaprogramming long enough you'll come up with similar things. Like, in Pseudo-Struct I use a recursively defined return type.
<tgschultz>
and std.mem.asBytes uses a function to match the constness of whatever is passed to it.
<andrewrk>
tgschultz, yes, generally ELF is what people want for build-exe in freestanding. do you have another use case?
<tgschultz>
dos
<tgschultz>
but it doesn't prodce an ELF in debug from what I can tell
<andrewrk>
that is surprising, how are you checking?
<andrewrk>
elf files start with "\x7fELF"
<tgschultz>
No, I'm mistaken. I checked with a hex editor and it is ELF in both modes. just dumping the raw bytes to the console doesn't show that in the debug case for some reason though.
scientes has joined #zig
<tgschultz>
probably the debug case happens to contain backspaces or home or something in it shortly after
<andrewrk>
hmm I have never considered the use case of targeting DOS
<tgschultz>
neat, I'm breaking new ground.
<andrewrk>
if it's important to you and you're willing to sort of take ownership of the feature, you can add a new OS target
<tgschultz>
I was considering it, depending on how things went. I'm curious if I could use zig to make a protected mode dos game.
<andrewrk>
it might be nice to allow extending targets without having to commit to upstream zig, but for now that's how it works
<tgschultz>
from what little is available on the subject, LLVM probably won't get along well with real mode.
<andrewrk>
I think github user @jayschwa might share this use case
<andrewrk>
I talked to him in person yesterday; he's working on restoring some kind of doom-era game that he bought the rights to
<andrewrk>
catacombs
<tgschultz>
my kinda guy
<tgschultz>
he bought the rights to catacomb3d? Nice.
<tgschultz>
it was pre-wolf3d carmack, IIRC
<andrewrk>
yeah that's right
<tgschultz>
well, if I can prove the concept to myself I'm planning on streaming it. I've been wanting to stream some game dev for a while, but my other projects aren't suitable for a variety of reasons and I've wanted to make a dos game since I first read Tricks of the Game Programming Gurus as a kid.
<andrewrk>
sounds interesting
<DutchGh0st>
mhh
<DutchGh0st>
how do I set full debugmode in gdb?
qazo has quit [Quit: leaving]
<DutchGh0st>
because I want to figure out why @typeName(def.data.Var) crashes the compiler
<andrewrk>
DutchGh0st, I don't know what full debugmode is, but if you run the zig command using gdb, the back trace should be a pretty big clue about why it's crashing
<hryx>
one of the regulars at my monthly game dev meetup is making DOS games. so I assume it's still alive as a hobby (?) target especially for games
<DutchGh0st>
Assertion failed. This is a bug in the Zig compiler.???:?:?: 0x8704029 in ??? (???)???:?:?: 0x86c8494 in ??? (???)???:?:?: 0xe18a51f in ??? (???)
jayschwa has joined #zig
<andrewrk>
is that one of the release builds from ziglang.org/download?
<andrewrk>
you can build a debug version of zig from source
<tgschultz>
nothing about this code makes me think it would be unable to resolve the type though, so this is mysterious
<tgschultz>
huh, const_val.type == 0x3266750
<tgschultz>
oh wait, that's a pointer, not an id
<jayschwa>
yes, I am interested in using Zig for a DOS game. Catacomb 3D was originally 16-bit realmode, but I've removed almost all the assembly and self-modifying code, and hoping to get it working as 32-bit protected mode "soon". I think I did compile a "hello world" program using Zig and ran it in DOS a few months ago, but I'll need to dig around for that experiment.
<tgschultz>
if you find that, I'd be interested in having a look if you don't mind.
<tgschultz>
So with this bug the type is known to be ZigTypeIdMetaType with ResolveStatusUnstarted.
<jayschwa>
if I can find it and get it working again, I'll post it in a gist.
<tgschultz>
cool, I'd appreciate it.
<DutchGh0st>
but I gotta go now
<DutchGh0st>
goodluck hunting the bug down! I made an issue on github, I really wonder what the cause is!
DutchGh0st has quit [Remote host closed the connection]
kristoff_it has quit [Ping timeout: 245 seconds]
jevinskie has joined #zig
jjido has joined #zig
<tgschultz>
DutchGh0st, best guess with this bug is that @typeName expects the type to have been resolved, but for some reason it isn't.
<tgschultz>
my knowledge of compiler internals is still weak
jevinskie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jevinskie has joined #zig
jevinskie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kristoff_it has joined #zig
kristoff_it has quit [Ping timeout: 268 seconds]
halosghost has quit [Quit: WeeChat 2.4]
wootehfoot has quit [Read error: Connection reset by peer]
scientes has quit [Ping timeout: 258 seconds]
jayschwa has quit [Quit: Page closed]
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
scientes has joined #zig
lunamn has quit [Quit: leaving]
hio has quit [Quit: Connection closed for inactivity]
<andrewrk>
switching on error sets just got much better
<hryx>
:O
<hryx>
très bon
triplefox has joined #zig
<triplefox>
i would like to use zig as a build system for lua(i.e. compiling the lua executable from the standard 5.3.5 distribution). i'll do other things with it later but is there a good reference for just that?
<mikdusan>
5,001 commits
stratact has joined #zig
<hryx>
sup triplefox
<triplefox>
hello pal
<daurnimator>
triplefox: build system is completely undocumented at this point
<daurnimator>
triplefox: but lua should be pretty easy: build the core as a library by just adding all the .c files except lua.c and luac.c