Skip to content

Undefined symbol: _new_tunnel #397

Open
@mikeshappell

Description

@mikeshappell

Good morning everyone.

I am hoping this is a simple issue and someone can help me out. I have spent a lot of time searching for a solution without any luck.

Summary

I have created a static library using the instructions in the repository for the target triple aarch64-apple-ios. The library built without issues. However, when I try to compile the project using the library, I get this error: "Undefined symbol: _new_tunnel". As the library is properly added to my project and the required "bridging header" is correct, I used nm to look at the library and discovered that, in fact, the symbol is not in the library.

What can cause this issue and how can I produce a library which contains the necessary exports to use the library?

Details

Although I have built a version of the library for more than one target triple, let's focus on the aarch64-apple-ios case for the moment. I have installed rustup and have the following versions installed.

rustup 1.27.0 (2024-03-08)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active rustc version is rustc 1.77.1 (7cf61ebde 2024-03-27)
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: x86_64-apple-darwin23.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

I have also installed the target using rustup.

rustup target add aarch64-apple-ios

Then, I built the library using the command from the README.md, which was:

cargo build --lib --release --no-default-features --target aarch64-apple-ios

This builds and produces the static and dynamic libraries as expected. Using the nm command on the resulting library, I see the following information (excerpt, but includes the only reference to boringtun as the rest are the many dependencies of the project).

cd targets/aarch64-apple-ios/release
nm libboringtun.a > t.txt

First part of t.txt

boringtun.oltf1cth477n37t.rcgu.o:
                 U ___rdl_alloc
                 U ___rdl_alloc_zeroed
                 U ___rdl_dealloc
                 U ___rdl_realloc
                 U ___rg_oom
---------------- T ___rust_alloc
---------------- T ___rust_alloc_error_handler
---------------- D ___rust_alloc_error_handler_should_panic
---------------- T ___rust_alloc_zeroed
---------------- T ___rust_dealloc
---------------- D ___rust_no_alloc_shim_is_unstable
---------------- T ___rust_realloc

hmac-96c14486fb5f355e.hmac.f89c15fd2c601d84-cgu.0.rcgu.o:

pin_project_lite-3d50fbfca7744f31.pin_project_lite.3f539c677dac0c66-cgu.0.rcgu.o:

lock_api-d5f5fcd6e14ec8d4.lock_api.8554128397852c1-cgu.0.rcgu.o:

<snip>

I am unclear why none of the symbols I expected are present. To ensure there was not an issue with my setup, I installed a sample project that generates a simple static library and verified that after building it, the symbols that I expected to be present were in fact in the library.

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