Comments (10)
Thanks for the report! I think know where the issue is and hope I can find a bit of time and fix it before the end of the week.
from corrosion.
Edit: it seems only the Debug folder is populated, the Release folder is empty when that command executes.
I've done a bit of investigating and tried out multiple different things, but it turns out this one is actually quite hard to fix.
The "proper way" of adding the built outputs as BYPRODUCTS
of the cargo build
custom target is not an option, since the output location of the artifacts depend on target properties of the imported target, such as hostbuild
or the used cargo profile (dev/release/...). Sadly, BYPRODUCTS are not allowed to use target specific generator expressions.
I think I could perhaps work around the issue by creating per-config dummy output files, and using those files to specify the appropriate dependencies, but it requires a bit of refactoring.
from corrosion.
Are you setting any of the OUTPUT_DIRECTORY
variables in your project?
from corrosion.
In the original project I found this problem, yes.
In this test project I just created, no.
from corrosion.
@xTachyon Could you test if #492 fixes your main issue? It's not a complete fix, since if the user sets OUTPUT_DIRECTORY
to a path that does not differ per config, you would still run into the issue, while for normal CMake C/C++ executables CMake would implicitly add a $<CONFIG>
. I'll probably fix that too, but if #492 is sufficient, then I would open a seperate issue for it and fix it later.
from corrosion.
It's another error now!
➜ build cmake --build . --verbose
Change Dir: '/home/x/y/repos/mytest/build'
Run Build Command(s): /usr/bin/ninja -v
[0/7] cd /home/x/y/repos/mytest/the_rust_lib && /usr/bin/cmake -E env CC_x86_64_unknown_linux_gnu=/usr/bin/cc CXX_x86_64_unknown_linux_gnu=/usr/bin/c++ AR_x86_64_unknown_linux_gnu=/usr/bin/ar CORROSION_BUILD_DIR=/home/x/y/repos/mytest/build CARGO_BUILD_RUSTC=/home/x/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc /home/x/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo rustc --lib --target=x86_64-unknown-linux-gnu --package the_rust_lib --manifest-path /home/x/y/repos/mytest/the_rust_lib/Cargo.toml --target-dir /home/x/y/repos/mytest/build/Debug/cargo/build -- -Cdefault-linker-libraries=yes
Compiling the_rust_lib v0.1.0 (/home/x/y/repos/mytest/the_rust_lib)
Finished dev [unoptimized + debuginfo] target(s) in 0.07s
[2/7] cd /home/x/y/repos/mytest/build && /usr/bin/cmake -E make_directory /home/x/y/repos/mytest/build/Release && /usr/bin/cmake -E copy_if_different /home/x/y/repos/mytest/build/Release/cargo/build/x86_64-unknown-linux-gnu/release/libthe_rust_lib.a /home/x/y/repos/mytest/build/Release
FAILED: CMakeFiles/Release/_cargo-build_the_rust_lib.util Release/libthe_rust_lib.a /home/x/y/repos/mytest/build/Release/libthe_rust_lib.a
cd /home/x/y/repos/mytest/build && /usr/bin/cmake -E make_directory /home/x/y/repos/mytest/build/Release && /usr/bin/cmake -E copy_if_different /home/x/y/repos/mytest/build/Release/cargo/build/x86_64-unknown-linux-gnu/release/libthe_rust_lib.a /home/x/y/repos/mytest/build/Release
Error copying file (if different) from "/home/x/y/repos/mytest/build/Release/cargo/build/x86_64-unknown-linux-gnu/release/libthe_rust_lib.a" to "/home/x/y/repos/mytest/build/Release".
[3/7] cd /home/x/y/repos/mytest/build && /usr/bin/cmake -E make_directory /home/x/y/repos/mytest/build/Debug && /usr/bin/cmake -E copy_if_different /home/x/y/repos/mytest/build/Debug/cargo/build/x86_64-unknown-linux-gnu/debug/libthe_rust_lib.a /home/x/y/repos/mytest/build/Debug
ninja: build stopped: subcommand failed.
Edit: it seems only the Debug folder is populated, the Release folder is empty when that command executes.
from corrosion.
Could you share the test project you created?
from corrosion.
I believe the only relevant part of the project is the cmake:
cmake_minimum_required(VERSION 3.27)
project(mytest)
add_executable(mytest main.cpp)
add_subdirectory(corrosion)
corrosion_import_crate(MANIFEST_PATH
the_rust_lib/Cargo.toml
NO_LINKER_OVERRIDE
FLAGS
)
target_link_libraries(mytest the_rust_lib)
The rust lib is just a staticlib which exports a symbol, which main.cpp uses. I could share a zip with all the files if you want.
from corrosion.
Hmm, that doesn't sound very different from our rust2cpp
test case. If you don't mind to share it, I would like to test it with your zip. I'm travelling this week though (thus also the slow response), so I probably won't have time before next week to investigate.
from corrosion.
https://drive.google.com/file/d/1A1I2xiC5nqR5u8MJM6ZlQDEieGqn7OOX/view?usp=drive_link
from corrosion.
Related Issues (20)
- `corrosion_import_public_crate(CRATE_NAME "libc" VERSION "0.2")`-like feature / CMake-Crates.io integration? HOT 2
- Support `$<CONFIG>` in `OUTPUT_DIRECTORY` HOT 6
- [Bug]: Some crate requires AR_<triple> environment to cross-compile HOT 1
- [Bug]: Regression caused by passing AR? commit b72c8ceb52f5d0235ce0fc268cfeff20ce56e8d8? HOT 1
- Upstream Rust language support
- [Bug]:cross compile failed HOT 1
- [Bug]: cross compilation from linux to windows with build tools fails. HOT 4
- [Enhancement]: Vcpkg support HOT 5
- [Bug]: Macos build with -F rather than -L HOT 4
- unused crates in a workspace not included in package, but still expected HOT 3
- corrosion_import_crate: issue with PROFILE argument in combination with CRATES
- [Bug]: corrosion_link_libraries does not include transitive dependencies HOT 2
- Breaking change to target names containing dashes with Rust 1.79 HOT 3
- corrosion_experimental_cbindgen always triggers rebuilds of files that include the generated header HOT 3
- corrosion_link_libraries behavior vs. expectation HOT 1
- [Bug]: undefined symbols during link-time on Windows with LLVM HOT 8
- corrosion_set_features did not work HOT 8
- [Bug]: On error, FindRust puts `Rust_FOUND` in wrong scope HOT 1
- Detect and issue a warning if a different corrosion version is already included.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from corrosion.