llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.32k stars 11.21k forks source link

Improper Name Mangling for Windows Kernel APIs #19482

Closed llvmbot closed 10 years ago

llvmbot commented 10 years ago
Bugzilla Link 19108
Resolution INVALID
Resolved on Mar 26, 2014 10:31
Version unspecified
OS Windows 2000
Attachments Preprocessor output of CL.exe
Reporter LLVM Bugzilla Contributor
CC @asl,@rnk

Extended Description

Clang is emitting incorrect name manglings which result in failed linking.

For example: clang emits impKeInitializeEvent, while cl emits impKeInitializeEvent@12

Similar issues exist for KeWaitForSingleObject IoDetachDevice IoDeleteDevice PoStartNextPowerIrp PoCallDriver IoCreateDevice IoAttachDeviceToDeviceStack KeSetEvent

Attached is the source code, as preprocessed by cl.exe

rnk commented 10 years ago

I know nothing about building Windows drivers, but probably we should add support to clang-cl for the flag equivalent to -mrtd.

asl commented 10 years ago

clang performs correct here. The switch to stdcall calling convention is performed via the command line.

llvmbot commented 10 years ago

After further discussion on IRC. We realized that by specifying: clang-cl -Xclang -mrtd -c msvc-preprocessor.c

The output does properly link. This specifies the default calling convention as stdcall instead of cdecl.