slugmatt_ has quit [Read error: Connection reset by peer]
dtz has quit [Remote host closed the connection]
dtz has joined #zig
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
slugmatt_ has joined #zig
<diltsman>
Trying to add a compiler-rt function to Zig. I get this error: error: use of undeclared identifier '__aeabi_memcpy4'
<diltsman>
I added the file name to ZIG_STD_FILES.
<diltsman>
And I added the @export to compiler_rt.zig.
<andrewrk>
can you show the file that you're getting the error in?
<diltsman>
The error is on the @export line.
<diltsman>
Seems like it can't find the file that I created.
<andrewrk>
diltsman, "use of undeclared identifier" means that the identifier isn't found in the current scope
<andrewrk>
e.g. it's not in the file that it's being referenced in
<andrewrk>
if you're doing @export(__aeabi_memcpy4) then __aeabi_memcpy4 has to be in scope
<andrewrk>
e.g. in vim put the cursor on __aeabi_memcpy4 and press `*` and it should find it declared
<diltsman>
andrewrk: That means that I don't declare the @export in compiler_rt, right?
<diltsman>
Do I just need to add the file name to the CMakeLists.txt file?
<andrewrk>
diltsman, that's not correct. why not follow the example set by __aeabi_uidivmod?
<diltsman>
andrewrk, __aeabi_uidivmod is in compiler_rt.zig along with the export. Should I just put all of the ARM function in that file? I was trying to follow the same directory layout that compiler-rt has.
<andrewrk>
you can put it in another file if you want
<andrewrk>
then you'll need the CMakeLists.txt change, and you have to @import the file
<diltsman>
@import the file in compiler_rt.zig?
<diltsman>
Nevermind, I see it.
<diltsman>
Now that that is fixed...I have my aeabi_memcpy.zig file. When I build Zig it reformats the file and replaces all of the line endings with CRLF.
<andrewrk>
when you say "it reformats the file", what software are you referring to?
<diltsman>
I build the VS solution that CMake generated using "msbuild -p:Configuration=Release INSTALL.vcxproj"
<diltsman>
During the build the file gets reformatted.
<andrewrk>
are you sure it's not your text editor?
<andrewrk>
I've never experienced that happening when using msbuild -p:Configuration=Release INSTALL.vcxproj
<andrewrk>
maybe you are accidentally editing the installed copy rather than the source copy?
<diltsman>
I'm using VS Code. I save the file, run the build, and then the file is reformatted in the editor.
<diltsman>
Let me look at that.
<diltsman>
You're right. I am looking at the installed copy.
<diltsman>
So many things to trip you up. Finally hitting the compile error that I was expecting. Thanks!
<andrewrk>
no problem. thanks for working on compiler_rt
<diltsman>
At the very least I am going to get __aeabi_memcpy* and __aeabi_memset* done.
<diltsman>
Doesn't that mean that memcpy is public?
<andrewrk>
export and pub are different concepts - you can add a `pub` to that
<diltsman>
How do I have my function call the memcpy that is in builtin.zig?
<andrewrk>
diltsman, @memcpy
<diltsman>
Ah.
<daurnimator>
andrewrk: so how does that end up working? I recall that llvm can sometimes end up optimizing the implementation in there to a call to __aeabi_memcpy
<andrewrk>
daurnimator, yeah if it's the body of __aeabi_memcpy then it can't do that. it should probably just be 1 line of inline assembly that jumps to memcpy
<andrewrk>
I haven't looked at llvm's implementation yet
<daurnimator>
andrewrk: but memcpy ends up being a jump to __aeabi_memcpy...
<daurnimator>
there has to be some sort of annotation to tell llvm "this *is* the memcpy implementation; don't optimise me into a memcpy call"
<andrewrk>
if you name the function `memcpy` then it knows that
<andrewrk>
and export it
<daurnimator>
okay. I thought we might have been relying on e.g. `asm volatile` to avoid such things.
WilhelmVonWeiner has quit [Ping timeout: 246 seconds]
<andrewrk>
mikdusan, if you can show that the optimized code in release fast mode would benefit further from computed goto, I'll open an issue to add a feature to zig detecting this pattern and ensuring the optimization occurs
<andrewrk>
hi Sahnvour, just read your patch. looks great
<Sahnvour>
I shamelessly did not spend much time on this, so maybe that makes no difference for zig, just wanted to let you know
<andrewrk>
that's interesting, I wouldn't have expected the system v ABI to change so rapidly
<andrewrk>
thanks for letting me know
<andrewrk>
I'm about to give a 10 min talk on zig, should be fun. not sure if it's going to be recorded or not, but I'll turn the content into a blog post regardless
<Sahnvour>
yay for blog posts
Ichorio has quit [Ping timeout: 268 seconds]
Sahnvour has quit [Read error: Connection reset by peer]
fsateler has joined #zig
fsateler_ has quit [Ping timeout: 255 seconds]
fsateler has quit [Read error: Connection reset by peer]