Xmake 版本
v3.0.9+HEAD.2b184e
操作系统版本和架构
Linux Kali, Windows 10
描述问题
Well where do I start? I have spent the past week battling xmake and vscode to produce an executable for windows cross compiled from linux using LDC. It has not been easy and very frustrating getting to the bottom of the problem. As it stands the extension injects -m64 which is not allowed when using -mtriple=xxxxxxxx. The only way I have managed to get it to work is by changing xmake.js as follows.....
// get configure arguments
getConfigureArgs() {
const plat = this._option.get("plat");
const arch = this._option.get("arch");
const mode = this._option.get("mode");
const toolchain = this._option.get("toolchain");
let args = [];
if (os.platform !== this._option.get("plat")){
if(this._option.get("toolchain") === "ldc"){
args = ["f", "-p", `${plat}`, "-m", `${mode}`];
}else{
args = ["f", "-p", `${plat}`, "-a", `${arch}`, "-m", `${mode}`];
}
}else{
args = ["f", "-p", `${plat}`, "-a", `${arch}`, "-m", `${mode}`];
}
//let args = ["f", "-p", `${plat}`, "-a", `${arch}`, "-m", `${mode}`];
if (this._option.get("plat") == "android" && config_1.config.androidNDKDirectory != "") {
args.push(`--ndk=${config_1.config.androidNDKDirectory}`);
}
if (config_1.config.QtDirectory != "") {
args.push(`--qt=${config_1.config.QtDirectory}`);
}
if (config_1.config.WDKDirectory != "") {
args.push(`--wdk=${config_1.config.WDKDirectory}`);
}
if (config_1.config.buildDirectory != "") {
const buildDirectory = path.normalize(config_1.config.buildDirectory);
if (buildDirectory != path.join(utils.getProjectRoot(), "build")) {
args.push("-o", buildDirectory);
}
}
if (config_1.config.additionalConfigArguments) {
args.push(...config_1.config.additionalConfigArguments);
}
if (toolchain != "toolchain") {
args.push("--toolchain=" + toolchain);
}
return args;
}
That sorts out the first issue. Then I have had to change xmake/toolchains/ldc/xmake.lua as follows....
toolchain("ldc")
set_homepage("https://github.com/ldc-developers/ldc")
set_description("The LLVM-based D Compiler.")
on_check("check")
on_load(function (toolchain)
toolchain:add("toolset", "dc", "ldc2")
toolchain:add("toolset", "dcld", "ldc2")
toolchain:add("toolset", "dcsh", "ldc2")
toolchain:add("toolset", "dcar", "ldc2")
--local platform = config.platform
if not is_plat("cross") then
local march
if toolchain:is_arch("x86_64", "x64") then
march = "-m64"
elseif toolchain:is_arch("i386", "x86") then
march = "-m32"
end
toolchain:add("dcflags", march or "")
toolchain:add("dcshflags", march or "")
toolchain:add("dcldflags", march or "")
end
end)
which will now disable the -m64 injection when I select 'cross' as a platform in the status bar. That is just to get past the first hurdle. After that it is also required to create a custom platform and load that in just so I can use set_os(windows) and a custom toolchain for the rest of the shenanigans.....I understand that this is probably a niche use case and not many people will be doing this, but still, seeing as LDC is based on LLVM with built in ld.lld it is a powerfull cross compiler in its own right. In general though I am glad I moved to xmake because DUB is only good for simple projects and to get any thing to work requires json from DUB and json on the vscode tasks side of things. Personally I can't stand json, it is brittle, has no comments, and does not deserve it's position in the programming ecosphere. Any way hope this helps and keep up the good work and many thanks for supporting D which is probably the most underrated language despite everyone trying to copy its features with a 10 year lag (c++ anyone?). I am sure you can do better than my hack but now you have somewhere to start from. Sometimes it is not so good to try and auto configure things for people, maybe xmake needs an 'expert' mode for situations when the auto config gets in the way which is another reason why I moved away from DUB, try hacking that!!!!
期待的结果
?
工程配置
?
附加信息和错误日志
?
Xmake 版本
v3.0.9+HEAD.2b184e
操作系统版本和架构
Linux Kali, Windows 10
描述问题
Well where do I start? I have spent the past week battling xmake and vscode to produce an executable for windows cross compiled from linux using LDC. It has not been easy and very frustrating getting to the bottom of the problem. As it stands the extension injects -m64 which is not allowed when using -mtriple=xxxxxxxx. The only way I have managed to get it to work is by changing xmake.js as follows.....
// get configure arguments
getConfigureArgs() {
const plat = this._option.get("plat");
const arch = this._option.get("arch");
const mode = this._option.get("mode");
const toolchain = this._option.get("toolchain");
That sorts out the first issue. Then I have had to change xmake/toolchains/ldc/xmake.lua as follows....
toolchain("ldc")
set_homepage("https://github.com/ldc-developers/ldc")
set_description("The LLVM-based D Compiler.")
which will now disable the -m64 injection when I select 'cross' as a platform in the status bar. That is just to get past the first hurdle. After that it is also required to create a custom platform and load that in just so I can use set_os(windows) and a custom toolchain for the rest of the shenanigans.....I understand that this is probably a niche use case and not many people will be doing this, but still, seeing as LDC is based on LLVM with built in ld.lld it is a powerfull cross compiler in its own right. In general though I am glad I moved to xmake because DUB is only good for simple projects and to get any thing to work requires json from DUB and json on the vscode tasks side of things. Personally I can't stand json, it is brittle, has no comments, and does not deserve it's position in the programming ecosphere. Any way hope this helps and keep up the good work and many thanks for supporting D which is probably the most underrated language despite everyone trying to copy its features with a 10 year lag (c++ anyone?). I am sure you can do better than my hack but now you have somewhere to start from. Sometimes it is not so good to try and auto configure things for people, maybe xmake needs an 'expert' mode for situations when the auto config gets in the way which is another reason why I moved away from DUB, try hacking that!!!!
期待的结果
?
工程配置
?
附加信息和错误日志
?