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

Add a writeup of current optional imports design #47

Merged
merged 3 commits into from
Sep 4, 2019
Merged

Conversation

sbc100
Copy link
Member

@sbc100 sbc100 commented May 30, 2019

Document how weak imports are specified and the contents of the new custom section
used for this purpose

Fixes #36

@sbc100 sbc100 requested a review from sunfishcode May 30, 2019 18:55

```wasm
(func $statvfs (import "wasi:fs" "statvfs.weak"))
(global $statvfs_is_present (import "wasm:fs" "statvfs.is_present") i32)
Copy link
Member

Choose a reason for hiding this comment

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

What if we put the ".weak" and ".is_present" in the module name, rather than the field name? This is a little less intuitive, however it would address the concern about intruding on what would otherwise be the user's or compiler's namespace. (import "wasi:fs.weak" "statvfs") and (import "wasi:fs.is_present" "statvfs")?

Copy link
Member Author

Choose a reason for hiding this comment

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

Interesting. Kind of nasty but see you point. What do others think of this idea?

Copy link
Member

Choose a reason for hiding this comment

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

Another option would be to define a reserved character to use instead of .. It's unlikely any system would want to use \0 for its symbol names, for example.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there some existing encoding that we could reuse here, e.g. url encoding?

Copy link
Member Author

Choose a reason for hiding this comment

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

Using null bytes in strings seems a like asking for trouble.

Copy link

Choose a reason for hiding this comment

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

If any character (combination), then definitely something visible in ASCII.

@sbc100 sbc100 mentioned this pull request Jul 11, 2019
I wrote up this as initially proposed by Dan, using name mangling rather
than a custom section.  I believe there is still room to switch a custom
section if people feel strongly about it.

The main downsides I see of using such mangling are:

1. It is that reserves the ".weak" and ".is_present" suffixes
2. It might not play nicely with possible future attributes we might
   want to add to imports.

Fixes #36
@sbc100
Copy link
Member Author

sbc100 commented Aug 14, 2019

I've updated this PR, going back the custom section design, as discussed in the last meeting.

@sbc100 sbc100 changed the title Add a writeup of current weak imports design Add a writeup of current optional imports design Aug 23, 2019
@sbc100
Copy link
Member Author

sbc100 commented Aug 23, 2019

Update with name change to "optional"

@sbc100
Copy link
Member Author

sbc100 commented Aug 30, 2019

@sunfishcode ptal

@sunfishcode
Copy link
Member

Looks like all the feedback has been addressed! If anyone has further feedback, please file issues in the issue tracker.

@sunfishcode sunfishcode merged commit 8d45100 into master Sep 4, 2019
@sunfishcode sunfishcode deleted the weak_imports branch September 4, 2019 22:59
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.

Weak imports
7 participants