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

native, markused: implement -skip-unused #18036

Merged
merged 2 commits into from
Apr 24, 2023

Conversation

Spydr06
Copy link
Member

@Spydr06 Spydr06 commented Apr 23, 2023

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 the vlib/v/gen/native/gen.v file to implement the flag, the vlib/v/gen/native/tests/native_test.v file to enable the flag for testing, and the vlib/v/markused/markused.v file to mark only the main.main function as required for the native backend.

🤖 Generated by Copilot at fcf710a

  • Implement the -skip-unused flag for the native backend, which reduces the executable size by omitting unused functions (link, link, link)
    • Add a new method is_used_by_main to the Gen struct, which checks if a function declaration node is used by the main function (link)
    • Modify the gen_fn_decl method of the Gen struct, which generates the code for a function declaration, to skip the generation of unused or bodyless functions and print a verbose message (link)
    • Modify the mark_used function in the markused.v file, which marks the functions that are used by the main function or are required by the backend, to only mark the main.main function as required for the native backend (link)
  • Modify the test_native function in the native_test.v file, which runs the tests for the native backend, to add the -skip-unused flag to the compilation command (link)

@Spydr06
Copy link
Member Author

Spydr06 commented Apr 23, 2023

On a side note, I must say this new copilot feature seems very helpful

Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

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

Good work.

@Spydr06
Copy link
Member Author

Spydr06 commented Apr 23, 2023

When enabling the builtin module (see #17782), it still tries to compile some unused builtin functions, which obviously fail:
image

@Spydr06
Copy link
Member Author

Spydr06 commented Apr 23, 2023

You can merge it, I'll fix that issue another time.

@medvednikov medvednikov merged commit 7ac7020 into vlang:master Apr 24, 2023
l1mey112 pushed a commit to l1mey112/v that referenced this pull request Jun 7, 2023
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.

3 participants