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

unify ssize_t definition #11384

Merged
merged 1 commit into from
May 25, 2022
Merged

Conversation

mkatanbaf
Copy link
Contributor

@mkatanbaf mkatanbaf commented May 20, 2022

This PR removes the type tvm_ssize_t introduced in (PR11232) , and unifies the definition of ssize_t.
Initially, there was an issue with the Windows build in (PR10967) , since the ssize_t was not properly defined in rpc_channel_logger.h
our initial solution was to define the ssize_t in that specific file. but we got a redefinition error, since ssize_t was also defined in socket.h. We also tried to include socket.h in rpc_channel_logger.h but we got some errors on hexagon build. (PR11223)
Next attempt, we added another type, tvm_ssize_t, in c_runtime_api.h to resolve the redefinition issue (PR11232) and the plan was to propagate tvm_ssize_t to most of other ssize_t mentions to minimize confusion. The PR got merged, however, there are two issues with this solution. First, the c_runtime_api.h doesn't seem to be the appropriate place for the definition and required header files (here), and ssize_t is widely used in the codebase, so propagating the tvm_ssize_t requires changes all over the codebase.
This brings us to this current solution. It is basically back to our initial solution of defining ssize_t where it is needed (rpc_channel_logger.h ), and resolving the redefinition error by placing the definition in ssize.h file, and including it in both places. I believe this solution makes more sense because it doesn't add an unnecessary and potentially confusing type tvm_ssize_t and keeps the ssize_t definitions consistent.
@areusch, @mehrdadh, @manupa-arm

@leandron
Copy link
Contributor

Hi, I understand this is a draft PR, but it would be good to have a description with the motivation and context for this change to be submitted.

@junrushao
Copy link
Member

Hey thanks for this PR! Is the intention to remove tvm_ssize_t and replace with ssize_t instead?

@manupak
Copy link
Contributor

manupak commented May 20, 2022

Thanks @mkatanbaf !

I think this is because of #11232 (comment)

and this solution looks good (that it moves the introduction of the type to rpc related sources) but I agree it is better to mention this in the PR description
-- maybe its still better to keep tvm_ssize_t over overloading ssize_t

@junrushao
Copy link
Member

Thanks @manupa-arm for the context! It makes sense to me now :-) Yeah I agree with you that it would be better to keep tvm_ssize_t instead.

@mkatanbaf mkatanbaf changed the title fix ssize_t redifinition unify ssize_t difinition May 21, 2022
@mkatanbaf
Copy link
Contributor Author

Thanks @manupa-arm for the comment. As I explained in the PR description, I believe introducing tvm_ssize_t was not the right approach. I placed the ssize_t definition in a header file under src/support, and hopefully, that would address the redefinition concerns.

@mkatanbaf mkatanbaf marked this pull request as ready for review May 23, 2022 16:42
Copy link
Contributor

@manupak manupak left a comment

Choose a reason for hiding this comment

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

LGTM! I did not have a strong preference either way but have observed platform-specific redefinition of ssize_t too.

I ll let others have a look as well.

Copy link
Contributor

@areusch areusch left a comment

Choose a reason for hiding this comment

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

thanks for the fix @mkatanbaf !

@areusch
Copy link
Contributor

areusch commented May 23, 2022

regarding overloading ssize_t vs adding tvm_ssize_t, my main preference here is around when we do this in a public-facing header file (in that case I pushed for tvm_ssize_t to avoid stepping on system types outside tvm's purview. for an internal header in src/ i don't have a strong reason to care right now. if others do, i'm happy to go with their preference, though prefer such decisions to be rooted in more than just personal preference. this PR reverts to what we were using before, so i'm good with merging it and re-addressing later on if it becomes an issue.

@manupak
Copy link
Contributor

manupak commented May 24, 2022

I agree with @areusch that this is an internal header (will not bleed elsewhere) and should be the reasoning to support the change.

@manupak
Copy link
Contributor

manupak commented May 24, 2022

@mkatanbaf I ve noted the commit title is too long and commit body is empty. Whilst, we are still in the process of establishing commit message guidelines, I think it would be better to include a commit title and a body.

Would you be able to propose these before we merge / or push a commit that has these ?

@mkatanbaf mkatanbaf force-pushed the fix_ssize_t_redefinition branch 2 times, most recently from 8d04293 to acff804 Compare May 24, 2022 16:54
@mkatanbaf mkatanbaf changed the title unify ssize_t difinition unify ssize_t definition May 24, 2022
@mkatanbaf
Copy link
Contributor Author

Thanks @manupa-arm , I updated the commit title and body.

remove tvm_ssize_t type and unify the definition of ssize_t in Windows build
@manupak manupak merged commit 7e83c4a into apache:main May 25, 2022
@manupak
Copy link
Contributor

manupak commented May 25, 2022

Thanks @mkatanbaf @areusch @junrushao1994 ! This is merged now!

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.

5 participants