inconsistent section declaration errors in kernel 4.4 compiled with llvm r316199 |
||||||
Issue description
While trying to build Kernel with the llvm we are trying to use for next version, we get a bunch of these warnings (that get converted to errors).
I believe const_debug translates into __attribute__((__section__(".data..read_mostly")) ??
so, it will seem the compiler is correct?
Kernel team, can you help decide what to do with this issue?
I would like to say this is a P1 but leaving as P2 for now.
It is blocking the compiler migration.
chromeos-kernel-4_4-4.4.92-r1177: In file included from ../../../../../tmp/portage/sys-kernel/chromeos-kernel-4_4-4.4.92-r1177/work/chromeos-kernel-4_4-4.4.92/kernel/sched/debug.c:20:
chromeos-kernel-4_4-4.4.92-r1177: [1m../../../../../tmp/portage/sys-kernel/chromeos-kernel-4_4-4.4.92-r1177/work/chromeos-kernel-4_4-4.4.92/kernel/sched/sched.h:1430:33: [0m[0;1;31merror: [0m[1msection attribute is specified on redeclared variable [-Werror,-Wsection][0m
chromeos-kernel-4_4-4.4.92-r1177: extern const_debug unsigned int sysctl_sched_time_avg;
chromeos-kernel-4_4-4.4.92-r1177: [0;1;32m ^
chromeos-kernel-4_4-4.4.92-r1177: [0m[1m../../../../../tmp/portage/sys-kernel/chromeos-kernel-4_4-4.4.92-r1177/work/chromeos-kernel-4_4-4.4.92/include/linux/sched/sysctl.h:69:21: [0m[0;1;30mnote: [0mprevious declaration is here[0m
chromeos-kernel-4_4-4.4.92-r1177: extern unsigned int sysctl_sched_time_avg;
chromeos-kernel-4_4-4.4.92-r1177: [0;1;32m ^
chromeos-kernel-4_4-4.4.92-r1177: [0mIn file included from ../../../../../tmp/portage/sys-kernel/chromeos-kernel-4_4-4.4.92-r1177/work/chromeos-kernel-4_4-4.4.92/kernel/sched/debug.c:20:
chromeos-kernel-4_4-4.4.92-r1177: [1m../../../../../tmp/portage/sys-kernel/chromeos-kernel-4_4-4.4.92-r1177/work/chromeos-kernel-4_4-4.4.92/kernel/sched/sched.h:1431:33: [0m[0;1;31merror: [0m[1msection attribute is specified on redeclared variable [-Werror,-Wsection][0m
chromeos-kernel-4_4-4.4.92-r1177: extern const_debug unsigned int sysctl_sched_nr_migrate;
chromeos-kernel-4_4-4.4.92-r1177: [0;1;32m ^
chromeos-kernel-4_4-4.4.92-r1177: [0m[1m../../../../../tmp/portage/sys-kernel/chromeos-kernel-4_4-4.4.92-r1177/work/chromeos-kernel-4_4-4.4.92/include/linux/sched/sysctl.h:68:21: [0m[0;1;30mnote: [0mprevious declaration is here[0m
chromeos-kernel-4_4-4.4.92-r1177: extern unsigned int sysctl_sched_nr_migrate;
chromeos-kernel-4_4-4.4.92-r1177: [0;1;32m ^
chromeos-kernel-4_4-4.4.92-r1177: [0mIn file included from ../../../../../tmp/portage/sys-kernel/chromeos-kernel-4_4-4.4.92-r1177/work/chromeos-kernel-4_4-4.4.92/kernel/sched/debug.c:20:
chromeos-kernel-4_4-4.4.92-r1177: [1m../../../../../tmp/portage/sys-kernel/chromeos-kernel-4_4-4.4.92-r1177/work/chromeos-kernel-4_4-4.4.92/kernel/sched/sched.h:1432:33: [0m[0;1;31merror: [0m[1msection attribute is specified on redeclared variable [-Werror,-Wsection][0m
chromeos-kernel-4_4-4.4.92-r1177: extern const_debug unsigned int sysctl_sched_migration_cost;
,
Oct 27 2017
,
Oct 27 2017
Looks like we have to match the attributes in the header with the declarations in the source file. Since this will also affect v4.14 we should find a solution that is acceptable by upstream. BTW, how do I use r316199? I tried 'USE="llvm-next" sudo emerge llvm clang', but that leaves me with version 5.0_pre305632_p20170806-r10.
,
Oct 27 2017
We still need to land the llvm-next CL 724372. Once it lands, the problem can be reproed as: 1. sudo emerge cross-x86_64-cros-linux-gnu/gcc cross-armv7a-cros-linux-gnueabi/gcc cross-aarch64-cros-linux-gnu/gcc 2. USE="llvm-next" sudo emerge llvm clang cross-armv7a-cros-linux-gnueabi/compiler-rt cross-aarch64-cros-linux-gnu/compiler-rt 3. Modify (Need sudo) /usr/x86_64-pc-linux-gnu/*/gcc-bin/4.9.x/sysroot_wrapper.hardened files and comment out the line with '-Wno-section'. 4. Build 4.4 kernel.
,
Oct 30 2017
I sent a patch upstream: https://patchwork.kernel.org/patch/10033003/ I would prefer to wait a few days to see if there are further comments, but if you want to proceed with the compiler migration before that let me now and we can integrate the patch.
,
Oct 30 2017
We can proceed with the compiler migration before that if necessary since we have temporarily added -Wno-section to the compiler wrapper. It would be cleaner if we just add that workaround for the kernel but it depends on how easy it is to add for you.
,
Oct 31 2017
Upstream is reluctant about the change as is, it might still take a few days to get to a final solution.
,
Nov 1 2017
My patch was accepted upstream after all: https://chromium-review.googlesource.com/#/c/chromiumos/third_party/kernel/+/748688/
,
Nov 1 2017
cool. thanks
,
Nov 1 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/third_party/kernel/+/81d77aa0f392efdc582e7decb670357a114d620e commit 81d77aa0f392efdc582e7decb670357a114d620e Author: Matthias Kaehlcke <mka@chromium.org> Date: Wed Nov 01 23:47:18 2017 FROMGIT: sched/sysctl: Fix attributes of some extern declarations The definition of sysctl_sched_migration_cost, sysctl_sched_nr_migrate and sysctl_sched_time_avg includes the attribute const_debug. This attribute is not part of the extern declaration of these variables in include/linux/sched/sysctl.h, while it is in kernel/sched/sched.h, and as a result Clang generates warnings like this: kernel/sched/sched.h:1618:33: warning: section attribute is specified on redeclared variable [-Wsection] extern const_debug unsigned int sysctl_sched_time_avg; ^ ./include/linux/sched/sysctl.h:42:21: note: previous declaration is here extern unsigned int sysctl_sched_time_avg; The header only declares the variables when CONFIG_SCHED_DEBUG is defined, therefore it is not necessary to duplicate the definition of const_debug. Instead we can use the attribute __read_mostly, which is the expansion of const_debug when CONFIG_SCHED_DEBUG=y is set. Signed-off-by: Matthias Kaehlcke <mka@chromium.org> Reviewed-by: Nick Desaulniers <nick.desaulniers@gmail.com> Cc: Douglas Anderson <dianders@chromium.org> Cc: Guenter Roeck <groeck@chromium.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Shile Zhang <shile.zhang@nokia.com> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/20171030180816.170850-1-mka@chromium.org Signed-off-by: Ingo Molnar <mingo@kernel.org> (cherry picked from git.kernel.org tip/tip sched/core commit a9903f04e0a4ea522d959c2f287cdf0ab029e324) Conflicts: include/linux/sched/sysctl.h BUG= 778867 TEST=build for pyro with llvm-next no warning of section attribute specified on redeclared variable Change-Id: I5cb3572036d826feba8133dc0f74d10f3b04c985 Signed-off-by: Matthias Kaehlcke <mka@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/748688 Reviewed-by: Manoj Gupta <manojgupta@chromium.org> Reviewed-by: Guenter Roeck <groeck@chromium.org> [modify] https://crrev.com/81d77aa0f392efdc582e7decb670357a114d620e/include/linux/sched/sysctl.h
,
Nov 2 2017
,
Nov 2 2017
great! thanks for the quick fix.
,
Jan 22 2018
,
Jan 23 2018
|
||||||
►
Sign in to add a comment |
||||||
Comment 1 by llozano@chromium.org
, Oct 27 2017