Skip to content

rust-binary-calls-swift-package example doesn't work on a Linux environment #107

@yoching

Description

@yoching

Hello.
I'm trying to build a CLI application that is mainly written in Rust and calls some Swift functions, and I'm developing it on a Linux environment.
I tried to run rust-binary-calls-swift-package example, but it didn't run with following errors.
I'm using WSL2 with Ubuntu and swift-5.6.2-RELEASE-ubuntu20.04.

Do you know how I can make it work? Or, are Linux environments not supported?
Thank you in advance!

$ cargo run -p rust-binary-calls-swift-package
   Compiling proc-macro2 v1.0.42
   Compiling unicode-ident v1.0.2
   Compiling quote v1.0.20
   Compiling syn v1.0.98
   Compiling libc v0.2.126
   Compiling fastrand v1.8.0
   Compiling remove_dir_all v0.5.3
   Compiling cfg-if v1.0.0
   Compiling tempfile v3.3.0
   Compiling swift-bridge-ir v0.1.35 (/home/yoshikuni/GitHub/Rust/swift-bridge/crates/swift-bridge-ir)
   Compiling swift-bridge-build v0.1.35 (/home/yoshikuni/GitHub/Rust/swift-bridge/crates/swift-bridge-build)
   Compiling swift-bridge-macro v0.1.35 (/home/yoshikuni/GitHub/Rust/swift-bridge/crates/swift-bridge-macro)
   Compiling rust-binary-calls-swift-package v0.1.0 (/home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package)
   Compiling swift-bridge v0.1.35 (/home/yoshikuni/GitHub/Rust/swift-bridge)
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-m64" "/tmp/rustcBQCunq/symbols.o" "/home/yoshikuni/GitHub/Rust/swift-bridge/target/debug/deps/rust_binary_calls_swift_package-292e71af283f5de2.1w9emz731ogimejr.rcgu.o" "/home/yoshikuni/GitHub/Rust/swift-bridge/target/debug/deps/rust_binary_calls_swift_package-292e71af283f5de2.24kdsva5pt5pnbco.rcgu.o" "/home/yoshikuni/GitHub/Rust/swift-bridge/target/debug/deps/rust_binary_calls_swift_package-292e71af283f5de2.26896tw8fqt0v9fu.rcgu.o" "/home/yoshikuni/GitHub/Rust/swift-bridge/target/debug/deps/rust_binary_calls_swift_package-292e71af283f5de2.2tpci647um6thpo2.rcgu.o" "/home/yoshikuni/GitHub/Rust/swift-bridge/target/debug/deps/rust_binary_calls_swift_package-292e71af283f5de2.4dhdhlqomt6smcj1.rcgu.o" "/home/yoshikuni/GitHub/Rust/swift-bridge/target/debug/deps/rust_binary_calls_swift_package-292e71af283f5de2.4h8n84jaxycwap6v.rcgu.o" "/home/yoshikuni/GitHub/Rust/swift-bridge/target/debug/deps/rust_binary_calls_swift_package-292e71af283f5de2.4hpkoi5vvq6zq02l.rcgu.o" "/home/yoshikuni/GitHub/Rust/swift-bridge/target/debug/deps/rust_binary_calls_swift_package-292e71af283f5de2.abt62j993v3u99r.rcgu.o" "/home/yoshikuni/GitHub/Rust/swift-bridge/target/debug/deps/rust_binary_calls_swift_package-292e71af283f5de2.dj4o1vryudkth0e.rcgu.o" "/home/yoshikuni/GitHub/Rust/swift-bridge/target/debug/deps/rust_binary_calls_swift_package-292e71af283f5de2.zjy3tzpqmre36eq.rcgu.o" "/home/yoshikuni/GitHub/Rust/swift-bridge/target/debug/deps/rust_binary_calls_swift_package-292e71af283f5de2.1zen2gw3lpr0rw58.rcgu.o" "-Wl,--as-needed" "-L" "/home/yoshikuni/GitHub/Rust/swift-bridge/target/debug/deps" "-L" "/home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/.build/debug" "-L" "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/" "-L" "/usr/lib/swift" "-L" "/home/yoshikuni/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "-lswift-library" "/home/yoshikuni/GitHub/Rust/swift-bridge/target/debug/deps/libswift_bridge-882327837dd14bed.rlib" "-Wl,--start-group" "/home/yoshikuni/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-69edc9ac8de4d39c.rlib" "/home/yoshikuni/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-254ac8a4d96ed89e.rlib" "/home/yoshikuni/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-8bed7ede368468ef.rlib" "/home/yoshikuni/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-9da1150e6aeada6b.rlib" "/home/yoshikuni/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-dec39a40a22b358c.rlib" "/home/yoshikuni/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-7a90882341200e38.rlib" "/home/yoshikuni/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-6a5da46a37549d0a.rlib" "/home/yoshikuni/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-6dc3d1df7e408d5b.rlib" "/home/yoshikuni/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-9d89ad14c568d44a.rlib" "/home/yoshikuni/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-ecbdf47025adae10.rlib" "/home/yoshikuni/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-29db3ffec771ef22.rlib" "/home/yoshikuni/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-8b55ad9e1a2080d1.rlib" "/home/yoshikuni/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-f37a55941b8b3bbd.rlib" "/home/yoshikuni/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-c1d45d3d6971ce0d.rlib" "/home/yoshikuni/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-18ac7cbb154ecd62.rlib" "/home/yoshikuni/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-80c5909c82700e85.rlib" "/home/yoshikuni/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-aa7f747e2f6af7d5.rlib" "/home/yoshikuni/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-60d544c9f51ce476.rlib" "-Wl,--end-group" "/home/yoshikuni/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-d1bd89f2a607e488.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/yoshikuni/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/yoshikuni/GitHub/Rust/swift-bridge/target/debug/deps/rust_binary_calls_swift_package-292e71af283f5de2" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-nodefaultlibs"
  = note: /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/.build/debug/libswift-library.a(swift_library.swift.o): in function `$s13swift_library0A14_multiply_by_43nums5Int64VAE_tF':
          /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/Sources/swift-library/swift_library.swift:2: undefined reference to `$ss27_allocateUninitializedArrayySayxG_BptBwlFyp_Tg5'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/Sources/swift-library/swift_library.swift:2: undefined reference to `$sSS21_builtinStringLiteral17utf8CodeUnitCount7isASCIISSBp_BwBi1_tcfC'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/Sources/swift-library/swift_library.swift:2: undefined reference to `$sSSN'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/Sources/swift-library/swift_library.swift:2: undefined reference to `$sypN'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/Sources/swift-library/swift_library.swift:2: undefined reference to `$ss5print_9separator10terminatoryypd_S2StF'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/Sources/swift-library/swift_library.swift:2: undefined reference to `swift_bridgeObjectRelease'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/Sources/swift-library/swift_library.swift:2: undefined reference to `swift_bridgeObjectRelease'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/Sources/swift-library/swift_library.swift:2: undefined reference to `swift_release'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/Sources/swift-library/swift_library.swift:4: undefined reference to `$ss27_allocateUninitializedArrayySayxG_BptBwlFyp_Tg5'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/Sources/swift-library/swift_library.swift:4: undefined reference to `$sSS21_builtinStringLiteral17utf8CodeUnitCount7isASCIISSBp_BwBi1_tcfC'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/Sources/swift-library/swift_library.swift:4: undefined reference to `$ss5print_9separator10terminatoryypd_S2StF'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/Sources/swift-library/swift_library.swift:4: undefined reference to `swift_bridgeObjectRelease'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/Sources/swift-library/swift_library.swift:4: undefined reference to `swift_bridgeObjectRelease'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/Sources/swift-library/swift_library.swift:4: undefined reference to `swift_release'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/Sources/swift-library/swift_library.swift:8: undefined reference to `$ss27_allocateUninitializedArrayySayxG_BptBwlFyp_Tg5'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/Sources/swift-library/swift_library.swift:8: undefined reference to `$sSS21_builtinStringLiteral17utf8CodeUnitCount7isASCIISSBp_BwBi1_tcfC'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/Sources/swift-library/swift_library.swift:8: undefined reference to `$ss5print_9separator10terminatoryypd_S2StF'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/Sources/swift-library/swift_library.swift:9: undefined reference to `swift_bridgeObjectRelease'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/Sources/swift-library/swift_library.swift:9: undefined reference to `swift_bridgeObjectRelease'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/Sources/swift-library/swift_library.swift:9: undefined reference to `swift_release'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/.build/debug/libswift-library.a(swift_library.swift.o): in function `$ss27_finalizeUninitializedArrayySayxGABnlF':
          /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/<compiler-generated>:(.text+0x2a7): undefined reference to `$sSaMa'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/<compiler-generated>:(.text+0x2c0): undefined reference to `swift_retain'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/<compiler-generated>:(.text+0x2c9): undefined reference to `swift_release'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/.build/debug/libswift-library.a(swift_library.swift.o): in function `$ss5print_9separator10terminatoryypd_S2StFfA0_':
          /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/<compiler-generated>:(.text+0x2f6): undefined reference to `$sSS21_builtinStringLiteral17utf8CodeUnitCount7isASCIISSBp_BwBi1_tcfC'
          /usr/bin/ld: /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/.build/debug/libswift-library.a(swift_library.swift.o): in function `$ss5print_9separator10terminatoryypd_S2StFfA1_':
          /home/yoshikuni/GitHub/Rust/swift-bridge/examples/rust-binary-calls-swift-package/swift-library/<compiler-generated>:(.text+0x316): undefined reference to `$sSS21_builtinStringLiteral17utf8CodeUnitCount7isASCIISSBp_BwBi1_tcfC'
          collect2: error: ld returned 1 exit status
          
  = help: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

error: could not compile `rust-binary-calls-swift-package` due to previous error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions