native, markused: implement -skip-unused#18036
Merged
medvednikov merged 2 commits intovlang:masterfrom Apr 24, 2023
Merged
Conversation
Contributor
Author
|
On a side note, I must say this new copilot feature seems very helpful |
9 tasks
Contributor
Author
|
When enabling the builtin module (see #17782), it still tries to compile some unused builtin functions, which obviously fail: |
Contributor
Author
|
You can merge it, I'll fix that issue another time. |
l1mey112
pushed a commit
to l1mey112/v
that referenced
this pull request
Jun 7, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

As @spytheman demonstrated in the
#native-backenddiscord channel.This is another PR to get #17782 eventually working.
🤖 Generated by Copilot at fcf710a
This pull request adds the
-skip-unusedflag for the native backend, which allows skipping the generation of unused functions and improves the compilation speed and binary size. It modifies thevlib/v/gen/native/gen.vfile to implement the flag, thevlib/v/gen/native/tests/native_test.vfile to enable the flag for testing, and thevlib/v/markused/markused.vfile to mark only themain.mainfunction as required for the native backend.🤖 Generated by Copilot at fcf710a
-skip-unusedflag for the native backend, which reduces the executable size by omitting unused functions (link, link, link)is_used_by_mainto theGenstruct, which checks if a function declaration node is used by the main function (link)gen_fn_declmethod of theGenstruct, which generates the code for a function declaration, to skip the generation of unused or bodyless functions and print a verbose message (link)mark_usedfunction in themarkused.vfile, which marks the functions that are used by the main function or are required by the backend, to only mark themain.mainfunction as required for the native backend (link)test_nativefunction in thenative_test.vfile, which runs the tests for the native backend, to add the-skip-unusedflag to the compilation command (link)