On Fri, Jun 05, 2020 at 09:31:42AM +0200, Sebastien Marie wrote: Hello Sebastien,
A few thoughts on default Cargo options for release compilation: take them for what they're worth, which might not be very much! > + echo "overflow-checks = false" >>${WRKDIR}/.cargo/config; \ Personally I wouldn't mind if we experimented with "overflow-checks = true" since although overflow in Rust is not undefined behaviour, I've not yet seen a use that wasn't a bug (since people should use the 'unchecked' variants in such cases). I have heard various figures given for the performance impact of this, none of them very recent. If it turns out to make things horribly slow, I think we'd soon find out from users and could turn the overflow checks off! > + echo "lto = 'off'" >>${WRKDIR}/.cargo/config; \ My experience is that LTO gives around a 5% performance increase on average, at the cost of noticeable increases in compilation time. I believe it once used to trigger bugs in LLVM, although I have not seen this happen in the couple of years that I've been using this in my projects. If we can bear the compilation time hit (and I know that Rust ports are already slow to compile), this might be worth turning on. > + echo "panic = 'unwind'" >>${WRKDIR}/.cargo/config; \ Most Rust programs that I've seen don't make use of 'unwind' and can be 'abort', which leads to slightly smaller binaries. I'm not sure what to do about those programs that really do require 'unwind' though: make them turn it on via a flag? > + echo "codegen-units = 4" >>${WRKDIR}/.cargo/config; \ This one is tricky, because you get better optimisation at codegen-units=1, but less parallel compilation. However, that might not be a problem in the main usecase of building with dpb, where restricting compilation to a single core might even be thought an advantage? Laurie