xmake icon indicating copy to clipboard operation
xmake copied to clipboard

Custom rules not linking obj files in VS generator

Open maximegmd opened this issue 7 months ago • 4 comments

Xmake Version

v2.8.5+HEAD.debbd3ac3

Operating System Version and Architecture

Windows 11

Describe Bug

When using a custom rule with batchcmds to compile files the obj files are not linked in the state library.

WIth the repro project:

xmake

checking for Microsoft Visual Studio (x64) version ... 2022
checking for Microsoft C/C++ Compiler (x64) version ... 19.37.32825
[ 22%]: compiling.test lib.test
[ 22%]: compiling.release main.cpp
[ 44%]: compiling.release dummy.cpp
[ 55%]: archiving.release libhello.lib
[ 77%]: linking.release hello.exe
[100%]: build ok, spent 0.344s

With the vs project:

Build started...
1>------ Build started: Project: libhello, Configuration: release x64 ------
1>lib.cpp
1>dummy.cpp
1>libhello.vcxproj -> F:\Dev\repro\build\windows\x64\release\libhello.lib
2>------ Build started: Project: hello, Configuration: release x64 ------
2>main.cpp
2>main.obj : error LNK2019: unresolved external symbol "int __cdecl test_func(int,int)" (?test_func@@YAHHH@Z) referenced in function main
2>..\..\build\windows\x64\release\hello.exe : fatal error LNK1120: 1 unresolved externals
2>Done building project "hello.vcxproj" -- FAILED.
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build started at 1:35 PM and took 00.622 seconds ==========

Expected Behavior

Added obj files from batchcmds are included in link phase using the vs project generator.

Project Configuration

repro.zip

Additional Information and Error Logs

NA

maximegmd avatar Nov 08 '23 14:11 maximegmd

why do not use vsxmake generator? xmake project -k vsxmake

Although vs generator also supports custom scripts, it has some limitations and is not as well supported as vsxmake.

For example, right now it doesn't support adding object only files to vs projects.

waruqi avatar Nov 09 '23 02:11 waruqi

For a couple reasons:

  • Building is slower with vsxmake
  • Cleaning my solution takes almost 2 minutes

Everytime I give vsxmake a try again because I encounter an issue with the vs generator, there is way more friction and difficulties compared to the vs generator. As it is I can't use vsxmake, I can't justify 2 minutes to clean my solution and 3x longer compile times.

maximegmd avatar Nov 09 '23 09:11 maximegmd

For a couple reasons:

  • Building is slower with vsxmake
  • Cleaning my solution takes almost 2 minutes

Everytime I give vsxmake a try again because I encounter an issue with the vs generator, there is way more friction and difficulties compared to the vs generator. As it is I can't use vsxmake, I can't justify 2 minutes to clean my solution and 3x longer compile times.

Calling xmake to build a project shouldn't be this slow. Is it also slow if you run the xmake command directly to build?

waruqi avatar Nov 09 '23 14:11 waruqi

Adding a bit of context here, building/cleaning is slower for @maximegmd because he's building/cleaning the whole solution. Making VS call xmake config and xmake clean on every target. It's not slow for a single target.

I think we can improve the vsxmake generator to work a bit like Unreal Engine Visual Studio projects.

SirLynix avatar Nov 09 '23 14:11 SirLynix