Skip to content

Bitode fembed-bitcode-marker breaking iOS debug builds #301

Closed
@kali

Description

@kali

Hi,

It looks like the -fembed-bitcode-marker breaks the debug builds (it is not set on release bug).

To be honest, I'm not 100% sure where the actual issue is, but something looses track of the actually compiled symbols somewhere.

Here is a test-case. A rust wrapper library with a -sys underneath (with a void native_function() {} ), try to build test on the rusty wrapper.

First run: native, macos for reference.
Second run: test targetting ios, missing symbols while linking.
Third run: same with --release, disabling the fembed-bitcode-marker as a side effect, it compiles.

Forcing cc back to 1.0.5 make the probelm disappear. Or Using a patched cc-rs that do not put the bintcode-marker.

S 15/03 9:42 ~/dev/snips/tc-init-bitcode-marker% cargo test
   Compiling cc v1.0.7
   Compiling tc-init-bitcode-marker-sys v0.1.0 (file:///Users/kali/dev/snips/tc-init-bitcode-marker/tc-init-bitcode-marker-sys)
   Compiling tc-init-bitcode-marker v0.1.0 (file:///Users/kali/dev/snips/tc-init-bitcode-marker)
    Finished dev [unoptimized + debuginfo] target(s) in 2.73 secs
     Running target/debug/deps/tc_init_bitcode_marker-c331333640f6d205

running 1 test
test tests::it_works ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

   Doc-tests tc-init-bitcode-marker

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

S 15/03 9:42 ~/dev/snips/tc-init-bitcode-marker% TARGET_SYSROOT=`xcrun -sdk iphoneos --show-sdk-path` cargo test --target aarch64-apple-ios
   Compiling tc-init-bitcode-marker-sys v0.1.0 (file:///Users/kali/dev/snips/tc-init-bitcode-marker/tc-init-bitcode-marker-sys)
   Compiling tc-init-bitcode-marker v0.1.0 (file:///Users/kali/dev/snips/tc-init-bitcode-marker)
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-arch" "arm64" "-Wl,-syslibroot" "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.2.sdk" "-L" "/Users/kali/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/aarch64-apple-ios/lib" "/Users/kali/dev/snips/tc-init-bitcode-marker/target/aarch64-apple-ios/debug/deps/tc_init_bitcode_marker-5b76daec38646eb8.1bi40wzgjfa2z8fe.rcgu.o" "/Users/kali/dev/snips/tc-init-bitcode-marker/target/aarch64-apple-ios/debug/deps/tc_init_bitcode_marker-5b76daec38646eb8.1y16o1qfye96o7m0.rcgu.o" "/Users/kali/dev/snips/tc-init-bitcode-marker/target/aarch64-apple-ios/debug/deps/tc_init_bitcode_marker-5b76daec38646eb8.2k322vp0xntl1vb2.rcgu.o" "/Users/kali/dev/snips/tc-init-bitcode-marker/target/aarch64-apple-ios/debug/deps/tc_init_bitcode_marker-5b76daec38646eb8.3rngp6bm2u2q5z0y.rcgu.o" "/Users/kali/dev/snips/tc-init-bitcode-marker/target/aarch64-apple-ios/debug/deps/tc_init_bitcode_marker-5b76daec38646eb8.twro57p54np36np.rcgu.o" "-o" "/Users/kali/dev/snips/tc-init-bitcode-marker/target/aarch64-apple-ios/debug/deps/tc_init_bitcode_marker-5b76daec38646eb8" "/Users/kali/dev/snips/tc-init-bitcode-marker/target/aarch64-apple-ios/debug/deps/tc_init_bitcode_marker-5b76daec38646eb8.crate.allocator.rcgu.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/kali/dev/snips/tc-init-bitcode-marker/target/aarch64-apple-ios/debug/deps" "-L" "/Users/kali/dev/snips/tc-init-bitcode-marker/target/debug/deps" "-L" "/Users/kali/dev/snips/tc-init-bitcode-marker/target/aarch64-apple-ios/debug/build/tc-init-bitcode-marker-sys-bcd7b7491fb82c24/out" "-L" "/Users/kali/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/aarch64-apple-ios/lib" "/Users/kali/dev/snips/tc-init-bitcode-marker/target/aarch64-apple-ios/debug/deps/libtc_init_bitcode_marker_sys-f1d44cb505be7d46.rlib" "/Users/kali/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/aarch64-apple-ios/lib/libtest-24fa6627a68aaf09.rlib" "/Users/kali/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/aarch64-apple-ios/lib/libterm-18625f57bc60e498.rlib" "/Users/kali/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/aarch64-apple-ios/lib/libgetopts-85228cbd7e544789.rlib" "/Users/kali/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/aarch64-apple-ios/lib/libstd-df91e356061f8ac8.rlib" "/Users/kali/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/aarch64-apple-ios/lib/libpanic_unwind-1086e1d0e6cd90ef.rlib" "/Users/kali/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/aarch64-apple-ios/lib/libunwind-ce923fc11d74f968.rlib" "/Users/kali/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/aarch64-apple-ios/lib/liballoc_system-e87ca03f4215e4ef.rlib" "/Users/kali/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/aarch64-apple-ios/lib/liblibc-e959e9c0d1548c0e.rlib" "/Users/kali/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/aarch64-apple-ios/lib/liballoc-37638280ec40d743.rlib" "/Users/kali/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/aarch64-apple-ios/lib/libstd_unicode-0766335b25639e9e.rlib" "/Users/kali/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/aarch64-apple-ios/lib/libcore-e1a6bc6fd1c79bbc.rlib" "/Users/kali/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/aarch64-apple-ios/lib/libcompiler_builtins-c410c86b18328824.rlib" "-l" "System" "-l" "objc" "-framework" "Security" "-framework" "Foundation" "-l" "resolv" "-l" "c" "-l" "m"
  = note: Undefined symbols for architecture arm64:
            "_native_function", referenced from:
                tc_init_bitcode_marker::call_it::h8098132b2999850c in tc_init_bitcode_marker-5b76daec38646eb8.1bi40wzgjfa2z8fe.rcgu.o
          ld: symbol(s) not found for architecture arm64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)


error: aborting due to previous error

error: Could not compile `tc-init-bitcode-marker`.

To learn more, run the command again with --verbose.
[1]    55263 exit 101   TARGET_SYSROOT=`xcrun -sdk iphoneos --show-sdk-path` cargo test --target
S 15/03 9:42 ~/dev/snips/tc-init-bitcode-marker% TARGET_SYSROOT=`xcrun -sdk iphoneos --show-sdk-path` cargo test --target aarch64-apple-ios  --release
   Compiling cc v1.0.7
   Compiling tc-init-bitcode-marker-sys v0.1.0 (file:///Users/kali/dev/snips/tc-init-bitcode-marker/tc-init-bitcode-marker-sys)
   Compiling tc-init-bitcode-marker v0.1.0 (file:///Users/kali/dev/snips/tc-init-bitcode-marker)
    Finished release [optimized] target(s) in 5.20 secs
     Running target/aarch64-apple-ios/release/deps/tc_init_bitcode_marker-5701cd311fc4ffc2
error: could not execute process `/Users/kali/dev/snips/tc-init-bitcode-marker/target/aarch64-apple-ios/release/deps/tc_init_bitcode_marker-5701cd311fc4ffc2` (never executed)

Caused by:
  Bad CPU type in executable (os error 86)
[1]    55299 exit 101   TARGET_SYSROOT=`xcrun -sdk iphoneos --show-sdk-path` cargo test --target

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions