native, markused: implement -skip-unused
#18036
Merged
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-backend
discord channel.This is another PR to get #17782 eventually working.
🤖 Generated by Copilot at fcf710a
This pull request adds the
-skip-unused
flag 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.v
file to implement the flag, thevlib/v/gen/native/tests/native_test.v
file to enable the flag for testing, and thevlib/v/markused/markused.v
file to mark only themain.main
function as required for the native backend.🤖 Generated by Copilot at fcf710a
-skip-unused
flag for the native backend, which reduces the executable size by omitting unused functions (link, link, link)is_used_by_main
to theGen
struct, which checks if a function declaration node is used by the main function (link)gen_fn_decl
method of theGen
struct, which generates the code for a function declaration, to skip the generation of unused or bodyless functions and print a verbose message (link)mark_used
function in themarkused.v
file, which marks the functions that are used by the main function or are required by the backend, to only mark themain.main
function as required for the native backend (link)test_native
function in thenative_test.v
file, which runs the tests for the native backend, to add the-skip-unused
flag to the compilation command (link)