[arch-projects] [devtools] [PATCH] add ccache support
Users can set a ccache directory (which must be writeable by the user nobody) to be mapped to /build/.ccache (which is the directory, that ccache will use in the chroot) Signed-off-by: Dominik Heidler <dheidler@gmail.com> --- makechrootpkg.in | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index 1cd08fb..7cf0031 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -21,6 +21,7 @@ run_namcap=false temp_chroot=false chrootdir= passeddir= +ccachedir= declare -a install_pkgs declare -i ret=0 @@ -58,10 +59,11 @@ usage() { echo " Default: $copy" echo '-n Run namcap on the package' echo '-T Build in a temporary directory' + echo '-C <dir> The ccache directory to use' exit 1 } -while getopts 'hcur:I:l:nT' arg; do +while getopts 'hcur:I:l:C:nT' arg; do case "$arg" in h) usage ;; c) clean_first=true ;; @@ -71,6 +73,7 @@ while getopts 'hcur:I:l:nT' arg; do l) copy="$OPTARG" ;; n) run_namcap=true; makepkg_args="$makepkg_args -i" ;; T) temp_chroot=true; copy+="-$$" ;; + C) ccachedir="$OPTARG" ;; *) makepkg_args="$makepkg_args -$arg $OPTARG" ;; esac done @@ -84,6 +87,8 @@ chrootdir=$(readlink -e "$passeddir") [[ ! -d $chrootdir ]] && die "No chroot dir defined, or invalid path '%s'" "$passeddir" [[ ! -d $chrootdir/root ]] && die "Missing chroot dir root directory. Try using: mkarchroot %s/root base-devel" "$chrootdir" +[[ -n $ccachedir && ! -d $ccachedir ]] && die "Invalid path '%s' given for ccache directory" "$ccachedir" + # Detect chrootdir filesystem type chroottype=$(stat -f -c %T "$chrootdir") @@ -349,6 +354,7 @@ download_sources if arch-nspawn "$copydir" \ --bind-ro="$PWD:/startdir_host" \ --bind-ro="$SRCDEST:/srcdest_host" \ + ${ccachedir:+"--bind=$ccachedir:/build/.ccache"} \ /chrootbuild then move_products -- 1.8.3.4
On Fri, Aug 09, 2013 at 09:38:27AM +0200, Dominik Heidler wrote:
Users can set a ccache directory (which must be writeable by the user nobody) to be mapped to /build/.ccache (which is the directory, that ccache will use in the chroot)
Signed-off-by: Dominik Heidler <dheidler@gmail.com> ---
Looks fine, but I still have trouble grok'ing the usefulness of this. If you "import" the ccache directory, there's no telling what's in it -- there might be object files compiled using CFLAGS incompatible with the final output (resulting in a package that won't necessarily work as you expect). For example, my local builds (not using devtools) add -march=native and (sometimes) -flto. Building with devtools, there's no way these should be added. Is ccache smart enough to recompile the .o files in this case?
makechrootpkg.in | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/makechrootpkg.in b/makechrootpkg.in index 1cd08fb..7cf0031 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -21,6 +21,7 @@ run_namcap=false temp_chroot=false chrootdir= passeddir= +ccachedir= declare -a install_pkgs declare -i ret=0
@@ -58,10 +59,11 @@ usage() { echo " Default: $copy" echo '-n Run namcap on the package' echo '-T Build in a temporary directory' + echo '-C <dir> The ccache directory to use' exit 1 }
-while getopts 'hcur:I:l:nT' arg; do +while getopts 'hcur:I:l:C:nT' arg; do case "$arg" in h) usage ;; c) clean_first=true ;; @@ -71,6 +73,7 @@ while getopts 'hcur:I:l:nT' arg; do l) copy="$OPTARG" ;; n) run_namcap=true; makepkg_args="$makepkg_args -i" ;; T) temp_chroot=true; copy+="-$$" ;; + C) ccachedir="$OPTARG" ;; *) makepkg_args="$makepkg_args -$arg $OPTARG" ;; esac done @@ -84,6 +87,8 @@ chrootdir=$(readlink -e "$passeddir") [[ ! -d $chrootdir ]] && die "No chroot dir defined, or invalid path '%s'" "$passeddir" [[ ! -d $chrootdir/root ]] && die "Missing chroot dir root directory. Try using: mkarchroot %s/root base-devel" "$chrootdir"
+[[ -n $ccachedir && ! -d $ccachedir ]] && die "Invalid path '%s' given for ccache directory" "$ccachedir" + # Detect chrootdir filesystem type chroottype=$(stat -f -c %T "$chrootdir")
@@ -349,6 +354,7 @@ download_sources if arch-nspawn "$copydir" \ --bind-ro="$PWD:/startdir_host" \ --bind-ro="$SRCDEST:/srcdest_host" \ + ${ccachedir:+"--bind=$ccachedir:/build/.ccache"} \ /chrootbuild then move_products -- 1.8.3.4
On Fri, Aug 9, 2013 at 1:43 PM, Dave Reisner <d@falconindy.com> wrote:
On Fri, Aug 09, 2013 at 09:38:27AM +0200, Dominik Heidler wrote:
Users can set a ccache directory (which must be writeable by the user nobody) to be mapped to /build/.ccache (which is the directory, that ccache will use in the chroot)
Signed-off-by: Dominik Heidler <dheidler@gmail.com> ---
Looks fine, but I still have trouble grok'ing the usefulness of this. If you "import" the ccache directory, there's no telling what's in it -- there might be object files compiled using CFLAGS incompatible with the final output (resulting in a package that won't necessarily work as you expect). For example, my local builds (not using devtools) add -march=native and (sometimes) -flto. Building with devtools, there's no way these should be added.
Is ccache smart enough to recompile the .o files in this case?
According to the manpage, it is.
makechrootpkg.in | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/makechrootpkg.in b/makechrootpkg.in index 1cd08fb..7cf0031 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -21,6 +21,7 @@ run_namcap=false temp_chroot=false chrootdir= passeddir= +ccachedir= declare -a install_pkgs declare -i ret=0
@@ -58,10 +59,11 @@ usage() { echo " Default: $copy" echo '-n Run namcap on the package' echo '-T Build in a temporary directory' + echo '-C <dir> The ccache directory to use' exit 1 }
-while getopts 'hcur:I:l:nT' arg; do +while getopts 'hcur:I:l:C:nT' arg; do case "$arg" in h) usage ;; c) clean_first=true ;; @@ -71,6 +73,7 @@ while getopts 'hcur:I:l:nT' arg; do l) copy="$OPTARG" ;; n) run_namcap=true; makepkg_args="$makepkg_args -i" ;; T) temp_chroot=true; copy+="-$$" ;; + C) ccachedir="$OPTARG" ;; *) makepkg_args="$makepkg_args -$arg $OPTARG" ;; esac done @@ -84,6 +87,8 @@ chrootdir=$(readlink -e "$passeddir") [[ ! -d $chrootdir ]] && die "No chroot dir defined, or invalid path '%s'" "$passeddir" [[ ! -d $chrootdir/root ]] && die "Missing chroot dir root directory. Try using: mkarchroot %s/root base-devel" "$chrootdir"
+[[ -n $ccachedir && ! -d $ccachedir ]] && die "Invalid path '%s' given for ccache directory" "$ccachedir" + # Detect chrootdir filesystem type chroottype=$(stat -f -c %T "$chrootdir")
@@ -349,6 +354,7 @@ download_sources if arch-nspawn "$copydir" \ --bind-ro="$PWD:/startdir_host" \ --bind-ro="$SRCDEST:/srcdest_host" \ + ${ccachedir:+"--bind=$ccachedir:/build/.ccache"} \ /chrootbuild then move_products -- 1.8.3.4
Am 09.08.2013 09:38, schrieb Dominik Heidler:
Users can set a ccache directory (which must be writeable by the user nobody) to be mapped to /build/.ccache (which is the directory, that ccache will use in the chroot)
Signed-off-by: Dominik Heidler <dheidler@gmail.com>
Could you try the more generic patch by Dave to bind directories into the chroot. See the mail titled "makechrootpkg: add generic support for additional bind mounts". Greetings, Pierre -- Pierre Schmitz, https://pierre-schmitz.com
It seems to work after applying the fix - see my answer on his patch On 8/18/13, Pierre Schmitz <pierre@archlinux.de> wrote:
Am 09.08.2013 09:38, schrieb Dominik Heidler:
Users can set a ccache directory (which must be writeable by the user nobody) to be mapped to /build/.ccache (which is the directory, that ccache will use in the chroot)
Signed-off-by: Dominik Heidler <dheidler@gmail.com>
Could you try the more generic patch by Dave to bind directories into the chroot. See the mail titled "makechrootpkg: add generic support for additional bind mounts".
Greetings,
Pierre
-- Pierre Schmitz, https://pierre-schmitz.com
participants (3)
-
Dave Reisner
-
Dominik Heidler
-
Pierre Schmitz