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 preview2_component_type.o to libc.a and libc.so #472

Merged
merged 1 commit into from
Feb 22, 2024

Conversation

dicej
Copy link
Contributor

@dicej dicej commented Feb 12, 2024

This file adds a custom section to each core module linked with wasi-libc. That custom section contains component type information needed by e.g. wasm-tools component new to generate a component from the module. It will be required once we start using any part of WASI 0.2.0 directly (vs. via a Preview 1 adapter). In addition, it allows developers to #include <wasi/preview2.h> in their code and make use of those APIs directly even if wasi-libc is not using them yet.

This file adds a custom section to each core module linked with wasi-libc.  That
custom section contains component type information needed by e.g. `wasm-tools
component new` to generate a component from the module.  It will be required
once we start using any part of WASI 0.2.0 directly (vs. via a Preview 1
adapter).  In addition, it allows developers to `#include <wasi/preview2.h>` in
their code and make use of those APIs directly even if wasi-libc is not using
them yet.

Signed-off-by: Joel Dice <[email protected]>
@@ -604,6 +607,10 @@ $(OBJDIR)/%.long-double.pic.o: %.c include_dirs
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -MD -MP -o $@ -c $<

$(OBJDIR)/preview2_component_type.pic.o $(OBJDIR)/preview2_component_type.o: $(LIBC_BOTTOM_HALF_SOURCES)/preview2_component_type.o
@mkdir -p "$(@D)"
cp $< $@
Copy link
Member

Choose a reason for hiding this comment

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

Is copying needed, or would it be enough to just add $(LIBC_BOTTOM_HALF_SOURCES)/preview2_component_type.o to LIBC_OBJS?

Copy link
Contributor Author

@dicej dicej Feb 21, 2024

Choose a reason for hiding this comment

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

Sorry, I saw this and then forgot to follow up. I'll see if I can eliminate the copy. I think I was concerned adding an already-generated object file to LIBC_OBJS would break a pattern rule somewhere, but we'll see...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I took another look at this, and I think eliminating the copy would be more trouble than it's worth since the pattern rules for building the .o files for libc.a and libc.so each need their own version (i.e. the .o and the .pic.o, respectively). The file is only 11KB so I don't think the copy adds noticeable bloat to the build.

@sunfishcode sunfishcode merged commit 0fe51d2 into WebAssembly:main Feb 22, 2024
8 checks passed
@sunfishcode
Copy link
Member

Sounds good. Thanks!

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.

2 participants