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

unresolved external symbol _DllMain #96423

Closed
ghost opened this issue Apr 26, 2022 · 3 comments · Fixed by #96444
Closed

unresolved external symbol _DllMain #96423

ghost opened this issue Apr 26, 2022 · 3 comments · Fixed by #96444
Assignees
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. O-windows-msvc Toolchain: MSVC, Operating system: Windows regression-untriaged Untriaged performance or correctness regression. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ghost
Copy link

ghost commented Apr 26, 2022

Code

I tried this code:

[lib]
crate_type = ["cdylib"]
#[no_mangle]
extern "system" fn DllMain(module: HINSTANCE, reason: u32, _reserved: *mut c_void) -> i32 {
    if reason == DLL_PROCESS_ATTACH {
        unsafe {
            DisableThreadLibraryCalls(module);
        }

        thread::spawn(move || unsafe { dll_attach() });

        return 1;
    }

    return 0;
}
error: linking with `link.exe` failed: exit code: 1120
symbols.o : error LNK2001: unresolved external symbol _DllMain
  Hint on symbols that are defined and could potentially match:
    _DllMain@12
C:\Users\random\Desktop\project\target\i686-pc-windows-msvc\debug\deps\test.dll : fatal error LNK1120: 1 unresolved externals

It seems like #[no_mangle] is not working anymore.

Version it worked on

rustc --version --verbose:

rustc 1.62.0-nightly (18f314e70 2022-04-24)
binary: rustc
commit-hash: 18f314e7027fe7084aaab8620c624a0d7bd29e70
commit-date: 2022-04-24
host: x86_64-pc-windows-msvc
release: 1.62.0-nightly
LLVM version: 14.0.1

Version with regression

rustc --version --verbose:

rustc 1.62.0-nightly (055bf4ccd 2022-04-25)
binary: rustc
commit-hash: 055bf4ccd521c2c2185166c86951be7be145727c
commit-date: 2022-04-25
host: x86_64-pc-windows-msvc
release: 1.62.0-nightly
LLVM version: 14.0.1

@ghost ghost added C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Apr 26, 2022
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Apr 26, 2022
@petrochenkov
Copy link
Contributor

Probably another issue with stdcall symbol name mangling uncovered by #95604.

cc #50176 #67399 #17806
cc @nbdd0121

@nbdd0121
Copy link
Contributor

Hmm, seems that we would have to replicate the name decoration scheme in Rust?

@nbdd0121
Copy link
Contributor

@rustbot claim

@wesleywiser wesleywiser added A-linkage Area: linking into static, shared libraries and binaries O-windows-msvc Toolchain: MSVC, Operating system: Windows labels Apr 26, 2022
@apiraino apiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 28, 2022
@bors bors closed this as completed in 5560c51 Apr 29, 2022
@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. O-windows-msvc Toolchain: MSVC, Operating system: Windows regression-untriaged Untriaged performance or correctness regression. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants