Commit 7d3ca92d authored by zhangyue's avatar zhangyue
Browse files

适配p800软件栈

parent a23c4d13
add_defines("ENABLE_KUNLUN_API") add_defines("ENABLE_KUNLUN_API")
local KUNLUN_HOME = os.getenv("KUNLUN_HOME") local KUNLUN_HOME = os.getenv("KUNLUN_HOME")
local XTDK_DIR = path.join(KUNLUN_HOME, "XTDK") local XRE_DIR = path.join(KUNLUN_HOME, "xre")
local XTDK_DIR = path.join(KUNLUN_HOME, "xtdk")
local XDNN_DIR = path.join(KUNLUN_HOME, "xhpc", "xdnn")
-- Add include dirs -- Add include dirs
add_includedirs(path.join(KUNLUN_HOME, "include"), {public=true}) add_includedirs(path.join(XRE_DIR, "include"), {public=true})
add_linkdirs(path.join(KUNLUN_HOME, "lib64")) add_includedirs(path.join(XTDK_DIR, "include"), {public=true})
add_includedirs(path.join(XDNN_DIR, "include"), {public=true})
add_linkdirs(path.join(XRE_DIR, "so"))
add_linkdirs(path.join(XDNN_DIR, "so"))
add_links("xpurt") add_links("xpurt")
add_links("xpuapi") add_links("xpuapi")
...@@ -18,7 +24,8 @@ rule("xpu") ...@@ -18,7 +24,8 @@ rule("xpu")
on_build_file(function (target, sourcefile) on_build_file(function (target, sourcefile)
local objectfile = target:objectfile(sourcefile) local objectfile = target:objectfile(sourcefile)
local basename = objectfile:gsub("%.o$", "") print("Compiling:", sourcefile, "->", objectfile)
-- local basename = objectfile:gsub("%.o$", "")
os.mkdir(path.directory(objectfile)) os.mkdir(path.directory(objectfile))
local cc = path.join(XTDK_DIR, "bin/clang++") local cc = path.join(XTDK_DIR, "bin/clang++")
local includedirs = table.concat(target:get("includedirs"), " ") local includedirs = table.concat(target:get("includedirs"), " ")
...@@ -27,20 +34,20 @@ rule("xpu") ...@@ -27,20 +34,20 @@ rule("xpu")
["arm64"] = "aarch64-linux-gnu" ["arm64"] = "aarch64-linux-gnu"
} }
local args = { local args = {
"--sysroot=/", -- "--sysroot=/",
"--target=" .. arch_map[os.arch()], "--target=" .. arch_map[os.arch()],
"-fPIC", "-fPIC",
"-pie", -- "-pie",
"--xpu-arch=xpu2", "--xpu-arch=xpu3",
"--basename", basename, -- "--basename", basename,
"-std=c++11", "-std=c++17",
"-O2", "-O2",
"-fno-builtin", "-fno-builtin",
"-g", -- "-g",
"-c", sourcefile, "-c", sourcefile,
"-v" "-o", objectfile
-- "-v"
} }
for _, includedir in ipairs(target:get("includedirs")) do for _, includedir in ipairs(target:get("includedirs")) do
...@@ -48,10 +55,12 @@ rule("xpu") ...@@ -48,10 +55,12 @@ rule("xpu")
end end
-- print(args) -- print(args)
os.execv(cc, args) local ok, code = os.execv(cc, args)
assert(ok == 0, "Compile failed: " .. sourcefile)
table.insert(target:objectfiles(), objectfile) table.insert(target:objectfiles(), objectfile)
table.insert(target:objectfiles(), basename .. ".device.bin.o") -- table.insert(target:objectfiles(), basename .. ".device.bin.o")
print(target:objectfiles()) -- print(target:objectfiles())
end) end)
rule_end() rule_end()
...@@ -62,7 +71,7 @@ target("infiniop-kunlun") ...@@ -62,7 +71,7 @@ target("infiniop-kunlun")
add_deps("infini-utils") add_deps("infini-utils")
on_install(function (target) end) on_install(function (target) end)
add_cxflags("-lstdc++ -fPIC") add_cxflags("-lstdc++ -fPIC -Wno-error=unused-function")
set_warnings("all", "error") set_warnings("all", "error")
set_languages("cxx17") set_languages("cxx17")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment