From 2e9beef9f244c6dbb8e7eb848057f704a3e43523 Mon Sep 17 00:00:00 2001 From: km2 Date: Sun, 7 Apr 2019 09:04:28 +0500 Subject: [PATCH] samsung-i9003: support gcc8 (!307) This patch forces the kernel to compile with gcc8 and includes by default INSTALL_MOD_STRIP=1. --- device/linux-samsung-i9003/APKBUILD | 171 +++++++----------- device/linux-samsung-i9003/compiler-gcc6.h | 69 ------- ...give-up-on-ilog2-const-optimizations.patch | 1 + .../gcc8-fix-put-user.patch | 1 + ...el-use-the-gnu89-standard-explicitly.patch | 1 + 5 files changed, 71 insertions(+), 172 deletions(-) delete mode 100644 device/linux-samsung-i9003/compiler-gcc6.h create mode 120000 device/linux-samsung-i9003/gcc7-give-up-on-ilog2-const-optimizations.patch create mode 120000 device/linux-samsung-i9003/gcc8-fix-put-user.patch create mode 120000 device/linux-samsung-i9003/kernel-use-the-gnu89-standard-explicitly.patch diff --git a/device/linux-samsung-i9003/APKBUILD b/device/linux-samsung-i9003/APKBUILD index 10c709765..53f415046 100644 --- a/device/linux-samsung-i9003/APKBUILD +++ b/device/linux-samsung-i9003/APKBUILD @@ -1,144 +1,109 @@ -# Based on linux-lg-mako. Changes: -# - add findutils makedepend (necessary for the initramfs) -# - it builds an initramfs - do not use ramdisk.cpio and -# ramdisk-recovery-device.cpio, in there, always use the -# initramfs from the recovery partition ("isorec") -# - directly boot to that initramfs, not only when the recovery -# key combination was pressed. -# - use Alpine's busybox-static instead of the pre-compiled -# binary, that comes with the source -# -# Kernel config changes, based on: arch/arm/configs/latona_defconfig -# - enable devtmpfs (needed for udev -> touch support in weston) -# - change compression from CONFIG_KERNEL_LZMA=y to -# CONFIG_KERNEL_GZIP=y (so it works with busybox) +# Reference: +# Kernel config based on: arch/arm/configs/latona_defconfig -_vendor=samsung -_flavor=samsung-i9003 -_hash="7b8d73dd32e6cd21107f9a963a32a5ed237a6e78" -_config="config-${_flavor}.armhf" - -pkgname=linux-${_flavor} +pkgname="linux-samsung-i9003" pkgver=3.0.101 -case $pkgver in - *.*.*) _kernver=${pkgver%.*};; - *.*) _kernver=$pkgver;; -esac -pkgrel=14 -arch="armhf" +pkgrel=15 pkgdesc="Samsung Galaxy SI SLC kernel" -url="https://github.com/dhiru1602/android_kernel_samsung_latona" -depends="" -makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev -findutils busybox-static-armhf gcc6" +arch="armhf" +_carch="arm" +_flavor="samsung-i9003" +url="https://kernel.org" +license="GPL-2.0-only" options="!strip !check !tracedeps" -install= +makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev devicepkg-dev busybox-static-armhf" + +# Compiler: latest GCC from Alpine +HOSTCC="${CC:-gcc}" +HOSTCC="${HOSTCC#${CROSS_COMPILE}}" + +# Source +_repository="android_kernel_samsung_latona" +_commit="7b8d73dd32e6cd21107f9a963a32a5ed237a6e78" +_config="config-${_flavor}.${arch}" source=" - $pkgname-$_hash.tar.gz::https://github.com/dhiru1602/android_kernel_samsung_latona/archive/${_hash}.tar.gz + $pkgname-$_commit.tar.gz::https://github.com/dhiru1602/${_repository}/archive/${_commit}.tar.gz $_config - compiler-gcc6.h 00_return_address.patch 01_twl_power_init.patch 02_mfd_driver_fix.patch 03_fix_paranoid_network_disabled.patch + gcc7-give-up-on-ilog2-const-optimizations.patch + gcc8-fix-put-user.patch + kernel-use-the-gnu89-standard-explicitly.patch init " -subpackages="" -license="GPL2" - -_abi_release=${pkgver} -_carch="arm" - -# Compiler: this kernel was only tested with GCC6. Feel free to make a merge -# request if you find out that it is booting working with newer GCCs as -# well. See for instructions. -if [ "${CC:0:5}" != "gcc6-" ]; then - CC="gcc6-$CC" - HOSTCC="gcc6-gcc" - CROSS_COMPILE="gcc6-$CROSS_COMPILE" -fi - -ksrcdir="$srcdir/android_kernel_samsung_latona-${_hash}" - -prepare() { - local _patch_failed= - cd "$ksrcdir" - - # first apply patches in specified order - for i in $source; do - case $i in - *.patch) - msg "Applying $i..." - if ! patch -s -p1 -N -i "$srcdir"/$i; then - echo $i >>failed - _patch_failed=1 - fi - ;; - esac - done - - if ! [ -z "$_patch_failed" ]; then - error "The following patches failed:" - cat failed - return 1 - fi - - # gcc6 support - cp -v "$srcdir/compiler-gcc6.h" "$ksrcdir/include/linux/" - - mkdir -p "$srcdir"/build - cp "$srcdir"/$_config "$srcdir"/build/.config - make -C "$ksrcdir" O="$srcdir"/build ARCH="$_carch" HOSTCC="$HOSTCC" \ - silentoldconfig - - - mkdir "$ksrcdir"/usr/latona_initramfs_files/ +builddir="$srcdir/${_repository}-${_commit}" +prepare_isorec() { # Use Alpine's busybox.static instead of the pre-compiled busybox shipped # with the source + mkdir "$builddir"/usr/latona_initramfs_files/ cp -v /usr/$(arch_to_hostspec $arch)/bin/busybox.static \ - "$ksrcdir"/usr/latona_initramfs_files/busybox + "$builddir"/usr/latona_initramfs_files/busybox - # use custom init script in the initramfs which loads the initramfs from - # the kernel2 partition ("isorec") - cp -v "$srcdir"/init "$ksrcdir"/usr/latona_initramfs_files/init + # do not use ramdisk.cpio and ramdisk-recovery-device.cpio, always use + # the initramfs from the recovery partition ("isorec"), so we can build + # it later and independently from the kernel. also directly boot that + # partition, not only when the recovery key combination was used. + cd "$builddir"/usr/ + mv latona_initramfs.list latona_initramfs.list_old + grep -v "../../ramdisk" latona_initramfs.list_old > latona_initramfs.list + cp -v "$srcdir"/init "$builddir"/usr/latona_initramfs_files/init + + # Paths supplied to gen_initramfs_list.sh are prefixed with "source/". + ln -s "$builddir" ln -s "$builddir"/source +} - mkdir -p "$srcdir"/build - cp "$srcdir"/$_config "$srcdir"/build/.config - make -C "$ksrcdir" O="$srcdir"/build ARCH="$_carch" HOSTCC="$HOSTCC" \ - silentoldconfig +prepare() { + default_prepare + prepare_isorec + cd "$builddir" + downstreamkernel_prepare "$srcdir" "$builddir" "$_config" "$_carch" "$HOSTCC" } build() { - cd "$srcdir"/build unset LDFLAGS - make ARCH="$_carch" CC="${CC:-gcc}" \ - KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine" \ + KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS" \ CFLAGS_MODULE=-fno-pic } package() { - install -Dm644 "$srcdir/build/arch/arm/boot/zImage" \ - "$pkgdir/boot/vmlinuz-$_flavor" - - install -D "$srcdir/build/include/config/kernel.release" \ + # kernel.release + install -D "$builddir/include/config/kernel.release" \ "$pkgdir/usr/share/kernel/$_flavor/kernel.release" - - cd "$srcdir"/build + + # zImage (find the right one) + cd "$builddir/arch/$_carch/boot" + _target="$pkgdir/boot/vmlinuz-$_flavor" + for _zimg in zImage-dtb Image.gz-dtb *zImage Image; do + [ -e "$_zimg" ] || continue + msg "zImage found: $_zimg" + install -Dm644 "$_zimg" "$_target" + break + done + if ! [ -e "$_target" ]; then + error "Could not find zImage in $PWD!" + return 1 + fi + + cd "$builddir" unset LDFLAGS echo "--[ Installing modules ]--" make ARCH="$_carch" CC="${CC:-gcc}" \ - KBUILD_BUILD_VERSION="$((pkgrel + 1))-Alpine" \ - INSTALL_MOD_PATH="$pkgdir" modules_install + KBUILD_BUILD_VERSION="$((pkgrel + 1))-postmarketOS" \ + INSTALL_MOD_PATH="$pkgdir" INSTALL_MOD_STRIP=1 modules_install } sha512sums="b7ca46b856a0c160ae36a98da39147deb85c054e902447ab68bcd4a011986eee486fb681d0bb832b9b57797aca35332483e99379b792bd467b1f030328bd83c7 linux-samsung-i9003-7b8d73dd32e6cd21107f9a963a32a5ed237a6e78.tar.gz ac6d9fd10aca7a9460d26bd78d70a6aacfdc9ca28ec10a04210211f748724dbb0018c6388d407327c8736f896c956b0d8ba4b3c72f05e65cd664a8261381a9a9 config-samsung-i9003.armhf -d80980e9474c82ba0ef1a6903b434d8bd1b092c40367ba543e72d2c119301c8b2d05265740e4104ca1ac5d15f6c4aa49e8776cb44264a9a28dc551e0d1850dcc compiler-gcc6.h c40eaa11547f5bc2b1ff965506bdfe3015ff16e4b5ad9ccb3b8134ceafd1d32407c4ef2b213e02e036ce1e9bdcbfe768dff7d4b054bec77705a176c1f783b6f5 00_return_address.patch 1972a2b5c429d6bf5fa1423e8805bb89bbd80c4efe6d235cb2037de6ba4d15c01e90239392161d6e5a0802eafaab6e8b468a49a12dc5b66469a111262cde2047 01_twl_power_init.patch 5b951a2ab60a89fbc3ca209960987035001a6f9147f8ab5c05a6b49ec6dee75d0b6d053bef28df37e583bfc903599beed16692e25ee363e6200e14839d0dda65 02_mfd_driver_fix.patch df62e03666313bb03d9a455eac875f170a55d378b6e56b847c1c6ff1ce5cfafcfdf1d7605754ca3c684840ea00357f9ec4c6621f6ff77377132a484b9258f6f7 03_fix_paranoid_network_disabled.patch +77eba606a71eafb36c32e9c5fe5e77f5e4746caac292440d9fb720763d766074a964db1c12bc76fe583c5d1a5c864219c59941f5e53adad182dbc70bf2bc14a7 gcc7-give-up-on-ilog2-const-optimizations.patch +197d40a214ada87fcb2dfc0ae4911704b9a93354b75179cd6b4aadbb627a37ec262cf516921c84a8b1806809b70a7b440cdc8310a4a55fca5d2c0baa988e3967 gcc8-fix-put-user.patch +ad0182a483791fc88e058838bc331b2f04a75ba291e763767babdb815efadfc3b4fda97e69e2e3f00a426cabea088e35297a92bd287592597d1e309be68ee92c kernel-use-the-gnu89-standard-explicitly.patch dd4094d5f4ec281d32f12af88cb22a782e497c8e52f69cf60b73ac7d6171fc95f1f8040b3d0ad2ff3f016d22ac1d91c5b522e5d03203534a76742bc55a082af5 init" diff --git a/device/linux-samsung-i9003/compiler-gcc6.h b/device/linux-samsung-i9003/compiler-gcc6.h deleted file mode 100644 index 844706318..000000000 --- a/device/linux-samsung-i9003/compiler-gcc6.h +++ /dev/null @@ -1,69 +0,0 @@ -// SOURCE: -// https://github.com/NextThingCo/CHIP-u-boot/issues/10#issuecomment-287515505 - -#ifndef __LINUX_COMPILER_H -#error "Please don't include directly, include instead." -#endif - -#define __used __attribute__((__used__)) -#define __must_check __attribute__((warn_unused_result)) -#define __compiler_offsetof(a, b) __builtin_offsetof(a, b) - -/* Mark functions as cold. gcc will assume any path leading to a call - to them will be unlikely. This means a lot of manual unlikely()s - are unnecessary now for any paths leading to the usual suspects - like BUG(), printk(), panic() etc. [but let's keep them for now for - older compilers] - - Early snapshots of gcc 4.3 don't support this and we can't detect this - in the preprocessor, but we can live with this because they're unreleased. - Maketime probing would be overkill here. - - gcc also has a __attribute__((__hot__)) to move hot functions into - a special section, but I don't see any sense in this right now in - the kernel context */ -#define __cold __attribute__((__cold__)) - -#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) - -#ifndef __CHECKER__ -# define __compiletime_warning(message) __attribute__((warning(message))) -# define __compiletime_error(message) __attribute__((error(message))) -#endif /* __CHECKER__ */ - -/* - * Mark a position in code as unreachable. This can be used to - * suppress control flow warnings after asm blocks that transfer - * control elsewhere. - * - * Early snapshots of gcc 4.5 don't support this and we can't detect - * this in the preprocessor, but we can live with this because they're - * unreleased. Really, we need to have autoconf for the kernel. - */ -#define unreachable() __builtin_unreachable() - -/* Mark a function definition as prohibited from being cloned. */ -#define __noclone __attribute__((__noclone__)) - -/* - * Tell the optimizer that something else uses this function or variable. - */ -#define __visible __attribute__((externally_visible)) - -/* - * GCC 'asm goto' miscompiles certain code sequences: - * - * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670 - * - * Work it around via a compiler barrier quirk suggested by Jakub Jelinek. - * - * (asm goto is automatically volatile - the naming reflects this.) - */ -#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0) - -#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP -#define __HAVE_BUILTIN_BSWAP32__ -#define __HAVE_BUILTIN_BSWAP64__ -#define __HAVE_BUILTIN_BSWAP16__ -#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */ - diff --git a/device/linux-samsung-i9003/gcc7-give-up-on-ilog2-const-optimizations.patch b/device/linux-samsung-i9003/gcc7-give-up-on-ilog2-const-optimizations.patch new file mode 120000 index 000000000..da3d1ed41 --- /dev/null +++ b/device/linux-samsung-i9003/gcc7-give-up-on-ilog2-const-optimizations.patch @@ -0,0 +1 @@ +../../.shared-patches/linux/gcc7-give-up-on-ilog2-const-optimizations.patch \ No newline at end of file diff --git a/device/linux-samsung-i9003/gcc8-fix-put-user.patch b/device/linux-samsung-i9003/gcc8-fix-put-user.patch new file mode 120000 index 000000000..1d40b2674 --- /dev/null +++ b/device/linux-samsung-i9003/gcc8-fix-put-user.patch @@ -0,0 +1 @@ +../../.shared-patches/linux/gcc8-fix-put-user.patch \ No newline at end of file diff --git a/device/linux-samsung-i9003/kernel-use-the-gnu89-standard-explicitly.patch b/device/linux-samsung-i9003/kernel-use-the-gnu89-standard-explicitly.patch new file mode 120000 index 000000000..a5f4de276 --- /dev/null +++ b/device/linux-samsung-i9003/kernel-use-the-gnu89-standard-explicitly.patch @@ -0,0 +1 @@ +../../.shared-patches/linux/kernel-use-the-gnu89-standard-explicitly.patch \ No newline at end of file