<preyalone>
Look, I was really eager today to learn Zig and help contribute. But when I'm banned from assisting with problems on the GitHub repo, there's not much I can do to address any bugs I come across. I can't be a part of something with a policy clapping your hands over your ears to ignore the bugs. So I'm out.
preyalone was banned on #zig by ChanServ [*!*@gateway/web/irccloud.com/x-zusiwsmotklgffrv]
preyalone was kicked from #zig by ChanServ [Banned: did not acknowledge any feedback of their behavior]
<andrewrk>
you're welcome to try again in 30 days
<pixelherodev>
wowers
<pixelherodev>
s/(ers)/z&/
scientes has quit [Quit: ZNC 1.8.2+deb1+b1 - https://znc.in]
Enrico204 has quit [Ping timeout: 265 seconds]
notzmv has joined #zig
<ifreund>
yeah, bit of an effort vampire that one
<leeward>
Zig isn't in Debian. That's a private repo.
powerofzero has quit [Ping timeout: 264 seconds]
<fengb>
But it’s our fault it isn’t updated
<fengb>
Gotta police the internet
<leeward>
Yep. Whoever maintains that package probably ought to have included a -doc package to go with it.
<andrewrk>
zig cc being used with cgo to cross-compile cgo applications
<leeward>
Interesting.
<ifreund>
yeah, that is pretty exciting
<g-w1>
its very exciting that the person doesn't have any background with zig
<ifreund>
A great way to get a zig binary on more developers machines
<leeward>
This whole "no dependencies" thing seems to be pretty popular.
<fengb>
It convinced Whitequark to take a second look too :P
powerofzero has joined #zig
<g-w1>
Would it be a good project to just do the static-clang thing without zig, or is a good idea to have zig in it to expose more people?
<ifreund>
g-w1: no reason to have 2 separate codebases implementing the same thing, and getting a zig compiler everywhere is certainly a nice side effect :D
<g-w1>
yep thats what I thought, just checking with other people
<andrewrk>
the static-clang thing depends on zig, that's what our compiler-rt is implemented in :)
<andrewrk>
also the zig cc feature is implemented in zig, and the caching system, and the linker driver, and also partially linking...
<fengb>
Why can’t LLVM compiler-rt work cross platform?
<andrewrk>
you could work on it to make it do that and it would look a lot like what the zig project is doing, except with C code instead
<andrewrk>
most of the code works cross platform fine
<andrewrk>
a lot of the value zig provides is in the details of "glue code" making things just work
<andrewrk>
I know it often doesn't feel like it because we have a bunch of open bugs
<andrewrk>
but we really have massivly simplified what is normally a complex problem domain
a92 has joined #zig
<karchnu>
I was first interested in Zig to get rid of gcc and clang bullshit, and replace them for an OS. So I'm not really surprised here. :)
notzmv has quit [Ping timeout: 256 seconds]
jicksaw has quit [Quit: ZNC is kill]
jicksaw has joined #zig
<g-w1>
andrewrk: I was watching your old stream about the self-hosted compiler, and you mentioned single static assignment tree and that zir, wasm, and scopes use it. I cant find anything about it online though. Are there any articles/blog posts/papers I could read to learn more about it? I assume the biggest difference with ssa is that there is mutability so no need for phi instruction.
<daurnimator>
even if things aren't correct they could be consistent :/
allan0 has quit [Ping timeout: 272 seconds]
allan0 has joined #zig
<daurnimator>
I was sitting here wondering if there was a notable distinction on which should be used when
<powerofzero>
Hi, I just ran into the problem of the compiler not letting me a have a struct that includes a pointer to a value of the same type. What is the prefered workaround for these kinds of structures?
wallyduchamp has quit [Remote host closed the connection]
wallyduchamp has joined #zig
a_chou has joined #zig
HollMax has joined #zig
<HollMax>
Hi, when I run `zig run foo.zig`, it compiles in -O Debug by default, right?
<HollMax>
Because I'm getting a segfault without much to go by, so I'd like to know, if my code is wrong, or it never gets to run because of an ICE
<daurnimator>
powerofzero: I don't understand, could you share an example of what you're trying to do?
<daurnimator>
HollMax: a segfault in the compiler or in your program?
<daurnimator>
HollMax: use `build-exe` to get your application, then run it under gdb and/or valgrind.
<HollMax>
my bad, should've used `build-exe` from the start
<HollMax>
anyway, it's an ICE, will file after lunch
<HollMax>
I don't know what I'm doing, but it's my 4th time trying to use Zig, and I always find an ICE/missing feature
<daurnimator>
powerofzero: hmmm. that's a little weird. you might be able to use @This() instead
<powerofzero>
That didn't work, same error. I also tried indirection through a const Self = @This() but that also gave the same error.
<daurnimator>
powerofzero: I think the error might be when generating an error message....
<daurnimator>
powerofzero: `atomic.Int(?*Block)` doesn't really make sense... that's not an integer type you're passing
<powerofzero>
as far as I can tell from the atomic.Int source, it should work just fine like that. Plus there is no atomic.Ptr
<daurnimator>
it's probably trying to compile e.g. `@atomicLoad(?*Block, ....)` and then trying to generate an error message
<daurnimator>
hmmm. I guess the operation does make sense.....
<powerofzero>
Oh shoot yeah I checked whether it could be a pointer, but not an optional pointer, which it can't be.
<powerofzero>
ok yeah that fixed the problem.
<powerofzero>
though now I have the new one of needing to emulate a ?*Block.
<daurnimator>
powerofzero: it does sound like you should file an issue though: either we need to make @atomic take optional pointers; or we need to fix the error message
<daurnimator>
powerofzero: as a workaround use a `atomic.Int(usize)` and @intToPtr/@ptrToInt ?
<powerofzero>
Yes, I'll probably do both of those things. Thanks for the help.
nycex- has quit [Remote host closed the connection]
nycex has joined #zig
<daurnimator>
powerofzero: maybe there should be a `atomic.Pointer()` that does the @intToPtr/@ptrToInt for you
<daurnimator>
I'm not sure atomic.Int taking a pointer *should* make sense :P
<daurnimator>
wait, does @intToPtr even work on an optional pointer?
<daurnimator>
if it does that seems like a wart
a_chou has quit [Quit: a_chou]
<powerofzero>
I think so, based on the docs "If the destination pointer type does not allow address zero and address is zero, this invokes safety-checked Undefined Behavior."
zippoh has quit [Ping timeout: 272 seconds]
waleee-cl has quit [Quit: Connection closed for inactivity]
earnestly has quit [Ping timeout: 256 seconds]
HollMax has quit [Ping timeout: 245 seconds]
ur5us has quit [Ping timeout: 260 seconds]
powerofzero has quit [Ping timeout: 265 seconds]
[RMS] has quit [Ping timeout: 240 seconds]
<andrewrk>
yes @intToPtr works with optional pointers and it's intentional. why wouldn't it?
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
HollMax has joined #zig
HollMax45 has joined #zig
HollMax has quit [Ping timeout: 245 seconds]
HollMax45 has left #zig [#zig]
HollMax has joined #zig
<daurnimator>
andrewrk: because an optional pointer isn't of type pointer: its of type optional.
<HollMax>
so apparently switching on a slice is valid, but only if it has 1 slice branch
lucid_0x80 has joined #zig
<andrewrk>
HollMax, switching on a slice is intended to always be a compile error
<daurnimator>
andrewrk: it brings up inconsistencies like @ptrToInt only allowing optionals if the base pointer type is not allow-zero
<HollMax>
I'm on 0.7.0 and it segfaults with more branches, but appears to work with 1 branch
<HollMax>
and it behaves the same on master
<andrewrk>
daurnimator, that's fine, everything makes sense
HollMax has quit [Remote host closed the connection]
xmn11 has quit [Ping timeout: 260 seconds]
rzezeski has quit [Read error: Connection reset by peer]
tracernz has quit [Ping timeout: 264 seconds]
rzezeski has joined #zig
tracernz has joined #zig
r0bby has quit [Ping timeout: 260 seconds]
kwilczynski has quit [Ping timeout: 264 seconds]
kushalp has quit [Ping timeout: 260 seconds]
procnto has quit [Ping timeout: 268 seconds]
kwilczynski has joined #zig
r0bby has joined #zig
procnto has joined #zig
kushalp has joined #zig
<andrewrk>
there is precent for zig treating ?*T as both a pointer and an optional
leon-p has quit [Quit: leaving]
ur5us has joined #zig
<daurnimator>
andrewrk: so you think the issue above is really that @atomicLoad should take `?*T` when `T` is incompletely known?
<andrewrk>
I don't understand what you mean by "incompletely known" - you mean like an opaque type?
<andrewrk>
I'm skeptical of the value of std.atomic.Int, I suspect this person would be better off using the atomic builtins
xackus has joined #zig
drvirgilio has quit [Ping timeout: 260 seconds]
drvirgilio has joined #zig
decentpenguin has quit [Quit: ZNC crashed or something]
decentpenguin has joined #zig
marnix has quit [Ping timeout: 240 seconds]
marnix has joined #zig
sord937 has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
wallyduchamp has quit [Ping timeout: 260 seconds]
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
ur5us has joined #zig
haliucinas has quit [Remote host closed the connection]
haliucinas has joined #zig
cole-h has quit [Ping timeout: 265 seconds]
Pistahh has quit [Ping timeout: 240 seconds]
xackus has quit [Ping timeout: 265 seconds]
hnOsmium0001 has quit [Quit: Connection closed for inactivity]
tetsuo-cpp has joined #zig
albertito has quit [Ping timeout: 265 seconds]
Enrico204 has joined #zig
albertito has joined #zig
tetsuo-cpp has quit [Ping timeout: 258 seconds]
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
earnestly has joined #zig
ur5us has quit [Ping timeout: 264 seconds]
TheLemonMan has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
<TheLemonMan>
leeward, sorry for the long delay, LLD's error is telling you there's something fishy with how the object file is laid out
<TheLemonMan>
the text section ended up at 0x10000, that's way over the 16bit limit
<TheLemonMan>
so, you need a linker script, I've succesfully compiled your example using TI's msp430elf.x
<TheLemonMan>
don't forget to comment out the `OUTPUT_FORMAT` part, LLD doesn't recognize the elf32-msp430 string
<TheLemonMan>
andrewrk, std.atomic.Int is awesome, it stops you from using non-atomic ops by mistake (and it also serves as a self-documenting type, when you see atomic.Int being used you know to watch out for concurrency issues)
gonzus has joined #zig
<gonzus>
I am trying to understand how the key gets stored in a StringHashMap. Looking at the code, I think the place where a new key,val pair is stored in the hash looks like this: `entry.* = .{ .key = key, .value = undefined }` -- however, if the key is a slice of u8, this is not actually creating a copy of those u8s; is that correct?
<dutchie>
nice. i still don't understand when i should be using the various Ordering types :(
<ifreund>
gonzus: yes that's right, you are responsible for ensuring the slices is valid for the lifetime of the StringHashMap
<ifreund>
there's aslo BufMap which will dupe slices for you but has a more limited API
xackus has joined #zig
<gonzus>
Oh... this is a bit surprising then. I though the whole point of having a specific HashMap type for strings was precisely to ensure the keys being properly copied into the map, and not just referenced.
<gonzus>
Can you point me to an idiomatic example of zig putting data in a StringHashMap?
<ifreund>
the point of StringHashMap is the hash function it uses
<gonzus>
My use case: I have a fixed buffer, which I use to read lines from a file using `readUntilDelimiterOrEof()`, and I want to store data in the map, keyed on a substring of each line. But clearly the keys will be overwritten, if I understood you correctly.
<gonzus>
Got you. This might be an improvement to the docs (or perhaps they already contain that explanation about the hash function).
<ifreund>
yep, so you probably want to call std.mem.Allocator.dupe() on each key and put the result in the hashmap
<gonzus>
Aha, sweet. Will try that.
<ifreund>
(and then free all the keys right before calling deinit() on the map)
<ifreund>
in some cases you wouldn't need to dupe the keys though, e.g. if the keys were all slices into a buffer that outlives the map
<ifreund>
and so if StringHashMap duped the keys for you in that situation it would be sub optimal
<gonzus>
And since I am already on this topic: I found myself wanting to create a key from several other strings / slices (and maybe some other scalar values). What would be the idiomatic way to create a formatted string (a la sprintf) from a bunch of values (on which I would later want to call dupe())?
Pistahh has joined #zig
<gonzus>
Right, understood. Not my use case, but of course something that could happen (for example, if you read the whole contents of the file into a buffer at once).
<dutchie>
gonzus: ArrayList(u8) has a Writer interface so you can format to it
<ifreund>
you could use std.fmt.AllocPrint(), and you wouldn't need to dupe() the result as it allready allocates a new slice
<dutchie>
oh yeah, or AllocPrint
<ifreund>
if you just want to join them, there's std.mem.concat() as well
<dutchie>
TheLemonMan: thanks, i've read quite a few things along those lines. I'm guessing .Monotonic is the same as relaxed?
<gonzus>
You know what, I didn't even know about the existence of ArrayList until now... :-) -- I guess I need to spend some more time trawling through the std lib code.
<dutchie>
or Unordered?
<gonzus>
ifreund does `std.mem.concat()` allocate memory as well? (checking myself now...)
<ifreund>
yes
<ifreund>
it takes an allocator as a parameter which is a pretty solid hint :D
<gonzus>
X-P
nycex has quit [Remote host closed the connection]
nycex has joined #zig
ifreund1 has joined #zig
ifreund has quit [Disconnected by services]
ifreund1 is now known as ifreund
<TheLemonMan>
dutchie, monotonic is memory_order_relaxed
<dutchie>
yeah, i read that too. i think i ended up deciding that .Monotonic was correct for a simple "total number of successes across a bunch of threads"
<dutchie>
i.e. `@atomicRmw(usize, &counter, .Add, 1, .Monotonic)`
<TheLemonMan>
it depends on what you need that counter for
<dutchie>
i spawn a bunch of threads, which do their work, incrementing the counter when they "succeed". then i wait for them all and report the counter at the end of the run
<TheLemonMan>
oh then that should be fine
<dutchie>
could i even use unordered for that?
<TheLemonMan>
that's dangerous for a rmw
<TheLemonMan>
leeward, I've sent a PR to fix the OUTPUT_FORMAT problem, you can track its status here https://reviews.llvm.org/D92931
<gonzus>
ifreund say I want to create something like a list of interned strings. So I want to read the strings from somewhere, allocate a copy of each and then add that to an `ArrayList`. I would love to declare that as `ArrayList([]const u8)` but I am not sure I will be able to later iterate over the list and deallocate all the copies. If that is the case,
<gonzus>
should I declare this as `ArrayList([*]u8)`? And if so, how would I later find the length of each string in the list?
<dutchie>
gonzus: []const u8 will be fine. free does some magic to cast it to non-const
<TheLemonMan>
dutchie, the int.atomic wrappers are also meant to protect the user from specifying invalid orderings (eg. acquire on a store or unordered on a rmw)
<gonzus>
Great, trying that now.
<TheLemonMan>
but that's not yet implemented, I'll bump it up in my todo list
<dutchie>
TheLemonMan: cool!
hexaflex has joined #zig
hlolli has joined #zig
<protheory8-new-m>
How do I pass an async function as argument? I tried just doing `fn() void`, but the compiler gives me an error: `error: expected async function, found 'fn() void'`.
<ikskuh>
you need to explicitly set the callconv(.Async)
<ikskuh>
fn() callconv(.Async) void
knebulae has quit [Read error: Connection reset by peer]
<protheory8-new-m>
thanks
knebulae has joined #zig
[RMS] has joined #zig
<protheory8-new-m>
So now I'm trying to get @asyncCall to work, I'm creating frame buffer, but compiler complains about `error: unable to evaluate constant expression: `var bytes: [1024]u8 align(@alignOf(@Frame(async_fn))) = undefined;`
<protheory8-new-m>
* So now I'm trying to get @asyncCall to work, I'm creating frame buffer, but compiler complains about `error: unable to evaluate constant expression: var bytes: [1024]u8 align(@alignOf(@Frame(async_fn))) = undefined;`
<protheory8-new-m>
and points to `async_fn` with a caret character
<ikskuh>
is async_fn a pointer?
<ikskuh>
or a comptime known value?
<protheory8-new-m>
It's function argument with type of `fn() callconv(.Async) void`, that's a function pointer, right?
<ikskuh>
yeah
<ikskuh>
so you have to make it comptime to be able to query this kind of information
<protheory8-new-m>
how?
<protheory8-new-m>
ah
<protheory8-new-m>
just add comptime?
<protheory8-new-m>
to argument type
<ikskuh>
yeah :)
<protheory8-new-m>
well that didn't work
sord937 has quit [Ping timeout: 240 seconds]
sord937 has joined #zig
<protheory8-new-m>
what do I do now?
<protheory8-new-m>
`std.debug.print("Val: {}\n", .{@alignOf(@Frame(async_fn))});` also doesn't work :(
<TheLemonMan>
protheory8-new-m, you want `comptime <param name>: <type>`
waleee-cl has joined #zig
<ifreund>
and see @frameSize() if you need it to be runtime known
[RMS] has quit [Ping timeout: 260 seconds]
xackus has quit [Ping timeout: 240 seconds]
<protheory8-new-m>
TheLemonMan: After I did that, it seems like just calling `async_fn();` works, without doing `@asyncCall();` at all
<ifreund>
well yeah, it's comptime :D
<protheory8-new-m>
Thanks for help everyone
<protheory8-new-m>
what is @asyncCall used for then
<ifreund>
if the function is runtime known, you need it
wallyduchamp has joined #zig
dumenci has joined #zig
powerofzero has joined #zig
lucid_0x80 has quit [Ping timeout: 256 seconds]
wallyduchamp has quit [Ping timeout: 264 seconds]
<fengb>
asyncCall seems to be really buggy when calling a non pointer
donniewest has joined #zig
marnix has quit [Ping timeout: 272 seconds]
marnix has joined #zig
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
earnestly has quit [Ping timeout: 258 seconds]
earnestly has joined #zig
albertito has quit [Ping timeout: 272 seconds]
marnix has quit [Ping timeout: 256 seconds]
marnix has joined #zig
albertito has joined #zig
<betawaffle>
what happened to the `zig builtin` command?
wallyduchamp has joined #zig
<TheLemonMan>
dead
<TheLemonMan>
zig build-exe --show-builtin, replace build-exe with build-lib or something other subcommand
<TheLemonMan>
leeward, #7366 should fix many problems, getting the whole stdlib 16bit-usize clean is a bigger (and harder) task
cole-h has joined #zig
gonzus has quit [Remote host closed the connection]
cren has joined #zig
hnOsmium0001 has joined #zig
notzmv has joined #zig
xackus has joined #zig
<g-w1>
/join #aerc
<g-w1>
sry about that
marnix has quit [Read error: Connection reset by peer]
marnix has joined #zig
Akuli has joined #zig
wallyduchamp has quit [Ping timeout: 260 seconds]
<leeward>
TheLemonMan: Nifty! I'll try it.
marnix has quit [Ping timeout: 256 seconds]
marnix has joined #zig
wootehfoot has joined #zig
dumenci has quit [Ping timeout: 260 seconds]
marnix has quit [Ping timeout: 272 seconds]
jzelinskie has quit [Ping timeout: 272 seconds]
jzelinskie_ has joined #zig
zippoh has joined #zig
<andrewrk>
TheLemonMan, I see your point about std.atomic.Int
wallyduchamp has joined #zig
<andrewrk>
0.7.1 is looking like quite a tasty release
<andrewrk>
no breaking changes, 60+ bugs fixed
<ifreund>
:)
<ikskuh>
andrewrk: with full release notes? *grin*
<andrewrk>
I still need to catch up for 0.7.0
<ikskuh>
take your time
<ikskuh>
i know you want to finish stage2 earlier than everything else, and i can relate :D
<ifreund>
it will be a glorious day when stage 2 can compile river :D
jjsullivan1 has quit [Remote host closed the connection]
<ikskuh>
oh yeah
<ikskuh>
or showdown
<ikskuh>
or any other projec
<ikskuh>
*project
<ikskuh>
but the most glorious day is when stage2 will be able to compile stage2
<ifreund>
indeed
jjsullivan1 has joined #zig
<andrewrk>
TheLemonMan, do you think largest_atomic_size going from 16 to 8 on modern CPUs could possibly regress perf?
LanceThePants has quit [Read error: Connection reset by peer]
LanceThePants has joined #zig
<TheLemonMan>
andrewrk, none of those intrinsics is actually emitted on x86/x64
<andrewrk>
I see
<andrewrk>
these look like some nice compiler_rt improvements
<andrewrk>
TheLemonMan, mind slapping this in there real quick before I hit merge? https://clbin.com/pIdcU
<TheLemonMan>
sure thing, one sec...
<TheLemonMan>
done!
<TheLemonMan>
we missed the deadline to request some LLVM 11.1.0 backports :(
<andrewrk>
damn
<andrewrk>
we got about a 1-2 month window now to get bug fixes into master branch before the 12 release is cut
<andrewrk>
all aboard the merge train! choo choo!
marnix has joined #zig
FireFox317 has joined #zig
<FireFox317>
andrewrk, im not able to repro #7042 anymore
<andrewrk>
FireFox317, I suspect that was #3825 (lld calling exit())
<andrewrk>
we still need to fix the locking problem though right?
<FireFox317>
lol ofcourse it was, forgot that
<viashimo>
w/in 18
<TheLemonMan>
win 19
<FireFox317>
andrewrk, yes i think so. However it is a usecase that is not that common, running multiple `zig build` instances, however also the use case where you have a `zig build run` running and then modifiying the build script or the sources
<FireFox317>
Im not that pleased that we have to copy the build executable every time
<andrewrk>
hmm yeah let me think about it some more
<andrewrk>
ifreund, good news: I researched crtbegin.so/crtend.so and indeed they come from bad glibc legacy decisions and in zig we don't need them in the linker line
<andrewrk>
s/so/o/
<andrewrk>
since zig also provides the libunwind source we control the entire mechanism
<ifreund>
andrewrk: I assume you saw my messages in #musl? that is good news indeed
<ifreund>
as far as I can tell all were missing is libc.so instead of libc.a
<ifreund>
which is what I'm working on now
<andrewrk>
yeah
<FireFox317>
andrewrk, so currently when i have `zig build run` running (just a sleep loop) in one terminal and then in another terminal `zig build run` again, it blocks on the second command, because of the lock
<andrewrk>
that sounds right. some other interesting tidbits are that musl helpfully puts everything into libc.so so you can just ignore all those other libs
<ifreund>
yeah, so far the more closely I look at musl the more I love about it
<andrewrk>
FireFox317, sorry I have a meeting right now will be back in an hour ish
<ifreund>
If I can get river running on it I'll probably try and switch to a musl based void install
<FireFox317>
The PR (#7041) I submitted fixes that issue, by not locking. But on Windows we have to copy the build exectuable, because we cant change a running executable.
<FireFox317>
andrewrk, Okay no problem! :)
<leeward>
TheLemonMan: It looks like it compiles with your change without errors, though I'm having trouble getting Zig to link the interrupt vector table in for me.
<TheLemonMan>
are you using TI's linker scripts?
<leeward>
No, I'm trying to do the whole thing in Zig.
<leeward>
It works fine if I have zig build-obj and link it myself.
<leeward>
But build-exe and freestanding doesn't bring the C runtime in with it so I'm duplicating it in my Zig code.
<TheLemonMan>
using gnu's ld?
<leeward>
Yeah, using gnu ld works fine.
<leeward>
The thing I'm trying to get working now is zig build-exe
<leeward>
because that would be awesome
<TheLemonMan>
you can use that if you specify a linker script
<leeward>
Oh, I can specify linker scripts for Zig to use! Of course I can.
<TheLemonMan>
I got your program to build and link with lld using one
<TheLemonMan>
comment OUTPUT_FORMAT away and it'll work anyway
wilsonk__ is now known as wilsonk
<pixelherodev>
I think I'm going to stick to CBE for now - Ineed it for other projects, and the official plan is CBE-based compiler, so it's probably better for now
<pixelherodev>
Problem is, I don't know that I'll have the motivation to work on a new compiler once that plan is done :(
<pixelherodev>
ah well, not a big deal
<leeward>
Cool, it linked. Now I just have to get that stupid isr table in.
<TheLemonMan>
@export should do the trick
<leeward>
TheLemonMan: It's saying my vector table won't fit because it overflowed by 32 bytes. That's exactly the same amount I would expect if it were using 32-bit function pointers instead of 16-bit. Coincidence? Maybe.
<TheLemonMan>
is @sizeOf(*T) right?
<leeward>
checking
<TheLemonMan>
that and @sizeOf(fn)
<andrewrk>
FireFox317, back. hmm, and we didn't have this problem before the caching overhaul because we didn't have incremental compilation, so we would put all the input files as part of the cache hash
<FireFox317>
andrewrk, yes that could be the case indeed.
<leeward>
TheLemonMan: @sizeOf (fn () callconv(.C) noreturn) is indeed 2, and the table's size is 64. Now I don't know what's going on.
<TheLemonMan>
A L I E N S
<leeward>
I'm gonna try just dropping half the table and see what it emits.
<TheLemonMan>
oh, what's the @alignOf for a function?
<leeward>
ooh, good question
<leeward>
though I would expect that to affect the table size
<leeward>
Well, it does emit something when I chop the table in half. Gotta figure out what to give objdump to convince it to show it to me.
<TheLemonMan>
it depends on how you're defining the table
<leeward>
-j .vectors
<leeward>
actually, it looks right
<andrewrk>
FireFox317, do you know what all the rules are for what you are allowed to do to running executables in windows? for example, are we allowed to rename the .exe of a running executable? can we then rename something else into the old path?
<leeward>
Huh, maybe the user's guide and my linker script disagree about how big the interrupt vector table is.
<FireFox317>
andrewrk, i have no idea really. I could do some checks. But im not really using windows to code, normally i use linux for that. But i just find hacking on the compiler fun :D
<leeward>
The bottom 16 are all device-specific, so maybe this chip just doesn't use any of them.
<andrewrk>
FireFox317, I just tested it, it works
cren has quit [Quit: cren]
<andrewrk>
so that's a tool in our windows toolbox - we can overwrite a running exe by renaming it and renaming something else into its place
<TheLemonMan>
leeward, don't forget we support the .Interrupt calling convention for msp430
<FireFox317>
andrewrk, oh that works yeah? Thats awesome
<leeward>
TheLemonMan: Yep, I have ISR defined as `fn () callconv(.Interrupt) void`
<andrewrk>
FireFox317, I suspect we could even skip the first step...
<leeward>
It did correctly generate reti instructions in my empty isr.
<TheLemonMan>
cool, 'tis the year of zig on msp430 then
marnix has quit [Ping timeout: 240 seconds]
wootehfoot has quit [Read error: Connection reset by peer]
<leeward>
TheLemonMan: Incidentally, I noticed that .Interrupt generated extra crap when building for AVR. I ended up using .Signal as the calling convention for ISRs there as a workaround. IIRC, it's like that in the LLVM test suite too.
jzelinskie_ is now known as jzelinskie
<TheLemonMan>
what kind of crap?
<leeward>
just a few extra instructions
<TheLemonMan>
probably some kind of prologue
<leeward>
ah, an sei
<leeward>
I took notes! "llvm emits an extra sei instruction"
<leeward>
hmm, no blinky
xackus has quit [Ping timeout: 256 seconds]
<TheLemonMan>
the extra sei is probably there to make it work across different revisions
<leeward>
Oh wow, that's fun. I must have told GCC what processor I was using.
<leeward>
yep, passed -mmcu=atmega328p to it
<TheLemonMan>
is the sei inserted at the very beginning?
<leeward>
I think so.
<TheLemonMan>
if so that may be a way to enable nested irqs
<leeward>
I'll have to compile it to check...
<leeward>
Yep, the first instruction is sei.
<TheLemonMan>
my money is on the nested irq hypotesis
<leeward>
Could be. It's different behavior from avr-gcc, but that doesn't make it wrong.
<leeward>
Anyway, back to msp430-land. objdump shows me the vector table for the C version, and for the elf I link with gcc, but not (unless I force it to with -j) for the pure zig one. Time to see if anything else is different.
<andrewrk>
FireFox317, I think the ideal user experience would be to try to do the standard in-place binary patch of an exe on windows, and if we get the error from changing the running executable, then we resort to the trick of moving the executable to a random temp path, copying it to its original location, flagging the moved exe file with DELETE_ON_CLOSE, and then doing the in-place binary patching on the copy
<andrewrk>
basically, detect the error, and handle it by doing a bunch of syscalls to bend windows to our will
<FireFox317>
i will see if i have time to implement that tomorrow, but if you want to do it for 0.7.1 you can also do it :)
<andrewrk>
well we can start by simply releasing the lock on the build exe right?
<FireFox317>
yeah definitely!
<FireFox317>
I will adjust my PR to only do that
<FireFox317>
and then we can open an issue to track the problem on windows
<andrewrk>
sounds good. I don't think it has to block 0.7.1
<leeward>
Hmm, I should check if I'm actually using the same linker scripts.
<FireFox317>
i dont think either
zippoh has quit [Read error: Connection reset by peer]
<andrewrk>
FireFox317, thanks for talking it through with me :)
<TheLemonMan>
I can't spot anything wrong :\
<FireFox317>
you are welcome :)
<leeward>
Hmm, I'll take a look at the executable and see if there's anything different in the instructions that are emmitted.
<TheLemonMan>
oh wait, .vectors is A in one and AX in the other
<TheLemonMan>
that may explain why you're not seeing the section content in `objdump -d`
<leeward>
ooh
<FireFox317>
andrewrk, #7041 has been updated!
<andrewrk>
thanks
<leeward>
Yeah, that would explain it. I don't think it needs to be X in the ELF; it doesn't store instructions.
donniewest has quit [Quit: WeeChat 3.0]
<leeward>
Hmm, interesting. The compiler is doing things to my inline assembler. I passed it "mov #0, r15" and it generated a "clr r15" which saves 2 bytes of code space
<FireFox317>
leeward, did you put a volatile on it?
<FireFox317>
or just an asm block?
<leeward>
asm volatile
<FireFox317>
oh interesting
<TheLemonMan>
sometimes the assembler is smart enough to pick another encoding
<leeward>
Oh, right, it could have been the assembler. That makes sense.
<leeward>
Interesting. It also took `mov &0x0200,0x0120` and made it into `mov &0x0200,288(r0)` where r0 is the 0-register and 0x120 is 288
<TheLemonMan>
yeah, you can get pretty creative while generating constants
<ikskuh>
andrewrk: how much would you recommend using libsoundio for gamedev? *grin*
<leeward>
Blinking!
<leeward>
I had to `jmp main` instead of `call main` at the end of _start.
powerofzero has quit [Ping timeout: 246 seconds]
<andrewrk>
ikskuh, I think it's a pretty solid library. been meaning to convert it to zig of course :)
<ikskuh>
translate-c it and go? :D
<leeward>
TheLemonMan: I just went from `zig build-exe (many arguments) something.zig` straight to `mspdebug tilib prog something` with no extra steps in the middle, and it worked!
<ikskuh>
i wonder how much work is it to write a game-quality mixer on top of it
<TheLemonMan>
leeward, the next step is wrapping that in a build.zig
<leeward>
TheLemonMan: At the moment, it's in a Makefile, but...you're right.
<andrewrk>
congrats leeward & TheLemonMan :D
<leeward>
\o/
<leeward>
Alright, I'm going to let this blink by itself for a while and get some dinner. laters
<TheLemonMan>
homemade christmas lights, powered by Zig
* andrewrk
queues up Wizards In Winter
powerofzero has joined #zig
<andrewrk>
ikskuh, one of the side-projects I want to make is a game engine designed for rapid prototyping (such as game jams)
<andrewrk>
just some sloppy, dirty 2D fun
<ikskuh>
ah, sounds good :)
<ikskuh>
zig showdown needs some sound
<andrewrk>
I do think libsoundio is a good place to start
<ikskuh>
yeah, i think so, too
<ikskuh>
doing audio in 100% zig is a too hard job for now
<andrewrk>
happy to give out maintainer hats to zig-showdown people
<ikskuh>
:O
<andrewrk>
the hardest thing about libsoundio is when you get a pull request, it's impossible to test it on all the relevant hardware
<TheLemonMan>
yak sharing
<ikskuh>
andrewrk: i can imagine
<andrewrk>
so you get people saying here this patch improves stuff for me *shrug* and then what do you do?
<ikskuh>
question is: does it worsen it for others?
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<ikskuh>
oh and andrewrk: is "all platforms are in scope" still true? *grin*
<andrewrk>
ikskuh, yes - some notable ones are missing but would be welcome additions
<ikskuh>
i'll go with adding some "tracking/reminder" issues
<ikskuh>
i was discussing calling convs with eleanor earlier
karchnu has quit [Ping timeout: 260 seconds]
[RMS] has joined #zig
FireFox317 has quit [Quit: Leaving]
hexaflex has quit [Quit: Going offline, see ya! (www.adiirc.com)]