Skip to content

No compile-time error when referencing non-public module #8505

Description

@joshuawarner32

The following produces a difficult to understand link error, rather than a compile error. Rust 0.7, ubuntu 12.04 x86_64.

hello.rs:

extern mod world;

fn main() {
  println("hello " + world::columbus::explore());
}

world.rs:

#[ link(name = "world",
        vers = "0.1")];

#[ crate_type = "lib" ];

mod columbus {
  pub fn explore() -> &str { "world" }
}

Compiling hello.rs gives this error:
error: linking with cc failed with code 1
note: cc arguments: -L/usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib -m64 -o hello hello.o -L/usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib -lstd-6c65cf4b443341b1-0.7 -L. -lworld-15fb3a718ea23983-0.1 -lrustrt -lrt -lpthread -L. -lrt -ldl -lm -lmorestack -lrustrt -Wl,-rpath,$ORIGIN/../../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib -Wl,-rpath,$ORIGIN/. -Wl,-rpath,/usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib -Wl,-rpath,/tmp/test/.
note: hello.o: In function main::_f3d4197390d6bb2a::_0$x2e0': hello.rc:(.text+0x54): undefined reference tocolumbus::explore::_3de4895354bdc485::_0$x2e1'
collect2: ld returned 1 exit status

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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