Index: head/devel/linux-kernel/Makefile =================================================================== --- head/devel/linux-kernel/Makefile (revision 452005) +++ head/devel/linux-kernel/Makefile (revision 452006) @@ -1,172 +1,172 @@ # Created by: Tobias Kortkamp # $FreeBSD$ # To configure the Linux kernel yourself run # # make _menuconfig # # first, afterwards proceed with the normal port installation. This # is optional. # # By default the Linux config file is saved in work/linux-config. You # can override it by setting LINUX_KCONFIG. If you need it later copy # it somewhere else before running make clean, or it's gone! # # To use an existing Linux config file pass the absolute path with # LINUX_KCONFIG=/path/to/linux/config to the port (on the command line # or via /etc/make.conf). Enabling either the XEN or KVM option will # merge the KVM/XEN-specific default config with your own. # # You can run any Makefile targets of Linux by prefixing it with an # underscore (_). This setups a build environment for you so has # benefits over going to ${WRKSRC} yourself. # # You won't be able to build 64-bit kernels on FreeBSD/i386. gcc is # missing support for this. # # By default the kernel is installed into ${PREFIX}/linux-kernel. # Override by setting LINUX_INSTALL_PATH. Same for kernel modules and # LINUX_MOD_INSTALL_PATH. PORTNAME= linux-kernel PORTVERSION= 4.9.5 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= devel MASTER_SITES= KERNEL_ORG/linux/kernel/v4.x DISTNAME= linux-${DISTVERSION} MAINTAINER= tobik@FreeBSD.org COMMENT= Linux kernel LICENSE= GPLv2 LICENSE_FILE= ${WRKSRC}/COPYING BUILD_DEPENDS= bash:shells/bash \ gcp:sysutils/coreutils \ gsed:textproc/gsed \ gnubc>0:math/gnubc # USE_GCC adds a run dependency on gcc, which is nonsense for this # port so we add a binutils and gcc build dependency ourselves. Using # 'gcc>0' to always install gcc even on FreeBSD 9.3, where base's gcc # is too old. BUILD_DEPENDS+= gcc>0:lang/gcc \ binutils>0:devel/binutils USES= tar:xz gmake ncurses perl5 shebangfix SHEBANG_FILES= scripts/check_extable.sh \ scripts/coccicheck \ scripts/config \ scripts/decode_stacktrace.sh \ scripts/gfp-translate \ scripts/kernel-doc \ scripts/mkuboot.sh \ scripts/objdiff ONLY_FOR_ARCHS= i386 amd64 # Override LINUX_KCONFIG to set the Linux configuration file to use LINUX_KCONFIG?= ${WRKDIR}/linux-config .if !exists(${LINUX_KCONFIG}) ALL_TARGET= defconfig .endif OPTIONS_DEFINE= FIRMWARE KVM MODULES XEN OPTIONS_DEFAULT= KVM FIRMWARE_DESC= Install firmware KVM_DESC= KVM guest kernel support MODULES_DESC= Build and install kernel modules XEN_DESC= Xen dom0 and guest kernel support .include # Unfortunately options helpers can't be used here. KVM_ALL_TARGET # would append 'kvmconfig' to the end of ALL_TARGET but it needs to go # before 'bzImage'. .if ${PORT_OPTIONS:MKVM} ALL_TARGET+= kvmconfig .endif .if ${PORT_OPTIONS:MXEN} ALL_TARGET+= xenconfig .endif ALL_TARGET+= bzImage INSTALL_TARGET= install .if ${PORT_OPTIONS:MMODULES} ALL_TARGET+= modules INSTALL_TARGET+= modules_install .endif .if ${PORT_OPTIONS:MFIRMWARE} INSTALL_TARGET+= firmware_install .endif # Setup build environment ## For menuconfig, config, etc. HOST_EXTRACFLAGS+= -DCURSES_LOC='' -DKBUILD_NO_NLS=1 HOST_LOADLIBES+= -Wl,-rpath=${LOCALBASE}/lib LINUX_ARCH?= x86 LINUX_SUBARCH?= x86 LINUX_INSTALL_PATH?= ${PREFIX}/linux-kernel LINUX_MOD_INSTALL_PATH?= ${LINUX_INSTALL_PATH} ## Pretend to be Linux (for ACPI) KCFLAGS+= -D_LINUX -D__linux__ HOST_EXTRACFLAGS+= -I${BUILD_WRKSRC}/freebsd-build-support/include ## Make sure ${LOCALBASE}/bin is in the PATH for Poudriere/Synth MAKE_ENV+= PATH="${BUILD_WRKSRC}/freebsd-build-support/bin:${LOCALBASE}/bin:${PATH}" \ HOST_EXTRACFLAGS="${HOST_EXTRACFLAGS}" \ HOST_LOADLIBES="${HOST_LOADLIBES}" \ KCFLAGS="${KCFLAGS}" \ BASH="${LOCALBASE}/bin/bash" MAKE_ARGS+= ARCH="${LINUX_ARCH}" \ SUBARCH="${LINUX_SUBARCH}" \ KCONFIG_CONFIG="${LINUX_KCONFIG}" \ INSTALL_PATH="${STAGEDIR}${LINUX_INSTALL_PATH}" \ INSTALL_MOD_PATH="${STAGEDIR}${LINUX_MOD_INSTALL_PATH}" \ V=1 post-patch: # Create empty include files which Linux' build tools require, but # are not needed on FreeBSD. Saves us from patching code. @${MKDIR} ${WRKSRC}/freebsd-build-support/include @${TOUCH} ${WRKSRC}/freebsd-build-support/include/byteswap.h @${TOUCH} ${WRKSRC}/freebsd-build-support/include/endian.h @${TOUCH} ${WRKSRC}/freebsd-build-support/include/features.h # Setup some tools that Linux' build system uses where FreeBSD's # versions are not compatible enough with GNU's. @${MKDIR} ${WRKSRC}/freebsd-build-support/bin @${LN} -s ${LOCALBASE}/bin/gcp ${WRKSRC}/freebsd-build-support/bin/cp @${LN} -s ${LOCALBASE}/bin/gsed ${WRKSRC}/freebsd-build-support/bin/sed # Some scripts expect the config file in /.config @${LN} -sf ${LINUX_KCONFIG} ${WRKSRC}/.config # Run Makefile targets of Linux with e.g. make _menuconfig. Run make # _help to see a list of available targets. Prefix targets with _. # Some of Linux' targets are duplicates of the ports tree's and this # should hopefully prevent conflicts between them. .for target in ${.TARGETS:M_*} ${target}: patch @(cd ${BUILD_WRKSRC} && ${DO_MAKE_BUILD} ${target:S/_//}) @${ECHO} "Linux configuration file: ${LINUX_KCONFIG}" .endfor pre-build: @${ECHO} "using ${LINUX_KCONFIG}" pre-install: @${MKDIR} ${STAGEDIR}${LINUX_INSTALL_PATH} @${MKDIR} ${STAGEDIR}${LINUX_MOD_INSTALL_PATH} post-install: # With the multitude of options available in the Linux kernel # maintaining a proper plist is going to be near impossible, so we # generate it on the fly here. @(cd ${STAGEDIR}${PREFIX} && \ ${FIND} -s linux-kernel -type f -o -type l >> ${TMPPLIST}) .include Index: head/devel/linux-kernel/files/patch-gcc7 =================================================================== --- head/devel/linux-kernel/files/patch-gcc7 (nonexistent) +++ head/devel/linux-kernel/files/patch-gcc7 (revision 452006) @@ -0,0 +1,127 @@ +From 474c90156c8dcc2fa815e6716cc9394d7930cb9c Mon Sep 17 00:00:00 2001 +From: Linus Torvalds +Date: Thu, 2 Mar 2017 12:17:22 -0800 +Subject: give up on gcc ilog2() constant optimizations + +gcc-7 has an "optimization" pass that completely screws up, and +generates the code expansion for the (impossible) case of calling +ilog2() with a zero constant, even when the code gcc compiles does not +actually have a zero constant. + +And we try to generate a compile-time error for anybody doing ilog2() on +a constant where that doesn't make sense (be it zero or negative). So +now gcc7 will fail the build due to our sanity checking, because it +created that constant-zero case that didn't actually exist in the source +code. + +There's a whole long discussion on the kernel mailing about how to work +around this gcc bug. The gcc people themselevs have discussed their +"feature" in + + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72785 + +but it's all water under the bridge, because while it looked at one +point like it would be solved by the time gcc7 was released, that was +not to be. + +So now we have to deal with this compiler braindamage. + +And the only simple approach seems to be to just delete the code that +tries to warn about bad uses of ilog2(). + +So now "ilog2()" will just return 0 not just for the value 1, but for +any non-positive value too. + +It's not like I can recall anybody having ever actually tried to use +this function on any invalid value, but maybe the sanity check just +meant that such code never made it out in public. + +Reported-by: Laura Abbott +Cc: John Stultz , +Cc: Thomas Gleixner +Cc: Ard Biesheuvel +Signed-off-by: Linus Torvalds +--- + include/linux/log2.h | 13 ++----------- + tools/include/linux/log2.h | 13 ++----------- + 2 files changed, 4 insertions(+), 22 deletions(-) + +diff --git include/linux/log2.h include/linux/log2.h +index ef3d4f6..c373295 100644 +--- include/linux/log2.h ++++ include/linux/log2.h +@@ -16,12 +16,6 @@ + #include + + /* +- * deal with unrepresentable constant logarithms +- */ +-extern __attribute__((const, noreturn)) +-int ____ilog2_NaN(void); +- +-/* + * non-constant log of base 2 calculators + * - the arch may override these in asm/bitops.h if they can be implemented + * more efficiently than using fls() and fls64() +@@ -85,7 +79,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n) + #define ilog2(n) \ + ( \ + __builtin_constant_p(n) ? ( \ +- (n) < 1 ? ____ilog2_NaN() : \ ++ (n) < 2 ? 0 : \ + (n) & (1ULL << 63) ? 63 : \ + (n) & (1ULL << 62) ? 62 : \ + (n) & (1ULL << 61) ? 61 : \ +@@ -148,10 +142,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n) + (n) & (1ULL << 4) ? 4 : \ + (n) & (1ULL << 3) ? 3 : \ + (n) & (1ULL << 2) ? 2 : \ +- (n) & (1ULL << 1) ? 1 : \ +- (n) & (1ULL << 0) ? 0 : \ +- ____ilog2_NaN() \ +- ) : \ ++ 1 ) : \ + (sizeof(n) <= 4) ? \ + __ilog2_u32(n) : \ + __ilog2_u64(n) \ +diff --git tools/include/linux/log2.h tools/include/linux/log2.h +index 4144666..d5677d3 100644 +--- tools/include/linux/log2.h ++++ tools/include/linux/log2.h +@@ -13,12 +13,6 @@ + #define _TOOLS_LINUX_LOG2_H + + /* +- * deal with unrepresentable constant logarithms +- */ +-extern __attribute__((const, noreturn)) +-int ____ilog2_NaN(void); +- +-/* + * non-constant log of base 2 calculators + * - the arch may override these in asm/bitops.h if they can be implemented + * more efficiently than using fls() and fls64() +@@ -78,7 +72,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n) + #define ilog2(n) \ + ( \ + __builtin_constant_p(n) ? ( \ +- (n) < 1 ? ____ilog2_NaN() : \ ++ (n) < 2 ? 0 : \ + (n) & (1ULL << 63) ? 63 : \ + (n) & (1ULL << 62) ? 62 : \ + (n) & (1ULL << 61) ? 61 : \ +@@ -141,10 +135,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n) + (n) & (1ULL << 4) ? 4 : \ + (n) & (1ULL << 3) ? 3 : \ + (n) & (1ULL << 2) ? 2 : \ +- (n) & (1ULL << 1) ? 1 : \ +- (n) & (1ULL << 0) ? 0 : \ +- ____ilog2_NaN() \ +- ) : \ ++ 1 ) : \ + (sizeof(n) <= 4) ? \ + __ilog2_u32(n) : \ + __ilog2_u64(n) \ +-- +cgit v1.1 + Property changes on: head/devel/linux-kernel/files/patch-gcc7 ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property