<frett27>
TheLemonMan, when compiling with your patch and this command line : zig build-exe -target arm-linux-musleabihf -mcpu arm1176jzf_s --object /usr/lib/arm-linux-gnueabihf/libleveldb.a -Lpaho.mqtt.c/build/output -Lpaho.mqtt.c/src --object paho.mqtt.c/src/libpaho-mqtt3c.a -lc iotmonitor.zig
<frett27>
TheLemonMan, sorry, i was disturbed, back again,
<TheLemonMan>
frett27, found the problem, I'll write a patch
<frett27>
i'm not aware of all, but want to learn, love zig
<frett27>
TheLemonMan, how can i get into zig internal smoothly, i started with external view, the language, i have lot to learn on the compile stuff also.
<frett27>
what do you suggest ?
<frett27>
is there are things i can do on my time ?
<frett27>
TheLemonMan, it will be nice to have a zig iot project, monitoring and "rule them all those iot devices :-)"
<frett27>
Tests, docs ?
<pixelherodev>
Would patches adding ELF *writing* to std.elf be accepted?
<pixelherodev>
Or is that out of scope of stdlib?
<ikskuh>
i think andrewrk dumps ZIR into an ELF file right now?
<ikskuh>
So maybe his branch already contains that?
<pixelherodev>
IIRC it just writes it as ZIR
<pixelherodev>
Writing to ELF is in the *plans*
<ikskuh>
ah
<ikskuh>
so it will probably be required
* ikskuh
is interested in better ELF I/O as well :)
<TheLemonMan>
frett27, the best way is to get your feet wet by fixing some contributor-friendly bug
livcd has quit [Ping timeout: 250 seconds]
<frett27>
TheLemonMan, yes i'm still in this mind set, think the building of small applications can also help lean and focus on important thing for project
AndroidKitKat has left #zig [#zig]
<ifreund>
is there a way to set the active field of a union without assigning it?
<ifreund>
is my_union.tag1 = undefined; ok?
Xavi92 has quit [Remote host closed the connection]
<ifreund>
yeah looks like that crashes, shoot
<ifreund>
imo that should be allowed
cole-h has joined #zig
<companion_cube>
is tag1 the discriminant tag?
joey152 has quit [Remote host closed the connection]
<ifreund>
no, the union itself is undefined
<ifreund>
i want to set the active tag and then call my init function like `my_union.tag1.init()`
<ifreund>
and yes there's a reason I don't do `my_union.tag1 = MyType.init()`, MyType can't be moved around without breaking pointers due to the design choices of libwayland
<ifreund>
I supposed I could have two init functions, but that's super ugly
<xackus_>
the deduplication of pointer ZigTypes differing by is_const, is_volatile, etc is special cased
<xackus_>
andrewrk TheLemonMan
dermetfan has quit [Ping timeout: 265 seconds]
dermetfan has joined #zig
<TheLemonMan>
yeah that's tricky to solve, the types have the correct (and same) structure but different names
<TheLemonMan>
you could special-case the ?[]T case but that feels hacky
<xackus_>
i can try rewrite it recursively
joey152 has joined #zig
<xackus_>
another solution would be to separate the type and cv modifiers, but would probably require more work
<TheLemonMan>
every time I see something that requires too much effort I move it on the stage2 stack heh
<xackus_>
but this is needed for zig0 :(
foobles has joined #zig
<TheLemonMan>
yeah I meant I put it on hold
<xackus_>
it's not that much code, I will probably try the recursive rewrite
Vexu has joined #zig
marijnfs_ has joined #zig
<marijnfs_>
im using a c-library that uses void pointers, i use ?*c_void on the zig side for them, is that correct?
<xackus_>
actually resolution is already recursive, i will put a new field that points to the canonical ZigType
<marijnfs_>
I'm somehow getting issues when using the functions in a spawned thread
aerona has quit [Remote host closed the connection]
<TheLemonMan>
xackus_, try changing the LLVM type name only
<TheLemonMan>
the inner slice llvm type is correctly generated after dropping the qualifiers
<TheLemonMan>
so you need a function to mint a new "base" type w/o any qualifier
<xackus_>
yeah, i noticed the inner slice type is correct
marijnfs_ has quit [Ping timeout: 260 seconds]
marijnfs_ has joined #zig
<TheLemonMan>
the C ABI is so badly implemented for ARM32 that the compiler is not even able to call zig_clang.cpp methods without corrupting random memory
<TheLemonMan>
frett27, you're better off cross-compiling stuff for the time being
<marler8997>
found a cool way to initialize my new allocators, instead of makeSliceAllocator(makeAlignAllocator(makeLogAllocator(MmapAllocator { }))), you can do Alloc.mmap.log().align().slice().init
<ifreund>
that is a lot cleaner
dermetfan has quit [Ping timeout: 265 seconds]
livcd has joined #zig
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
Vexu has quit [Ping timeout: 260 seconds]
<frett27>
TheLemonMan, ok so embedding libs directly, and compile the whole on x64 is the way to go then, big thank's for analysis
Vexu has joined #zig
marijnfs_ has quit [Ping timeout: 260 seconds]
Xavi92 has joined #zig
marijnfs_ has joined #zig
hwerrno has joined #zig
<hwerrno>
hello, every one this is the first time i am using irc
<foobles>
hello
<foobles>
this is the first IRC channel i have ever joined as well
<Xavi92>
Welcome hwerrno :)
<hwerrno>
zig is very cool
<hwerrno>
help
<hwerrno>
😁️
<foobles>
help with what?
<foobles>
hwerrno
<andrewrk>
welcome hwerrno
wootehfoot has joined #zig
<andrewrk>
I'm planning to do a zig live coding stream today in a couple hours
<ifreund>
\o/ I will be there
<nephele>
Hmm, a couple could be 2 or more :)
<andrewrk>
I'll pick a concrete time soon, need to take care of some chores first
<drasko>
And alo I do not understand this one: `pub fn inStream(file: File) io.InStream(File, ReadError, read)` takes one parameter (file)
<drasko>
and we gave it none
<foobles>
when you use file.inStream(), `file` is the parameter
<foobles>
thats how dot-notation works
<foobles>
the thing on the left of the dot is passed as the first parameter
<drasko>
Ah, OK, thanks
<drasko>
this is valuable info
<drasko>
And what about this: `pub const InStream = io.InStream(File, ReadError, read);` - isn't `pub const InStream` publicly used member of File struct?
marijnfs_ has quit [Ping timeout: 246 seconds]
<foobles>
what do you mean?
<foobles>
`pub const InStream` is a constant of the struct itself
<foobles>
in your example `self.conn.file` is not the File struct
<foobles>
its just an instance of the file struct
<foobles>
which means you cant access the struct's constants through it
<drasko>
And in instance of the struct I can not use consts of the struct?
<dirkson>
Hey all. Tinkering around with using zig to build C. Compared to just calling gcc/clang directly, the binaries zig builds for me are very chubby (Double the size) and include links to libraries I don't use (libpthread, libm, etc). What's going on?
<ifreund>
nephele: i think that github pull requests are preferred, but that's really a question for andrewrk
<nephele>
Yeah i don't have a github account, so was wondering if that was okay too
<dirkson>
I suspect it's somehow related to zig's targets system, but I don't understand that at all. The documentation says that the targets don't depend on system files, then immediately shows a zig-compiled binary linking to the system libraries.
<nephele>
dirkson, clang ships libcxx zig standardlib and musl sourcecode per default
<andrewrk>
nephele, yes you can, but you might have to occasionally send reminder emails if you don't get attention on the patches
<nephele>
zig*
<ifreund>
dirkson: if you're building a debug build then zig is enabling UBSAN and maybe doing other things
<ifreund>
try a release build and see if that's more what you'd expect
<nephele>
andrewrk, ah that is fine, I'll prep my first patch to send then (for compiler-rt)
<dirkson>
ifreund: That'd explain a lot of the oddities for sure. I assume it builds debug default?
<ifreund>
but in generaly it's the same as building zig code, you just use addCSourceFile()
<ifreund>
s/aly/al/
<dirkson>
andrewrk: I have C code, I want zig to compile it for me. I know it can do it, and there are even rumors that build.zig can do it, but I've had a hard time finding info about it
<nephele>
"zig cc" can be used like you would use clang
<ifreund>
yes build.zig can do it, though docs for the zig build system are somewhat lacking atm
<ifreund>
the link i send has an example which is probably what you're looking for
<dirkson>
nephele: Hey! That's good info. That produces a very similarly sized binary to gcc.
<dirkson>
Had to work out how to disable mouse support in my irc client. It had... novel ideas of how the mouse should interact, none of which included being able to click or select links :-/
Xavi92 has quit [Ping timeout: 246 seconds]
<nephele>
The best irc clients are ones that ban random people on touch input ;)
<dirkson>
Hah, clearly!
<ifreund>
yeah... I spent some time reading source code to write my build.zig but the result is quite nice
<dirkson>
nephele: Yeah, your link is great too. Between the two links I should be able to tinker around for some time.
<nephele>
But, can build.zig build me a linux from scratch? ;)
<ifreund>
has anyone tried yet? I don't see why not...
<nephele>
Well, i did start writing a zig executable to namespace and start compiling stuff, but i didn't use build.zig :P
<dirkson>
Idle curiosities: Zig appears to use something clang-related to actually compile. Can that be swapped to gcc? And since zig is aiming at eventual self hosting, does that mean interesting things for the future of zig C compilation? Also, I seem to remember zig grumping at me about my use of tabs in earlier versions, but it didn't mention them when I inserted them in build.zig - Any particular reason?
<nephele>
I really really doubt it, the swapping to gcc part, because zig uses libclang to link against and not clang standalone as such
<nephele>
zig uses llvm in the backend to compile all its fancy stuff, and libclang uses that too, so one big happy compiler based on llvm :P
<dirkson>
That's unsurprising, but unfortunate, as I believe gcc still produces faster code than clang on average. Horrible error messages and debugging though.
<dirkson>
nephele: Yeah, I'm not strong on llvm-stuff. Will zig still use the llvm stuff when it's self-hosted?
<nephele>
Well, no, it will be written in zig
<nephele>
but the zig compiler now using llvm will continue to do so in the future
<nephele>
bootstrapping :D
<dirkson>
Yeah, that makes sense.
<Snektron>
Will llvm be eliminated completely in self hosted?
<FireFox317>
andrewrk, any update on the stream time? :)
<andrewrk>
I'm waiting for my gf to finish playing D&D and then I'll pick a time :)
Xavi92 has joined #zig
Xavi92 has quit [Remote host closed the connection]
wootehfoot has quit [Ping timeout: 260 seconds]
wootehfoot has joined #zig
<Winterfury>
Pardon my noobishness, but does Zig officially require Windows 8 or newer to run? I'm asking because it looks like the binary from zig.windows-i386-0.6.0.zip is not compatible with Windows 7.
<Winterfury>
Running it gives me the message about missing entry point in KERNEL32.dll for GetSystemTimePreciseAsFileTime (which is, according to MSDN, a part of Windows 8 API).
<ifreund>
Winterfury: yes that's right
<Winterfury>
I see.
<andrewrk>
note that microsoft has stopped supporting windows 7
xackus_ has quit [Ping timeout: 260 seconds]
<andrewrk>
zig has longer support lifecycles for non-proprietary OS's
<marler8997>
where does andrew livestream, twitch? and what's is username?
<drasko>
How to force delay in program? std.time.sleep(3000000); does not seem to stop execution for 3 seconds as I would expect
dermetfan has quit [Ping timeout: 244 seconds]
<drasko>
sorry, just saw that these are nanos
Vexu has quit []
Akuli has quit [Quit: Leaving]
<yrashk>
I was thinking about consistency of the language. Built-in functions do give an appearance of a function call; but not all of them are in fact function calls, are they?
<andrewrk>
ok stream is happening at 19:00 in my time zone, which is in 1hr 6min
<drasko>
handlers are actually not executed asynchronously - when client connects to a server and connection is accepted, whole hadler runs and blocks for 5 secs, preventing other clients to connect
<fengb>
Sleep isn’t async
<fengb>
Async isn’t threading. You need to switch to a non blocking mechanism
<drasko>
Is there an example of a non-blocking TCP server
<drasko>
fengb, or some other example that demonstrates non-blocking mechanism in Zig
Aransentin has joined #zig
<fengb>
Well... the IO handling should be non blocking. Maybe at some point we can switch sleep to be non blocking too
<fengb>
e.g. using the outStream or inStream should “just work”
<fengb>
It’s still pretty new so there may not be a lot of examples
<Aransentin>
I have an array of structs of known length that I'd like to make a bitmask for. Can you make a comptime function that returns an uN for an integer input? e.g. for a list length of 27 I'd get an `u27` back that I can use as a type for my mask.
<Aransentin>
I guess I can write a giant switch with one return statement for every length, but that won't look very pretty.
<fengb>
It’s possible yes. PackedIntArray might be able to do what you want
<mikdusan>
Aransentin: in comptime you can also `const host = @as(std.meta.IntType(unsigned, 27), 0);` and then iterate on AOS, and set each bit on host accordingly.
<Aransentin>
Ah, that's exactly what I want
<Aransentin>
Thanks! :)
<mikdusan>
i'm assuming AOS is comptime known length
<Aransentin>
Yep
marijnfs_ has joined #zig
<mikdusan>
as fengb pointed out (I've never used it) PackedIntArray looks ideal. maybe PackedIntArray(u1, 27) and then saves you all the bitshift/masking work