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

cargo rustc --crate-type support #433

Closed
riidefi opened this issue Aug 16, 2023 · 10 comments · Fixed by #557
Closed

cargo rustc --crate-type support #433

riidefi opened this issue Aug 16, 2023 · 10 comments · Fixed by #557

Comments

@riidefi
Copy link

riidefi commented Aug 16, 2023

Motivation: Compiling a project for multiple targets, it can often be necessary to have both a cdylib and staticlib version of a crate. Unfortunately, on some targets (WASM) cdylibs are a build error. There is no good way to conditionally have build types, and the Rust team appears to have no interest in adding that, in favor of cargo rustc with --crate-type.

For an example of its usage, see rust-lang/cargo#10356
This is the RFC rust-lang/rfcs#3180 (comment)

Information on conditional staticlib/such and why that probably isn't coming: rust-lang/cargo#4881 (comment)

I believe ideally in corrosion, we would simply not require cdylib/staticlib be specified in Cargo.toml and pass the crate type from corrosion_import_crate? Is this feasible?

@jschwe
Copy link
Collaborator

jschwe commented Aug 16, 2023

I believe ideally in corrosion, we would simply not require cdylib/staticlib be specified in Cargo.toml

This is currently not the case, but there is no technical reason preventing this aside from requiring a higher minimum rust version.

The --crate-type flag can be used in corrosion already though, take a look at this example / test:

https://github.com/corrosion-rs/corrosion/blob/master/test/crate_type/crate_type/CMakeLists.txt

@riidefi
Copy link
Author

riidefi commented Aug 16, 2023

Edit: I spoke too soon--see my next message. Oh, thank you so much! That works perfectly. I wonder if it would make sense to put this information in the missing target error (i.e. it may be best practice not to edit Cargo.toml here?) Otherwise I can close this issue.

@riidefi
Copy link
Author

riidefi commented Aug 16, 2023

I spoke too soon. It appears crate-type isn't working as I had expected?

1> CMake generation started for configuration: 'Clang-x64-Debug'.
1> Found and using vcpkg toolchain file (C:/Users/rii/Documents/dev/vcpkg/scripts/buildsystems/vcpkg.cmake).
1> Environment settings:
1>     CXXFLAGS=-m64 -fdiagnostics-absolute-paths
1>     CFLAGS=-m64 -fdiagnostics-absolute-paths
1> Command line: "C:\WINDOWS\system32\cmd.exe" /c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Ninja"  -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\rii\Documents\dev\RiiStudio\out\install\Clang-x64-Debug" -DCMAKE_C_COMPILER:FILEPATH="C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/Tools/Llvm/x64/bin/clang-cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/Tools/Llvm/x64/bin/clang-cl.exe"  -DRust_CARGO_TARGET=x86_64-pc-windows-msvc -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" -DCMAKE_TOOLCHAIN_FILE="C:/Users/rii/Documents/dev/vcpkg/scripts/buildsystems/vcpkg.cmake" "C:\Users\rii\Documents\dev\RiiStudio" 2>&1"
1> Working directory: C:\Users\rii\Documents\dev\RiiStudio\out\build\Clang-x64-Debug
1> [CMake] -- CPM: adding package [email protected] (10.0.0)
1> [CMake] -- Version: 10.0.0
1> [CMake] -- Build type: Debug
1> [CMake] -- CPM: adding package [email protected] (v0.18)
1> [CMake] -- CPM: adding package corrosion@ (master)
1> [CMake] -- Rust Toolchain: nightly-x86_64-pc-windows-msvc
1> [CMake] -- Using Corrosion as a subdirectory
1> [CMake] CMake Error at out/build/Clang-x64-Debug/_deps/corrosion-src/cmake/CorrosionGenerator.cmake:287 (message):
1> [CMake]   Found no targets in 1 packages..
1> [CMake] 
1> [CMake]   Please keep in mind that corrosion will only import Rust `bin` targets
1> [CMake]   or`staticlib` or `cdylib` library targets.The following packages were found
1> [CMake]   in the Manifest: gctex
1> [CMake] Call Stack (most recent call first):
1> [CMake]   out/build/Clang-x64-Debug/_deps/corrosion-src/cmake/Corrosion.cmake:1051 (_generator_add_cargo_targets)
1> [CMake]   CMakeLists.txt:196 (corrosion_import_crate)
1> [CMake] -- Configuring incomplete, errors occurred!
1> 'C:\WINDOWS\system32\cmd.exe' '/c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Ninja"  -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\rii\Documents\dev\RiiStudio\out\install\Clang-x64-Debug" -DCMAKE_C_COMPILER:FILEPATH="C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/Tools/Llvm/x64/bin/clang-cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/Tools/Llvm/x64/bin/clang-cl.exe"  -DRust_CARGO_TARGET=x86_64-pc-windows-msvc -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" -DCMAKE_TOOLCHAIN_FILE="C:/Users/rii/Documents/dev/vcpkg/scripts/buildsystems/vcpkg.cmake" "C:\Users\rii\Documents\dev\RiiStudio" 2>&1"' execution failed with error: ''C:\WINDOWS\system32\cmd.exe' '/c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Ninja"  -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\rii\Documents\dev\RiiStudio\out\install\Clang-x64-Debug" -DCMAKE_C_COMPILER:FILEPATH="C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/Tools/Llvm/x64/bin/clang-cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/PROGRAM FILES/MICROSOFT VISUAL STUDIO/2022/COMMUNITY/VC/Tools/Llvm/x64/bin/clang-cl.exe"  -DRust_CARGO_TARGET=x86_64-pc-windows-msvc -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" -DCMAKE_TOOLCHAIN_FILE="C:/Users/rii/Documents/dev/vcpkg/scripts/buildsystems/vcpkg.cmake" "C:\Users\rii\Documents\dev\RiiStudio" 2>&1"' returned with exit code: 1'.

Cargo.toml

[lib]
crate-type=["lib", "staticlib"]

via

# In Debug builds, we are forced to use .dll due to incompatible _ITERATOR_DEBUG_LEVEL values: 0 in cc-rs via Rust and 2 in C++.
# In release builds we should prefer static libraries, though, due to minimize failure points during the update process.
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
  set(RECURSIVE_CPP_CRATE_TYPE cdylib)
else()
  set(RECURSIVE_CPP_CRATE_TYPE staticlib)
endif()

corrosion_import_crate(MANIFEST_PATH source/gctex/Cargo.toml CRATE_TYPES ${RECURSIVE_CPP_CRATE_TYPE} FLAGS --crate-type=${RECURSIVE_CPP_CRATE_TYPE})

Adding cdylib to the Cargo.toml fixes the issue, but of course breaks the earlier fix!

@jschwe
Copy link
Collaborator

jschwe commented Aug 16, 2023

Adding cdylib to the Cargo.toml fixes the issue, but of course breaks the earlier fix!

Could you clarify what is broken? The expected behavior is that CRATE_TYPES only imports a subset of types (but not more), and --crate-type=x will cause cargo rustc to build only that crate type. This should allow you to only import the type you need.

@riidefi
Copy link
Author

riidefi commented Aug 16, 2023

Could you clarify what is broken? The expected behavior is that CRATE_TYPES only imports a subset of types (but not more), and --crate-type=x will cause cargo rustc to build only that crate type. This should allow you to only import the type you need.

For context, I have a crate that I import directly with Cargo (gctex), but is also used as a library by pure Rust code; I cannot make a dylib wrapper library easily as I don't think it'll export transitive symbols. I was looking for a way to only opt-in to cdylib on Windows Debug, and totally remove that value from the TOML file.

@jschwe
Copy link
Collaborator

jschwe commented Aug 17, 2023

