Skip to content

Commit

Permalink
fix mold option and use --as-needed flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthapz committed Oct 6, 2023
1 parent b9a24e0 commit 6a94051
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 43 deletions.
8 changes: 8 additions & 0 deletions examples/log/console-logger/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@ target("console-logger")

add_files("src/main.cpp")

add_ldflags("-Wl,--as-needed")
add_shflags("-Wl,--as-needed")

if has_config("mold") then
add_ldflags("-Wl,-fuse-ld=mold")
add_shflags("-Wl,-fuse-ld=mold")
end

set_group("examples/stormkit-log")
8 changes: 8 additions & 0 deletions examples/log/file-logger/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@ target("file-logger")

add_files("src/main.cpp")

add_ldflags("-Wl,--as-needed")
add_shflags("-Wl,--as-needed")

if has_config("mold") then
add_ldflags("-Wl,-fuse-ld=mold")
add_shflags("-Wl,-fuse-ld=mold")
end

set_group("examples/stormkit-log")
8 changes: 8 additions & 0 deletions examples/wsi/event_handler/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@ target("event_handler")
add_files("win32/*.manifest")
end

add_ldflags("-Wl,--as-needed")
add_shflags("-Wl,--as-needed")

if has_config("mold") then
add_ldflags("-Wl,-fuse-ld=mold")
add_shflags("-Wl,-fuse-ld=mold")
end

set_group("examples/stormkit-wsi")
8 changes: 8 additions & 0 deletions examples/wsi/polling/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@ target("polling")
add_files("win32/*.manifest")
end

add_ldflags("-Wl,--as-needed")
add_shflags("-Wl,--as-needed")

if has_config("mold") then
add_ldflags("-Wl,-fuse-ld=mold")
add_shflags("-Wl,-fuse-ld=mold")
end

set_group("examples/stormkit-wsi")
34 changes: 21 additions & 13 deletions tests/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,34 @@ local enabled_tests = {}
for name, _ in pairs(modules) do
if name == "core" or has_config("enable_" .. name) then
target(name .. "-tests")
set_group("tests")
set_kind("binary")
set_languages("cxxlatest", "clatest")
set_group("tests")
set_kind("binary")
set_languages("cxxlatest", "clatest")

add_files("src/main.cpp", path.join("src", name, "**.cpp"), "src/Test.mpp", "src/Test.cpp")
add_files("src/main.cpp", path.join("src", name, "**.cpp"), "src/Test.mpp", "src/Test.cpp")

add_deps("stormkit-" .. name)
add_ldflags("-Wl,--as-needed")
add_shflags("-Wl,--as-needed")

if has_config("mold") then
add_ldflags("-Wl,-fuse-ld=mold")
add_shflags("-Wl,-fuse-ld=mold")
end

add_deps("stormkit-" .. name)
target_end()

table.append(enabled_tests, name .. "-tests")
end
end

target("tests")
set_group("tests")
set_kind("phony")
add_deps(table.unwrap(enabled_tests))
set_group("tests")
set_kind("phony")
add_deps(table.unwrap(enabled_tests))

on_run(function(target)
for _, subtarget in ipairs(target:deps()) do
subtarget:run()
end
end)
on_run(function(target)
for _, subtarget in ipairs(target:deps()) do
subtarget:run()
end
end)
56 changes: 26 additions & 30 deletions xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ modules = {
image = {
packages = { "gli", "libpng", "libjpeg-turbo" },
modulename = "Image",
public_deps = { "stormkit-core" }
public_deps = { "stormkit-core" },
},
main = {
modulename = "Main",
Expand All @@ -58,17 +58,19 @@ modules = {
modulename = "Wsi",
public_deps = { "stormkit-core" },
deps = { "stormkit-log" },
packages = is_plat("linux") and { "libxkbcommon",
"libxkbcommon-x11",
"libxcb",
"xcb-util-keysyms",
"xcb-util",
"xcb-util-wm",
"xcb-util-errors",
"wayland",
"wayland-protocols",
} or nil,
frameworks = is_plat("macosx") and {"CoreFoundation", "Foundation", "AppKit", "Metal", "IOKit", "QuartzCore" } or nil,
packages = is_plat("linux") and {
"libxkbcommon",
"libxkbcommon-x11",
"libxcb",
"xcb-util-keysyms",
"xcb-util",
"xcb-util-wm",
"xcb-util-errors",
"wayland",
"wayland-protocols",
} or nil,
frameworks = is_plat("macosx") and { "CoreFoundation", "Foundation", "AppKit", "Metal", "IOKit", "QuartzCore" }
or nil,
custom = function()
if is_plat("linux") then
add_rules("wayland.protocols")
Expand Down Expand Up @@ -124,9 +126,9 @@ modules = {
-- "VULKAN_HPP_NO_EXCEPTIONS", uncomment when vk::raii is supported without exceptions
},
custom = function()
remove_files("src/Gpu/Execution/**.cpp")
remove_files("modules/stormkit/Gpu/Execution.mpp")
remove_files("modules/stormkit/Gpu/Execution/**.mpp")
remove_files("src/Gpu/Execution/**.cpp")
remove_files("modules/stormkit/Gpu/Execution.mpp")
remove_files("modules/stormkit/Gpu/Execution/**.mpp")
if is_plat("linux") then
add_defines("VK_USE_PLATFORM_XCB_KHR")
add_defines("VK_USE_PLATFORM_WAYLAND_KHR")
Expand Down Expand Up @@ -273,14 +275,8 @@ add_cxflags(
add_cxflags("-fstrict-aliasing", "-Wstrict-aliasing", { tools = { "clang", "gcc" } })
add_mxflags("-fstrict-aliasing", "-Wstrict-aliasing", { tools = { "clang", "gcc" } })

add_cxxflags(
"-Wno-missing-field-initializers",
{ tools = { "clang" } }
)
add_mxxflags(
"-Wno-missing-field-initializers",
{ tools = { "clang" } }
)
add_cxxflags("-Wno-missing-field-initializers", { tools = { "clang" } })
add_mxxflags("-Wno-missing-field-initializers", { tools = { "clang" } })

if not is_plat("windows") and not is_plat("macosx") then
add_syslinks("stdc++_libbacktrace")
Expand Down Expand Up @@ -311,8 +307,6 @@ option_end()

option("mold")
set_default(false)
add_ldflags("-Wl,-fuse-ld=mold")
add_shflags("-Wl,-fuse-ld=mold")
option_end()

if get_config("libc++") then
Expand All @@ -324,13 +318,13 @@ if get_config("libc++") then
set_policy("build.c++.clang.fallbackscanner", true)

target("stdmodules")
set_kind("object")
set_languages("c++latest")
set_kind("object")
set_languages("c++latest")

add_files("stdmodules/**.cppm")
add_files("stdmodules/**.cppm")

add_cxxflags("-Wno-reserved-module-identifier")
set_policy("build.c++.clang.fallbackscanner", false)
add_cxxflags("-Wno-reserved-module-identifier")
set_policy("build.c++.clang.fallbackscanner", false)
target_end()
end

Expand Down Expand Up @@ -479,6 +473,8 @@ for name, module in pairs(modules) do
if get_config("libc++") then
add_deps("stdmodules")
end
add_ldflags("-Wl,--as-needed")
add_shflags("-Wl,--as-needed")
target_end()
end
end
Expand Down

0 comments on commit 6a94051

Please sign in to comment.