Skip to content

raw-dylib compilation fails targeting nightly-i686-pc-windows-gnu when function name begins with 'L' #104453

Closed
@kennykerr

Description

@kennykerr

While testing raw-dylib support against nightly-i686-pc-windows-gnu I noticed that it would fail with a cryptic error.

Here's a minimal repro: https://github.com/kennykerr/repro-raw-dylib

#![feature(raw_dylib)]
#![feature(native_link_modifiers_verbatim)]

#[link(name = "kernel32.dll", kind = "raw-dylib", modifiers = "+verbatim", import_name_type = "undecorated")]
extern "stdcall" {
    fn LoadLibraryA(name: *const u8) -> isize;
}

#[test]
fn test() {
    assert_ne!(0, unsafe { LoadLibraryA("kernel32.dll\0".as_ptr()) });
}

This compiles and runs cleanly i686-pc-windows-msvc but fails on i686-pc-windows-gnu with the following error:

error: assembler label 'LoadLibraryA' can not be undefined
rust version 1.67.0-nightly (e631891f7 2022-11-13)

@dpaoliello pointed out that it seems that if we have an undecorated symbol that begins with 'L' (yep) then LLVM assumes that it is an assembler label, hence the error.

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions