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

add_ldflags("-subsystem:windows")只在64位上生效 #5947

Closed
1143910315 opened this issue Dec 8, 2024 · 5 comments
Closed

add_ldflags("-subsystem:windows")只在64位上生效 #5947

1143910315 opened this issue Dec 8, 2024 · 5 comments
Labels

Comments

@1143910315
Copy link
Contributor

Xmake 版本

2.9.6+HEAD.abd15c255

操作系统版本和架构

Windows 10 专业版 22H2 19045.5011

描述问题

我使用add_ldflags("-subsystem:windows"),为什么只在64位上生效,而x86上提示被忽略?

期待的结果

x86应该也可以隐藏控制台才对吧

工程配置

主工程

add_rules("mode.debug", "mode.release", "mode.releasedbg")
add_rules("plugin.vsxmake.autoupdate")
if is_mode("debug") then
    set_runtimes("MDd")
    add_requires("webui", {debug = true})
    add_requires("date", {debug = true})
else
    set_runtimes("MD")
    add_requires("webui")
    add_requires("date")
end
includes("ui/xmake.lua")

target("WebUIXMakeTemplate")
    add_packages(
        "webui",
        "date"
    )
    add_cxflags(
        "cl::/utf-8"
    )
    set_warnings("allextra")
    if is_mode("debug") then
        add_defines("_DEBUG")
        set_symbols("debug", "edit")
    else
        if is_plat("windows") then
            add_ldflags("-subsystem:windows")
        end
    end
    set_kind("binary")
    add_deps("ui")
    add_includedirs("src")
    add_headerfiles("src/**.h")
    add_files("src/**.cpp")
    set_languages("clatest", "cxxlatest")

子工程

target("ui")
    add_extrafiles("*.json")
    add_extrafiles("*.ts")
    add_extrafiles("*.js")
    add_extrafiles("*.html")
    add_extrafiles("src/**")
    add_extrafiles("public/**")
    on_build(function (target)
        local option = import("core.base.option")
        local oldir = os.cd(os.scriptdir())
        os.setenv("UI_BUILD_DIR", target:targetdir().."/dist")
        if os.host() == "windows" then
            if option.get("verbose") then
                os.exec("pnpm.cmd build --emptyOutDir")
            else
                os.run("pnpm.cmd build --emptyOutDir")
            end
        else
            if option.get("verbose") then
                os.exec("pnpm build --emptyOutDir")
            else
                os.run("pnpm build --emptyOutDir")
            end
        end
        os.cd(oldir)
    end)

附加信息和错误日志

Run xmake -v -y
  xmake -v -y
  shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
  env:
    PNPM_HOME: C:\Users\runneradmin\setup-pnpm\node_modules\.bin
