[m-rev.] for review: Make link-time optimisation with clang work.

Julien Fischer jfischer at opturion.com
Tue Jan 28 15:13:21 AEDT 2020


On Tue, 28 Jan 2020, Peter Wang wrote:

> configure.ac:
>    Add -flto to LINK_SHARED_OBJ and LINK_SHARED_OBJ_SH commands
>    when LTO is enabled with clang.
>
>    Search for and use LTO-aware llvm-ar, llvm-ranlib and llvm-nm
>    programs in place of the normal tools.
>
> diff --git a/configure.ac b/configure.ac
> index 6dbee8860..b27565dce 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -5361,8 +5361,17 @@ if test "$mercury_cv_lto" = "yes"; then
>             NM=${GCC_NM:-$NM}
>             ;;
>         clang*)
> +            # Also consider using flto=thin
>             CFLAGS_FOR_LTO="-flto"
>             LDFLAGS_FOR_LTO="-flto"
> +            LINK_SHARED_OBJ="$LINK_SHARED_OBJ -flto"
> +            LINK_SHARED_OBJ_SH="$LINK_SHARED_OBJ_SH -flto"
> +            AC_CHECK_TOOL([LLVM_AR], [llvm-ar], [])
> +            AC_CHECK_TOOL([LLVM_RANLIB], [llvm-ranlib], [])
> +            AC_CHECK_TOOL([LLVM_NM], [llvm-nm], [])
> +            AR=${LLVM_AR:-$AR}
> +            RANLIB=${LLVM_RANLIB:-$RANLIB}
> +            NM=${LLVM_NM:-$NM}
>             ;;
>         *)
>             CFLAGS_FOR_LTO=""

That's fine.

Julien.


More information about the reviews mailing list