New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework many POSIX and C lib with new trait feature #2996
Conversation
@LeeTibbert I can address the issues above. If you have a minute to look and see what might be wrong with the Windows builds, I would be appreciative. |
Re: Windows builds. On the case. 5 Minutes later: All the Windows builds are currently in process. I'll check back in 1/2 hour or so 10 Minutes later. CI is still progressing. A few Windows builds have completed.
It looks like the definition is using a Ptr[Byte] and the (LLVM intrinsic?) is expecting a 64 bit value Lets see what other Windows, macOS, multi-arch, and Linux say. Did something obvious change with the declaration of memset? I'll rat around. 2022-11-14 19:56 UTC -- There is a Linux failure with SN 2.11 with the same memset message as two of the Windows The Windows 2019 failed by just rolling over on its back and wiggling its Later the evening, after this CI, dust settles, I will have to clone this PR and So far, I see nothing obviously wrong. The SN 2.11 build throws some errors |
@LeeTibbert It seems to only happen on Windows - I changed Maybe @WojciechMazur needs to take a look. It could have gotten more strict so maybe a call site is bad - could only This is the only site that seems Windows specific - https://github.com/scala-native/scala-native/blob/main/javalib/src/main/scala/java/io/File.scala#L681 |
It happens on Linux SN 2.11 (sometimes). I just double checked the logs above. I may have a clue.
The stackalloc is using a windows.DWord (as you mentioned). Has that line I did not see a Dfoo which would chameleon 32/64 bit the way that CSize will. As a debugging shot in the dark, you could hard code that If I am onto something, Scala 2.11 may be doing us a favor here by complaining, |
The errors are probably caused by wrong type signature by using boxed type (CSize) instead of primtive int/long. I'll try to fix this issue in the compiler plugin soon |
Depending on the order of loading defns one of the memset declarations would survive:
The first one is correct one as it takes unboxed values. Second one takes boxed values. For Ptr[_] it does not make any difference because at codegen both class reference and primitive ptr are represented as |
Definitions in clib string: def memset(dest: Ptr[Byte], ch: CInt, count: CSize): Ptr[Byte] = extern In runtime libc like this. def memset(dest: RawPtr, ch: CInt, count: CSize): RawPtr = extern |
Just trying to do little heavy lifting to get towards a POSIX lib that can be used on its own.
There are definitely cases where it is unclear where things should go especially for types. In C we can have header files defined once so they can be referenced more than one place and they won't conflict. In Scala we could have them as
type
s in more than one place and they could conflict onimport
. This is an area we need to work out best practices.This still doesn't solve the "I have to look at 2 specs at the same time" problem but at least we know it can be defined once either in C shared with POSIX or POSIX only.
In general in the
javalib
with could seelibc
imports because lib C can do some things but it may be more likely that we seeposix
orwindows
as the main imports for native code.For a developer, they should be able to just import
libc
orposix
depending on what they need. We still have quite a bit of work in this area but it is getting better.