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

function name mangle when create 32bit dll #23689

Closed
kbkpbot opened this issue Feb 11, 2025 · 2 comments
Closed

function name mangle when create 32bit dll #23689

kbkpbot opened this issue Feb 11, 2025 · 2 comments
Assignees
Labels
Bug This tag is applied to issues which reports bugs. OS: Windows Bugs/feature requests, that are specific to Windows OS. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.

Comments

@kbkpbot
Copy link
Contributor

kbkpbot commented Feb 11, 2025

Describe the bug

When create a 32bit dll with MSVC, export function names were mangled, for example

in c code, func function name will become _func or _func@8

Reproduction Steps

code.v

fn C._vinit_caller()
fn C._vcleanup_caller()

@[export: 'func']
@[callconv: 'stdcall']
fn func() {
	C._vinit_caller()
	println('Begin DLL')
	for i in 0 .. 10 {
		println('${i}')
	}
	println('End DLL')
	C._vcleanup_caller()
}
v code.v -shared -cc msvc -m32 
tcc -impdef code.dll -v -o code.def

open the generated code.def file.

Expected Behavior

open the generated code.def file. show :

LIBRARY code.dll

EXPORTS
func
_vcleanup_caller
_vinit_caller

Current Behavior

open the generated code.def file. show :

LIBRARY code.dll

EXPORTS
_func@0
_vcleanup_caller
_vinit_caller

Possible Solution

generate a temp.def which contain export function names, then append a /DEF to the .rsp file

... /DEF:"D:\v\bug\shared\temp.def"

Additional Information/Context

-m32 is skipped by msvc.

V version

V 0.4.9 f9d3bd3

Environment details (OS name and version, etc.)

V full version

V 0.4.9 f9d3bd3

OS

windows, Microsoft Windows 10 企业版 LTSC 19044 64 位

Processor

16 cpus, 64bit, little endian, AMD Ryzen 7 7840H with Radeon 780M Graphics

Memory

14.91GB/27.69GB

V executable

D:\v\v\v\v.exe

V last modified time

2025-01-20 00:57:58

V home dir

OK, value: D:\v\v\v

VMODULES

OK, value: C:\Users\DDT.vmodules

VTMP

OK, value: C:\Users\DDT\AppData\Local\Temp\v_0

Current working dir

OK, value: D:\v\bug\shared

Git version

git version 2.43.0.windows.1

V git status

weekly.2025.03-5-gf9d3bd39-dirty (107 commit(s) behind V master)

.git/config present

true

cc version

N/A

gcc version

N/A

clang version

N/A

msvc version

用于 x86 的 Microsoft (R) C/C++ 优化编译器 19.39.33523 版

tcc version

tcc version 0.9.28rc 2024-12-30_mob@68000c01* (x86_64 Windows)

tcc git status

N/A

emcc version

N/A

glibc version

N/A

@kbkpbot kbkpbot added the Bug This tag is applied to issues which reports bugs. label Feb 11, 2025
@kbkpbot kbkpbot self-assigned this Feb 11, 2025
Copy link

Connected to Huly®: V_0.6-22110

@kbkpbot
Copy link
Contributor Author

kbkpbot commented Feb 11, 2025

default 64bit has no this problem

@felipensp felipensp added OS: Windows Bugs/feature requests, that are specific to Windows OS. Unit: cgen Bugs/feature requests, that are related to the default C generating backend. labels Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. OS: Windows Bugs/feature requests, that are specific to Windows OS. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.
Projects
None yet
Development

No branches or pull requests

2 participants