All of lore.kernel.org
 help / color / mirror / Atom feed
* [question] kernel build fails with O0 gcc optimization flag
@ 2015-11-25 17:12 Yury Norov
  2015-11-25 17:45 ` Vladimir Murzin
  2015-11-25 18:06 ` Russell King - ARM Linux
  0 siblings, 2 replies; 4+ messages in thread
From: Yury Norov @ 2015-11-25 17:12 UTC (permalink / raw)
  To: linux-arm-kernel

Hi all.

I changed optimization from O2 to O0 in Makefile:
        609 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
        610 KBUILD_CFLAGS   += -Os $(call cc-disable-warning,maybe-uninitialized,)
        611 else
        612 KBUILD_CFLAGS   += -O2 <-- here
        613 endif

And broke the build. O1 looks fine.

I tried Ubuntu and Cavium GCC:
        gcc version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu1) 
        gcc version 5.2.0 (Cavium Development Version) 

Kernel is v4.3, defconfig, ARCH=arm64.

What am I doing wrong?

BR,
Yury.

[...]
  CC      arch/arm64/kernel/debug-monitors.o
In file included from include/linux/ioport.h:12:0,
                 from include/linux/device.h:16,
                 from include/linux/node.h:17,
                 from include/linux/cpu.h:16,
                 from arch/arm64/kernel/debug-monitors.c:21:
In function ?__percpu_add?,
    inlined from ?enable_debug_monitors? at arch/arm64/kernel/debug-monitors.c:91:6:
include/linux/compiler.h:492:38: error: call to ?__compiletime_assert_97? declared with attribute error: BUILD_BUG failed
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
                                      ^
include/linux/compiler.h:475:4: note: in definition of macro ?__compiletime_assert? prefix ## suffix();    \
    ^
include/linux/compiler.h:492:2: note: in expansion of macro ?_compiletime_assert?
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
  ^
include/linux/bug.h:50:37: note: in expansion of macro ?compiletime_assert?
 #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                     ^
include/linux/bug.h:84:21: note: in expansion of macro ?BUILD_BUG_ON_MSG?
 #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
                     ^
./arch/arm64/include/asm/percpu.h:91:3: note: in expansion of macro ?BUILD_BUG?
   BUILD_BUG();      \
   ^
./arch/arm64/include/asm/percpu.h:97:1: note: in expansion of macro ?PERCPU_OP?
 PERCPU_OP(add, add)
 ^
In function ?__percpu_add?,
    inlined from ?enable_debug_monitors? at arch/arm64/kernel/debug-monitors.c:95:6:
include/linux/compiler.h:492:38: error: call to ?__compiletime_assert_97? declared with attribute error: BUILD_BUG failed
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
                                      ^
include/linux/compiler.h:475:4: note: in definition of macro ?__compiletime_assert?
    prefix ## suffix();    \
    ^
include/linux/compiler.h:492:2: note: in expansion of macro ?_compiletime_assert?
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
  ^
include/linux/bug.h:50:37: note: in expansion of macro ?compiletime_assert?
 #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                     ^
include/linux/bug.h:84:21: note: in expansion of macro ?BUILD_BUG_ON_MSG?
 #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
                     ^
./arch/arm64/include/asm/percpu.h:91:3: note: in expansion of macro ?BUILD_BUG?
   BUILD_BUG();      \
   ^
./arch/arm64/include/asm/percpu.h:97:1: note: in expansion of macro ?PERCPU_OP?
 PERCPU_OP(add, add)
 ^
In function ?__percpu_add?,
    inlined from ?disable_debug_monitors? at arch/arm64/kernel/debug-monitors.c:111:6:
include/linux/compiler.h:492:38: error: call to ?__compiletime_assert_97? declared with attribute error: BUILD_BUG failed
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
                                      ^
include/linux/compiler.h:475:4: note: in definition of macro ?__compiletime_assert?
    prefix ## suffix();    \
    ^
include/linux/compiler.h:492:2: note: in expansion of macro ?_compiletime_assert?
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
  ^
