buildpkg: try more dynamic approach to compiler settings

This commit is contained in:
udeved 2016-06-09 10:01:42 +02:00
parent 2d5355423d
commit 5f566540a8
10 changed files with 69 additions and 45 deletions

View file

@ -28,6 +28,14 @@ SHARED_BASE = \
SETS_PKG = \ SETS_PKG = \
data/pkg.d/default.set data/pkg.d/default.set
ARCH_CONF = \
data/pkgarch.d/i686.conf \
data/pkgarch.d/x86_64.conf \
data/pkgarch.d/aarch64.conf \
data/pkgarch.d/arm.conf \
data/pkgarch.d/armv6h.conf \
data/pkgarch.d/armv7h.conf
BIN_PKG = \ BIN_PKG = \
bin/checkpkg \ bin/checkpkg \
bin/lddd \ bin/lddd \
@ -134,6 +142,9 @@ install_pkg:
install -dm0755 $(DESTDIR)$(SYSCONFDIR)/manjaro-tools/pkg.d install -dm0755 $(DESTDIR)$(SYSCONFDIR)/manjaro-tools/pkg.d
install -m0644 ${SETS_PKG} $(DESTDIR)$(SYSCONFDIR)/manjaro-tools/pkg.d install -m0644 ${SETS_PKG} $(DESTDIR)$(SYSCONFDIR)/manjaro-tools/pkg.d
install -dm0755 $(DESTDIR)$(SYSCONFDIR)/manjaro-tools/pkgarch.d
install -m0644 ${ARCH_CONF} $(DESTDIR)$(SYSCONFDIR)/manjaro-tools/pkgarch.d
install -dm0755 $(DESTDIR)$(PREFIX)/bin install -dm0755 $(DESTDIR)$(PREFIX)/bin
install -m0755 ${BIN_PKG} $(DESTDIR)$(PREFIX)/bin install -m0755 ${BIN_PKG} $(DESTDIR)$(PREFIX)/bin
@ -184,6 +195,7 @@ uninstall_base:
uninstall_pkg: uninstall_pkg:
for f in ${SETS_PKG}; do rm -f $(DESTDIR)$(SYSCONFDIR)/manjaro-tools/pkg.d/$$f; done for f in ${SETS_PKG}; do rm -f $(DESTDIR)$(SYSCONFDIR)/manjaro-tools/pkg.d/$$f; done
for f in ${ARCH_CONF}; do rm -f $(DESTDIR)$(SYSCONFDIR)/manjaro-tools/pkgarch.d/$$f; done
for f in ${BIN_PKG}; do rm -f $(DESTDIR)$(PREFIX)/bin/$$f; done for f in ${BIN_PKG}; do rm -f $(DESTDIR)$(PREFIX)/bin/$$f; done
rm -f $(DESTDIR)$(PREFIX)/bin/find-libprovides rm -f $(DESTDIR)$(PREFIX)/bin/find-libprovides
for f in ${SHARED_PKG}; do rm -f $(DESTDIR)$(PREFIX)/share/manjaro-tools/$$f; done for f in ${SHARED_PKG}; do rm -f $(DESTDIR)$(PREFIX)/share/manjaro-tools/$$f; done

View file

@ -40,6 +40,7 @@ display_settings(){
msg2 "buildsets: %s" "$(list_sets ${sets_dir_pkg})" msg2 "buildsets: %s" "$(list_sets ${sets_dir_pkg})"
msg2 "buildset_pkg: %s" "${buildset_pkg}" msg2 "buildset_pkg: %s" "${buildset_pkg}"
msg2 "is_buildset: %s" "${is_buildset}" msg2 "is_buildset: %s" "${is_buildset}"
msg2 "pkgarch_dir: %s" "${pkgarch_dir}"
msg "OPTIONS:" msg "OPTIONS:"
msg2 "arch: %s" "${target_arch}" msg2 "arch: %s" "${target_arch}"
@ -135,6 +136,7 @@ done
prepare_conf "${target_arch}" prepare_conf "${target_arch}"
mirrors_conf=$(get_pac_mirrors_conf "${target_branch}") mirrors_conf=$(get_pac_mirrors_conf "${target_branch}")
makepkg_conf=$(get_makepkg_conf "${target_arch}")
mkchroot_args+=(-C ${pacman_conf} -M ${makepkg_conf} -S ${mirrors_conf} -B "${build_mirror}/${target_branch}") mkchroot_args+=(-C ${pacman_conf} -M ${makepkg_conf} -S ${mirrors_conf} -B "${build_mirror}/${target_branch}")

View file

@ -0,0 +1,3 @@
carch="aarch64"
chost="aarch64-unknown-linux-gnu"
cflags="-march=armv8-a -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"

3
data/pkgarch.d/arm.conf Normal file
View file

@ -0,0 +1,3 @@
carch="arm"
chost="armv5tel-unknown-linux-gnueabi"
cflags="-march=armv5te -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"

View file

@ -0,0 +1,3 @@
carch="armv6h"
chost="armv6l-unknown-linux-gnueabihf"
cflags="-march=armv6 -mfloat-abi=hard -mfpu=vfp -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"

View file

@ -0,0 +1,3 @@
carch="armv7h"
chost="armv7l-unknown-linux-gnueabihf"
cflags="-march=armv7-a -mfloat-abi=hard -mfpu=vfpv3-d16 -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"

3
data/pkgarch.d/i686.conf Normal file
View file

@ -0,0 +1,3 @@
carch="i686"
chost="i686-pc-linux-gnu"
cflags="-march=i686 -mtune=generic -O2 -pipe -fstack-protector-strong"

View file

@ -0,0 +1,3 @@
carch="x86_64"
chost="x86_64-pc-linux-gnu"
cflags="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong"

View file

@ -16,56 +16,38 @@ get_makepkg_conf(){
cp "${DATADIR}/makepkg.conf" "$conf" cp "${DATADIR}/makepkg.conf" "$conf"
sed -i "$conf" \ sed -i "$conf" \
-e "s|@CARCH[@]|$2|g" \ -e "s|@CARCH[@]|$carch|g" \
-e "s|@CHOST[@]|$3|g" \ -e "s|@CHOST[@]|$chost|g" \
-e "s|@CARCHFLAGS[@]|$4|g" -e "s|@CARCHFLAGS[@]|$cflags|g"
echo "$conf" echo "$conf"
} }
load_compiler_settings(){
local tarch="$1"
[[ -f ${pkgarch_dir}/$tarch.conf ]] || return 1
source ${pkgarch_dir}/$tarch.conf
return 0
}
# $1: target_arch # $1: target_arch
prepare_conf(){ prepare_conf(){
if ! is_valid_arch_pkg "$1";then if ! is_valid_arch_pkg "$1";then
die "%s is not a valid arch!" "$1" die "%s is not a valid arch!" "$1"
fi fi
local carch chost cflags pac_arch='default' local pac_arch='default'
case "$1" in
'arm') if [[ "$1" == 'multilib' ]];then
carch="$1" load_compiler_settings "x86_64"
chost="armv5tel-unknown-linux-gnueabi" pac_arch='multilib'
cflags="-march=armv5te -O2 -pipe -fstack-protector --param=ssp-buffer-size=4" is_multilib=true
;; else
'armv6h') load_compiler_settings "$1"
carch="$1" fi
chost="armv6l-unknown-linux-gnueabihf"
cflags="-march=armv6 -mfloat-abi=hard -mfpu=vfp -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"
;;
'armv7h')
carch="$1"
chost="armv7l-unknown-linux-gnueabihf"
cflags="-march=armv7-a -mfloat-abi=hard -mfpu=vfpv3-d16 -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"
;;
'aarch64')
carch="$1"
chost="aarch64-unknown-linux-gnu"
cflags="-march=armv8-a -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"
;;
'x86_64'|'multilib')
carch="x86_64"
chost="x86_64-pc-linux-gnu"
cflags="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong"
if [[ "$1" == 'multilib' ]];then
pac_arch='multilib'
is_multilib=true
fi
;;
'i686')
carch="$1"
chost="i686-pc-linux-gnu"
cflags="-march=i686 -mtune=generic -O2 -pipe -fstack-protector-strong"
;;
esac
pacman_conf="${DATADIR}/pacman-$pac_arch.conf" pacman_conf="${DATADIR}/pacman-$pac_arch.conf"
@ -73,8 +55,6 @@ prepare_conf(){
pkg_dir="${cache_dir_pkg}/${target_branch}/$1" pkg_dir="${cache_dir_pkg}/${target_branch}/$1"
[[ "$pac_arch" == 'multilib' ]] && target_arch='x86_64' [[ "$pac_arch" == 'multilib' ]] && target_arch='x86_64'
makepkg_conf=$(get_makepkg_conf "${target_arch}" "$carch" "$chost" "$cflags")
} }
pkgver_equal() { pkgver_equal() {

View file

@ -92,6 +92,16 @@ list_sets(){
echo $prof echo $prof
} }
# $1: pkgarch_dir
list_pkgarches(){
local arch temp
for item in $(ls $1/*.conf); do
temp=${item##*/}
arch=${arch:-}${arch:+|}${temp%.set}
done
echo $arch
}
# $1: sets_dir # $1: sets_dir
# $2: buildset # $2: buildset
eval_buildset(){ eval_buildset(){
@ -241,6 +251,8 @@ init_buildpkg(){
sets_dir_pkg="${SYSCONFDIR}/pkg.d" sets_dir_pkg="${SYSCONFDIR}/pkg.d"
pkgarch_dir="${SYSCONFDIR}/pkgarch.d"
[[ -d ${USERCONFDIR}/pkg.d ]] && sets_dir_pkg=${USERCONFDIR}/pkg.d [[ -d ${USERCONFDIR}/pkg.d ]] && sets_dir_pkg=${USERCONFDIR}/pkg.d
[[ -z ${buildset_pkg} ]] && buildset_pkg='default' [[ -z ${buildset_pkg} ]] && buildset_pkg='default'
@ -545,10 +557,10 @@ is_valid_init(){
} }
is_valid_arch_pkg(){ is_valid_arch_pkg(){
case $1 in eval "case $1 in
'i686'|'x86_64'|'multilib'|'arm'|'armv6h'|'armv7h'|'aarch64') return 0 ;; $(list_pkgarches "${pkgarch_dir}")|multilib) return 0 ;;
*) return 1 ;; *) return 1 ;;
esac esac"
} }
is_valid_arch_iso(){ is_valid_arch_iso(){