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/
waleee-cl has quit [Quit: Connection closed for inactivity]
guan has quit [Ping timeout: 260 seconds]
betawaffle has quit [Ping timeout: 272 seconds]
kwilczynski has quit [Ping timeout: 260 seconds]
_whitelogger has joined #zig
haliucinas has quit [Remote host closed the connection]
haliucinas has joined #zig
mmx870 has quit [Quit: The Lounge - https://thelounge.chat]
mmx870 has joined #zig
<andrewrk> PC9801, the rust code is calling into dynamically linked (not shown) code but the zig code is 100% all there
<andrewrk> you probably intend to turn on release builds for both of them
decentpenguin has quit [Read error: Connection reset by peer]
<wilsonk> lol, I didn't even look at the rust code enough to realize it was calling into dynamically linked code...duh
decentpenguin has joined #zig
<andrewrk> that said, I turned on optimizations and am seeing that the rust code got a lot smaller than the optimized zig code. it looks like the formatting code turned into some vectorized stuff. unclear if this is better or worse than the rust code, would have to execute it to find out
<andrewrk> and uh, yeah, actually the optimized rust code is calling a (not shown) function for printing, so again it's not a fair comparison
<andrewrk> PC9801, you can make it fair by using an extern function for printing the values and using an export function instead of main: https://godbolt.org/z/KosohG
craigo has quit [Ping timeout: 258 seconds]
ifreund has quit [Read error: Connection reset by peer]
xenon has joined #zig
ifreund has joined #zig
xenon has quit [Remote host closed the connection]
Biolunar has quit [Ping timeout: 272 seconds]
eleanor-nb has joined #zig
gpanders has joined #zig
gpanders_ has quit [Ping timeout: 264 seconds]
<eleanor-nb> I'm thinking of beefing up the RISC-V inline assembler in stage 2. The conceptual problem I'm running into is: how do we do labels?
<eleanor-nb> Relative labels can be handled locally, but absolute labels will have to be passed on to later stages of codegen, which will need to be aware of RISC-Vsymbol vagaries.
<eleanor-nb> Also, incremental compilation will not like that.
<eleanor-nb> With more thought, I think that absolute labels should not be allowed, and function bindings should only be allowed in `call`, whose implementation we override.
dddddd has quit [Ping timeout: 240 seconds]
<eleanor-nb> To make relative jumps work across function calls, it won't be enough to keep track of output address internally -- we'd need to either track exact byte counts of codegen outputs, or get the current output address.
dddddd has joined #zig
<eleanor-nb> Here's what I'm thinking:
<eleanor-nb> (Nvm, still thinking.)
ofelas has joined #zig
eleanor-nb has quit [Remote host closed the connection]
<Ristovski> Is there anything else besides LTO not being applied across Zig<->C boundary that could theoretically impose a performance regression when mixing Zig and C?
waleee-cl has joined #zig
<scientes> Ristovski, PIC, but otherwise that is basically it. You might want to add a trampoline in some cases to prevent speculative execution.
<Ristovski> scientes: Ah cool, thanks
<scientes> PIC is position independent code
<Ristovski> Yeah I am aware :P
<PC9801> andrewrk thanks! this makes sense
<ofelas> does anyone know why: unable to call function with naked calling convention?
<ifreund> ofelas: you're going to have to give a little more context than that, could you paste the code and error message somewhere?
<ofelas> error message here https://pastebin.com/ZyWic12V
wootehfoot has joined #zig
<ifreund> um, shouldn't your entry point be the only callconv(.Naked) function?
mikdusan has quit [Ping timeout: 256 seconds]
<ifreund> pretty sure .Naked means that the function can only be called as an entry point, not from zig code
<ofelas> I'm blindly following this FreeRTOS Cortex-M3 port calling conventions at the moment, haven't spent to much time analyzing as the "inline" asm fixed the problem
<daurnimator> no you should be able to call naked from anywhere
<ofelas> it seems C can call naked functions so I thought Zig could too
<ifreund> this suggests otherwise no?
<daurnimator> ifreund: hmm, looks like we only support calling naked with assembly
<ifreund> we could definitely use some better docs on calling conventions at least
<daurnimator> ifreund: a naked function is essentially saying "I'll handle the calling convention myself with assembly 'I will grab my own args from registers/the stack'"
<daurnimator> "I'll handle it myself" is not inherently incompatible with other calling conventions; but it *might* be
<daurnimator> i.e. its giving the developer enough rope to hang themselvess
<ifreund> makes sense
<daurnimator> _start has to be naked.... because there is no other calling convention for it: you have to do it yourself. but there's no reason you can't write a naked function that does e.g. 20 nops and then the internals of C calling convention
xackus_ has joined #zig
xackus_ has quit [Ping timeout: 258 seconds]
invokesus has joined #zig
joey152 has joined #zig
cole-h has joined #zig
craigo has joined #zig
<scientes> when I showed our _start to people they were a bit scared it wasn't assembly
<scientes> ofelas, zig can call naked functions
<scientes> but it doesn't make much sense to do that
<scientes> as if you are not using standard calling conventions (or fastcc) then you do the call yourself, and not with llvm
wootehfoot has quit [Ping timeout: 264 seconds]
<marler8997_> is there a way to make a function use the C ABI without making it externally visible?
<BaroqueLarouche> callconv(.C) ?
<marler8997_> that's it, thanks BaroqueLarouche
gpanders has quit [Ping timeout: 240 seconds]
gpanders has joined #zig
wootehfoot has joined #zig
<ifreund> anyone know if there's a non-hacky way to output a library to $PREFIX/lib/security/foo.so with the zig build system?
factormystic has quit [Quit: The Lounge - https://thelounge.chat]
nvmd has joined #zig
factormystic has joined #zig
traviss_ has quit [Remote host closed the connection]
jabb has joined #zig
traviss has joined #zig
<andrewrk> idea being to insert that "security" dir there?
<andrewrk> is that some kind of standard?
<ifreund> that's what pam uses
<ifreund> I'm writing a pam module and using zig of course
<andrewrk> ifreund, I think you can overwrite Builder.lib_dir field
<ifreund> on 0.6.0 at least whatever I set gets overwritten in resolveInstallPrefix()
<ifreund> tried setting the name of the library to "security/foo" as well but there's a check that disallows it as an invalid name
<andrewrk> alright well sounds like it's not really possible but patch welcome. the build should be fully configurable, shouldn't get in people's way
<andrewrk> ifreund, is this something that makes sense to be configured by the project, or by the user doing the install?
<andrewrk> maybe we make a standard option that is always available to override the lib dir?
<ifreund> configured by the project in this case I believe. pam looks for modules in /lib/security by default and so my project should install to $prefix/lib/security
<ifreund> users should only need to specify e.g. /usr as the prefix, they shouldn't need to know where pam will search for modules
cole-h has quit [Quit: Goodbye]
jabb has quit [Ping timeout: 240 seconds]
xackus_ has joined #zig
<andrewrk> makes sense
rzezeski has quit [Quit: Connection closed for inactivity]
<ifreund> hmm, automatically prefixing my .so file with lib also doesn't fit with the conventions for pam
<ifreund> maybe I should just be using addObject
<scientes> ifreund, I remember when systemd wrote a pam module
<scientes> it was hell
<ifreund> lol
<scientes> you have to do all these crazy things
<ifreund> all mine is going to do is set XDG_RUNTIME_DIR
<ifreund> I wouldn't need this if I was using (e)logind of course
<marler8997_> Reading about X and came accross the X "Principles" here, looks like good advice that confirms some of the things I've learned in my years: https://en.wikipedia.org/wiki/X_Window_System#Principles
<andrewrk> this one goes against zig philosophy: "If you can get 90 percent of the desired effect for 10 percent of the work, use the simpler solution"
<andrewrk> zig is all about doing extra labor to close that last 10%
<marler8997_> an interesting detail, of course, it depends on how important that "effect" is
<marler8997_> when it comes to proper error handling, Zig definitely aims for the 100% approach
<marler8997_> but then again, I wouldn't say Zig had to add 90% more complexity to handle 100% of errors
<andrewrk> not assuming memory allocation will succeed would be the main example
<andrewrk> many programming languages are fundamentally built on the premise that memory is infinite
<marler8997_> It is infinite from the processor's perspective, because if you ever run out, you get murdered by the OOM...so it's infinite as far as you know :)
<marler8997_> *process's perspective (not processor)
<andrewrk> there are many environments where that is not true
<andrewrk> if you're writing library code, the premise is that it's intended to be reusable code, and therefore behaving correctly on many environments is part of the features the library is providing
<marler8997_> yeah starting a language with this premise is a much needed thing in my opinion
AshOhms has joined #zig
AshOhms has quit [Client Quit]
AshOhms has joined #zig
nullheroes has quit [Quit: WeeChat 2.9]
_Vi has joined #zig
_whitelogger has joined #zig
<ronsor> hey, does anyone have advice for getting stack traces on UEFI?
nvmd has quit [Quit: Later nerds.]