Okay, let's see if I understood correctly:

  1. You can't specify cdylib in the Cargo.toml, because the crate is also used as an rlib from a different crate, and compilation of the cdylib would fail in that case (corrosion not involved yet).
  2. Removing cdylib from the Cargo.toml prevents corrosion from importing the crate as a shared library (as of now).

@riidefi
Copy link
Author

riidefi commented Aug 17, 2023

Yes. In particular, here is the error I get trying:

test2>cargo build --target wasm32-unknown-emscripten
   Compiling gctex v0.1.13 (C:\Users\rii\Documents\dev\RiiStudio\source\gctex)
error: linking with `emcc.bat` failed: exit code: 1
  |
  = note: "cmd" "/c" "emcc.bat" "-s" "EXPORTED_FUNCTIONS=[\"_gctex_get_version_unstable_api\",\"_rii_compute_image_size\",\"_rii_compute_image_size_mip\",\"_rii_decode\",\"_rii_encode_cmpr\",\"_rii_encode_i4\",\"_rii_encode_i8\",\"_rii_encode_ia4\",\"_rii_encode_ia8\",\"_rii_encode_rgb565\",\"_rii_encode_rgb5a3\",\"_rii_encode_rgba8\"]" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.17rp284l0x2pot6u.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.1n5vah9ws5xw6fkb.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.1q9l6mrnu3hpjo69.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.27jkyty5gxrfhtpt.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.29ilby6qtge70aek.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.2g8qw485fdtu516l.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.2nxqddkwqq4rz3g5.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.2o6uqsmeekawqqa7.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.2pbramd2wom9adr1.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.2yiusn4ccknfpcgs.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.34t86ufwyn12mbvb.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.3883ijjla3wbb3xc.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.3abyyid8wfd28jk3.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.3du82c6gfiohbtws.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.3q8y1wehho4vs8p2.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.4afovdp51i2dhrbc.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.4i4njprezja61rxp.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.4l3oi4wptfseld9g.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.530fl9qrlx9wakok.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.55qw00jmo0a6dex5.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.7mo4eqnlmi54w62.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.84z83d4tsyd92dl.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.a2vian2t32b3kof.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.m9x13e9dfc4b62j.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.u97f33j97dkxf2q.rcgu.o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.2o9i1m83tzd3fv8b.rcgu.o" "-L" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps" "-L" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\debug\\deps" "-L" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\build\\gctex-f530dd9c1510f823\\out" "-L" "C:\\Users\\rii\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib" "-l" "gctex.a" "-l" "stdc++" "C:\\Users\\rii\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libstd-7c3b3f7689bc1c83.rlib" "C:\\Users\\rii\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libpanic_unwind-70a8bf30a1dacb6e.rlib" "C:\\Users\\rii\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\librustc_demangle-318f03c0204d6199.rlib" "C:\\Users\\rii\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libstd_detect-fc0ab1d97e1d5e2b.rlib" "C:\\Users\\rii\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libhashbrown-a647cd868483d936.rlib" "C:\\Users\\rii\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\librustc_std_workspace_alloc-8e83e196cc9b4859.rlib" "C:\\Users\\rii\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libminiz_oxide-fcc95ec3ecab738f.rlib" "C:\\Users\\rii\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libadler-87555aabff657f4a.rlib" "C:\\Users\\rii\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libunwind-91678a4ff9591526.rlib" "C:\\Users\\rii\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libcfg_if-e40872114c12e72c.rlib" "C:\\Users\\rii\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\liblibc-41654b2b9a7cb0b0.rlib" "C:\\Users\\rii\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\liballoc-5c30fb5c1b923b8a.rlib" "C:\\Users\\rii\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\librustc_std_workspace_core-dccfe230458f39f9.rlib" "C:\\Users\\rii\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libcore-ff850c1994b8a1ec.rlib" "C:\\Users\\rii\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\libcompiler_builtins-3790817cb9c768d1.rlib" "-l" "c" "-s" "DISABLE_EXCEPTION_CATCHING=0" "-L" "C:\\Users\\rii\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib" "-L" "C:\\Users\\rii\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\wasm32-unknown-emscripten\\lib\\self-contained" "-o" "C:\\Users\\rii\\Documents\\dev\\RiiStudio\\source\\test2\\target\\wasm32-unknown-emscripten\\debug\\deps\\gctex.wasm" "-O0" "-g" "-sABORTING_MALLOC=0" "-Wl,--fatal-warnings"
  = note: wasm-ld: error: C:\Users\rii\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\wasm32-unknown-emscripten\lib\libstd-7c3b3f7689bc1c83.rlib(std-7c3b3f7689bc1c83.std.5a4bd94f5fe922c7-cgu.0.rcgu.o): undefined symbol: open64
          wasm-ld: error: C:\Users\rii\Documents\dev\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\libstandalonewasm.a(__main_void.o): undefined symbol: main
          emcc: error: 'C:/Users/rii/Documents/dev/emsdk/upstream/bin\wasm-ld.exe -o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.wasm C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.17rp284l0x2pot6u.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.1n5vah9ws5xw6fkb.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.1q9l6mrnu3hpjo69.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.27jkyty5gxrfhtpt.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.29ilby6qtge70aek.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.2g8qw485fdtu516l.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.2nxqddkwqq4rz3g5.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.2o6uqsmeekawqqa7.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.2pbramd2wom9adr1.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.2yiusn4ccknfpcgs.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.34t86ufwyn12mbvb.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.3883ijjla3wbb3xc.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.3abyyid8wfd28jk3.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.3du82c6gfiohbtws.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.3q8y1wehho4vs8p2.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.4afovdp51i2dhrbc.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.4i4njprezja61rxp.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.4l3oi4wptfseld9g.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.530fl9qrlx9wakok.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.55qw00jmo0a6dex5.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.7mo4eqnlmi54w62.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.84z83d4tsyd92dl.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.a2vian2t32b3kof.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.m9x13e9dfc4b62j.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.u97f33j97dkxf2q.rcgu.o C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps\gctex.2o9i1m83tzd3fv8b.rcgu.o -LC:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\deps -LC:\Users\rii\Documents\dev\RiiStudio\source\test2\target\debug\deps -LC:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\build\gctex-f530dd9c1510f823\out -LC:\Users\rii\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\wasm32-unknown-emscripten\lib C:\Users\rii\Documents\dev\RiiStudio\source\test2\target\wasm32-unknown-emscripten\debug\build\gctex-f530dd9c1510f823\out\libgctex.a.a C:\Users\rii\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\wasm32-unknown-emscripten\lib\libstd-7c3b3f7689bc1c83.rlib C:\Users\rii\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\wasm32-unknown-emscripten\lib\libpanic_unwind-70a8bf30a1dacb6e.rlib C:\Users\rii\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\wasm32-unknown-emscripten\lib\librustc_demangle-318f03c0204d6199.rlib C:\Users\rii\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\wasm32-unknown-emscripten\lib\libstd_detect-fc0ab1d97e1d5e2b.rlib C:\Users\rii\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\wasm32-unknown-emscripten\lib\libhashbrown-a647cd868483d936.rlib C:\Users\rii\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\wasm32-unknown-emscripten\lib\librustc_std_workspace_alloc-8e83e196cc9b4859.rlib C:\Users\rii\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\wasm32-unknown-emscripten\lib\libminiz_oxide-fcc95ec3ecab738f.rlib C:\Users\rii\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\wasm32-unknown-emscripten\lib\libadler-87555aabff657f4a.rlib C:\Users\rii\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\wasm32-unknown-emscripten\lib\libunwind-91678a4ff9591526.rlib C:\Users\rii\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\wasm32-unknown-emscripten\lib\libcfg_if-e40872114c12e72c.rlib C:\Users\rii\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\wasm32-unknown-emscripten\lib\liblibc-41654b2b9a7cb0b0.rlib C:\Users\rii\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\wasm32-unknown-emscripten\lib\liballoc-5c30fb5c1b923b8a.rlib C:\Users\rii\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\wasm32-unknown-emscripten\lib\librustc_std_workspace_core-dccfe230458f39f9.rlib C:\Users\rii\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\wasm32-unknown-emscripten\lib\libcore-ff850c1994b8a1ec.rlib C:\Users\rii\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\wasm32-unknown-emscripten\lib\libcompiler_builtins-3790817cb9c768d1.rlib -lc-debug -LC:\Users\rii\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\wasm32-unknown-emscripten\lib -LC:\Users\rii\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\wasm32-unknown-emscripten\lib\self-contained --fatal-warnings -LC:\Users\rii\Documents\dev\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten C:\Users\rii\Documents\dev\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\crt1.o -lGL -lal -lhtml5 -lstandalonewasm -lstubs-debug -lc-debug -ldlmalloc -lcompiler_rt -lc++ -lc++abi-debug -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-cxx-exceptions -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr C:\Users\rii\AppData\Local\Temp\tmpzjgobseelibemscripten_js_symbols.so --export-if-defined=gctex_get_version_unstable_api --export-if-defined=rii_compute_image_size --export-if-defined=rii_compute_image_size_mip --export-if-defined=rii_decode --export-if-defined=rii_encode_cmpr --export-if-defined=rii_encode_i4 --export-if-defined=rii_encode_i8 --export-if-defined=rii_encode_ia4 --export-if-defined=rii_encode_ia8 --export-if-defined=rii_encode_rgb565 --export-if-defined=rii_encode_rgb5a3 --export-if-defined=rii_encode_rgba8 --export-if-defined=__get_exception_message --export-if-defined=free --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__start_em_lib_deps --export-if-defined=__stop_em_lib_deps --export-if-defined=__start_em_js --export-if-defined=__stop_em_js --export=emscripten_stack_get_end --export=emscripten_stack_get_free --export=emscripten_stack_get_base --export=emscripten_stack_get_current --export=emscripten_stack_init --export=stackSave --export=stackRestore --export=stackAlloc --export=__errno_location --export=__cxa_is_pointer_type --export=__cxa_can_catch --export=__cxa_increment_exception_refcount --export=__cxa_decrement_exception_refcount --export=setThrew --export=__cxa_free_exception --export=__get_exception_message --export=free --export-table -z stack-size=65536 --initial-memory=16777216 --max-memory=16777216 --stack-first' failed (returned 1)


