Open heckerpowered opened 3 months ago
Bot detected the issue body's language is not English, translate it automatically.
Title: XMake link parameter generation error
add_ldflags("$(shell " .. llvm_config .. " --ldflags)")
add_ldflags("$(shell " .. llvm_config .. " --libs all)", {force=true})
-- add_syslinks("$(shell " .. llvm_config .. " --system-libs)")
使用以下配置可以在我的平台上通过编译,测试发现llvm-config --system-libs在我的机器上会生成空串,但我必须要将其注释掉。 其次,llvm-config --libs all生成-lLLVM18,但xmake认为其是无效的,默认将其忽略,我必须使用force = true 做出以上两点修改后可以在我的机器上正常构建,但测试发现Windows机器并不需要做出这两点修改也可以正常构建,我单方面认为这是XMake的问题
Bot detected the issue body's language is not English, translate it automatically.
add_ldflags("$(shell " .. llvm_config .. " --ldflags)") add_ldflags("$(shell " .. llvm_config .. " --libs all)", {force=true}) -- add_syslinks("$(shell " .. llvm_config .. " --system-libs)")
Using the following configuration can compile on my platform. Testing found that llvm-config --system-libs will generate an empty string on my machine, but I have to comment it out. Secondly, llvm-config --libs all generates -lLLVM18, but xmake thinks it is invalid and ignores it by default, I have to use force=true After making the above two modifications, it can be built normally on my machine. However, the test found that the Windows machine does not need to make these two modifications to build normally. I unilaterally think this is a problem with XMake.
其次,llvm-config --libs all生成-lLLVM18,但xmake认为其是无效的,默认将其忽略,我必须使用force = true
add_ldflags 默认会自动检测,不保证一定检测成功,根据warnings 提示加 force 就行了。。正常。
不建议走 shell 这么玩,走 package 集成,也能找系统库。
https://github.com/xmake-io/xmake-repo/blob/dev/packages/l/llvm/fetch.lua
Bot detected the issue body's language is not English, translate it automatically.
It is not recommended to use shell to do this. You can also use package integration to find system libraries.
https://github.com/xmake-io/xmake-repo/blob/dev/packages/l/llvm/fetch.lua
https://discord.com/channels/785173387962089492/1037914914477592716/1278755928589602847
package("libllvm")
do
on_install(function (package)
import("lib.detect.find_tool")
local llvm_config = find_tool("llvm-config")
local cflags_raw = os.iorunv(llvm_config.program, { "--cflags" })
local cppflags_raw = os.iorunv(llvm_config.program, { "--cppflags" })
local cxxflags_raw = os.iorunv(llvm_config.program, { "--cxxflags" })
local ldflags_raw = os.iorunv(llvm_config.program, { "--ldflags" })
local cflags = cflags_raw:split("%s+") or {}
local cppflags = cppflags_raw:split("%s+") or {}
local cxxflags = cxxflags_raw:split("%s+") or {}
local ldflags = ldflags_raw:split("%s+") or {}
package:add("cflags", cflags)
package:add("cxflags", cppflags)
package:add("cxxflags", cxxflags)
package:add("ldflags", ldflags)
end)
end
package_end()
add_requires("libllvm")
Xmake 版本
xmake v2.9.4+20240729
操作系统版本和架构
macOS Sequoia 15.0
描述问题
XMake生成了错误的链接参数
命令llvm-config生成如下:
xmake生成的链接命令如下:
错误信息:
我单方面认为是因为XMake链接参数生成错误
期待的结果
生成正确的链接选项,如
工程配置
add_rules("mode.debug", "mode.release") add_rules("plugin.compile_commands.autoupdate")
local llvm_config = "/opt/homebrew/opt/llvm/bin/llvm-config"
target("BugTest") set_kind("binary") add_files("src/*.cpp") set_toolchains("llvm")
附加信息和错误日志