Skip to content

Linker fails to link rlibs on arm64_32-apple-watchos #103508

Closed
@thomcc

Description

@thomcc

In rust-random/getrandom#317 I tried to add watchOS and tvOS support to getrandom. During this process, I tried to do a cargo test --no-run build for watchOS, which gave me a long error output, seemingly indicating that the linker was ignoring rlibs:

$ cargo test --no-run --target=arm64_32-apple-watchos --features=std -Zbuild-std
   Compiling compiler_builtins v0.1.82
   Compiling core v0.0.0 (/Users/thom/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core)
   Compiling libc v0.2.135
   Compiling cc v1.0.73
   Compiling memchr v2.5.0
   Compiling std v0.0.0 (/Users/thom/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/std)
   Compiling libc v0.2.134
   Compiling unwind v0.0.0 (/Users/thom/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/unwind)
   Compiling rustc-std-workspace-core v1.99.0 (/Users/thom/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/rustc-std-workspace-core)
   Compiling alloc v0.0.0 (/Users/thom/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/alloc)
   Compiling cfg-if v0.1.10
   Compiling adler v0.2.3
   Compiling cfg-if v1.0.0
   Compiling rustc-demangle v0.1.21
   Compiling rustc-std-workspace-alloc v1.99.0 (/Users/thom/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/rustc-std-workspace-alloc)
   Compiling panic_abort v0.0.0 (/Users/thom/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/panic_abort)
   Compiling panic_unwind v0.0.0 (/Users/thom/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/panic_unwind)
   Compiling gimli v0.25.0
   Compiling miniz_oxide v0.4.0
   Compiling hashbrown v0.12.3
   Compiling std_detect v0.1.5 (/Users/thom/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/stdarch/crates/std_detect)
   Compiling object v0.26.2
   Compiling addr2line v0.16.0
   Compiling rustc-std-workspace-std v1.99.0 (/Users/thom/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/rustc-std-workspace-std)
   Compiling proc_macro v0.0.0 (/Users/thom/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/proc_macro)
   Compiling unicode-width v0.1.10
   Compiling getopts v0.2.21
   Compiling test v0.0.0 (/Users/thom/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/test)
   Compiling getrandom v0.2.8 (/Users/thom/src/getrandom)
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-arch" "arm64_32" "/var/folders/rw/gsmfnk2s12d34hywmktc28q40000gn/T/rustcNYxOPt/symbols.o" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/rdrand-b52dd97b5239a0b7.2ork2r0rcxk94nbd.rcgu.o" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/rdrand-b52dd97b5239a0b7.4jje0c9039g88kgo.rcgu.o" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/rdrand-b52dd97b5239a0b7.4pecv3q9ri5hy0zd.rcgu.o" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/rdrand-b52dd97b5239a0b7.b3n7dwxrwzxbdcp.rcgu.o" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/rdrand-b52dd97b5239a0b7.lsfs3nk3c01pk5.rcgu.o" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/rdrand-b52dd97b5239a0b7.rqzkfwxeqxih7xp.rcgu.o" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/rdrand-b52dd97b5239a0b7.3saglnyvx5ikb5f6.rcgu.o" "-L" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps" "-L" "/Users/thom/src/getrandom/target/debug/deps" "-L" "/Users/thom/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/arm64_32-apple-watchos/lib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libtest-e8407cf03fd58926.rlib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libgetopts-5e24c94c3b28df0e.rlib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libunicode_width-418a066791e771b4.rlib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/librustc_std_workspace_std-1b2a72518ff8604b.rlib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libstd-c164cc8175dfef3f.rlib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libpanic_unwind-91156a10bf4dd4e5.rlib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libobject-76bf7c072cc6ff68.rlib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libmemchr-3c9deff40f724412.rlib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libaddr2line-cd2dc24440645334.rlib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libgimli-817e0acbb0be0869.rlib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/librustc_demangle-dd4d413b6a90232b.rlib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libstd_detect-309d48fe36d039a2.rlib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libcfg_if-52e3d2adfc8cb734.rlib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libhashbrown-1527b3242773f09f.rlib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libminiz_oxide-e6feb1ffc6ec23e3.rlib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libadler-819cfeddc3afb6c4.rlib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/librustc_std_workspace_alloc-53a6423750846103.rlib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libunwind-56369296e40eca8b.rlib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libcfg_if-68520f3f6d145118.rlib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/liblibc-427814d894d71fdc.rlib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/liballoc-ce9b80b9f986a4d6.rlib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/librustc_std_workspace_core-599d32924b1c01f2.rlib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libcore-d8712872fdd20492.rlib" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libcompiler_builtins-1125f1819af83722.rlib" "-lSystem" "-lobjc" "-framework" "Security" "-framework" "Foundation" "-lc" "-lm" "-isysroot" "/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS9.0.sdk" "-Wl,-syslibroot" "/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS9.0.sdk" "-L" "/Users/thom/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/arm64_32-apple-watchos/lib" "-o" "/Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/rdrand-b52dd97b5239a0b7" "-Wl,-dead_strip" "-nodefaultlibs"
  = note: ld: warning: directory not found for option '-L/Users/thom/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/arm64_32-apple-watchos/lib'
          ld: warning: directory not found for option '-L/Users/thom/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/arm64_32-apple-watchos/lib'
          ld: warning: ignoring file /var/folders/rw/gsmfnk2s12d34hywmktc28q40000gn/T/rustcNYxOPt/symbols.o, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libunicode_width-418a066791e771b4.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/librustc_std_workspace_std-1b2a72518ff8604b.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libpanic_unwind-91156a10bf4dd4e5.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libmemchr-3c9deff40f724412.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libaddr2line-cd2dc24440645334.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libobject-76bf7c072cc6ff68.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libstd_detect-309d48fe36d039a2.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libcfg_if-52e3d2adfc8cb734.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libtest-e8407cf03fd58926.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libgimli-817e0acbb0be0869.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libhashbrown-1527b3242773f09f.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/librustc_std_workspace_alloc-53a6423750846103.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libunwind-56369296e40eca8b.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libcfg_if-68520f3f6d145118.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libminiz_oxide-e6feb1ffc6ec23e3.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/librustc_std_workspace_core-599d32924b1c01f2.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/liblibc-427814d894d71fdc.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libcompiler_builtins-1125f1819af83722.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libstd-c164cc8175dfef3f.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libgetopts-5e24c94c3b28df0e.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/librustc_demangle-dd4d413b6a90232b.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libadler-819cfeddc3afb6c4.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/liballoc-ce9b80b9f986a4d6.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          ld: warning: ignoring file /Users/thom/src/getrandom/target/arm64_32-apple-watchos/debug/deps/libcore-d8712872fdd20492.rlib, building for watchOS-arm64_32 but attempting to link with file built for unknown-arm64
          Undefined symbols for architecture arm64_32:
            "std::rt::lang_start_internal::h0a6997aae5e7685a", referenced from:
                std::rt::lang_start::h57ca5847e0db6f0d in rdrand-b52dd97b5239a0b7.4pecv3q9ri5hy0zd.rcgu.o
            "core::hint::black_box::h02254acf856e3b06", referenced from:
                std::sys_common::backtrace::__rust_begin_short_backtrace::h185210fb7a6c39f0 in rdrand-b52dd97b5239a0b7.2ork2r0rcxk94nbd.rcgu.o
            "test::test_main_static::hc3a2eb5568ebf3fc", referenced from:
                rdrand::main::h700cce9a9d899f8f in rdrand-b52dd97b5239a0b7.b3n7dwxrwzxbdcp.rcgu.o
            "_rust_eh_personality", referenced from:
                Dwarf Exception Unwind Info (__eh_frame) in rdrand-b52dd97b5239a0b7.2ork2r0rcxk94nbd.rcgu.o
                Dwarf Exception Unwind Info (__eh_frame) in rdrand-b52dd97b5239a0b7.4jje0c9039g88kgo.rcgu.o
          ld: symbol(s) not found for architecture arm64_32
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

This seems to indicate that we aren't invoking the linker correctly on arm64_32-apple-watchos, or that it doesn't understand rlibs for some other reason. This is on macOS 13.0 and the SDKs from XCode 14.0.1. Perhaps that is related? I'm not sure.

CC @vladimir-ea, @deg4uss3r (listed as owners of that target on https://doc.rust-lang.org/nightly/rustc/platform-support/apple-watchos.html)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesO-watchosOperating System: watchOST-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions