Skip to content
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

improvement: Limit amount of compiled code, restrict glue layer only referenced files. #3849

Conversation

WojciechMazur
Copy link
Contributor

By using @define annotation we can limit amount of glue layer that needs to be compiled - we add an entry for potentially optional bindings and guard the glue-layer with #if defined(x) preprocesor conditions. This should allow to lower number of compilation errors in non-posix compliant systems, especially on 32-bit architectures.

The need of controlling the amount of C glue layer files on non-compatible runtimes was already needed in the WASM/WASI prototype https://github.com/WojciechMazur/scala-native/tree/scala-wasm and when targeting Playdate devices (arm v7, limited C/POSIX stdlib) kubukoz#1

Based on these changes we're removing usages of stdatomic in minimal single-threaded execution

@ekrich
Copy link
Member

ekrich commented Mar 24, 2024

One idea I had was perhaps we could have different plugin versions or allow the plugin to remove the posixlib dependency for example on certain platforms.

Copy link
Member

@ekrich ekrich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just this one spelling issue.

clib/src/main/resources/scala-native/complex.c Outdated Show resolved Hide resolved
clib/src/main/scala/scala/scalanative/libc/complex.scala Outdated Show resolved Hide resolved
@WojciechMazur
Copy link
Contributor Author

One idea I had was perhaps we could have different plugin versions or allow the plugin to remove the posixlib dependency for example on certain platforms.

I think it might quite a complex feature to make it correct. Also some of posixlib definitions might be used on Windows, because some of them might be compatible, eg. sockets. In general control of what to be compiled shall be more stable then removing possibly unused ones.

@WojciechMazur WojciechMazur force-pushed the improve/compile-only-used-sources branch from 9d928f4 to 4bc522b Compare March 24, 2024 13:52
@WojciechMazur WojciechMazur merged commit efabf74 into scala-native:main Mar 24, 2024
61 checks passed
@WojciechMazur WojciechMazur deleted the improve/compile-only-used-sources branch March 24, 2024 20:49
@kubukoz
Copy link
Contributor

kubukoz commented Apr 17, 2024

OMG how did I miss this before? This is amazing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants