Rollup merge of #104511 - dpaoliello:privateglobalworkaround, r=michaelwoerister
Mark functions created for `raw-dylib` on x86 with DllImport storage class Fix for #104453 ## Issue Details On x86 Windows, LLVM uses 'L' as the prefix for any private global symbols (`PrivateGlobalPrefix`), so when the `raw-dylib` feature creates an undecorated function symbol that begins with an 'L' LLVM misinterprets that as a private global symbol that it created and so fails the compilation at a later stage since such a symbol must have a definition. ## Fix Details Mark the function we are creating for `raw-dylib` with `DllImport` storage class (this was already being done for MSVC at a later point for `callee::get_fn` but not for GNU (due to "backwards compatibility")): this will cause LLVM to prefix the name with `__imp_` and so it won't mistake it for a private global symbol.
This commit is contained in:
commit
cc2397b2cd
6 changed files with 30 additions and 1 deletions
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#[link(name = "extern", kind = "raw-dylib", import_name_type = "undecorated")]
|
||||
extern "C" {
|
||||
fn LooksLikeAPrivateGlobal(i: i32);
|
||||
fn cdecl_fn_undecorated(i: i32);
|
||||
#[link_name = "cdecl_fn_undecorated2"]
|
||||
fn cdecl_fn_undecorated_renamed(i: i32);
|
||||
|
|
@ -84,6 +85,13 @@ extern {
|
|||
|
||||
pub fn main() {
|
||||
unsafe {
|
||||
// Regression test for #104453
|
||||
// On x86 LLVM uses 'L' as the prefix for private globals (PrivateGlobalPrefix), which
|
||||
// causes it to believe that undecorated functions starting with 'L' are actually temporary
|
||||
// symbols that it generated, which causes a later check to fail as the symbols we are
|
||||
// creating don't have definitions (whereas all temporary symbols do).
|
||||
LooksLikeAPrivateGlobal(13);
|
||||
|
||||
cdecl_fn_undecorated(1);
|
||||
cdecl_fn_undecorated_renamed(10);
|
||||
cdecl_fn_noprefix(2);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void _cdecl LooksLikeAPrivateGlobal(int i) {
|
||||
printf("LooksLikeAPrivateGlobal(%d)\n", i);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void _cdecl cdecl_fn_undecorated(int i) {
|
||||
printf("cdecl_fn_undecorated(%d)\n", i);
|
||||
fflush(stdout);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
LIBRARY extern
|
||||
EXPORTS
|
||||
LooksLikeAPrivateGlobal
|
||||
cdecl_fn_undecorated
|
||||
cdecl_fn_undecorated2
|
||||
cdecl_fn_noprefix
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
LIBRARY extern
|
||||
EXPORTS
|
||||
LooksLikeAPrivateGlobal
|
||||
cdecl_fn_undecorated
|
||||
cdecl_fn_undecorated2
|
||||
cdecl_fn_noprefix
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
LooksLikeAPrivateGlobal(13)
|
||||
cdecl_fn_undecorated(1)
|
||||
cdecl_fn_undecorated2(10)
|
||||
cdecl_fn_noprefix(2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue