<andrewrk>
I'm about to break a lot of stuff, want to make sure I do it right
<daurnimator>
andrewrk: I think you might be making a few mistakes with the current draft PR
<andrewrk>
daurnimator, let me push my changes from today and you can provide some review comments
<daurnimator>
e.g. IMO, "os/linux/posix" doesn't make sense. -> there should be os/linux/* that contains direct bindings to linux things. And then there should be os/posix/linux.zig, which would implement posix (and yes *only* things defined in posix; not all the little extras) on top of os/linux
<andrewrk>
sounds like your disagreement is only with the naming convention?
<daurnimator>
andrewrk: I don't think so. e.g. why is `pub const SYS_read = 0;` under os/linux/posix? SYS_read doesn't have anything to do with posix
<merlyndmg>
I don't know if it's desired, but I've created a pull request to switch from libpng+zlib to stb_image for the tetris demo. It made it easier to get it working on windows, and simplified the loading code a tiny bit: https://github.com/andrewrk/tetris/pull/18
<andrewrk>
merlyndmg, nice, that's a good improvement!
<andrewrk>
daurnimator, on linux SYS_read is in the same namespace as all the posix libc stuff
<andrewrk>
it's the same abstraction layer, just linux specific
<daurnimator>
andrewrk: but that's linux libc convention. which is something I don't even think we should have!
<daurnimator>
IMO there are 3 layers of interest: 'low level' (actual syscall ABI), 'posix' (POSIX defined portable bits), 'zig specific' (high level wrappers like std/fs that take advantage of whatever is best for the platform)
<andrewrk>
daurnimator, I pushed my changes from today - feel free to make specific suggestions about how to rename/move stuff
<andrewrk>
I agree that those are the layers
<andrewrk>
with my recent changes SYS_read can move to be private to the syscall wrappers file
<daurnimator>
andrewrk: why private?
<daurnimator>
andrewrk: also, what would you think of defining e.g. syscalls as an enum?
<daurnimator>
andrewrk: hrm. reviewing the PR... it's really hard to figure out where to put design comments. github wants me to associate with specific lines.
<andrewrk>
just add general comments to the PR
<andrewrk>
syscalls as an enum is more complicated because the syscalls that are available are arch-dependent
<andrewrk>
why private? I'm saying that it can be as you suggested, where they're not in std.os.posix
<andrewrk>
try to be specific with your review - this change is necessary and happening. it solves a bunch of things that weren't solved before. but if there are specific improvements to be made I'm happy to do them
<daurnimator>
andrewrk: comment left. (I also feel like this is something that might be easier discussed with voice/audio)
<daurnimator>
comment updated with better formatting and an extra dot point or two
<merlyndmg>
Was about to look into getting rid of the console when building on windows and found an unmerged pull request from two weeks ago. I'm guessing that's not done yet :)
<merlyndmg>
getting more and more curious how these linux->windows cross compiles are working out perfectly. some magic there!
coolreader18 has quit [Ping timeout: 272 seconds]
<fengb>
It's actually so seamless that I get confused when it's not available in other langauges
<merlyndmg>
hmmm trying to figure out if there's a way to just send arbitrary linker commands from the build script
<merlyndmg>
found some addBuildOption thing, but not sure quite how it works yet
fengb has quit [Ping timeout: 256 seconds]
<merlyndmg>
hmm, looks like it might be a convention to add variables to some standard compile-time config file, not necessarily something that actually affects the build behavior itself
<emekankurumeh[m]>
what do you mean get rid of console on windows?
<emekankurumeh[m]>
if you want to disable the console for graphical applications just pass --subsytem windows to zig when building
<merlyndmg>
I'm building the tetris example myself on windows, and seeing what I can do to document or improve that process. The version I am compiling right now is popping up the window, like it should, but is also popping up a console window as well. The "official" windows binary off the readme doesn't do that. I think it's cross-compiled from linux
<merlyndmg>
"just pass this when building" so far I've been using the build.zig script. I haven't figured out a way to pass arbitrary flags to the build command, only specific ones that have been crafted in the build system to pass through. If there's a magic passthrough or a way to get my build command line that would help a lot :)
<merlyndmg>
(the build command line that corresponds to what the build script is doing)
<merlyndmg>
but yeah, I found the --subsystem windows flag, and I figured out a way that I *think* scammed the build system into giving up the command line. Trying it out now
Ichorio has joined #zig
<daurnimator>
merlyndmg: "giving up"?
<daurnimator>
merlyndmg: are you looking for --verbose-cc?
<emekankurumeh[m]>
no, a way to pass raw args to the zig build process
<emekankurumeh[m]>
through a build script
<merlyndmg>
--verbose-cc only works for C targets. I have zig targets as well. Looking for the equivalent "zig.exe build-exe" command line
<merlyndmg>
I added an error to one of my source files and it spit it out. Would be nice if I could find a command line option that did it on purpose
<merlyndmg>
--verbose-link is helping me debug the subsystem thing a tiny bit, but it's definitely passing /SUBSYSTEM:console even though I specified --subsystem windows on the zig build-exe command line
<merlyndmg>
starting to think I should be running zig.exe in a debugger :)
hio has joined #zig
Aransentin has quit []
<merlyndmg>
hrm, not sure if this should be a bug report without running the compiler in a debugger. But it seems like the codegen tries to auto-detect the subsystem whenever any key named functions get exported, and wipes out whatever your subsystem selection is. But that doesn't work so hot, because it also seems that you can't actually provide any function name besides "main" or bootstrap.zig dies
<merlyndmg>
so can't just switch to using WinMain for example
<merlyndmg>
I will try to see if I can compile the compiler and make sure I'm actually hitting those breakpoint before I submit it though
<daurnimator>
merlyndmg: hrm? you should be able to use WinMain
noonien has quit [Read error: Connection reset by peer]
<merlyndmg>
C:\Users\fjkdlafjkdlaf\development\zig-windows-x86_64-0.4.0+b660134a\lib\zig\std\special\bootstrap.zig:107:33: error: root source file has no member called 'main'
<merlyndmg>
there's a chance this behavior changed since 4.0. I accidentally clobbered my master build and replaced it with the 4.0 build. Let me reacquire the master build and see if that helps...
<merlyndmg>
(hence why line 107 vs line 113)
<merlyndmg>
nope, same error on line 113 now
noonien has joined #zig
<daurnimator>
maybe line 14 needs to gain a WinMain case?
<daurnimator>
uh, 17
<merlyndmg>
I think WinMainCRTStartup is the shim that's normally added that calls winmain. However in this case it's calling `callMain` which is still trying to call standard main
<merlyndmg>
line 51 (last line of WinMainCRTStartup) I think should be calling WinMain instead?
<merlyndmg>
been a while since I've done win32 junk, so going off old memories
<merlyndmg>
Yeah that article seems to match exactly what I saw when going through the source code over the last few minutes
<merlyndmg>
the "security cookie", setting up for SEH, grabbing some handles, setting up QueryPerformanceCounter, etc
<merlyndmg>
Since a lot of that is for C++, can probably do a simpler version of a lot of it
<merlyndmg>
or a possibly better idea (maybe it breaks some compatibility use cases?) is to let the user manually specify the stuff and only auto-detect stuff as a fallback. I'd rather not have a WinMain in a cross-platform compatible program
<merlyndmg>
If it's indeed clobbering my options, I'd rather it didn't do that :)
<merlyndmg>
oh. "the source code" I meant above was the CRT source code that comes installed w/ visual studio, not the zig source code
lqd has quit [Ping timeout: 248 seconds]
knebulae has quit [Remote host closed the connection]
lqd has joined #zig
nikki93 has quit [Ping timeout: 252 seconds]
noonien has quit [Ping timeout: 250 seconds]
nikki93 has joined #zig
<merlyndmg>
"both C and C++ will initialze the so-called security cookie
<merlyndmg>
used as part of
<merlyndmg>
stack buffer overrun detection." - sounds like this might be an important thing to do on windows
r1b has quit [Ping timeout: 248 seconds]
<merlyndmg>
(also from that raymond chen article you linked)
<merlyndmg>
Seems that putting large values on the stack blows up, seemingly related to that "security cookie" thing. Not sure if zig has to worry about that or not, if linking to pre-compiled code for example.
cbarrett has joined #zig
<merlyndmg>
anyhow, this is all a tangent for me. I just care about the subsystem right now :) and I should worry about that tomorrow instead, cause it's late
<merlyndmg>
oh, also could be that global C++ constructors won't get called unless the right startup code is invoked, too. If that C++ code is extern "C", could be linked by zig, too.
hio has quit [Ping timeout: 248 seconds]
hio has joined #zig
sadanjon has joined #zig
rbscott has joined #zig
sadanjon has quit [Client Quit]
<rbscott>
Hello, I recently submitted a PR(https://github.com/ziglang/zig/pull/2469) to implement unionInit, but wasn't sure what is required to contribute. Any chance someone can point me in the right direction?
<daurnimator>
rbscott: sending a PR is all you have to do.
<daurnimator>
rbscott: misc things I notice: 1. trailing whitespace in your files. 2. WIP commits. -> I'd rebase those away.
<rbscott>
Sounds good, I will sort out those items. Is there a recommended linter by any chance?
<daurnimator>
rbscott: run through `zig fmt` :)
<daurnimator>
rbscott: for the C++ code I'm not so sure
<rbscott>
daurnimator: Wil do, thanks!
avoidr has quit [Quit: leaving]
rbscott has quit [Ping timeout: 256 seconds]
Ichorio has quit [Ping timeout: 248 seconds]
return0e has joined #zig
<tgschultz>
unionInit would clean up a hack I had to do in Deserializer. I'll have to keep an eye out for the merge so I change that right away.
rivten has joined #zig
knebulae has joined #zig
hio has quit [Quit: Connection closed for inactivity]
meheleventyone has joined #zig
meheleventyone has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
meheleventyone has joined #zig
return0e_ has joined #zig
return0e_ has quit [Remote host closed the connection]
FireFox317 has quit [Read error: Connection reset by peer]
SamTebbs33 has joined #zig
rivten has quit [Quit: Page closed]
marijnfs_ has quit [Read error: Connection reset by peer]
hio has joined #zig
avoidr has joined #zig
<nilshi>
Hello. I'm starting with the zig tutorial right now.
<nilshi>
Is anyone using the editor Geany and has recommendation for a color scheme etcß
<nilshi>
?
<andrewrk>
hi nilshi
<andrewrk>
I believe the 2 popular editors for zig are vscode and vim
<tgschultz>
someone was on here a few days ago with a Geany build with zig support weren't they?
<nilshi>
I put zig run %file as build and I'm using C color scheme at the moment. This is quite fine for most of the way. I was just wondering if anyone is active in that direction
<sadanjon>
I was expecting it to print: "xxx 1\nxxx 3\nxxx 2\n" if called with true, but it print "xxx 1\nxxx2"
<sadanjon>
help? :)
<tgschultz>
yeah, on godbolt it confirms that the errdefer isn't even compiled.
<tgschultz>
I don't see an existing issue for it, but it seems like a bug to me.
<tgschultz>
oh interesting... sadanjon, what happens when you call with false?
<sadanjon>
ah same result I think, let me recheck
<sadanjon>
yes
<sadanjon>
*same result
<tgschultz>
ok, yeah, that matches godbolt. for a second there I thought it had compiled the errdefer
scientes has joined #zig
<sadanjon>
Hi, tgschultz, I tried another variation here: https://pastebin.com/9cSWxx85 this one gives out an error 'error: unable to make error union out of number literal'
<tgschultz>
I'm pretty sure that is a known issue, you'll have to cast it `i32(1);`
<sadanjon>
Ah I see, cool, thanks!
<sadanjon>
Should I try to open an issue on github?
<andrewrk>
I'm pretty sure there's an issue for that already
<sadanjon>
Thanks tgschultz, andrewrk <3
halosghost has quit [Quit: WeeChat 2.4]
scientes has quit [Ping timeout: 272 seconds]
<nilshi>
Any recommendation to get a 2D drawing frame on the screen and an event loop for keypresses?
<andrewrk>
nilshi, SDL2 or GLFW
<nilshi>
via C, right?
<andrewrk>
yes
Ichorio has quit [Ping timeout: 250 seconds]
<emekankurumeh[m]>
nilshi, several people are working on pure zig solutions to that me, included
<nilshi>
that is good to know
<nilshi>
I don't know any of the game oriented toolkits anyway, so I have to learn everything.
<nilshi>
SDL, Raylib or whatever the names for the C libs
marijnfs has joined #zig
<nrdmn>
what's the current state of package management in zig? Is anything about that being worked on?
<andrewrk>
nrdmn, look at the roadmap sections of 0.3.0 and 0.4.0 release notes
<nrdmn>
hmm ok
marijnfs_ has joined #zig
<BitPuffin>
nilshi: yeah I've started using raylib in zig
<BitPuffin>
It wouldn't be a bad idea to write a competitor in pure zig
marijnfs has quit [Ping timeout: 268 seconds]
<nilshi>
BitPuffin: raylib has been on my list for quite a while. But first I have to look up how to properly call C code from zig.
<marijnfs_>
is the package manager gonna be in a live coding soon?
<andrewrk>
marijnfs_, getting an early version of the package manager done is a 0.5.0 goal, and if accomplished going to be a major feat
marijnfs__ has quit [Remote host closed the connection]
marijnfs has joined #zig
marijnfs_ has quit [Ping timeout: 272 seconds]
<marijnfs>
sweet
<marijnfs>
is there a reason why zig doesn't configure with llvm-9? I can't build it now
<andrewrk>
I haven't made an llvm9 branch yet
<andrewrk>
llvm trunk is still in breaking changes mode; they haven't branched for 9.0.0 yet
<marijnfs>
yeah the llvm structure changed a lot
<daurnimator>
andrewrk: is there a provisional date for 0.5.0?
<daurnimator>
andrewrk: as much as I would like the package manager in there.... I have a high suspicion that it will take on the order of a year to get one written
<daurnimator>
andrewrk: see my comment for why I don't think that should exist...
<andrewrk>
yep
<daurnimator>
andrewrk: "Convert "errno"-style error codes into Zig errors." => std/os wouldn't have errno in the first place; 'errno' would be a std/c* concept
<daurnimator>
"cross platform abstracting." => I don't think this belongs in std/os
<andrewrk>
I don't think you're trying to solve the same problem I am
<andrewrk>
daurnimator, if errno is a c concept, where does the code go that turns libc errno into zig errors? is it duplicated N times for darwin, freebsd, netbsd, dragonflybsd, and what about linux when linking libc?