From patchwork Wed Dec 14 15:14:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 88036 Delivered-To: patch@linaro.org Received: by 10.182.112.6 with SMTP id im6csp183820obb; Wed, 14 Dec 2016 07:14:47 -0800 (PST) X-Received: by 10.84.149.139 with SMTP id m11mr206992487pla.38.1481728487053; Wed, 14 Dec 2016 07:14:47 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j130si53147510pgc.309.2016.12.14.07.14.46; Wed, 14 Dec 2016 07:14:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756315AbcLNPOn (ORCPT + 25 others); Wed, 14 Dec 2016 10:14:43 -0500 Received: from mail-qt0-f171.google.com ([209.85.216.171]:33886 "EHLO mail-qt0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755788AbcLNPOl (ORCPT ); Wed, 14 Dec 2016 10:14:41 -0500 Received: by mail-qt0-f171.google.com with SMTP id n6so27089408qtd.1 for ; Wed, 14 Dec 2016 07:14:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=REgVSoafW1ccH1tl5B9zAm+ElJXErnSstcr+niW0Sr4=; b=RsF7HwyWoXikVeFdN8WYVixYcsMUxgKj7V3hiaaXVb5sle9bWeA8UyDTJkYGzBS2cp CAJ3BylvYKVRuFpgWCpLymbR6zxVSw1c5LcmN8n+N4EaLqzuQJt0WzB8cm84m/n5zQH0 Qu2Yj4bQ+ogMLFEq2W6A0ZRVhbt8zp2TConn4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=REgVSoafW1ccH1tl5B9zAm+ElJXErnSstcr+niW0Sr4=; b=QS0/2Z8Jz5aYyUtoaJ1HUgIpGkzzlDbyZdSxnmFFLtE81PsH8WWtSD0cAsNOH53FPy sLq/KwkaffxM/gRjTmHkNfhpbezXixuxMH09DBax+iXGHCb0eKNuNk53pQDCpMq/ZBUH I+wt9kTdjc6UI1EBQiRKGFoL4lEYcdn6Mu4LAyjiObevJ7XzNrvtaDaO+x5aKrpKNvsL pQ1XmQVVTlSzCu0JUbV5UaX4EqIOKTOq5R+YpLcwDoJhWPRDMgHS8gpsCtMR9t50YMrW UcE3LQEFe0JfZ5igXnW5QjigfCMCux/CCC1nEO+LQ+mPUbtHuxgzx80paIfeM/yJSwYk 5rMg== X-Gm-Message-State: AKaTC01nJGeWe6BJ5QlyGqwv6VUk6mNR++yZG9XqbvZ5YYDdrAwa5BZMdW0bL78CdrHntyej X-Received: by 10.237.38.37 with SMTP id z34mr100508273qtc.73.1481728480626; Wed, 14 Dec 2016 07:14:40 -0800 (PST) Received: from xanadu.home ([2607:fa48:6e39:d410:feaa:14ff:fea7:ed77]) by smtp.gmail.com with ESMTPSA id o31sm31794074qtf.20.2016.12.14.07.14.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Dec 2016 07:14:40 -0800 (PST) Date: Wed, 14 Dec 2016 10:14:39 -0500 (EST) From: Nicolas Pitre To: Guenter Roeck cc: "linux-kernel@vger.kernel.org" Subject: Re: Build failures due to missing 'posix_timer_event' In-Reply-To: Message-ID: References: User-Agent: Alpine 2.20 (LFD 67 2015-01-07) MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 14 Dec 2016, Guenter Roeck wrote: > avr32:allnoconfig: > > kernel/built-in.o: In function `do_adjtimex': > (.text+0x1d748): undefined reference to `posix_timer_event' > make[1]: *** [vmlinux] Error 1 > > metag:allnoconfig: > > kernel/built-in.o: In function `alarm_handle_timer': > alarmtimer.c:(.text.alarm_handle_timer+0x38): undefined reference to > `posix_timer_event' > > openrisc:allnoconfig: > > kernel/built-in.o: In function `alarm_handle_timer': > alarmtimer.c:(.text+0x3fca4): undefined reference to `posix_timer_event' > > unicore32:allnoconfig: > > kernel/built-in.o: In function `alarm_handle_timer': > memremap.c:(.text+0x31c1c): undefined reference to `posix_timer_event' > > Since I don't run allnoconfig builds for all architectures, I strongly suspect > that more are affected. This is a known problem. Oddly enough only those "less popular" architectures are affected. > Looking into alarmtimer.c, with seems to call posix_timer_event() > unconditionally, I don't entirely understand how this can work in the > first place. Maybe I am missing something, though. The magic is in alarmtimer_init(): if (IS_ENABLED(CONFIG_POSIX_TIMERS)) { posix_timers_register_clock(CLOCK_REALTIME_ALARM, &alarm_clock); posix_timers_register_clock(CLOCK_BOOTTIME_ALARM, &alarm_clock); } If CONFIG_POSIX_TIMERS is not enabled, the condition becomes a constant zero. The posix_timers_register_clock calls are then optimized away by the compiler. In turn the alarm_clock structure has no longer any reference to it and therefore is also optimized away, including its method functions such as alarm_timer_create() and finally alarm_handle_timer(). But for some reasons, some gcc versions (mainly for "secondary" architectures) fail to optimize away all that code, and a dead reference to posix_timer_event() remains in the compiled code. There is a fix already queued in the mm tree. It goes like this: posix-timers: give lazy compilers some help optimizing code away The OpenRISC compiler (so far) fails to optimize away a large portion of code containing a reference to posix_timer_event in alarmtimer.c when CONFIG_POSIX_TIMERS is unset. Let's give it a direct clue to let the build succeed. This fixes [linux-next:master 6682/7183] alarmtimer.c:undefined reference to `posix_timer_event' reported by kbuild test robot. Signed-off-by: Nicolas Pitre Cc: Thomas Gleixner Cc: Josh Triplett Signed-off-by: Andrew Morton diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 9b08ca391a..3921cf7fea 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -516,7 +516,8 @@ static enum alarmtimer_restart alarm_handle_timer(struct alarm *alarm, spin_lock_irqsave(&ptr->it_lock, flags); if ((ptr->it_sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_NONE) { - if (posix_timer_event(ptr, 0) != 0) + if (IS_ENABLED(CONFIG_POSIX_TIMERS) && + posix_timer_event(ptr, 0) != 0) ptr->it_overrun++; }