Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x86_64 MSVC coretest::ptr::test_variadic_fnptr: "error LNK2019: unresolved external symbol" #36076

Closed
hanna-kruppe opened this issue Aug 28, 2016 · 7 comments

Comments

@hanna-kruppe
Copy link
Contributor

I get a linker error when building coretest as part of the check step, or more specifically check-crate-std. The source of the problem is the test test_variadic_fnptr in src/coretest/ptr.rs, and the same error can be provoked by this self-contained program:

fn main() {
    extern "C" {
        fn printf(_: *const u8, ...);
    }
    let p: unsafe extern "C" fn(*const u8, ...) = printf;
    let _q = p.clone();
}

Some notes:

  • compiling with optimizations will inline the clone and subsequently eliminate all the code including the part taking the address of printf, and then it compiles just fine.
  • It appears related to being variadic, since fabs in place of printf worked just fine.
  • It doesn't matter whether I take the address of the function or call it.

Meta

Reproduced with a rustup-provided nightly from August 21 and with the current bootstrap compiler (beta-2016-08-17).

@nagisa
Copy link
Member

nagisa commented Aug 28, 2016

printf function is not a thing in MSVC. That test ought to be removed, because we test variadic functions in this test, including the function pointer.

@hanna-kruppe
Copy link
Contributor Author

Why aren't the MSVC bots seeing the same error, then?

@nagisa
Copy link
Member

nagisa commented Aug 28, 2016

Well existence of an actual function might depend on MSVC version, I guess. (e.g. the ulibc and the old libc implementation) Perhaps that’s the reason buildbots haven’t been failing?

printf function is not a thing in MSVC

I really meant to say that it is not guaranteed to be a function and may be a macro too (i.e. does not export a symbol to link to)

@hanna-kruppe hanna-kruppe changed the title x86_64 MSVC + extern variadic fn: "error LNK2019: unresolved external symbol" x86_64 MSVC coretest::ptr::test_variadic_fnptr: "error LNK2019: unresolved external symbol" Aug 28, 2016
@retep998
Copy link
Member

@nagisa If we can detect whether we're using a new enough MSVC version, we can tell the Rust to tell the linker to link legacy_stdio_definitions.lib which provides printf.

@nagisa
Copy link
Member

nagisa commented Aug 29, 2016

Why? Just use the test helper we have exactly for this issue.

On Aug 29, 2016 7:06 AM, "Peter Atashian" notifications@github.com wrote:

@nagisa https://github.com/nagisa If we can detect whether we're using
a new enough MSVC version, we can tell the Rust to tell the linker to link
legacy_stdio_definitions.lib which provides printf.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#36076 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AApc0kIHqgBhmwimFtgaSuSDYaLKcIyzks5qklrOgaJpZM4Ju9Nn
.

@retep998
Copy link
Member

@nagisa Well sure, that's probably easier and more reliable.

@hanna-kruppe
Copy link
Contributor Author

hanna-kruppe commented Aug 29, 2016

Are the test helpers available to coretest? Because test_variadic_fnptr tests some library features (hashing, clone, equality) that should, ideally, be tested there and not in a run-pass test.

Edit: They are not.

nagisa added a commit to nagisa/rust that referenced this issue Aug 29, 2016
sophiajt pushed a commit to sophiajt/rust that referenced this issue Aug 31, 2016
… r=brson

Fix the test_variadic_ptr fn on printf-less sys

Fixes rust-lang#36076
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants