boost: improve links (#4271)

* boost: improve links

* add asan support
pull/4273/head
star9029 6 months ago committed by GitHub
parent 5cca6cf9b7
commit f5776dbb8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 61
      packages/b/boost/xmake.lua

@ -114,18 +114,21 @@ package("boost")
end end
return linkname return linkname
end end
-- we need the fixed link order
local sublibs = {log = {"log_setup", "log"}, if not package:is_plat("windows") then
python = {"python", "numpy"}, -- we need the fixed link order
stacktrace = {"stacktrace_backtrace", "stacktrace_basic"}} local sublibs = {log = {"log_setup", "log"},
for _, libname in ipairs(libnames) do python = {"python", "numpy"},
local libs = sublibs[libname] stacktrace = {"stacktrace_backtrace", "stacktrace_basic"}}
if libs then for _, libname in ipairs(libnames) do
for _, lib in ipairs(libs) do local libs = sublibs[libname]
package:add("links", get_linkname(package, lib)) if libs then
for _, lib in ipairs(libs) do
package:add("links", get_linkname(package, lib))
end
else
package:add("links", get_linkname(package, libname))
end end
else
package:add("links", get_linkname(package, libname))
end end
end end
-- disable auto-link all libs -- disable auto-link all libs
@ -281,8 +284,11 @@ package("boost")
else else
table.insert(argv, "address-model=32") table.insert(argv, "address-model=32")
end end
local cxxflags
local linkflags local cxxflags = {}
local linkflags = {}
table.join2(cxxflags, table.wrap(package:config("cxflags")))
table.join2(cxxflags, table.wrap(package:config("cxxflags")))
if package:is_plat("windows") then if package:is_plat("windows") then
local vs_runtime = package:config("vs_runtime") local vs_runtime = package:config("vs_runtime")
if package:config("shared") then if package:config("shared") then
@ -293,14 +299,16 @@ package("boost")
table.insert(argv, "runtime-link=shared") table.insert(argv, "runtime-link=shared")
end end
table.insert(argv, "toolset=" .. build_toolset) table.insert(argv, "toolset=" .. build_toolset)
cxxflags = "-std:c++14" table.insert(cxxflags, "-std:c++14")
elseif package:is_plat("mingw") then elseif package:is_plat("mingw") then
table.insert(argv, "toolset=gcc") table.insert(argv, "toolset=gcc")
elseif package:is_plat("macosx") then elseif package:is_plat("macosx") then
table.insert(argv, "toolset=darwin") table.insert(argv, "toolset=darwin")
-- fix macosx arm64 build issue https://github.com/microsoft/vcpkg/pull/18529 -- fix macosx arm64 build issue https://github.com/microsoft/vcpkg/pull/18529
cxxflags = "-std=c++14 -arch " .. package:arch() table.insert(cxxflags, "-std=c++14")
table.insert(cxxflags, "-arch")
table.insert(cxxflags, package:arch())
local xcode = package:toolchain("xcode") or import("core.tool.toolchain").load("xcode", {plat = package:plat(), arch = package:arch()}) local xcode = package:toolchain("xcode") or import("core.tool.toolchain").load("xcode", {plat = package:plat(), arch = package:arch()})
if xcode:check() then if xcode:check() then
local xcode_dir = xcode:config("xcode") local xcode_dir = xcode:config("xcode")
@ -308,30 +316,35 @@ package("boost")
local target_minver = xcode:config("target_minver") local target_minver = xcode:config("target_minver")
if xcode_dir and xcode_sdkver then if xcode_dir and xcode_sdkver then
local xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX" .. xcode_sdkver .. ".sdk" local xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX" .. xcode_sdkver .. ".sdk"
cxxflags = cxxflags .. " -isysroot " .. xcode_sdkdir table.insert(cxxflags, "-isysroot")
table.insert(cxxflags, xcode_sdkdir)
end end
if target_minver then if target_minver then
cxxflags = cxxflags .. " -mmacosx-version-min=" .. target_minver table.insert(cxxflags, "-mmacosx-version-min=" .. target_minver)
end end
end end
else else
cxxflags = "-std=c++14" table.insert(cxxflags, "-std=c++14")
if package:config("pic") ~= false then if package:config("pic") ~= false then
cxxflags = cxxflags .. " -fPIC" table.insert(cxxflags, "-fPIC")
end end
end end
if package.has_runtime and package:has_runtime("c++_shared", "c++_static") then if package.has_runtime and package:has_runtime("c++_shared", "c++_static") then
cxxflags = (cxxflags or "") .. " -stdlib=libc++" table.insert(cxxflags, "-stdlib=libc++")
linkflags = (linkflags or "") .. " -stdlib=libc++" table.insert(linkflags, "-stdlib=libc++")
if package:has_runtime("c++_static") then if package:has_runtime("c++_static") then
linkflags = linkflags .. " -static-libstdc++" table.insert(linkflags, "-static-libstdc++")
end end
end end
if package:config("asan") then
table.insert(cxxflags, "-fsanitize=address")
table.insert(linkflags, "-fsanitize=address")
end
if cxxflags then if cxxflags then
table.insert(argv, "cxxflags=" .. cxxflags) table.insert(argv, "cxxflags=" .. table.concat(cxxflags, " "))
end end
if linkflags then if linkflags then
table.insert(argv, "linkflags=" .. linkflags) table.insert(argv, "linkflags=" .. table.concat(linkflags, " "))
end end
for _, libname in ipairs(libnames) do for _, libname in ipairs(libnames) do
if package:config("all") or package:config(libname) then if package:config("all") or package:config(libname) then

Loading…
Cancel
Save