[+] Update TLS model (gcc)

[*] Fix circular references
This commit is contained in:
Reece Wilson 2021-06-22 19:27:45 +01:00
parent 100644b0de
commit 112a98c3e1
3 changed files with 40 additions and 11 deletions

View File

@ -322,15 +322,11 @@ function JsonProcessor(info)
local iface = proj.processor
if (isWeakCircularReference(dep)) then
print("handling circular reference", dep)
iface:handleReference(true)
return
end
if (isProjectLoaded(dep)) then
defines(("_auhas_" .. dep):upper() .. "=1")
iface:handleReference()
iface:handleReference(isWeakCircularReference(dep))
if (not this.info.isStatic) then
iface:handleLink()
end

View File

@ -76,6 +76,16 @@ local boilerplateProject = function(name, projectType, src, inc, dest, root)
if ((projectType == "SharedLib") or
(projectType == "StaticLib")) then
pic "On"
if (usingGXX) then
-- TODO: we dont actually support gxx
-- We expect clang or msvc
-- msvcs thread local is fine, windows has always had decent thread in/out callbacks
-- clang has a cross platform, per variable solution
-- -> `__thread <type> <name> __attribute__((tls_model("initial-exec")));`
-- initial-exec is recommended when pic is on. does not work for dynamically loaded modules
buildoptions{"-ftls-model=initial-exec"}
end
end
end

View File

@ -90,7 +90,8 @@ function addVisit(ina)
local project = {
info = info,
processor = nil
processor = nil,
deps = {}
}
local cwd = getroot()
@ -143,7 +144,8 @@ function addScript(ina)
local project = {
info = info,
processor = nil
processor = nil,
deps = {}
}
local procesor = userRequire(args.script)
@ -185,12 +187,15 @@ _G["_resolved_dep"] = {}
function processDepSearch(proj, resolveProject)
local name = proj.info.name
_G["_resolved_dep"][name] = name
if (not proj.resolvedDeps) then
if (proj.processor.resolveDependencies) then
proj.processor:resolveDependencies(function(name, soft)
table.insert(proj.deps, name)
if (_G["_resolved_dep"][name]) then
return
end
@ -316,8 +321,26 @@ function processProject(name, required, noNs)
return true
end
function isWeakCircularReference(name)
return projectsblocked[name] and not projectsemitted[name]
function isWeakCircularReference(depName)
local curName = getCurrentProjectName()
local cur = projectsprocessor[curName]
if (not cur) then
return
end
local dep = projectsprocessor[depName]
if (not dep) then
return
end
for index, value in ipairs(dep.deps) do
if value == curName then
return true
end
end
return false
end
function isProjectLoaded(name)