-
Notifications
You must be signed in to change notification settings - Fork 824
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
chore: Build Wasmer on musl #2003
Conversation
bors try |
tryBuild failed: |
bors try |
tryBuild failed: |
bors try |
tryTimed out. |
bors try |
bors try |
tryAlready running a review |
bors try- |
bors try |
tryBuild failed: |
bors try- |
bors try |
tryBuild failed: |
bors try |
dea45a5
to
ce154a2
Compare
bors try |
ce154a2
to
ec0d85d
Compare
ec0d85d
to
ecf1683
Compare
@@ -1,6 +1,11 @@ | |||
# ignore wasm-c-api binaries | |||
wasm-c-api-* | |||
test-* | |||
wasm-c-api/example/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change related to musl?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope.
It can be extracted to a dedicated PR if needed.
ecf1683
to
bbfb99b
Compare
bors try |
2133: fix: Use space-indent when calling functions outside of rules r=Hywan a=jubianchi This should fix failures in: * https://github.com/wasmerio/wasmer-nightly/pull/14/checks?check_run_id=1938612785 * https://github.com/wasmerio/wasmer-nightly/pull/13/checks?check_run_id=1938633577 This will unblock #2003 Co-authored-by: jubianchi <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The asset upload duplication must be fixed, but apart from that, I'm approving this PR. Good job!
ifeq ($(IS_WINDOWS), 1) | ||
cp target/release/wasmer_c_api.dll package/lib/wasmer.dll | ||
cp target/release/wasmer_c_api.lib package/lib/wasmer.lib | ||
else | ||
ifeq ($(IS_DARWIN), 1) | ||
|
||
# Windows | ||
if [ -f $(TARGET_DIR)/wasmer_c_api.dll ]; then \ | ||
cp $(TARGET_DIR)/wasmer_c_api.dll package/lib/wasmer.dll ;\ | ||
fi | ||
if [ -f $(TARGET_DIR)/wasmer_c_api.lib ]; then \ | ||
cp $(TARGET_DIR)/wasmer_c_api.lib package/lib/wasmer.lib ;\ | ||
fi | ||
|
||
# For some reason in macOS arm64 there are issues if we copy constantly in the install_name_tool util | ||
rm -f package/lib/libwasmer.dylib | ||
cp target/release/libwasmer_c_api.dylib package/lib/libwasmer.dylib | ||
cp target/release/libwasmer_c_api.a package/lib/libwasmer.a | ||
# Fix the rpath for the dylib | ||
install_name_tool -id "@rpath/libwasmer.dylib" package/lib/libwasmer.dylib | ||
else | ||
# In some cases the .so may not be available, for example when building against musl (static linking) | ||
if [ -f target/release/libwasmer_c_api.so ]; then \ | ||
cp target/release/libwasmer_c_api.so package/lib/libwasmer.so ;\ | ||
fi; | ||
cp target/release/libwasmer_c_api.a package/lib/libwasmer.a | ||
endif | ||
endif | ||
if [ -f $(TARGET_DIR)/libwasmer_c_api.dylib ]; then \ | ||
cp $(TARGET_DIR)/libwasmer_c_api.dylib package/lib/libwasmer.dylib ;\ | ||
install_name_tool -id "@rpath/libwasmer.dylib" package/lib/libwasmer.dylib ;\ | ||
fi | ||
|
||
if [ -f $(TARGET_DIR)/libwasmer_c_api.so ]; then \ | ||
cp $(TARGET_DIR)/libwasmer_c_api.so package/lib/libwasmer.so ;\ | ||
fi | ||
if [ -f $(TARGET_DIR)/libwasmer_c_api.a ]; then \ | ||
cp $(TARGET_DIR)/libwasmer_c_api.a package/lib/libwasmer.a ;\ | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this new approach. It's more “error-proof”.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was actually just about to comment that I think it's more error prone as we'll silently fail if we're missing any of these files and will just have to wait until a user reports or we notice that we didn't release one of the files we intended to.
Ideally our packaging logic would be tested and not live in our CI file. We've lost a ton of things done in CI over time from all the CI migrations we've done -- I wouldn't put anything too critical there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do think the above code is better though, but we do need tests for our packaging logic and the change above makes the need for tests greater.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MarkMcCaskey the problem with our previous strategy here was we relied on the host OS to define the files to copy.
This is not always the right thing to do, for example when we cross-compile this is why I changed that. Also, our strategy was not adaptative: if a user decides to change his build configuration (for example move from cdylib
to staticlib
) he'll have to change the Makefile. With this change, everything will automatically work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that makes sense, my one concern is just that it's less specific. Rather than encoding an expected state of the world "given condition X, we must have files Y, Z, ..." we just take whatever is there. So any bug that affects the files we produce will now go unnoticed. Put another way, the new code is less brittle and picky, but it's so non-brittle and picky that it won't complain if things are broken, where the old code would.
I think the real fix is to just have actual testing for our release process but I think that's out of scope for this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's accept the present patch, and then immediately open a new PR to test the package/
directory? We also have various scheduled tests that run basedwasmer-nightly
(like in wasmer-go
, wasmer-php
etc.).
@@ -173,7 +172,7 @@ jobs: | |||
- name: Test | |||
run: | | |||
make test | |||
if: matrix.target != 'aarch64-apple-darwin' | |||
if: matrix.build != 'macos-arm64' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are target and build the same here? It seems like they could be different
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
matrix.target
and matrix.os
are names defined by either Rust or GitHub. matrix.build
is something we chosse on our side so I prefer to rely on our naming convention here.
If GitHub forces us to change the os
this will not impact the workflow. Same for target
(even if it's unlikely they will change)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure that makes sense, I just want to check that there aren't extra semantics here. If I remember correctly, arm64 Mac used target
or some other key for a very specific purpose and I think the difference might have been important because of cross-compilation or something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MarkMcCaskey yeah, to build for M1 we cross compile so we define (in the matrix) the Rust target to use and we were also using this in our conditionals.
But now, we have a problem: when GitHub will support M1 directly, we won't cross-compile anymore (we won't force the target through the matrix). Without my change, this would also require to change all the conditionals. With my change, we only update the matrix and we are done.
ifeq ($(IS_WINDOWS), 1) | ||
cp target/release/wasmer_c_api.dll package/lib/wasmer.dll | ||
cp target/release/wasmer_c_api.lib package/lib/wasmer.lib | ||
else | ||
ifeq ($(IS_DARWIN), 1) | ||
|
||
# Windows | ||
if [ -f $(TARGET_DIR)/wasmer_c_api.dll ]; then \ | ||
cp $(TARGET_DIR)/wasmer_c_api.dll package/lib/wasmer.dll ;\ | ||
fi | ||
if [ -f $(TARGET_DIR)/wasmer_c_api.lib ]; then \ | ||
cp $(TARGET_DIR)/wasmer_c_api.lib package/lib/wasmer.lib ;\ | ||
fi | ||
|
||
# For some reason in macOS arm64 there are issues if we copy constantly in the install_name_tool util | ||
rm -f package/lib/libwasmer.dylib | ||
cp target/release/libwasmer_c_api.dylib package/lib/libwasmer.dylib | ||
cp target/release/libwasmer_c_api.a package/lib/libwasmer.a | ||
# Fix the rpath for the dylib | ||
install_name_tool -id "@rpath/libwasmer.dylib" package/lib/libwasmer.dylib | ||
else | ||
# In some cases the .so may not be available, for example when building against musl (static linking) | ||
if [ -f target/release/libwasmer_c_api.so ]; then \ | ||
cp target/release/libwasmer_c_api.so package/lib/libwasmer.so ;\ | ||
fi; | ||
cp target/release/libwasmer_c_api.a package/lib/libwasmer.a | ||
endif | ||
endif | ||
if [ -f $(TARGET_DIR)/libwasmer_c_api.dylib ]; then \ | ||
cp $(TARGET_DIR)/libwasmer_c_api.dylib package/lib/libwasmer.dylib ;\ | ||
install_name_tool -id "@rpath/libwasmer.dylib" package/lib/libwasmer.dylib ;\ | ||
fi | ||
|
||
if [ -f $(TARGET_DIR)/libwasmer_c_api.so ]; then \ | ||
cp $(TARGET_DIR)/libwasmer_c_api.so package/lib/libwasmer.so ;\ | ||
fi | ||
if [ -f $(TARGET_DIR)/libwasmer_c_api.a ]; then \ | ||
cp $(TARGET_DIR)/libwasmer_c_api.a package/lib/libwasmer.a ;\ | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was actually just about to comment that I think it's more error prone as we'll silently fail if we're missing any of these files and will just have to wait until a user reports or we notice that we didn't release one of the files we intended to.
Ideally our packaging logic would be tested and not live in our CI file. We've lost a ton of things done in CI over time from all the CI migrations we've done -- I wouldn't put anything too critical there
ifeq ($(IS_WINDOWS), 1) | ||
cp target/release/wasmer_c_api.dll package/lib/wasmer.dll | ||
cp target/release/wasmer_c_api.lib package/lib/wasmer.lib | ||
else | ||
ifeq ($(IS_DARWIN), 1) | ||
|
||
# Windows | ||
if [ -f $(TARGET_DIR)/wasmer_c_api.dll ]; then \ | ||
cp $(TARGET_DIR)/wasmer_c_api.dll package/lib/wasmer.dll ;\ | ||
fi | ||
if [ -f $(TARGET_DIR)/wasmer_c_api.lib ]; then \ | ||
cp $(TARGET_DIR)/wasmer_c_api.lib package/lib/wasmer.lib ;\ | ||
fi | ||
|
||
# For some reason in macOS arm64 there are issues if we copy constantly in the install_name_tool util | ||
rm -f package/lib/libwasmer.dylib | ||
cp target/release/libwasmer_c_api.dylib package/lib/libwasmer.dylib | ||
cp target/release/libwasmer_c_api.a package/lib/libwasmer.a | ||
# Fix the rpath for the dylib | ||
install_name_tool -id "@rpath/libwasmer.dylib" package/lib/libwasmer.dylib | ||
else | ||
# In some cases the .so may not be available, for example when building against musl (static linking) | ||
if [ -f target/release/libwasmer_c_api.so ]; then \ | ||
cp target/release/libwasmer_c_api.so package/lib/libwasmer.so ;\ | ||
fi; | ||
cp target/release/libwasmer_c_api.a package/lib/libwasmer.a | ||
endif | ||
endif | ||
if [ -f $(TARGET_DIR)/libwasmer_c_api.dylib ]; then \ | ||
cp $(TARGET_DIR)/libwasmer_c_api.dylib package/lib/libwasmer.dylib ;\ | ||
install_name_tool -id "@rpath/libwasmer.dylib" package/lib/libwasmer.dylib ;\ | ||
fi | ||
|
||
if [ -f $(TARGET_DIR)/libwasmer_c_api.so ]; then \ | ||
cp $(TARGET_DIR)/libwasmer_c_api.so package/lib/libwasmer.so ;\ | ||
fi | ||
if [ -f $(TARGET_DIR)/libwasmer_c_api.a ]; then \ | ||
cp $(TARGET_DIR)/libwasmer_c_api.a package/lib/libwasmer.a ;\ | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do think the above code is better though, but we do need tests for our packaging logic and the change above makes the need for tests greater.
chore: Update workflow to reflect what we have in wasmerio/wasmer#2003
bors r+ |
This patch adds a specific build for musl. Currently, it will only support JIT engine.
I also changes the workflow definition a bit so we don't depend on the OS name but rather on the environment ID which is our convention.
Closes #1482
Closes #1766
Description
Review