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

Fix "create-exe" for windows-x86_64 target #3299

Merged
merged 36 commits into from
Nov 18, 2022
Merged

Conversation

fschutt
Copy link
Contributor

@fschutt fschutt commented Nov 11, 2022

No description provided.

@fschutt fschutt requested a review from syrusakbary as a code owner November 11, 2022 10:23
@fschutt fschutt force-pushed the fix-create-exe-windows branch from d2af38e to ddf4b33 Compare November 14, 2022 14:20
@fschutt fschutt marked this pull request as draft November 15, 2022 10:36
@fschutt
Copy link
Contributor Author

fschutt commented Nov 15, 2022

This is currently stuck on zig cc not properly linking the object files:

zig cc -target x86_64-windows-gnu -L. -l:wasmer.lib -I. "-isystem" ./python.obj ./wasmer_main.c ./volume.o -o ./python.exe

allfiles.zip
allfiles 2.zip

@fschutt
Copy link
Contributor Author

fschutt commented Nov 16, 2022

Windows build to test:

x86_64-windows-gnu-python.zip

@fschutt
Copy link
Contributor Author

fschutt commented Nov 16, 2022

@syrusakbary At this point the error is fixed for every system except the x86_64-windows target: zig build-exe doesn't output a target file,but doesn't output an error either. It works for every other target (the original error of stdio.h not found is fixed by switching from zig cc to zig build-exe).

All I can do at this point is to report a bug to zig and ask for help.

zigbug.zip

@fschutt fschutt marked this pull request as ready for review November 18, 2022 10:38
@fschutt fschutt enabled auto-merge November 18, 2022 16:02
@fschutt
Copy link
Contributor Author

fschutt commented Nov 18, 2022

Seems like it will go through now.

@fschutt
Copy link
Contributor Author

fschutt commented Nov 18, 2022

bors r+

bors bot added a commit that referenced this pull request Nov 18, 2022
3299: Fix "create-exe" for windows-x86_64 target r=fschutt a=fschutt



Co-authored-by: Felix Schütt <[email protected]>
Co-authored-by: Felix Schütt <[email protected]>
@fschutt fschutt merged commit 58d8415 into master Nov 18, 2022
@fschutt fschutt deleted the fix-create-exe-windows branch November 18, 2022 17:20
@bors
Copy link
Contributor

bors bot commented Nov 18, 2022

This PR was included in a batch that successfully built, but then failed to merge into master (it was a non-fast-forward update). It will be automatically retried.

lib/cli/src/commands/create_exe.rs Show resolved Hide resolved
Comment on lines +583 to +588
libwasmer_parent.pop();
cmd.arg(libwasmer_parent.join("winsdk/ADVAPI32.lib"));
cmd.arg(libwasmer_parent.join("winsdk/BCRYPT.lib"));
cmd.arg(libwasmer_parent.join("winsdk/KERNEL32.lib"));
cmd.arg(libwasmer_parent.join("winsdk/USERENV.lib"));
cmd.arg(libwasmer_parent.join("winsdk/WS2_32.lib"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have a list of these files?

It might be a good idea to pull them into a constant at the top of the file, that way we can set up tests to make sure all the *.lib files are always included with Wasmer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it's just the libraries that I found out that libwasmer.a depends on.

There is no way to find out the libraries, except for using Google to lookup which DLL the missing functions belong to.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh no, what I meant was instead of copy-pasting the cmd.arg(libwasmer_parent.join(...)) line for every library, we should store them in a constant and use a loop.

const VENDORED_LIBRARIES: &[&str] = &[
    "ADVAPI32.lib",
    "BCRYPT.lib",
    ...
];

That way we can add a test to the wasmer CLI that makes sure all the libraries are embedded in the installer. It'd be annoying if the list of libraries we tell the compiler to link against and the list of libraries bundled with wasmer got out of sync. We probably wouldn't notice until weeks later when our first user wants to do networking and finds we forgot to give them WS2_32.lib.

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've made a loop with fs::read_dir now, so we don't need to hardcode any paths, it will just link to every object in the /winsdk folder.

.arg(&output_path)
.output()
.context("Could not execute `zig`")?
println!("{:?}", cmd);
Copy link
Contributor

Choose a reason for hiding this comment

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

We can delete this one, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically we can, but I left it in on purpose so I can see which zig command gets output.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use log::debug!(), then? End users probably don't want to see the full command-line we are using to generate EXEs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, I migrated to log::debug

lib/cli/src/commands/create_exe.rs Show resolved Hide resolved
lib/cli/src/commands/create_exe.rs Show resolved Hide resolved
lib/cli/src/commands/create_exe.rs Show resolved Hide resolved
lib/cli/src/commands/create_exe.rs Show resolved Hide resolved
lib/registry/src/lib.rs Show resolved Hide resolved
lib/registry/src/lib.rs Show resolved Hide resolved
tests/integration/cli/tests/run.rs Show resolved Hide resolved
fschutt added a commit that referenced this pull request Nov 18, 2022
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