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

builtin: link user32 for boehm GC on Windows #20767

Merged
merged 1 commit into from
Feb 10, 2024

Conversation

zeozeozeo
Copy link
Contributor

Before this commit, V didn't link with user32 on Windows for compilers other than tcc, so the MessageBoxA call in gcboehm was an unresolved symbol.
This fixes #20724.

Before this commit, V didn't link with user32 on Windows for compilers
other than tcc, so the MessageBoxA call in gcboehm was an unresolved
symbol.
This fixes vlang#20724.
@felipensp felipensp added OS: Windows Bugs/feature requests, that are specific to Windows OS. Build V build error on any OS/CPU architecture. labels Feb 9, 2024
@spytheman
Copy link
Member

Does that happen only on a 32bit windows?

For me, on win11, 64bit, with clang from winlibs.com:
image

@spytheman
Copy link
Member

Hm, the issue says that you are working in a 64bit windows environment 🤔, weird.

@spytheman
Copy link
Member

spytheman commented Feb 9, 2024

The above used this to compile the GC code in thirdparty\libgc\gc.c:

clang -std=c99 -D_DEFAULT_SOURCE   -fwrapv  -D GC_NOT_DLL=1 -D GC_WIN32_THREADS=1 \
-D GC_BUILTIN_ATOMIC=1 -D GC_THREADS=1 -I "D:\programs\v\thirdparty\libgc\include" \
-o "C:\Users\delia\.vmodules\cache\15\15b737768ed213bcb57ac57f6af5d433.module.builtin.o" \
-c "D:\programs\v\thirdparty\libgc\gc.c"

which also passed for me without warnings.

@spytheman
Copy link
Member

What is your clang version @zeozeozeo ?

@zeozeozeo
Copy link
Contributor Author

What is your clang version @zeozeozeo ?

clang version 18.1.0rc
Target: x86_64-pc-windows-msvc
Thread model: posix

@spytheman
Copy link
Member

Can you please try this separately, in the root folder of the project:

clang -std=c99 -D_DEFAULT_SOURCE -fwrapv  -D GC_NOT_DLL=1 -D GC_WIN32_THREADS=1 \
-D GC_BUILTIN_ATOMIC=1 -D GC_THREADS=1 -I "thirdparty\libgc\include" \ 
-c "thirdparty\libgc\gc.c" \
-o x.o

@zeozeozeo
Copy link
Contributor Author

Can you please try this separately, in the root folder of the project:

clang -std=c99 -D_DEFAULT_SOURCE -fwrapv  -D GC_NOT_DLL=1 -D GC_WIN32_THREADS=1 \
-D GC_BUILTIN_ATOMIC=1 -D GC_THREADS=1 -I "thirdparty\libgc\include" \ 
-c "thirdparty\libgc\gc.c" \
-o x.o

this works and outputs the x.o file with 32 warnings (https://pastebin.com/8s6qQCr6)

@zeozeozeo
Copy link
Contributor Author

I use the clang bundled with LLVM: https://github.com/llvm/llvm-project/releases
Perhaps using clang from winlibs.com would fix this issue

@spytheman
Copy link
Member

I use the clang bundled with LLVM: https://github.com/llvm/llvm-project/releases Perhaps using clang from winlibs.com would fix this issue

Yes, I can confirm, it fails with clang from the official release:

d:\programs\v\aaa>clang --version
(built by Brecht Sanders, r5) clang version 17.0.6
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: d:/programs/mingw64/bin

d:\programs\v\aaa>
d:\programs\v\aaa>d:\programs\LLVM\bin\clang.exe --version
clang version 18.1.0rc
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: d:\programs\LLVM\bin

d:\programs\v\aaa>
d:\programs\v\aaa>v -cc clang .

d:\programs\v\aaa>
d:\programs\v\aaa>
d:\programs\v\aaa>v -cc d:\programs\LLVM\bin\clang.exe .
==================
D:\programs\v\aaa\aaa.exe : fatal error LNK1120: 1 unresolved externals
clang: error: linker command failed with exit code 1120 (use -v to see invocation)
...
==================
(Use `v -cg` to print the entire error message)

builder error:
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

https://github.com/vlang/v/issues/new/choose

You can also use #help on Discord: https://discord.gg/vlang


d:\programs\v\aaa>

@spytheman
Copy link
Member

With the change in this PR, it works with the LLVM's clang too.

Excellent work.

@spytheman spytheman merged commit 99579ac into vlang:master Feb 10, 2024
54 checks passed
@zeozeozeo zeozeozeo deleted the luser32-boehm-windows branch February 10, 2024 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build V build error on any OS/CPU architecture. OS: Windows Bugs/feature requests, that are specific to Windows OS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Linker error when compiling with -cc clang on Windows
3 participants