include/linux/bug.h:50:37: note: in expansion of macro ?compiletime_assert?
 #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                     ^
include/linux/bug.h:84:21: note: in expansion of macro ?BUILD_BUG_ON_MSG?
 #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
                     ^
./arch/arm64/include/asm/percpu.h:91:3: note: in expansion of macro ?BUILD_BUG?
   BUILD_BUG();      \
   ^
./arch/arm64/include/asm/percpu.h:97:1: note: in expansion of macro ?PERCPU_OP?
 PERCPU_OP(add, add)
 ^
In function ?__percpu_add?,
    inlined from ?disable_debug_monitors? at arch/arm64/kernel/debug-monitors.c:115:6:
include/linux/compiler.h:492:38: error: call to ?__compiletime_assert_97? declared with attribute error: BUILD_BUG failed
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
                                      ^
include/linux/compiler.h:475:4: note: in definition of macro ?__compiletime_assert?
    prefix ## suffix();    \
    ^
include/linux/compiler.h:492:2: note: in expansion of macro ?_compiletime_assert?
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
  ^
include/linux/bug.h:50:37: note: in expansion of macro ?compiletime_assert?
 #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                     ^
include/linux/bug.h:84:21: note: in expansion of macro ?BUILD_BUG_ON_MSG?
 #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
                     ^
./arch/arm64/include/asm/percpu.h:91:3: note: in expansion of macro ?BUILD_BUG?
   BUILD_BUG();      \
   ^
./arch/arm64/include/asm/percpu.h:97:1: note: in expansion of macro ?PERCPU_OP?
 PERCPU_OP(add, add)
 ^
In function ?__list_add_rcu?,
    inlined from ?list_add_rcu? at include/linux/rculist.h:80:2,
    inlined from ?register_break_hook?@arch/arm64/kernel/debug-monitors.c:279:2:
include/linux/compiler.h:492:38: error: call to ?__compiletime_assert_54? declared with attribute error: Need native word sized stores/loads for atomicity.
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
                                      ^
include/linux/compiler.h:475:4: note: in definition of macro ?__compiletime_assert?
    prefix ## suffix();    \
    ^
include/linux/compiler.h:492:2: note: in expansion of macro ?_compiletime_assert?
  _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
  ^
include/linux/compiler.h:495:2: note: in expansion of macro ?compiletime_assert?
  compiletime_assert(__native_word(t),    \
  ^
./arch/arm64/include/asm/barrier.h:44:2: note: in expansion of macro ?compiletime_assert_atomic_type?
  compiletime_assert_atomic_type(*p);    \
  ^
include/linux/rcupdate.h:677:34: note: in expansion of macro ?smp_store_release?
 #define rcu_assign_pointer(p, v) smp_store_release(&p, RCU_INITIALIZER(v))
                                  ^
include/linux/rculist.h:54:2: note: in expansion of macro ?rcu_assign_pointer?
  rcu_assign_pointer(list_next_rcu(prev), new);
  ^
scripts/Makefile.build:258: recipe for target 'arch/arm64/kernel/debug-monitors.o' failed
make[1]: *** [arch/arm64/kernel/debug-monitors.o] Error 1
Makefile:941: recipe for target 'arch/arm64/kernel' failed
make: *** [arch/arm64/kernel] Error 2

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [question] kernel build fails with O0 gcc optimization flag
  2015-11-25 17:12 [question] kernel build fails with O0 gcc optimization flag Yury Norov
@ 2015-11-25 17:45 ` Vladimir Murzin
  2015-11-25 18:06 ` Russell King - ARM Linux
  1 sibling, 0 replies; 4+ messages in thread
From: Vladimir Murzin @ 2015-11-25 17:45 UTC (permalink / raw)
  To: linux-arm-kernel

On 25/11/15 17:12, Yury Norov wrote:
> Hi all.
> 
> I changed optimization from O2 to O0 in Makefile:
>         609 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
>         610 KBUILD_CFLAGS   += -Os $(call cc-disable-warning,maybe-uninitialized,)
>         611 else
>         612 KBUILD_CFLAGS   += -O2 <-- here
>         613 endif
> 
> And broke the build. O1 looks fine.
> 
> I tried Ubuntu and Cavium GCC:
>         gcc version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu1) 
>         gcc version 5.2.0 (Cavium Development Version) 
> 
> Kernel is v4.3, defconfig, ARCH=arm64.
> 
> What am I doing wrong?

