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/
fengb has joined #zig
<fengb> Is there a way to force zig out of comptime?
<fengb> error: unable to evaluate constant expression: const byte_slice = try self.reallocFn(self, ([*]u8)(undefined)[0..0], undefined, byte_count, alignment);
<fengb> As much as I'd like to preallocate on the heap... >_>
<scientes> you can
<scientes> not sure with zig
<scientes> but with c you just put your fixed buffer in a differn't elf section
<scientes> using a GNU extension
<fengb> I'm trying to allocate at runtime but zig is insisting trying at comptime
<scientes> well comp-time allocator is a new thing
squeek502 has joined #zig
<daurnimator> fengb: it shouldn't unless you're in a comptime block somewhere
<daurnimator> fengb: infact zig will usually always prefer runtime over comptime
<fengb> Yeah user error, I was exporting this in a struct -_-
<daurnimator> fengb: your question still suggests an improvement in the language/tools though: some way to check "why am I comptime" -> something in the stacktrace?
<fengb> Ah, maybe something like `src/main.zig:99:24: note: forced comptime call from here`
<tgschultz> fengb, I believe it's your use of undefined in the old_align parameter?
<tgschultz> or not, I guess I should read the chat string farther
<daurnimator> fengb: yes, that sounds like a helpful compiler note. maybe make a feature request? :)
karrick_ has joined #zig
karrick_ has quit [Remote host closed the connection]
karrick_ has joined #zig
karrick_ has quit [Remote host closed the connection]
<tgschultz> scientes: so I tried passing my assembly as a C file, and it fails to build it. -v makes it look like it is trying to execute gcc!?
<tgschultz> tell me that isn't the case, because if so that's a pretty bad oversight.
karrick_ has joined #zig
<scientes> rofl
<tgschultz> passing it as --c-source doesn't work either, something about a d file. --assembly worked
<scientes> > something about a d file.
<scientes> thats a bug
<tgschultz> great, so we deprecated a perfectly working command in favor of one that doesn't work.
<scientes> actually the .d bug was something that DIDNT work with --assembly
<scientes> guess that patch was a POS
<scientes> tgschultz, its calling gcc -E right?
<tgschultz> hold on, maybe I'm just tragically out of date
<daurnimator> Does anyone know how zig deals with floating point rounding mode?
karrick_ has quit [Remote host closed the connection]
<daurnimator> scientes: that's not rounding mode is it, just -ffast-math?
<scientes> Results assume the round-to-nearest rounding mode.
<scientes> thats IEEE 754
<scientes> otherwise you need these https://llvm.org/docs/LangRef.html#constrainedfp
<scientes> daurnimator, you can actually call those without changing the compiler
<tgschultz> ok, well scratch my complaint. --c-source does work on latest master. trying to build with cc doesn't. I would have thought it would invoke the zig-c compiler, but -v tells me: `"gcc" -v -m32 -o a.out "C:\\Users\\TANNER~1\\AppData\\Local\\Temp\\dpmi-b94a02.o"`
<scientes> just use export "llvm.foo.bar"
<scientes> tgschultz, check it in strace to make sure
<tgschultz> windows don't got dat
<scientes> tgschultz, because ARGV[0] != AT_PROG
<tgschultz> though I do have process mon
<scientes> ahhh...
<daurnimator> scientes: more thinking about risks of functions behaving differently at comptime vs runtime (and hence differently depending on optimization level) due to e.g. a library changing the rounding mode
<scientes> then i have no idea, i'm a Linux person
<scientes> daurnimator, zig should always be IEEE 754
<daurnimator> yeah.... and IEEE754 has different rounding modes
<scientes> unless you set optimized mode
<scientes> oh i c
<scientes> well if a shared library changes it, that is outside of zig's control
<daurnimator> yep.
<daurnimator> but I have a feeling it makes certain optimizations zig makes invalid
<scientes> if you want to add other rounding modes to zig, via those contrained modes (I am not sure about softfloat support for the compttime however), then go ahead
<daurnimator> I'll make an issue....
<scientes> <daurnimator> but I have a feeling it makes certain optimizations zig makes invalid
<scientes> explain (in the issue)
<tgschultz> oh my, the horror. zig searches the entire path for every conceivable executable format named CC, including JS, WSH, and COM
<scientes> tgschultz, yeah, that is that shit patch
<scientes> sorry i shouldn't use such harsh words, he is a valued member
<tgschultz> same with ptxas
<tgschultz> checks a bunch of c:/etc/distro-name-release...
<scientes> zig wants builds to be in-house, so that is def. a bug
<scientes> well, clang actually calls into gcc for assembly, IIRC
<tgschultz> then the tripples for native and target-gcc.exe....
<tgschultz> oh, and by exe I mean every conceivable executable format again
<scientes> I don't think assembler is something llvm wants to be
<tgschultz> then finally "just" gcc.everyformatever. wow
<scientes> tgschultz, meh, cpu features on Linux is just as bad
<tgschultz> well it isn't a very good one, but assembly is a real thing that actuall exists and if you want to write system level code you're going to need it
<scientes> tgschultz, i mean dynamic library features
<scientes> and there is exactly one library (glibc) that even uses that stupid feature
<scientes> which is obsolete by elf function multi-versioning
<scientes> hopefully they drop that stupid feature
<tgschultz> yeah, I'm not a fan of glibc for other reasons, like its historical hostility to static linking
<scientes> the developers wouldn't be opposed to getting libm to build without libc
<scientes> and Ulrich Drepper was an incredible programmer
<scientes> libm has a bunch of high quality stuff in it
<scientes> well i mean its not so great, but there isn't anything better
<daurnimator> 'was'?
<scientes> he works for BoA now
<scientes> doing who knows what
<daurnimator> huh? isn't he at redhat now?
<scientes> anyways, not much of a manager
<scientes> but wrap some invaluable essays
<scientes> *wrote
coolreader18 has joined #zig
<coolreader18> scientes, could you help me out translating the assembly from gcc/nasm to zig/at&t?
<scientes> coolreader18, i know very little about assembly
<scientes> coolreader18, and gcc is also at&t syntax
<scientes> well actually i'm coding ppc64 assembly right now...
<coolreader18> do you know how to translate c's `register int asm("r0")` to zig?
<coolreader18> it seems like it's just a regular-ish variable but I'm not sure if the asm("r0") changes the meaning a lot
<shachaf> It changes the meaning by telling it what register to put the variable in.
<coolreader18> is that reproducible in zig?
<shachaf> I don't know that Zig supports that exact feature.
<shachaf> You probably need to use the inline asm syntax.
karrick_ has joined #zig
<scientes> clang's support of that is also buggy
<scientes> maybe i should have filed a bug
<shachaf> The inline asm syntax should let you specify everything you need, it's just a bit awkward.
<scientes> shachaf, not always.
karrick_ has quit [Remote host closed the connection]
<scientes> well actually
<shachaf> (But not as awkward as gcc, which gives every register its own name!)
<scientes> anyways, I was trying to bind the arm link register to a variable, and clang just pruned the instructions
<scientes> cause i was doing something quite weird
<shachaf> The return address register?
<scientes> the link register
<shachaf> Is that not the register with the return address?
<scientes> yes
<shachaf> Anyway if you're doing something weird enough you're probably better off moving more of the code into assembly.
<scientes> i was promoting the lr so i could put date in the instruction stream
<scientes> *data
<scientes> so on return it jumps over the data
<scientes> and i could read the data by reading the lr
<tgschultz> coolreader18 you've seen https://ziglang.org/documentation/master/#Assembly ?
<coolreader18> tgschultz yeah, I've been using it
karrick_ has joined #zig
lunamn has quit [Quit: leaving]
<scientes> coolreader18, oh! just look at the assembly in arm64.zig
<scientes> that should get you really close
<scientes> (I wrote that)
<scientes> the difference is that the syscall is in the instruction stream, rather than in register r8
<scientes> (x8 means it is a u64)
<scientes> coolreader18, i personally found assembly in zig to be quite difficult as well
<scientes> it takes some getting use to the syntax
karrick_ has quit [Remote host closed the connection]
<scientes> coolreader18, if you want to ask someone to do something for you, you need to give them all the tools, and explain the whole problem
<coolreader18> thanks, I'll keep that in mind
<coolreader18> basically what I'm trying to do is like you suggested, make syscalls straight from zig without needing ndless' libc
<scientes> that is cool
<scientes> the other thing is that you need to figure out how to call that llvm --lower-atomic pass
<scientes> just on this target
<scientes> (assuming there is no preemption)
<coolreader18> would that involve using `ZigLLVMInitializeLowerIntrinsicsPass` from `zig_llvm.cpp`?
<coolreader18> I can't find anywhere where that's used though
<scientes> no that is for intrinsics
<scientes> well actually i need to look into it
<scientes> coolreader18, you need LLVMAddLowerAtomicPass
<scientes> it will look very similar to that one however
<coolreader18> đź‘Ť
<tgschultz> so does anyone know what the inline asm errors with i386-windows are about? I know that it isn't a supported target, but it used to at least compile.
<scientes> tgschultz, paste?
<tgschultz> same as end of this issue: https://github.com/ziglang/zig/issues/537
<scientes> so this is the clang built into zig?
<fengb> Is DirectAllocator broken in macOS? https://gist.github.com/fengb/13a21cd949e05eca1bc80e96093f5c37
<fengb> I must be doing something wrong. Tests are fine if they don't go through my wrapper
<tgschultz> scientes no idea. I'm not doing anything special, it gives that even with a main that returns u8(0) and nothing else.
<scientes> maybe do a git bisect
<scientes> if it worked before
<tgschultz> that was a long time ago from what I recall
<daurnimator> fengb: so what's zee_alloc? :)
<scientes> I did a git bisect on llvm and that takes ages to build
<scientes> however zig is more likely to have builds you can't even test
lunamn has joined #zig
scientes has quit [Ping timeout: 246 seconds]
marmotini_ has joined #zig
<fengb> Minimal general purpose allocator
<fengb> Mostly a toy since I've never implemented an allocator before, but also trying to make it tiny for wasm deploys
<daurnimator> fengb: header/footer based or radix tree?
<fengb> Uh... radix tree sounds more correct (lol)
<fengb> Probably neither? I'm just making stuff up as I go
<daurnimator> fengb: where do you keep metadata about an allocation?
<daurnimator> the three possible answers are: 1. next to the allocation. 2. somewhere central. 3. no metadata
<daurnimator> fengb: https://github.com/fengb/zee_alloc/blob/master/src/main.zig#L86 <-- you probably want log2_ceil
<daurnimator> oh wait... you're dividing
<fengb> Probably!
<fengb> log2(page_size) - log2_ceil(memsize)
<daurnimator> fengb: bug I think I see: you alloc for alignment+size but only free by size
<fengb> Oh
<fengb> I mean, nothing really works yet. Just tossing ideas on paper
<daurnimator> fengb: also after a shrink, a free will go back into a smaller bucket than it otherwise could
<fengb> And it seems like I'm basically reimplementing dlmalloc poorly... so I might want to reconsider
<daurnimator> fengb: I have an stackable allocator almost written.... but I am stuck on supporting zig's alignment well
<daurnimator> I think I almost have a solution; but it's so complex to write my brain hurts... don't look forward to debugging it
<daurnimator> I blame it on selecting option 1. above: I wrote it so that metadata is next to each allocation.
<fengb> Yeah I punted on memory alignment. I think it's as simple as round up to power of 2
<fengb> I saw a floorPowerOfTwo but I really want ceilPowerOfTwo
<daurnimator> fengb: the problem with aligning is that if you want your metadata "next to the allocation", then your metadata needs to move along with it
<fengb> Ha!
<fengb> I'm not sure I need metadata with this strategy: alignment should always be aligned to power of 2 for small stuff, and aligned to page size for big stuff
<fengb> I'm probably missing something
<fengb> A lot of things
<daurnimator> fengb: but in zig an allocation can say: give me 4096 bytes, aligned to 2GB
<fengb> Oh
<fengb> Nah, you can only get 4k back :P
<fengb> Are alignments consistent or do I need to take each instance separately?
hio has quit [Ping timeout: 259 seconds]
<daurnimator> fengb: what do you mean?
lqd has quit [Ping timeout: 252 seconds]
odc has quit [Read error: Connection reset by peer]
r1b has quit [Ping timeout: 252 seconds]
<fengb> Would all memory of size X have alignment of Y
<fengb> Or size X + ptr P
cbarrett has quit [Ping timeout: 252 seconds]
lqd has joined #zig
cbarrett has joined #zig
hio has joined #zig
<daurnimator> fengb: every allocation can be different
r1b has joined #zig
odc has joined #zig
stratact has joined #zig
coolreader18 has quit [Ping timeout: 244 seconds]
hio has quit [Quit: Connection closed for inactivity]
fengb has quit [Ping timeout: 256 seconds]
marmotini has joined #zig
marmotini_ has quit [Ping timeout: 258 seconds]
ijneb has quit [Ping timeout: 244 seconds]
return0e_ has joined #zig
return0e has quit [Ping timeout: 258 seconds]
Aransentin has quit []
avoidr has quit [Quit: leaving]
marijnfs has joined #zig
jjido has joined #zig
_whitelogger has joined #zig
edr has joined #zig
marmotini has quit [Ping timeout: 272 seconds]
<daurnimator> why is there no @atomicSave ?
marmotini_ has joined #zig
<daurnimator> or as llvm calls it s/Save/Store/
marmotini_ has quit [Quit: Leaving]
scientes has joined #zig
halosghost has joined #zig
neceve has joined #zig
jevinskie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Zaab1t has joined #zig
merlyndmg has joined #zig
<donpdonp> isnt that what @atomicRmw does?
jjido_ has joined #zig
<merlyndmg> I'm trying to figure out how to get zig to properly link to a DLL via its import lib, while compiling a program on windows. It keeps saying all the symbols from the DLL are missing, even though dumpbin say the export lib and the dll both have them. (this is lib epoxy in this case, for the tetris demo). Anyone have a link to instructions on how to get it working?
meheleventyone has joined #zig
jevinskie has joined #zig
halosghost is now known as wit
wit is now known as hg
wilsonk has quit [Ping timeout: 258 seconds]
meheleventyone has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
wilsonk has joined #zig
andrewrk has joined #zig
<andrewrk> hello
jjido_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<shritesh> đź‘‹
<nrdmn> hello
<andrewrk> beautiful, with the new firefox update, the zig docs are light/dark depending on your browser preference
neceve has quit [Read error: Connection reset by peer]
<shritesh> Safari had that for quite a while on macOS. I hope it comes to iOS in the next update.
<merlyndmg> can I cross-post (or just link) a Q I put on reddit in here?
<andrewrk> merlyndmg, definitely
<merlyndmg> For the crosspost - should I be able to link to a pre-compiled C DLL w/ Windows as the target? I've tried it via `exe.linkSystemLibrary("epoxy.lib");` and it gives me errors that it can't find any of the DLL's (or in this case link lib's) symbols
<merlyndmg> well, windows as the host too :)
<andrewrk> merlyndmg, yes you should be able to do this. one way to do it is to put the DLL name after `extern` in your declarations. e.g. `extern "kernel32"`. this will automatically generate the .lib and put it on the link line. unfortunately this doesn't work with @cImport
<andrewrk> if you have a .lib to link against I believe it should be exe.addObjectFile. sorry for the bad name, this should be changed
<merlyndmg> cool I'll try mucking about with that! I also saw that function when looking at the zig source
<merlyndmg> the zig source and existing scripts kinda look like the only "docs" for the build system rn. did you want someone to do some placeholder improvements for that, or is it better to work on it when you can give it real attention?
<merlyndmg> or is it too in flux to want placeholders
<andrewrk> that's correct. part of the issue is effort not directed at build system docs, but yes a big issue is that it is still very much in flux
<andrewrk> especially once package management comes out, it will change a lot
<merlyndmg> If it's going to change significantly sounds like it might be wasted effort to doc what's there now for sure
<andrewrk> the parts of the zig project that are documented are a bit more stable
<merlyndmg> is it intentional that the readme looks like it has the same outline as "the docs", but is actually up to date?
FireFox317 has joined #zig
<merlyndmg> (if you can't tell, trying to see if there's any part of the docs I would be qualified to do some busy work on, or at least file tickets for, etc)
<andrewrk> I'm not sure what you mean - the content in the readme is different than the content of the docs. I'm assuming "the docs" -> http://ziglang.org/documentation/master/
<scientes> andrewrk, i can't reproduce and i'm on 69.0a1. i turned on the dark theme
<merlyndmg> That statement was mostly due to "zig build system" being in both. I guess the release notes are just gigantic at this point. which is pretty cool
<andrewrk> ah you meant release notes, not readme
<scientes> and browser.in-content.dark-mode is true
<merlyndmg> https://ziglang.org/download/0.4.0/release-notes.html vs https://ziglang.org/documentation/0.4.0/ - I think. I saw zig build in multiple places, and thought I saw the tier list in multiple places, so thought I was seeing at least partially duped docs. Probably was just a late night and I got confused. Looking at them again this morning they look quite different, so nevermind
Zaab1t has quit [Quit: bye bye friends]
jevinskie has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jevinskie has joined #zig
<andrewrk> alright it's time to get through these pull requests
<shritesh> The homepage has dark mode too now? Nice
<scientes> it isn't working for me
<scientes> linux nightly (69)
<andrewrk> scientes, you can look at the source, the problem is client side if it isn't working
<scientes> yeah i saw the source too
avoidr has joined #zig
FireFox317 has quit [Quit: Page closed]
Aransentin has joined #zig
marijnfs_ has joined #zig
<marijnfs_> does someone have experience linking to libcuda? i'm getting /usr/lib/libcuda.so is incompatible with elf_x86_64
<emekankurumeh[m]> welcome back andrewrk
<shritesh> I tried to generate nvptx a few weeks ago and gave up.
<andrewrk> marijnfs, I think you need to give a cuda target to your zig code
<andrewrk> yeah either nvptx or nvptx64. note that both of these are "tier 4" targets which means you'll probably have to get involved in zig development if you want to use them
<marijnfs_> andrewrk: hmm that sounds indeed experimental, when I just link to cuda_rt (runtime) it seems to link at least, but can't run it
<shritesh> I couldn’t get anything practical done without being able to annotate functions as host/device.
<scientes> but if you get involved it would probably be considered a reasonable target
<scientes> also OpenCL
marijnfs_ has quit [Ping timeout: 245 seconds]
marijnfs_ has joined #zig
<merlyndmg> "exe.addObjectFile" - this is for static libs, or does it also work for DLL "export libs"?
<shritesh> Is OpenCL language independent? I always thought you’d have to pass the kernel source code to the driver like OpenGL shaders?
<merlyndmg> I am getting the same errors when converting to use that, with DLL export libs (not static libs)
<Aransentin> Q: If I write a WebSocket server, there could be a lot of different lower protocols that you might want to put it on
<Aransentin> e.g. TCP, TLS, UWSGI... and maybe some other protocol wants to lie on top of WebSockets. Is there a natural Zig-stdlib pattern to do this?
<Aransentin> (Maybe giving it two IO abstractions to feed from/into like OpenSSL BIOs, but not as 🤮)
<shritesh> Maybe the pattern used by memory allocators? There are some that piggyback on another.
<andrewrk> we're going to want some kind of async stream abstraction
<tgschultz> andrewrk: btw, I tried your suggestion of hacking codegen to force an i386-unknown-none-coff target, but then LLVM just complains that it won't build a coff for a non-Windows OS because how dare I even think such a thing.
<andrewrk> merlyndmg, as far as I'm aware static libs and DLL export libs are the same thing
wootehfoot has joined #zig
marijnfs__ has joined #zig
marijnfs_ has quit [Ping timeout: 248 seconds]
<tgschultz> though at this point I'm pretty sure coff wouldn't help anyway. I need to produce an LE or straight MZ executable to work with most DPMI hosts, or PE in the case of one, so I'm probably going to have to write some kind of translator from ELF to one of those.
<emekankurumeh[m]> dll export libs link to the dll, whereas static libs are actually statically linked in
wootehfoot has quit [Read error: Connection reset by peer]
<Aransentin> Hmm, yeah... Though in the case of the memory allocators, all the events come from the top of the "stack" and propagate downwards; in the IO case, there might events all over the place
<marijnfs__> is there a way to directly give a full path to a library to link to? it's resolving to the wrong library for me, and I can't override the initial search dirs
btbytes has joined #zig
<andrewrk> marijnfs, --object
marijnfs_ has joined #zig
marijnfs__ has quit [Ping timeout: 272 seconds]
hg has quit [Quit: WeeChat 2.4]
scientes has quit [Remote host closed the connection]
scientes has joined #zig
scientes has quit [Max SendQ exceeded]
<nrdmn> seems like I can assign extern variables at declaration. Does that make sense?
<merlyndmg> I don't think DLL .lib files are the same as static .lib files. They don't contain object code. I think they just handle the DLL load and forward calls to the DLL. Maybe you mean that they should just link in the same way, and should just work?
<merlyndmg> I will try the other method that you suggested now, since exe.addObjectFile is getting the same linker errors
marijnfs__ has joined #zig
marijnfs_ has quit [Ping timeout: 268 seconds]
marijnfs_ has joined #zig
marijnfs__ has quit [Ping timeout: 246 seconds]
marijnfs__ has joined #zig
marijnfs_ has quit [Ping timeout: 268 seconds]
coolreader18 has joined #zig
marijnfs__ has quit [Remote host closed the connection]
merlyndmg has quit [Quit: Page closed]
merlyndmg has joined #zig
ijneb has joined #zig