Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/tools/msc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,17 @@
function msc.getldflags(cfg)
local map = iif(cfg.kind ~= p.STATICLIB, msc.linkerFlags, msc.librarianFlags)
local flags = config.mapFlags(cfg, map)

if cfg.entrypoint then
-- /ENTRY requires that /SUBSYSTEM is set.
if cfg.kind == "ConsoleApp" then
table.insert(flags, "/SUBSYSTEM:CONSOLE")
elseif cfg.kind ~= "WindowedApp" then -- already set by above map
table.insert(flags, "/SUBSYSTEM:NATIVE") -- fallback
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm, cfg.kind == "WindowedApp" is set by the above mapFlags call?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there is just above (line 290)

		kind = {
			SharedLib = "/DLL",
			WindowedApp = "/SUBSYSTEM:WINDOWS"
		},

table.insert(flags, '/ENTRY:' .. cfg.entrypoint)
end

table.insert(flags, 1, "/NOLOGO")

-- Ignore default libraries
Expand Down
24 changes: 24 additions & 0 deletions tests/tools/test_msc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,30 @@
test.contains("/fsanitize=fuzzer", msc.getcxxflags(cfg))
end

--
-- Check entrypoint linker options.
--

function suite.ldflags_entrypoint_windows()
kind "WindowedApp"
entrypoint "main2"
prepare()
test.contains("/SUBSYSTEM:WINDOWS", msc.getldflags(cfg))
test.contains("/ENTRY:main2", msc.getldflags(cfg))
end
function suite.ldflags_entrypoint_console()
kind "ConsoleApp"
entrypoint "main2"
prepare()
test.contains("/SUBSYSTEM:CONSOLE", msc.getldflags(cfg))
test.contains("/ENTRY:main2", msc.getldflags(cfg))
end
function suite.ldflags_entrypoint_other()
entrypoint "main2"
prepare()
test.contains("/SUBSYSTEM:NATIVE", msc.getldflags(cfg))
test.contains("/ENTRY:main2", msc.getldflags(cfg))
end

--
-- Check handling of additional linker options.
Expand Down