Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upHandle target specific outputs such as .wasm or .dll.lib #4570
Conversation
rust-highfive
assigned
alexcrichton
Oct 3, 2017
This comment has been minimized.
This comment has been minimized.
rust-highfive
commented
Oct 3, 2017
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
tatsuya6502
referenced this pull request
Oct 3, 2017
Closed
Cargo does not provide a .wasm file in the correct location when building for wasm32-unknown-emscripten #4535
This comment has been minimized.
This comment has been minimized.
Please do not merge this; we found a problem with wasm target. See this comment for details. |
This comment has been minimized.
This comment has been minimized.
I added one more commit to address the problem. Now this PR is ready for merge. |
This comment has been minimized.
This comment has been minimized.
Summary of ChangesFor bin target of wasm32-unknown-emscripten
Before this PR: [package]
name = "wasm-test"
# ...% tree target/wasm32-unknown-emscripten/
target/wasm32-unknown-emscripten/
└── debug
├── build
├── deps
│ ├── wasm_test-0f5ba9409d843569.js
│ ├── wasm_test-0f5ba9409d843569.wasm
│ ├── wasm_test-0f5ba9409d843569.wasm.map
│ └── wasm_test-0f5ba9409d843569.wast
├── examples
├── incremental
├── native
├── wasm-test.d
└── wasm-test.js
6 directories, 6 filesAfter this PR: % tree target/wasm32-unknown-emscripten/
target/wasm32-unknown-emscripten/
└── debug
├── build
├── deps
│ ├── wasm-test.js <== no metadata, hyphen
│ ├── wasm_test.wasm <== no metadata
│ ├── wasm_test.wasm.map
│ └── wasm_test.wast
├── examples
├── incremental
├── native
├── wasm_test.d
├── wasm-test.d
├── wasm-test.js
└── wasm_test.wasm <== added
6 directories, 8 filesFor cdylib/dylib targets of *-pc-windows-msvc
Before this PR: [package]
name = "cdylib-test"
# ...
[lib]
crate-type = ["cdylib"]PS C:\Users\tatsuya\Documents\cdylib-test> dir .\target\debug\deps\
Directory: C:\Users\tatsuya\Documents\cdylib-test\target\debug\deps
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 10/5/2017 06:20 PM 115200 cdylib_test.dll
-a---- 10/5/2017 06:20 PM 2141 cdylib_test.dll.exp
-a---- 10/5/2017 06:20 PM 3892 cdylib_test.dll.lib
-a---- 10/5/2017 06:20 PM 1085440 cdylib_test.pdb
PS C:\Users\tatsuya\Documents\cdylib-test> dir .\target\debug\
Directory: C:\Users\tatsuya\Documents\cdylib-test\target\debug
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 10/5/2017 06:20 PM .fingerprint
d----- 10/5/2017 06:20 PM build
d----- 10/5/2017 06:20 PM deps
d----- 10/5/2017 06:20 PM examples
d----- 10/5/2017 06:20 PM incremental
d----- 10/5/2017 06:20 PM native
-a---- 10/5/2017 06:20 PM 0 .cargo-lock
-a---- 10/5/2017 06:20 PM 119 cdylib_test.d
-a---- 10/5/2017 06:20 PM 115200 cdylib_test.dllAfter this PR:
|
alexcrichton
reviewed
Oct 5, 2017
|
Nice! I've got just one small nit but otherwise this looks great to me and should be good to go. If you're extra enterprising (this is optional) I think we could tackle #4056 with this infrastructure as well, but again, that's optional! |
| @@ -478,9 +481,11 @@ impl<'a, 'cfg> Context<'a, 'cfg> { | |||
| // doing this eventually. | |||
| let __cargo_default_lib_metadata = env::var("__CARGO_DEFAULT_LIB_METADATA"); | |||
| if !unit.profile.test && | |||
| (unit.target.is_dylib() || unit.target.is_cdylib()) && | |||
| (unit.target.is_dylib() || unit.target.is_cdylib() || | |||
| (unit.target.is_bin() && self.target_triple().starts_with("wasm32-"))) && | |||
This comment has been minimized.
This comment has been minimized.
alexcrichton
Oct 5, 2017
Member
Could this be refactored into a dedicated method? Something like:
fn fails_to_work_with_mangled_filename(...) -> bool {
// ...
}(just to make it a bit more clear as to the intent)
This comment has been minimized.
This comment has been minimized.
|
Thank you for reviewing the codes.
Ah, alright, there is another. Sure. I will take that. I have macOS environment and will have some time to spare in coming weekend. |
This comment has been minimized.
This comment has been minimized.
|
Nice! My thinking is that we probably just need to lift up the That actually reminds me, maybe we should lift up the pdb files produced with MSVC debug info as well? Again though, both of these are optional, we can always tackle in future PRs :) |
kennytm
referenced this pull request
Oct 7, 2017
Closed
Line numbers in backtrace still do not appear on macOS for Cargo projects #4490
This comment has been minimized.
This comment has been minimized.
|
I did not have enough time to update this PR last weekend. I was only able to reproduce the debugger problems on macOS and Windows MSVC; no time for updating the codes. I will try to work on them in tomorrow evening (It is Monday evening now in my time zone). My impression is I can address macOS debugger problem in this PR in a couple of days, but not Windows one. I found the full-path to the PDB file is embedded in Windows binary, so I can't move the PDB to anywhere else. It seems there is a way to remove the full-path via a linker flag. But I guess we will need to change |
This comment has been minimized.
This comment has been minimized.
|
Ok no worries! Let's go ahead and get this in and iterate in-tree @bors: r+ |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Oct 9, 2017
This comment has been minimized.
This comment has been minimized.
|
|
tatsuya6502 commentedOct 3, 2017
•
edited
Fixes #4500, #4535
Until now, Cargo does not have any knowledge about target-specific output files. It relies solely on rustc for this sort of information (
rustc --print=file-names ...).As a result, Cargo does not place some build artifacts (files) to target/{debug,release} directory. These files include *.wasm for wasm32-unknown-emscripten target and *.dll.lib for *-pc-windows-msvc cdylib target.
This commit will add such knowledge to Cargo so that *.wasm and *.dll.lib will be placed in target/{debug,release} directory.
EDIT: I added a summary of changes. Please read it for more details of changes.
IMPORTANT
Although I added test cases for both wasm32-unknown-emscripten and *-pc-windows-msvc cdylib targets,
I did not do manual testing on wasm32-unknown-emscripten target as I do not have an environment with emscripten installed. It will be appreciated if anybody tests this change for wasm32-unknown-emscripten target.EDIT: Tested for both wasm32-unknown-emscripten and x86_64-pc-windows-msvc. Thanks @Herschel for the help.