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

How can I enable Rust features in Swift? #1953

Closed
FoodChain1028 opened this issue Jan 23, 2024 · 1 comment
Closed

How can I enable Rust features in Swift? #1953

FoodChain1028 opened this issue Jan 23, 2024 · 1 comment

Comments

@FoodChain1028
Copy link

full error traceback

How can I enable rust features in swift?

We are building a project that uses uniffi to generate swift library to call rust.

However, when we used uniffi::build_foreign_language_testcases!() function to test the function in swift, it turned out that the features are not enabled like this:

gpu-benchmarks feature not enabled!
thread '<unnamed>' panicked at 'gpu-benchmarks feature not enabled!', src/lib.rs:183:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Swift/ErrorType.swift:200: Fatal error: Error raised at top level: mopro.(unknown context at $10f04699c).UniffiInternalError.rustPanic("gpu-benchmarks feature not enabled!")
Stack dump:
0.      Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -interpret /Users/foodchain/Documents/PSE/mopro-21/mopro-ffi/tests/bindings/test_mopro_gpu_benchmarks.swift -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -I /Users/foodchain/Documents/PSE/mopro-21/mopro-ffi/target/tmp/mopro-ffi-c9b386fc8fa179b3 -color-diagnostics -new-driver-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -Xcc -fmodule-map-file=/Users/foodchain/Documents/PSE/mopro-21/mopro-ffi/target/tmp/mopro-ffi-c9b386fc8fa179b3/moproFFI.modulemap -module-name test_mopro_gpu_benchmarks -disable-clang-spi -target-sdk-version 14.2 -target-sdk-name macosx14.2 -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins -lmopro_ffi -ltestmod_mopro
1.      Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
3.      Compiling with the current language version
4.      While running user code "/Users/foodchain/Documents/PSE/mopro-21/mopro-ffi/tests/bindings/test_mopro_gpu_benchmarks.swift"
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x00000001039d9abc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x000000010663fcb0 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x00000001063a9054 SignalHandler(int) + 352
3  libsystem_platform.dylib 0x00000001841a4a24 _sigtramp + 56
4  libswiftCore.dylib       0x0000000193a6f1e8 $ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF + 268
5  libswiftCore.dylib       0x0000000193b0ca24 $ss5ErrorPsSYRzs17FixedWidthInteger8RawValueSYRpzrlE5_codeSivg + 0
6  libswiftCore.dylib       0x000000010dbfc6d4 $ss5ErrorPsSYRzs17FixedWidthInteger8RawValueSYRpzrlE5_codeSivg + 18446744071462386864
7  swift-frontend           0x0000000104f8ddb8 llvm::orc::runAsMain(int (*)(int, char**), llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, llvm::Optional<llvm::StringRef>) + 1276
8  swift-frontend           0x0000000100ff57e8 swift::RunImmediately(swift::CompilerInstance&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&, swift::IRGenOptions const&, swift::SILOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>&&) + 11524
9  swift-frontend           0x0000000105f19c24 processCommandLineAndRunImmediately(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>&&, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::FrontendObserver*, int&) + 484
10 swift-frontend           0x0000000105f21650 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 1464
11 swift-frontend           0x0000000105f1cf00 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 3020
12 swift-frontend           0x0000000105f20854 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4568
13 swift-frontend           0x0000000105f87d44 swift::mainEntry(int, char const**) + 4408
14 dyld                     0x0000000183df50e0 start + 2360

I tried to fix this by building in features, however, it wasn't working.

@mhammond
Copy link
Member

The features are specified when you are building the Rust crate. It's not possible to specify them from the bindings because they are run after the crate has been built.

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

No branches or pull requests

2 participants