set codegen units properly in cargo config

This commit is contained in:
LordMZTE 2023-08-13 07:58:21 +02:00
parent 0c3ce3d22e
commit e40f93fd5f
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
2 changed files with 7 additions and 2 deletions

View file

@ -1,3 +1,4 @@
<! local ncpus = tonumber(opt.system "nproc") !>
[target.x86_64-unknown-linux-gnu]
linker = "/usr/bin/clang"
rustflags = ["-Clink-arg=-fuse-ld=lld"]
@ -5,4 +6,7 @@ rustflags = ["-Clink-arg=-fuse-ld=lld"]
[profile.release]
lto = true
opt-level = 3
codegen-units = 1
codegen-units = <% math.min(ncpus, 4) %>
[profile.debug]
codegen-units = <% ncpus %>

View file

@ -57,7 +57,8 @@ cg.opt.system = function(cmd)
if handle == nil then
error("Failed to spawn process" .. cmd)
end
return handle:read("*a"):gsub("%s+", "")
local data, _ = handle:read("*a"):gsub("%s$", "")
return data
end
-- Compile the input as lua. Meant to be used as a post-processor.