ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
zolk3ri has quit [Remote host closed the connection]
<alexnask>
translate-c should be able to pick them up
<kevw>
it uses extern void to declare the function, and then you use a #define to implement the function
<alexnask>
I've generated windows headers with it
<alexnask>
Ah hmm
<kevw>
now that i see the "mixing object files" section in the docs, I think one possible answer might be to have a main.c that does the #define SOKOL_IMPL
<kevw>
and then the @cInclude without the @cDefine(SOKOL_IMPL) so that the declaration gets picked up
<kevw>
but ideally I could just @cInclude the header twice(?)
<alexnask>
Right you should be able to do a @cImport with the define and one without
<kevw>
when i do translate-c without the IMPL define, the zig file has
<kevw>
ah, so @cImport twice does compile the zig file, but then I get an undefined symbol for _sg_setup in the linker
<kevw>
i'm going to try the main.c thing
<alexnask>
you should probably
<alexnask>
just have a C file that defines SOKOL_IMPL and includes it
<alexnask>
and compile that to an object file
<alexnask>
then link that with the zig file that just @cInclude's to generate the function prototypes
<alexnask>
I don't get the advantage of a header only library in C, I see why it makes sense in C++ :P
<kevw>
the pains people go to deal with the lack of a module system
<kevw>
just adding exe.addSourceFile("src/sokol-impl.c"); results in reached unreachable code _assert: 0x10461fec9 in ??? (???) _LibExeObjStep_addSourceFile: 0x1046381a4 in ??? (???)
<kevw>
but perhaps addSourceFile needs to be from an addCExecutable like in the docs
<alexnask>
Im not too sure about the build system sorry
<kevw>
it's ok, thanks for your help!
<alexnask>
I don't know if compilation of C files is available yet, you could just compile it once and keep the .o around
<alexnask>
and add that to the linker objects in the build file
<alexnask>
I guess headeronly libraries are useful if you want to build in a single translation unit
<alexnask>
Functions marked as inline should always be inlined
<alexnask>
I would suggest a zero_init(comptime T: type) T function
<MajorLag1>
functions marked as inline that can't be inlined are a compile error
<kevw>
great!
<kevw>
yeah I'm stumped until I can pass a [*]const opaque_type pointer to the c library I'm trying to use, and calling @ptrCast results in the LLVM ERROR: Cannot select I pasted in the issue above
<kevw>
really excited to try to get a small game loop going!
Ichorio has joined #zig
adagio1 has joined #zig
<alexnask>
I'll take a look at the code in a bit, first time I come accross a LLVM error on @ptrCast personally
<kevw>
i ran a zig debug compiler and got an assert: Assertion failed: (LLVMGetTypeKind(LLVMTypeOf(value)) == LLVMPointerTypeKind), function gen_assign_raw, file /Users/kevin/src/zig/src/codegen.cpp, line 1769.
<andrewrk>
hello
<andrewrk>
kevw, you found a bug
<kevw>
andrewrk: let me know if there's any more info i can provide
<andrewrk>
if it's the same issue as the above linked github issue, I can reproduce the problem, so I have everything I need
<alexnask>
@andrewrk Is there any way to create a TldVar without making AST nodes?
<alexnask>
I know the type and ConstExprValue of the variable
<andrewrk>
I think the ast node is allowed to be null at least for some of the kinds of Tlds
<alexnask>
But it seems like all the logic is geared around AST nodes
<andrewrk>
if not, the logic can be reworked
<alexnask>
ir_gen_var_decl needs a type or expr AST node in the parent AstNodeVariableDeclaration
<alexnask>
(which I am creating)
<alexnask>
Anyway I'll look into bypassing it somehow for now
kristate has quit [Remote host closed the connection]
<alexnask>
Hmm actually I think if I mark it as resolved I may be able to circumvent all that
<alexnask>
But idk if it's a sane thing to do :P
<andrewrk>
I think there are enough gotchas in that code that if we're going to add complexity to it, it should be by understanding the logic and reworking it to make more sense rather than trying to hack in a new feature
<alexnask>
Seems to work
<alexnask>
Right
very-mediocre has quit [Ping timeout: 260 seconds]
<alexnask>
Well in this case I think it's more about me not having a complete mental picture of how all the passes etc work
<GitHub3>
[zig] andrewrk closed pull request #1158: Fix os_path_join for case where dirname is empty (master...os-join-empty-path-fix) https://git.io/f49Tl
<GitHub120>
zig/master 8e71428 Isaac Hier: Fix os_path_join for case where dirname is empty
<alexnask>
But I do think it's actually correct to say the variable decl is resolved in this context, it is generated directly with a type and value (this is @reify code)
<andrewrk>
ah, ok, in that case I'm fine with it
<alexnask>
Which should be done (with no tests etc) in a couple of hours
<alexnask>
Struct is done, union and enum are basically the same
<andrewrk>
I'm hoping to use the self hosted code as a test bed for rewriting the zig compiler logic in a sound and clear way, and then maybe backporting it to stage1
<GitHub154>
zig/master 4de60dd Andrew Kelley: langref: explicit cast section
fjvallarino has joined #zig
fjvallarino has quit [Remote host closed the connection]
fjvallarino has joined #zig
btbytes has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mahmudov has joined #zig
<alexnask>
@andrewrk I think stdcall on x86 expects a 4 byte aligned stack (as opposed to the win64 calling convention that expects a 16 byte aligned stack)
adagio1 has quit [Quit: Leaving.]
<andrewrk>
ah
<alexnask>
Although the MS official docs aren't clear on that :P
<alexnask>
So I don't think the win32 test failures are due to the stack alignment, could be wrong though
isd has quit [Ping timeout: 256 seconds]
btbytes has joined #zig
btbytes has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<oats>
where can I find documentation on the standard library?
<andrewrk>
oats, currently, only in the source code
adagio1 has joined #zig
<oats>
in /usr/lib/zig then?
btbytes has joined #zig
<oats>
also, I noticed that it says on the site that the standard library doesn't depend on libc
<oats>
how do you get around that?
<oats>
forgive my ignorance of programming language design, but I thought pretty much the only way to interface with the linux kernel is to use a libc of some kind
<andrewrk>
oats, if you downloaded zig then the standard library is in there. if you're building it from source the std lib is in the `std` directory
<andrewrk>
the linux kernel defines a stable ABI for syscalls
<andrewrk>
it's like calling a function, but you use an interrupt to activate kernel mode
<oats>
interesting
<andrewrk>
that's what libc does internally
<oats>
so a libc gives you an abstraction over making raw syscalls, do I understand that correctly?
<andrewrk>
correct
<andrewrk>
many libc functions are thin wrappers around syscalls
<oats>
are there examples of syscalls in the zig stdlib I can look at?
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<oats>
ahhh, that makes sense that it's backed by asm
alexnask_ has joined #zig
<oats>
I should've guessed :P
<oats>
that is very informative, thank you
alexnask has quit [Ping timeout: 248 seconds]
Ichorio has quit [Ping timeout: 240 seconds]
<alexnask_>
Does having a null union tag type result in auto generating an enum tag type make sense? (+ all union fields having an enum_field)
alexnask_ is now known as alexnask
<alexnask>
ir.cpp is getting pretty crazy, I thought it was around 16k loc and is now 21.5k on my branch :P
<andrewrk>
it's 20,702 on master
<andrewrk>
self hosted will be more organized since there is no compilation speed / performance penalty for splitting stuff up
<andrewrk>
alexnask, yeah I think null union tag type makes sense to represent union(enum)
<andrewrk>
either that or union(enum) { Auto, Explicit: type }
<alexnask>
Right, my idea is to use null for union(enum) {} when all union fields have enum_field != null and union {} when all union fields have enum_field == null
davr0s has joined #zig
<andrewrk>
I believe I have created a many producer, many consumer, thread-safe, lock-free, runtime configurable buffer size Channel data structure that integrates with the userland event loop
<andrewrk>
when the buffer is empty, consumers suspend and are resumed by producers; when the buffer is full, producers suspend and are resumed by consumers
<andrewrk>
time to test it with a thread pool
btbytes has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
btbytes has joined #zig
fjvallarino has quit [Remote host closed the connection]
fjvallarino has joined #zig
fjvallarino has quit [Ping timeout: 240 seconds]
<oats>
I really appreciate there being vim configs for zig already, that's super neat
<andrewrk>
it supports automatically running zig fmt too if you set it up
<andrewrk>
I've been using it
fjvallarino has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
btbytes has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
btbytes has joined #zig
btbytes has quit [Client Quit]
btbytes has joined #zig
btbytes has quit [Client Quit]
btbytes has joined #zig
btbytes has quit [Client Quit]
btbytes has joined #zig
tiehuis has joined #zig
<tiehuis>
andrewrk: when was the timeframe for more effort on the self-hosted compiler? have an okay enough Rational implementation for the moment if that was wanted.
<tiehuis>
just need to modify it to take by value vs. reference
<andrewrk>
tiehuis, I started working on the self hosted compiler as the main "big thing" after 1 bug fix, 1 doc improvement, & dealing with PRs every day
<andrewrk>
I think you've at least a few weeks until that becomes a blocker though
<tiehuis>
great, just wanted to check to see the timeframe
<andrewrk>
it's a slow start because I'm insisting on full multithreading / async I/O from the start
<tiehuis>
yeah, fair enough, may as well start off right when we have a clean slate
<andrewrk>
independent from that, though, I'm thinking that I'd like to make a well defined zig IR and start adding zig IR to zig IR tests and zig IR to llvm IR tests
<andrewrk>
hopefully then we can grow the self hosted compiler without having to support everything at once
<andrewrk>
I think with more focus on IR robustness we can solve most zig bugs