Skip to content

Commit 2a534c8

Browse files
issue/1033 add fpic ldflag for infinirt and fix python link
1 parent 06c3df5 commit 2a534c8

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

xmake.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ target("infinirt")
336336
if not is_plat("windows") then
337337
add_cxflags("-fPIC")
338338
add_cxxflags("-fPIC")
339+
add_ldflags("-fPIC", {force = true})
339340
end
340341
set_installdir(os.getenv("INFINI_ROOT") or (os.getenv(is_host("windows") and "HOMEPATH" or "HOME") .. "/.infini"))
341342
add_files("src/infinirt/*.cc")

xmake/nvidia.lua

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,10 @@ target("flash-attn-nvidia")
147147

148148
before_build(function (target)
149149
if FLASH_ATTN_ROOT ~= nil then
150-
local outdata = os.iorunv("python", {"-c", "import torch, os; print(os.path.dirname(torch.__file__))"}):trim()
151-
local TORCH_DIR = outdata
152-
153-
local outdata = os.iorunv("python", {"-c", "import sysconfig; print(sysconfig.get_paths()['include'])"}):trim()
154-
local PYTHON_INCLUDE = outdata
155-
156-
local outdata = os.iorunv("python", {"-c", "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))"}):trim()
157-
local PYTHON_LIB_DIR = outdata
150+
local TORCH_DIR = os.iorunv("python", {"-c", "import torch, os; print(os.path.dirname(torch.__file__))"}):trim()
151+
local PYTHON_INCLUDE = os.iorunv("python", {"-c", "import sysconfig; print(sysconfig.get_paths()['include'])"}):trim()
152+
local PYTHON_LIB_DIR= os.iorunv("python", {"-c", "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))"}):trim()
153+
local LIB_PYTHON = os.iorunv("python", {"-c", "import sysconfig, os; print(sysconfig.get_config_var('LDLIBRARY'))"}):trim()
158154
-- Include dirs
159155
target:add("includedirs", FLASH_ATTN_ROOT .. "/csrc/flash_attn/src", {public = false})
160156
target:add("includedirs", TORCH_DIR .. "/include/torch/csrc/api/include", {public = false})
@@ -165,7 +161,7 @@ target("flash-attn-nvidia")
165161

166162
-- Link libraries
167163
target:add("linkdirs", TORCH_DIR .. "/lib", PYTHON_LIB_DIR)
168-
target:add("links", "torch", "torch_cuda", "torch_cpu", "c10", "c10_cuda", "torch_python", "python3")
164+
target:add("links", "torch", "torch_cuda", "torch_cpu", "c10", "c10_cuda", "torch_python", LIB_PYTHON)
169165

170166
end
171167

0 commit comments

Comments
 (0)