Related -00 question has been recently discussed in [1]

[1] http://www.spinics.net/lists/arm-kernel/msg435802.html

Cheers
Vladimir

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [question] kernel build fails with O0 gcc optimization flag
  2015-11-25 17:12 [question] kernel build fails with O0 gcc optimization flag Yury Norov
  2015-11-25 17:45 ` Vladimir Murzin
@ 2015-11-25 18:06 ` Russell King - ARM Linux
  2015-11-25 19:56   ` Yury Norov
  1 sibling, 1 reply; 4+ messages in thread
From: Russell King - ARM Linux @ 2015-11-25 18:06 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Nov 25, 2015 at 08:12:29PM +0300, Yury Norov wrote:
> Hi all.
> 
> I changed optimization from O2 to O0 in Makefile:
>         609 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
>         610 KBUILD_CFLAGS   += -Os $(call cc-disable-warning,maybe-uninitialized,)
>         611 else
>         612 KBUILD_CFLAGS   += -O2 <-- here
>         613 endif

-O0 is not supported, sorry.

-- 
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [question] kernel build fails with O0 gcc optimization flag
  2015-11-25 18:06 ` Russell King - ARM Linux
@ 2015-11-25 19:56   ` Yury Norov
  0 siblings, 0 replies; 4+ messages in thread
From: Yury Norov @ 2015-11-25 19:56 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Nov 25, 2015 at 06:06:08PM +0000, Russell King - ARM Linux wrote:
> On Wed, Nov 25, 2015 at 08:12:29PM +0300, Yury Norov wrote:
> > Hi all.
> > 
> > I changed optimization from O2 to O0 in Makefile:
> >         609 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
> >         610 KBUILD_CFLAGS   += -Os $(call cc-disable-warning,maybe-uninitialized,)
> >         611 else
> >         612 KBUILD_CFLAGS   += -O2 <-- here
> >         613 endif
> 
> -O0 is not supported, sorry.
> 

If so, why not to notify explicitly?

Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
---
 Makefile            | 2 +-
 arch/arm64/Makefile | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 418e98a..a2e8d3a 100644
--- a/Makefile
+++ b/Makefile
@@ -602,7 +602,6 @@ all: vmlinux
 ARCH_CPPFLAGS :=
 ARCH_AFLAGS :=
 ARCH_CFLAGS :=
-include arch/$(SRCARCH)/Makefile
 
 KBUILD_CFLAGS	+= $(call cc-option,-fno-delete-null-pointer-checks,)
 
@@ -775,6 +774,7 @@ ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC)), y)
 	KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO
 endif
 
+include arch/$(SRCARCH)/Makefile
 include scripts/Makefile.kasan
 include scripts/Makefile.extrawarn
 
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 432b69a..d865544 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -20,6 +20,10 @@ KBUILD_DEFCONFIG := defconfig
 # Check for binutils support for specific extensions
 lseinstr := $(call as-instr,.arch_extension lse,-DCONFIG_AS_LSE=1)
 
+# Check KBUILD_CFLAGS for  '-O0' as it's not supported now.
+$(if $(findstring -O0,$(KBUILD_CFLAGS)), \
+	$(error ARM64 does not support O0 optimization level. Try O1 or higher))
+
 ifeq ($(CONFIG_ARM64_LSE_ATOMICS), y)
   ifeq ($(lseinstr),)
 $(warning LSE atomics not supported by binutils)
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-11-25 19:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-25 17:12 [question] kernel build fails with O0 gcc optimization flag Yury Norov
2015-11-25 17:45 ` Vladimir Murzin
2015-11-25 18:06 ` Russell King - ARM Linux
2015-11-25 19:56   ` Yury Norov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.