lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] ccache with autotools


From: Vadim Zeitlin
Subject: Re: [lmi] ccache with autotools
Date: Thu, 23 Feb 2023 15:48:07 +0100

On Thu, 23 Feb 2023 01:06:14 +0000 Greg Chicares <gchicares@sbcglobal.net> 
wrote:

GC> AIUI, the recommended way to use ccache with autotools is to
GC> override $CC and $CXX.

 Sorry to start by contradicting the premise of your question, but IMO it
isn't and the best way is the Debian way of just prepending /usr/lib/ccache
to the PATH and ensuring that there are links to all the installed
compilers in this directory, e.g. on my Sid system I have

% ls -l /usr/lib/ccache/*mingw*
lrwxrwxrwx 1 root root 16 Dec 15 01:58 /usr/lib/ccache/i686-w64-mingw32-g++ -> 
../../bin/ccache
lrwxrwxrwx 1 root root 16 Dec 15 01:55 /usr/lib/ccache/i686-w64-mingw32-gcc -> 
../../bin/ccache
lrwxrwxrwx 1 root root 16 Dec 15 01:55 /usr/lib/ccache/i686-w64-mingw32-gcc-12 
-> ../../bin/ccache
lrwxrwxrwx 1 root root 16 Jan 16 18:42 
/usr/lib/ccache/i686-w64-mingw32-gcc-12-posix -> ../../bin/ccache
lrwxrwxrwx 1 root root 16 Jan 16 18:42 
/usr/lib/ccache/i686-w64-mingw32-gcc-12-win32 -> ../../bin/ccache
lrwxrwxrwx 1 root root 16 Dec 15 01:58 /usr/lib/ccache/x86_64-w64-mingw32-g++ 
-> ../../bin/ccache
lrwxrwxrwx 1 root root 16 Dec 15 01:58 /usr/lib/ccache/x86_64-w64-mingw32-gcc 
-> ../../bin/ccache
lrwxrwxrwx 1 root root 16 Dec 15 01:58 
/usr/lib/ccache/x86_64-w64-mingw32-gcc-12 -> ../../bin/ccache
lrwxrwxrwx 1 root root 16 Jan 16 18:42 
/usr/lib/ccache/x86_64-w64-mingw32-gcc-12-posix -> ../../bin/ccache
lrwxrwxrwx 1 root root 16 Jan 16 18:42 
/usr/lib/ccache/x86_64-w64-mingw32-gcc-12-win32 -> ../../bin/ccache

(these links are automatically maintained by Debian package scripts, of
course, you don't need to manage them manually).

 One, but big, advantage of this approach is that it's completely
transparent and you can keep using the existing build system unchanged.


GC> However, in the cross-compilation case, $CC and $CXX aren't necessarily
GC> specified.

 I'm also not sure why is this so, i.e. what is the relationship between
specifying, or not specifying, these variables and cross-compiling, because
to me they seem orthogonal: you could be setting CXX to e.g. clang both
when cross-compiling and when not doing it, and you could also omit it in
both cases.

GC> Is there a way to accomplish this less bletcherously than as shown
GC> below?
GC> 
GC> diff --git a/install_wx.sh b/install_wx.sh
GC> index 6129ff0e7..fef6add43 100755
GC> --- a/install_wx.sh
GC> +++ b/install_wx.sh
GC> @@ -115,12 +115,21 @@ mkdir --parents "$build_dir"
GC>  cd "$build_dir"
GC>  printf 'Building %s with %s for %s.\n' "wx" "$LMI_COMPILER" "$LMI_TRIPLET"
GC>  
GC> +compiler_prefix="ccache "
GC> +case "$LMI_TRIPLET" in
GC> +    *-*-cygwin*|*-*-mingw*)
GC> +        compiler_prefix="${compiler_prefix}x86_64-w64-mingw32-"
GC> +        ;;
GC> +esac
GC> +
GC>  case "$LMI_COMPILER" in
GC>      (gcc)
GC>          valid_math="-frounding-math -fsignaling-nans"
GC>          # 'config_options' must not be double-quoted
GC>          # shellcheck disable=SC2086
GC>          "$wx_dir"/configure $config_options \
GC> +                CC="${compiler_prefix}gcc" \
GC> +               CXX="${compiler_prefix}g++" \
GC>            CPPFLAGS="-I$prefix/include" \
GC>              CFLAGS="$wx_cc_flags  $valid_math" \
GC>            CXXFLAGS="$wx_cxx_flags $valid_math" \
GC> @@ -132,8 +141,8 @@ case "$LMI_COMPILER" in
GC>          # 'config_options' must not be double-quoted
GC>          # shellcheck disable=SC2086
GC>          "$wx_dir"/configure $config_options \
GC> -                CC=clang \
GC> -               CXX=clang++ \
GC> +                CC="${compiler_prefix}clang" \
GC> +               CXX="${compiler_prefix}clang++" \
GC>            CPPFLAGS="-I$prefix/include" \
GC>              CFLAGS="$wx_cc_flags  $valid_math" \
GC>            CXXFLAGS="$wx_cxx_flags $valid_math -stdlib=libc++" \

 If you absolutely want to use ccache explicitly, then I guess this is the
way to do it, but I wouldn't mention it here at all and rely on the
symlinks instead.

 Regards,
VZ

Attachment: pgp5k4YZzNs3O.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]