error: could not compile `gctex` (lib) due to previous error

via

[package]
name = "test2"
version = "0.1.0"
edition = "2021"

[dependencies]
gctex = { path = "../gctex"}

Despite the fact that test2 presumably should only care about the rlib artifact, it appears to build all of gctex's targets.. for some reason.

@jschwe jschwe added this to the v0.5 milestone Aug 19, 2023
@jschwe
Copy link
Collaborator

jschwe commented Aug 19, 2023

Despite the fact that test2 presumably should only care about the rlib artifact, it appears to build all of gctex's targets

I suspect that cargo doesn't really know what kind of lib artifacts are needed, since e.g. the RUSTFLAG -C prefer-dynamic would influence this and RUSTFLAGS are not interpreted by cargo.

@ajtribick
Copy link

A use case that seems to be related here is building icu4x. The icu_capi crate that provides the FFI does not have a crate-type specified (and based on feedback, they say they are unable to add this), so Corrosion cannot find it. Otherwise the build would work fine using the technique from the crate_type example - verified by patching Corrosion to force a "staticlib" crate type rather than extracting it from the manifest.

@jschwe jschwe linked a pull request Sep 7, 2024 that will close this issue
@jschwe
Copy link
Collaborator

jschwe commented Sep 7, 2024

Added in #557

@jschwe jschwe closed this as completed Sep 7, 2024
@jschwe jschwe removed this from the v0.5 milestone Sep 7, 2024
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 a pull request may close this issue.

3 participants