New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 778867 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Nov 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Bug

Blocking:
issue 778316



Sign in to add a comment

inconsistent section declaration errors in kernel 4.4 compiled with llvm r316199

Project Member Reported by llozano@chromium.org, Oct 27 2017

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: ../../../../../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: error: section attribute is specified on redeclared variable [-Werror,-Wsection]
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:                                 ^
chromeos-kernel-4_4-4.4.92-r1177: ../../../../../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: note: previous declaration is here
chromeos-kernel-4_4-4.4.92-r1177: extern unsigned int sysctl_sched_time_avg;
chromeos-kernel-4_4-4.4.92-r1177:                     ^
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: ../../../../../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: error: section attribute is specified on redeclared variable [-Werror,-Wsection]
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:                                 ^
chromeos-kernel-4_4-4.4.92-r1177: ../../../../../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: note: previous declaration is here
chromeos-kernel-4_4-4.4.92-r1177: extern unsigned int sysctl_sched_nr_migrate;
chromeos-kernel-4_4-4.4.92-r1177:                     ^
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: ../../../../../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: error: section attribute is specified on redeclared variable [-Werror,-Wsection]
chromeos-kernel-4_4-4.4.92-r1177: extern const_debug unsigned int sysctl_sched_migration_cost;


 
Summary: inconsistent section declaration errors in kernel 4.4 compiled with llvm r316199 (was: inconsisten section declaration errors in kernel 4.4 compiled with llvm r316199)
Blocking: 778316

Comment 3 by mka@chromium.org, 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.
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.

Comment 5 by mka@chromium.org, 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.
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.


Comment 7 by mka@chromium.org, Oct 31 2017

Upstream is reluctant about the change as is, it might still take a few days to get to a final solution.

Comment 9 by lloz...@google.com, Nov 1 2017

cool. thanks
Project Member

Comment 10 by bugdroid1@chromium.org, Nov 1 2017

Labels: merge-merged-chromeos-4.4
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

Comment 11 by mka@chromium.org, Nov 2 2017

Status: Fixed (was: Assigned)
great! thanks for the quick fix.

Comment 13 by dchan@chromium.org, Jan 22 2018

Status: Archived (was: Fixed)

Comment 14 by dchan@chromium.org, Jan 23 2018

Status: Fixed (was: Archived)

Sign in to add a comment