checking for cl.exe ... C:\Program Files\Microsoft Visual Studio\[2](https://github.com/1143910315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:2)022\Enterprise\VC\Tools\MSVC\14.42.[3](https://github.com/1143910315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:3)4433\bin\HostX64\x86\cl.exe
checking for the c++ compiler (cxx) ... cl.exe
checking for C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\1[4](https://github.com/1143910315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:4).42.34433\bin\HostX64\x86\cl.exe ... ok
checking for flags (-O2) ... ok
checking for the c++ compiler (cxx) ... cl.exe

> [email protected] build D:\a\WebUIXMakeTemplate\WebUIXMakeTemplate\ui
> run-p type-check "build-only {@}" -- "--emptyOutDir"


> [email protected] type-check D:\a\WebUIXMakeTemplate\WebUIXMakeTemplate\ui
> vue-tsc --build


> [email protected] build-only D:\a\WebUIXMakeTemplate\WebUIXMakeTemplate\ui
> vite build "--emptyOutDir"

checking for flags (cl_external_includedir) ... ok
checking for flags (/utf-8) ... ok
checking for flags (-DNDEBUG) ... ok
[ 62%]: compiling.release src\main.cpp
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.42.34433\\bin\\HostX64\\x86\\cl.exe" -c -nologo -W4 -O2 -std:c++latest -MD -Isrc /EHsc -external:W0 -external:IC:\Users\runneradmin\AppData\Local\.xmake\packages\w\webui\2.4.2\1ec[5](https://github.com/1143910315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:5)dda831b846d1a0da8ced4f9b0c46\include -external:W0 -external:IC:\Users\runneradmin\AppData\Local\.xmake\packages\d\date\2024.05.14\a7[6](https://github.com/1143910315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:7)763f8a0c143f6ae2dbb658fe37985\include /utf-8 -DNDEBUG -Fobuild\.objs\WebUIXMakeTemplate\windows\x86\release\src\main.cpp.obj src\main.cpp
[ 62%]: compiling.release src\thread\ThreadPool.cpp
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.42.34433\\bin\\HostX64\\x86\\cl.exe" -c -nologo -W4 -O2 -std:c++latest -MD -Isrc /EHsc -external:W0 -external:IC:\Users\runneradmin\AppData\Local\.xmake\packages\w\webui\2.4.2\1ec5dda831b846d1a0da8ced4f9b0c46\include -external:W0 -external:IC:\Users\runneradmin\AppData\Local\.xmake\packages\d\date\2024.05.14\a[7](https://github.com/1143910315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:8)6763f8a0c143f6ae2dbb658fe37985\include /utf-8 -DNDEBUG -Fobuild\.objs\WebUIXMakeTemplate\windows\x[8](https://github.com/1143910315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:9)6\release\src\thread\ThreadPool.cpp.obj src\thread\ThreadPool.cpp
vite v6.0.3 building for production...
checking for flags (cl_sourceDependencies) ... ok
<script src="/webui.js"> in "/index.html" can't be bundled without type="module" attribute
transforming...
✓ 1450 modules transformed.
rendering chunks...
computing gzip size...
../build/windows/x86/release/dist/index.html                             0.57 kB │ gzip:  0.35 kB
../build/windows/x86/release/dist/assets/AboutView-CSIvawM[9](https://github.com/1143910315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:10).css          0.09 kB │ gzip:  0.[10](https://github.com/1143910315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:11) kB
../build/windows/x86/release/dist/assets/HomeView--a6GGwdj.css           1.06 kB │ gzip:  0.42 kB
../build/windows/x86/release/dist/assets/index-CRPeCLtU.css             [13](https://github.com/1143910315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:14).86 kB │ gzip:  3.60 kB
../build/windows/x86/release/dist/assets/InteractionView-CkJYQThS.css   16.66 kB │ gzip:  2.18 kB
../build/windows/x86/release/dist/assets/AboutView-Dvy73_es.js           0.23 kB │ gzip:  0.20 kB
../build/windows/x86/release/dist/assets/HomeView-DxLX_3dp.js            9.53 kB │ gzip:  3.33 kB
../build/windows/x86/release/dist/assets/InteractionView-D0RKPK0p.js    22.81 kB │ gzip:  8.30 kB
../build/windows/x86/release/dist/assets/index-j-kUeCLH.js             102.62 kB │ gzip: 42.13 kB
✓ built in 5.63s
checking for C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\[14](https://github.com/1143910315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:15).42.34433\bin\HostX64\x86\link.exe ... ok
checking for flags (-subsystem:windows) ... no
[ 87%]: linking.release WebUIXMakeTemplate.exe
"C:\\Program Files\\Microsoft Visual Studio\\[20](https://github.com/1143910315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:21)22\\Enterprise\\VC\\Tools\\MSVC\\14.42.34433\\bin\\HostX64\\x86\\link.exe" -nologo -dynamicbase -nxcompat -machine:x86 -libpath:C:\Users\runneradmin\AppData\Local\.xmake\packages\w\webui\2.4.2\1ec5dda831b846d1a0da8ced4f9b0c46\lib -libpath:C:\Users\runneradmin\AppData\Local\.xmake\packages\d\date\2024.05.14\a76763f8a0c143f6ae2dbb658fe37985\lib /opt:ref /opt:icf webui.lib date-tz.lib user32.lib advapi32.lib ole32.lib shell32.lib -out:build\windows\x86\release\WebUIXMakeTemplate.exe build\.objs\WebUIXMakeTemplate\windows\x86\release\src\main.cpp.obj build\.objs\WebUIXMakeTemplate\windows\x86\release\src\thread\ThreadPool.cpp.obj
checking for cl.exe ... C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.42.34433\bin\HostX64\x86\cl.exe
checking for the c compiler (cc) ... cl.exe
[100%]: build ok, spent [21](https://github.com/1143910315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:22).875s
warning: add_ldflags("-subsystem:windows") is ignored, please pass `{force = true}` or call `set_policy("check.auto_ignore_flags", false)` if you want to set it.
@1143910315 1143910315 added the bug label Dec 8, 2024
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: add_ldflags("-subsystem:windows") only takes effect on 64-bit

Xmake version

2.9.6+HEAD.abd15c255

Operating system version and architecture

Windows 10 Pro 22H2 19045.5011

Describe the problem

I use add_ldflags("-subsystem:windows"), why does it only take effect on 64-bit, but the prompt is ignored on x86?

Expected results

x86 should also be able to hide the console, right?

Project configuration

Main project

add_rules("mode.debug", "mode.release", "mode.releasedbg")
add_rules("plugin.vsxmake.autoupdate")
if is_mode("debug") then
    set_runtimes("MDd")
    add_requires("webui", {debug = true})
    add_requires("date", {debug = true})
else
    set_runtimes("MD")
    add_requires("webui")
    add_requires("date")
end
includes("ui/xmake.lua")

target("WebUIXMakeTemplate")
    add_packages(
        "webui",
        "date"
    )
    add_cxflags(
        "cl::/utf-8"
    )
    set_warnings("allextra")
    if is_mode("debug") then
        add_defines("_DEBUG")
        set_symbols("debug", "edit")
    else
        if is_plat("windows") then
            add_ldflags("-subsystem:windows")
        end
    end
    set_kind("binary")
    add_deps("ui")
    add_includedirs("src")
    add_headerfiles("src/**.h")
    add_files("src/**.cpp")
    set_languages("clatest", "cxxlatest")

subproject

target("ui")
    add_extrafiles("*.json")
    add_extrafiles("*.ts")
    add_extrafiles("*.js")
    add_extrafiles("*.html")
    add_extrafiles("src/**")
    add_extrafiles("public/**")
    on_build(function (target)
        local option = import("core.base.option")
        local oldir = os.cd(os.scriptdir())
        os.setenv("UI_BUILD_DIR", target:targetdir().."/dist")
        if os.host() == "windows" then
            if option.get("verbose") then
                os.exec("pnpm.cmd build --emptyOutDir")
            else
                os.run("pnpm.cmd build --emptyOutDir")
            end
        else
            if option.get("verbose") then
                os.exec("pnpm build --emptyOutDir")
            else
                os.run("pnpm build --emptyOutDir")
            end
        end
        os.cd(oldir)
    end)

Additional information and error logs

Run xmake -v -y
  xmake -v -y
  shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
  env:
    PNPM_HOME: C:\Users\runneradmin\setup-pnpm\node_modules\.bin
checking for cl.exe ... C:\Program Files\Microsoft Visual Studio\[2](https://github.com/1143910315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:2)022\Enterprise\VC\Tools\MSV C\14.42.[3](https://github.com/1143910315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:3)4433\bin\HostX64\x86\cl.exe
checking for the c++ compiler (cxx) ... cl.exe
checking for C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\1[4](https://github.com/1143910315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:4).42.34433\bin\ HostX64\x86\cl.exe ... OK
checking for flags (-O2) ... ok
checking for the c++ compiler (cxx) ... cl.exe

> [email protected] build D:\a\WebUIXMakeTemplate\WebUIXMakeTemplate\ui
> run-p type-check "build-only {@}" -- "--emptyOutDir"


> [email protected] type-check D:\a\WebUIXMakeTemplate\WebUIXMakeTemplate\ui
> vue-tsc --build


> [email protected] build-only D:\a\WebUIXMakeTemplate\WebUIXMakeTemplate\ui
> vite build "--emptyOutDir"

checking for flags (cl_external_includedir) ... ok
checking for flags (/utf-8) ... ok
checking for flags (-DNDEBUG) ... ok
[62%]: compiling.release src\main.cpp
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.42.34433\\bin\\HostX64\\x86\\cl.exe" -c - nologo -W4 -O2 -std:c++latest -MD -Isrc /EHsc -external:W0 -external:IC:\Users\runneradmin\AppData\Local\.xmake\packages\w\webui\2.4.2\1ec[5](https://github.com/1143910 315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:5)dda831b846d1a0da8ced4f9b0c46\include -external:W0 -external:IC:\Users\runneradmin\AppData\Local\.xmake\packages\d\date\2024.05.14\a7[6](https://github.com/114391 0315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:7)763f8a0c143f6ae2dbb658fe37985\include /utf-8 -DNDEBUG -Fobuild\.objs\WebUIXMakeTemplate\windows\x86\release\src\main.cpp.obj src\main.cpp
[62%]: compiling.release src\thread\ThreadPool.cpp
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.42.34433\\bin\\HostX64\\x86\\cl.exe" -c - nologo -W4 -O2 -std:c++latest -MD -Isrc /EHsc -external:W0 -external:IC:\Users\runneradmin\AppData\Local\.xmake\packages\w\webui\2.4.2\1ec5dda831b846d1a0da8ced4f9b0c46\include -external:W0 -external:IC:\Users\runneradmin\AppData\Local\.xmake\packages\d\date\2024.05.14\a[7](https://github.com/1143910 315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:8)6763f8a0c143f6ae2dbb658fe37985\include /utf-8-DNDEBUG -Fobuild\.objs\WebUIXMakeTemplate\windows\x[8](https://github.com/1143910315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:9)6\release\src\thread \ThreadPool.cpp.obj src\thread\ThreadPool.cpp
vite v6.0.3 building for production...
checking for flags (cl_sourceDependencies) ... ok
<script src="/webui.js"> in "/index.html" can't be bundled without type="module" attribute
transforming...
✓ 1450 modules transformed.
rendering chunks...
computing gzip size...
../build/windows/x86/release/dist/index.html 0.57 kB │ gzip: 0.35 kB
../build/windows/x86/release/dist/assets/AboutView-CSIvawM[9](https://github.com/1143910315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:10) .css 0.09 kB │ gzip: 0.[10](https://github.com/1143910315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:11) kB
../build/windows/x86/release/dist/assets/HomeView--a6GGwdj.css 1.06 kB │ gzip: 0.42 kB
../build/windows/x86/release/dist/assets/index-CRPeCLtU.css [13](https://github.com/1143910315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10: 14).86 kB │ gzip: 3.60 kB
../build/windows/x86/release/dist/assets/InteractionView-CkJYQThS.css 16.66 kB │ gzip: 2.18 kB
../build/windows/x86/release/dist/assets/AboutView-Dvy73_es.js 0.23 kB │ gzip: 0.20 kB
../build/windows/x86/release/dist/assets/HomeView-DxLX_3dp.js 9.53 kB │ gzip: 3.33 kB
../build/windows/x86/release/dist/assets/InteractionView-D0RKPK0p.js 22.81 kB │ gzip: 8.30 kB
../build/windows/x86/release/dist/assets/index-j-kUeCLH.js 102.62 kB │ gzip: 42.13 kB
✓ built in 5.63s
checking for C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\[14](https://github.com/1143910315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:15).42.34433\bin\HostX64 \x86\link.exe ...ok
checking for flags (-subsystem:windows) ... no
[87%]: linking.release WebUIXMakeTemplate.exe
"C:\\Program Files\\Microsoft Visual Studio\\[20](https://github.com/1143910315/WebUIXMakeTemplate/actions/runs/12222823918/job/340 93596204#step:10:21)22\\Enterprise\\VC\\Tools\\MSVC\\14.42.34433\\bin\\HostX64\\x86\\link.exe" -nologo -dynamicbase -nxcompat -machine:x86 -libpath:C:\Users\runneradmin\AppData\Local\.xmake\packages\w\webui\2.4.2\1ec5dda831b846d1a0da8ced4f9b0c46\lib -libpath:C:\Users\runneradmin\AppData\Local\.xmake\packages\d\date\2024.05.14\a76763f8a0c143f6ae2dbb658fe37985\lib /opt:ref /opt:icf webui.lib date-tz.lib user32.lib advapi32 .lib ole32.lib shell32.lib -out:build\windows\x86\release\WebUIXMakeTemplate.exe build\.objs\WebUIXMakeTemplate\windows\x86\release\src\main.cpp.obj build\.objs\WebUIXMakeTemplate\windows\x86\release\src\thread \ThreadPool.cpp.obj
checking for cl.exe ... C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.42.34433\bin\HostX64\x86\cl.exe
checking for the c compiler (cc) ... cl.exe
[100%]: build ok, spent [21](https://github.com/1143910315/WebUIXMakeTemplate/actions/runs/12222823918/job/34093596204#step:10:22).875s
warning: add_ldflags("-subsystem:windows") is ignored, please pass `{force = true}` or call `set_policy("check.auto_ignore_flags", false)` if you want to set it.

@waruqi
Copy link
Member

waruqi commented Dec 8, 2024

warning: add_ldflags("-subsystem:windows") is ignored, please pass {force = true} or call set_policy("check.auto_ignore_flags", false) if you want to set it.

提示不是很明显么,按提示操作

@1143910315
Copy link
Contributor Author

warning: add_ldflags("-subsystem:windows") is ignored, please pass {force = true} or call set_policy("check.auto_ignore_flags", false) if you want to set it.

提示不是很明显么,按提示操作

呃,试了一下确实可以,但是总感觉怪怪的,x64就不用这个{force = true}

@1143910315
Copy link
Contributor Author

也行吧

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


That's okay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants