Hey,
i have a question about that change. Is there a reason to disable LTO? I always enable it for my Rust projects and it works very well. If you dont mind me asking, what is the reason behind that default?

Thanks and greetings
Leo

Am 05.06.2020 um 09:31 schrieb Sebastien Marie:
Hi,

I would like to commit the following diff to devel/cargo, which control the
build "profile" of rust ports:


Index: cargo.port.mk
===================================================================
RCS file: /cvs/ports/devel/cargo/cargo.port.mk,v
retrieving revision 1.16
diff -u -p -r1.16 cargo.port.mk
--- cargo.port.mk       16 Mar 2020 10:55:36 -0000      1.16
+++ cargo.port.mk       5 Jun 2020 07:24:58 -0000
@@ -173,7 +173,8 @@ MODCARGO_post-patch += \
  .endfor
# configure hook. Place a config file for overriding crates-io index by
-# local source directory. Enabled by use of "CONFIGURE_STYLE=cargo".
+# local source directory, and set compilation options (based on release).
+# Enabled by use of "CONFIGURE_STYLE=cargo".
  MODCARGO_configure = \
        mkdir -p ${WRKDIR}/.cargo; \
        \
@@ -182,14 +183,21 @@ MODCARGO_configure = \
                >>${WRKDIR}/.cargo/config; \
        echo "[source.crates-io]" >>${WRKDIR}/.cargo/config; \
        echo "replace-with = 'modcargo'" >>${WRKDIR}/.cargo/config; \
-       \
-       if ! grep -qF '[profile.release]' ${MODCARGO_CARGOTOML}; then \
-               echo "" >>${MODCARGO_CARGOTOML}; \
-               echo "[profile.release]" >>${MODCARGO_CARGOTOML}; \
-               echo "opt-level = 2" >>${MODCARGO_CARGOTOML}; \
-               echo "debug = false" >>${MODCARGO_CARGOTOML}; \
-       fi ;
+.for _profile in release bench
+MODCARGO_configure += \
+       echo "" >>${WRKDIR}/.cargo/config; \
+       echo "[profile.${_profile}]" >>${WRKDIR}/.cargo/config; \
+       echo "opt-level = 2" >>${WRKDIR}/.cargo/config; \
+       echo "debug = 0" >>${WRKDIR}/.cargo/config; \
+       echo "debug-assertions = false" >>${WRKDIR}/.cargo/config; \
+       echo "overflow-checks = false" >>${WRKDIR}/.cargo/config; \
+       echo "lto = 'off'" >>${WRKDIR}/.cargo/config; \
+       echo "panic = 'unwind'" >>${WRKDIR}/.cargo/config; \
+       echo "incremental = false" >>${WRKDIR}/.cargo/config; \
+       echo "codegen-units = 4" >>${WRKDIR}/.cargo/config; \
+       echo "rpath = false" >>${WRKDIR}/.cargo/config;
+.endfor
# Update crates: place all crates on the same command line.
  .if !empty(MODCARGO_CRATES_UPDATE)



it moves compilations options setting from Cargo.toml (a file from the port) to 
.cargo/config file (a generated file)

the current version of cargo will look at the profile here too (it wasn't the
case when first commited), and it permits to avoid automatic modification of the
source file.

the compilation options used are based on release profile
(https://doc.rust-lang.org/cargo/reference/profiles.html#release) with the
following differences:

- opt-level is '2' (instead of '3')
- lto is 'off' (instead of 'false' which usually means 'thin')


I tested it on all ports with rust 1.44.0. I would commit it after lang/rust 
update.


Comments or OK ?


Reply via email to