<r4pr0n>
when compiled with zig, gdb highlights the for loop, when compiled with clang - either fsanitize-trap or not - it highlights the statement with the shift
<Kingsquee>
I'm trying to get the hang of making automatic SoA containers in zig, but the reference code I've found doesn't seem to compile anymore https://zig.godbolt.org/z/49iRj-
<Kingsquee>
also for the record this looks way too big-braned for what it does
<Kingsquee>
is there any way to just vararg the fields similar to rust macros?
<fengb>
We used to have varargs and it was very buggy
<nycex>
but i can't build zig, because even though i use -DCMAKE_PREFIX_PATH, it still wants to use my system llvm 9
<nycex>
so i get CMake Error at cmake/Findllvm.cmake:33 (message):
<nycex>
expected LLVM 10.x but found 9.0.1
<nycex>
how can i fix that?
<andrewrk>
maybe it's picking up llvm-config from your PATH
<nycex>
oh
<nycex>
i had to add $HOME/local/bin/ to the PATH
marijnfs_ has joined #zig
marijnfs1 has quit [Ping timeout: 265 seconds]
r4pr0n has quit [Quit: r4pr0n]
daex has quit [Ping timeout: 250 seconds]
daex has joined #zig
nephele_ has joined #zig
nephele has quit [Ping timeout: 260 seconds]
frmdstryr has quit [Quit: Konversation terminated!]
_Vi has quit [Ping timeout: 265 seconds]
ur5us has quit [Ping timeout: 260 seconds]
ur5us has joined #zig
marmotini_ has joined #zig
marmotini_ has quit [Ping timeout: 256 seconds]
ur5us has quit [Ping timeout: 260 seconds]
mahmudov has quit [Remote host closed the connection]
<pixelherodev>
One of the things I've taken to doing when implementing libraries is asserting that received values are valid (e.g. for my dynarec, that you're not trying to load a 64-bit value in a 32-bit register); this prevents a program from misusing the library and results in higher performance in release modes
darithorn has joined #zig
waleee-cl has quit [Quit: Connection closed for inactivity]
<daurnimator>
andrewrk: I saw you've vendored zig into the bootstrap repository: it would be cleaner to do so with a git subtree. happy to help
<daurnimator>
Anyone around particular familiar with LLVM? I'm curious to see if I can try and get https://github.com/luizperes/llvm-to-snes to work with zig: will probably need to update it to LLVM 10... then somehow hook up a new arch to zig?
nephele_ is now known as nephele
<pixelherodev>
daurnimator, you mean IR?
<pixelherodev>
I'd like to think I'm familiar with that by now :D
<pixelherodev>
If you figure out how to hook up an arch to Zig, let me know
<daurnimator>
pixelherodev: more about how a new target is added; hooking it up correctly; perhaps familiarity with how the interfaces have evolved from, say, LLVM7 to LLVM10
daex has quit [Ping timeout: 265 seconds]
daex has joined #zig
dddddd has quit [Ping timeout: 256 seconds]
<pixelherodev>
Ah, then I can't help
<pixelherodev>
I know the IR, but I'm using that knowledge to build a competitor to the official interfaces; I never bothered learning those
<pixelherodev>
(yet)
<pixelherodev>
LLVM doesn't seem to like optimizing dynarecs
<pixelherodev>
Takes much, *much* longer than optimizing projects that were far larger :(
<pixelherodev>
By which I mean it seems to hang indefinitely :(
<pixelherodev>
I'm switching on a type in a generic function, is there a way for `*u32 =>` to also match`*u32 align(4096)`?
<pixelherodev>
Or do I need to check @typeInfo and switch to if/else chains?
darithorn has quit [Quit: Leaving]
daex has quit [Ping timeout: 264 seconds]
<pixelherodev>
Maybe I'll just discard alignment info and do a cast before unmapping it
<mikdusan>
do you always have a pointer for the switch?
<pixelherodev>
No
<pixelherodev>
It can be a Register (enum type), a u32, a *u32, a u64, etc
<pixelherodev>
It's a generic Move instruction
<pixelherodev>
For x64
<pixelherodev>
There's a *lot* of permutations
<mikdusan>
I think you'll have to switch on typeinfo
<pixelherodev>
I just went with the "discard alignment" path
<pixelherodev>
I'm assuming it's harmless to not know the alignment
daex has joined #zig
<mikdusan>
how will you unmap without mem.page_size alignment?
<Kingsqueee>
so, it seems I can get the 'child' type of a pointer by doing std.meta.Chlid(somepointertype)
<Kingsqueee>
i.e. []u8 -> u8
<Kingsqueee>
is there a way to go the other way around?
<Kingsqueee>
e.g. pass in a u8 and get out a []u8 etc
<daurnimator>
Kingsqueee: just put [] in front of it
<daurnimator>
Kingsqueee: `const T = u8; const PT = []T;`
<daurnimator>
or whatever pointer type/attributes you want
<Kingsqueee>
...
<Kingsqueee>
yes okay
FireFox317 has joined #zig
mattmurr has joined #zig
mattmurr has quit [Quit: ZNC 1.7.2+deb3 - https://znc.in]
mattmurr has joined #zig
mattmurr has quit [Quit: ZNC 1.7.2+deb3 - https://znc.in]
mattmurr has joined #zig
mattmurr has quit [Quit: ZNC 1.7.2+deb3 - https://znc.in]
ur5us has joined #zig
josch557 has joined #zig
frett27 has joined #zig
frett27_ has joined #zig
<Snektron>
daurnimator: i had the same issue
<Snektron>
git reset --hard HEAD worked for me
frett27 has quit [Ping timeout: 256 seconds]
josch557 has quit [Ping timeout: 260 seconds]
Kingsqueee has quit [Quit: Konversation terminated!]
josch557 has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
ur5us has joined #zig
junon has quit [Quit: Leaving...]
ifreund has joined #zig
dddddd has joined #zig
ur5us has quit [Ping timeout: 260 seconds]
ifreund has quit [Quit: WeeChat 2.8]
marijnfs has quit [Ping timeout: 264 seconds]
marijnfs has joined #zig
mahmudov has joined #zig
basedtho has joined #zig
ifreund has joined #zig
marijnfs has quit [Quit: leaving]
FireFox317 has quit [Ping timeout: 250 seconds]
frett27_ has quit [Read error: Connection reset by peer]
mahmudov has quit [Remote host closed the connection]
<daurnimator>
andrewrk: hmmm. seems I don't have permission to edit other people's comments any more (to fix formatting etc.)? I know you redid the github permission sets a while ago....
mahmudov has joined #zig
waleee-cl has joined #zig
KoljaKube has joined #zig
josch557 has quit [Ping timeout: 260 seconds]
<KoljaKube>
Does the compiler only check code that is actually called?
<afontain_>
I think it does, except for parse error
<KoljaKube>
I guess that's one way to encourage test{}ing ;-)
<waleee-cl>
KoljaKube: pretty common compiler behaviour
<KoljaKube>
Been spending most of my time with javac and kotlinc, and I don't think those behave that way
<fengb>
Zig takes laziness to a whole new level
daex has quit [Ping timeout: 260 seconds]
daex has joined #zig
<KoljaKube>
I guess that's also the reason for having an unnamed test block @importing files into _?
<fengb>
Yep, `_ =` is a quick way of forcing a lazy reference into existence
<KoljaKube>
Got it, thanks
daex has quit [Ping timeout: 240 seconds]
daex has joined #zig
<ifreund>
one thing that kinda bugs me about zig tests is that I couldn't figureout a way to move them out of my src folder
afon has joined #zig
<ifreund>
anyone have an example doing that for a non-library project?
<fengb>
Add my main code as a separate package called “self” (because naming is hard)
<ifreund>
fengb: ah, I think that may have been the line I was missing
<fengb>
The std tends to stick test files as a sibling as the main file
<ifreund>
i was trying to import my main code as a package, but it said that everything was private
<KoljaKube>
waleee-cl: Sure that was the correct link? That only talks about linting unused vars
<KoljaKube>
And I just checked, my uncalled method returning the wrong type was found by the compiler
<waleee-cl>
KoljaKube: just did a quick test and yes, the type checking needs more coercing to ignore the unused methods
<KoljaKube>
Does zig support building libraries? If yes, what is emitted for broken code?
<fengb>
Zig prefers source based libraries
<fengb>
Only way to share binaries is with a C compatible library
<fengb>
And those are exposed with export, which also forces the unit to be built
<KoljaKube>
Ah, OK, thanks :-)
<ifreund>
fengb: looks like I have to make everything I want to use in my tests pub in my src/main.zig to use a separate folder, I think I'll just leave them scattered around my src dir since that seems cleaner
<KoljaKube>
Is there a way to force runtime evaluation of something?
<afontain_>
I'd be interrested in that ^, it totally makes sense in a `zig test …` or a debug build, if you ask me
<KoljaKube>
I currently have a problem with a global variable from a C library, whose value changes depending on where in my code I access it. I _think_ that it might be due to some compile time stuff, or at least I'm at a loss what else it might be
TheLemonMan has joined #zig
<KoljaKube>
Printing the line in my main() changes the behavior of the code executed _before_ that print O_o
<KoljaKube>
s/line/variable/
Cloudef has quit [Ping timeout: 245 seconds]
Cloudef has joined #zig
dddddd has quit [Ping timeout: 250 seconds]
cole-h has joined #zig
josch557 has joined #zig
FireFox317 has joined #zig
jessermeyer has joined #zig
darithorn has joined #zig
afon has left #zig [#zig]
josch557 has quit [Remote host closed the connection]
josch557 has joined #zig
jessermeyer has quit [Remote host closed the connection]
FireFox317 has quit [Ping timeout: 256 seconds]
<KoljaKube>
Phew, finally managed to build a minimal example for my problem
<KoljaKube>
By the way, the last issue I filed was answered within minutes on a sunday evening (CET) by andrewrk, which was really awesome :-)
FireFox317 has joined #zig
FireFox317 has quit [Client Quit]
FireFox317 has joined #zig
<FireFox317>
KoljaKube, could you try to run valgrind on the code, maybe it gives some clues
<KoljaKube>
FireFox317: Never used it before, and I need to make some food for the family now, but I've been looking for a while to find an excuse to get into it ;-)
FireFox317 has quit [Ping timeout: 265 seconds]
<TheLemonMan>
got most of the stdlib working on sparc64 o/
<fengb>
:o
<TheLemonMan>
the register windows are a novelty I had never found in any other ISA
<mikdusan>
what you never worked with Itanium ? :P
KoljaKube has quit [Ping timeout: 272 seconds]
return0e has joined #zig
<TheLemonMan>
thankfully not, but I've heard stories about it
<fengb>
I'm curious... could Itanium actually be a better arch?
<shakesoda>
fengb: my understanding is that itanium actually was pretty good as an arch
<shakesoda>
i don't know if this is accurate
<TheLemonMan>
afair it was a nightmare for compiler developers
<fengb>
I briefly studied it in college. But a lot of its complexity seemed to do with trying to SIMD everything
<fengb>
And lack of out-of-place execution
<TheLemonMan>
you had to be really really really smart to squeeze all its raw power
_Vi has joined #zig
KoljaKube has joined #zig
<shakesoda>
so... it was difficult in all the same ways it's currently difficult to get anywhere near the max throughput of architectures like x86_64?
<TheLemonMan>
I guess so, but only if you consider all the newfangled vector extensions
<Thalheim>
TheLemonMan: I am around all day so please ping if want to test on real hardware
<shakesoda>
TheLemonMan: i'm certainly considering those, they are relevant if you want to squeeze all the raw power out
<shakesoda>
that said, most of the real bottlenecks I see in the wild are things like not designing for cache locality
return0e has quit [Read error: Connection reset by peer]
return0e has joined #zig
KoljaKube has quit [Ping timeout: 265 seconds]
<shakesoda>
I've been working on optimizing for work (almost time to ship...) and there are high load areas with ~93% cache miss rates :|
<shakesoda>
glacially slow
<shakesoda>
the individually slow areas stopped being apparent recently so I had to bust out vtune to see what was going on, and it is as I feared
josch557 has quit [Ping timeout: 260 seconds]
diltsman has joined #zig
<TheLemonMan>
andrewrk, what's my disk quota on the aarch64 server?
<diltsman>
Does anyone know of an example of how to use ArrayList with OutStream?
<TheLemonMan>
Thalheim, I'm still trying to get everything to work correctly, we'll probably need a LLVM patch (and wait 'till LLVM 11)
<andrewrk>
TheLemonMan, the machine has 245G used, 173G available. As far as I'm concerned you can have as much as you want. Do I need to adjust some kind of setting?
<TheLemonMan>
nope, just wanted to ask if there were any limits
<TheLemonMan>
I'll use that to hack on LLVM :) that's much faster than my laptop
<andrewrk>
the only thing to keep in mind is this machine is provided to us by WorksOnARM and they could decide to revoke it at any time
<andrewrk>
if that happens I'd be happy to use zig funds to pay for a machine that is always up that you can have access to
<Thalheim>
WoA won't revoke it without good cause, rest assured
diltsman has quit [Remote host closed the connection]
KoljaKube has joined #zig
<TheLemonMan>
ok I have no idea how to use this NixOs thing, how do I get a gcc+binutils toolchain installed?
<pmwhite>
I don't have context for your question, but I use NixOS.
<pmwhite>
You can do "nix-env -iA nixos.gcc"
KoljaKube has quit [Ping timeout: 265 seconds]
<TheLemonMan>
got it to work, I had to `niv-env -p gcc` or something like that
<TheLemonMan>
gimme Debian or gimme death, I can't stand all those newfangled tools
<pmwhite>
Yeah, there are some confusing parts of nixos that must be waded through before you can begin to enjoy it. Arguable not worth it, but depends on the person o think.
traviss has joined #zig
josch557 has joined #zig
springworm has joined #zig
<traviss>
diltsman here's a really simple example of using an ArrayList's outStream to write a value to it: https://clbin.com/IikYd
<shakesoda>
the amount of @intToEnum I need to put everywhere with vulkan is really annoying :(
<shakesoda>
i feel like it'd be a lot easier if there were just a way to represent enum values that have c's integer duality that translate-c could use on these things
<andrewrk>
the enum equivalent of [*c]
<andrewrk>
I was also thinking that @intToEnum could possibly have its type parameter removed, and would infer from the result location
<shakesoda>
if you only had to @intToEnum only when you have to do away with the duality (e.g. for switching) there'd be a *lot* less noise dealing with c apis
<shakesoda>
inferring would help a lot too
<andrewrk>
we could also choose to translate c enums as integers rather than enums
<andrewrk>
this would go for most "casting" builtins: @ptrToInt, @bitCast, @intCast, etc
<andrewrk>
if you wanted to provide an explicit type you would wrap it with @as (or use an intermediate const variable with a type)
<shakesoda>
i feel like it's generally a win to have them as enums too
<shakesoda>
a lot of my compile errors are related to the way they're translated as both i guess, I'll do e.g. c.VK_WHATEVER where .VK_WHATEVER would infer the enum type
<shakesoda>
toOwnedSlice in getRequiredExtensions -> broken llvm module
<shakesoda>
looks like this might be #4907
<shakesoda>
rearranged it to work around
josch557 has quit [Remote host closed the connection]
josch557 has joined #zig
<josch557>
I'm seeing that std.math.big.Rational has private fns gcd and gcdLehmer, would it make sense to put that into big.Int and make it public?
ifreund has quit [Ping timeout: 256 seconds]
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
ifreund has joined #zig
springworm has quit [Ping timeout: 260 seconds]
<andrewrk>
quite possibly. tiehuis probably can answer that better than I can
<josch557>
Ok, I'll create a Proposal issue for that.
frett27 has joined #zig
rjtobin has joined #zig
springworm has joined #zig
<shakesoda>
how on earth do you open a dir that isn't relative to cwd
<andrewrk>
it can be relative to any other open dir
<shakesoda>
i want to open a dir with an absolute path and have absolutely no clue how to get one
<shakesoda>
everything i can find just does opendir from cwd
<shakesoda>
(and further in from there)
<andrewrk>
shakesoda, `std.fs.openDirAbsolute` hasn't been added yet (planned) but it's safe to pass an absolute path to fs.Dir.openDir
<springworm>
is there a motivation for comptime's branch quota other than reducing compilation time?
<andrewrk>
no
<andrewrk>
you can set the quota to whatever you want. it's just to prevent accidentally putting an infinite loop (or really slow logic)
<springworm>
cool. i'm curious how it counts branches -- is there branch counting code inserted before every branch instruction?
<springworm>
i guess i could read the ir but ..
<josch557>
Does it show up in the IR? I mean the code is executed at compile time, before code generation, right?
<andrewrk>
yeah the bookkeeping is all part of semantic analysis
<springworm>
oh i guess i've misunderstood comptime. is the compiler interpreting the code and not actually producing machine code?
rjtobin has quit [Ping timeout: 265 seconds]
<andrewrk>
correct. it emulates the target
<andrewrk>
consider that it works even for cross-compiling
<springworm>
that's radical. color me impressed
dddddd has joined #zig
<andrewrk>
furthermore, the compiler even has access to the target CPU model (if specified) and target CPU feature flags. so to be compliant with the zig language specification, a correct compiler will even emulate at compile-time, for example, the floating point bugs that a particular cpu model has, if that cpu model is the target
<andrewrk>
in practice what this means is that you can rely on e.g. hash() at compile-time and hash() at runtime producing the same result.
<andrewrk>
(barring bugs in the compiler itself)
wootehfoot has joined #zig
wootehfoot has quit [Ping timeout: 260 seconds]
springworm has quit [Remote host closed the connection]
squeek502 has quit [Quit: Leaving]
frett27_ has joined #zig
frett27 has quit [Ping timeout: 256 seconds]
josch557 has quit [Quit: ERC (IRC client for Emacs 26.3)]
poga has joined #zig
ifreund has quit [Ping timeout: 240 seconds]
frett27_ has quit [Ping timeout: 256 seconds]
squeek502 has joined #zig
squeek502 has quit [Read error: Connection reset by peer]