Skip to content

statics in closures returned using impl Trait: undefined symbols #40839

Closed as not planned
@TimNN

Description

@TimNN

I have Code like the following:

impl Docker {
    // #[inline] // marking this as inline fixes the problem
    pub fn new(handle: &Handle) -> impl Future<Item = Docker, Error = io::Error> {
        let client = hyper::Client::new(&handle);

        let docker = Docker {
            client: client,
        };

        // docker.version() returns a `impl Future`
        docker.version().map(|version| {
            println!("connected to docker {:?}", version);
            docker
        })
    }
}

When I'm calling Docker::new from another crate I get the following linker error:

  = note: Undefined symbols for architecture x86_64:
            "docker_run::Docker::new::_$u7b$$u7b$closure$u7d$$u7d$::__STATIC_FMTSTR::h39c0733cea565f9a", referenced from:
                docker_run::Docker::new::_$u7b$$u7b$closure$u7d$$u7d$::h260aa00d780d89c7 in docker_run-8e8c301168781829.0.o

Related symbols from the linked rlib:

$ objdump -t .../libdocker_run-b777eed0df4fdfc5.rlib | grep -F '6Docker3new28_$u7b$$u7b$closure$'
00000000000d5950 l       0e SECT   01 0000 [.text] __ZN10docker_run6Docker3new28_$u7b$$u7b$closure$u7d$$u7d$17h2a2bb6ebe6df45e4E
00000000000f96a0 l       0e SECT   05 0000 [.const_data] __ZN10docker_run6Docker3new28_$u7b$$u7b$closure$u7d$$u7d$15__STATIC_FMTSTR17h39c0733cea565f9aE

And from the object file in question:

objdump -t .../docker_run-8e8c301168781829.0.o  | grep -F '6Docker3new28_$u7b$$u7b$closure$'
00000000000033b0 l       0e SECT   01 0000 [.text] __ZN10docker_run6Docker3new28_$u7b$$u7b$closure$u7d$$u7d$17h260aa00d780d89c7E
0000000000000000 g       01 UND    00 0000 __ZN10docker_run6Docker3new28_$u7b$$u7b$closure$u7d$$u7d$15__STATIC_FMTSTR17h39c0733cea565f9aE

I hope this is enough for someone to get an idea, where the problem might be, other wise I can see about publishing a smaller testcase.

cc @michaelwoerister I guess this is related to the collector, which I believe is your area of expertise.

Metadata

Metadata

Assignees

Labels

A-linkageArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions