From patchwork Thu Apr 28 20:56:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 66932 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp431647qge; Thu, 28 Apr 2016 13:56:30 -0700 (PDT) X-Received: by 10.67.14.7 with SMTP id fc7mr23668993pad.1.1461876990610; Thu, 28 Apr 2016 13:56:30 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 141si12023816pfx.22.2016.04.28.13.56.30; Thu, 28 Apr 2016 13:56:30 -0700 (PDT) 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 S1753486AbcD1U42 (ORCPT + 30 others); Thu, 28 Apr 2016 16:56:28 -0400 Received: from mail-qg0-f49.google.com ([209.85.192.49]:33803 "EHLO mail-qg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753162AbcD1U41 (ORCPT ); Thu, 28 Apr 2016 16:56:27 -0400 Received: by mail-qg0-f49.google.com with SMTP id 90so19484481qgz.1 for ; Thu, 28 Apr 2016 13:56:26 -0700 (PDT) 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=BlK7qqSawzOQ0l6TD2Lxl508wkHD9buGfRe+roLD0rs=; b=V913gNq4ojc8F+GecSwjzxyHWN0bIw0qzUNInNHJjakJdEkzQP9H3s2NSCl6grBCq5 ES+y7Y3QhLtjh2AnkaxAdlprjIFggq6HpoN1lo8JrdXD8P4PzAeYA/8a99SjwJ4aAY43 ktGkXUZaFh5V0ffoRxwMiCpH2kBGhmqMsvJ+c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=BlK7qqSawzOQ0l6TD2Lxl508wkHD9buGfRe+roLD0rs=; b=Xfmgv27IdJP0IL68MUkwtFrQMr26nfGEPbuQt7XzGmemYttUwvxJTlohyrJcmjG7/t RpU6UyI8fM6dVHtueBXNFJ+y0bm4r2jn2L0aSdHxgHgH+BcP8XCb2j8NIkoL7qAA2lK1 aIfRSLHIGlLSh79BkFARf3bQmryy+/uSJlzM99KJH/K0LA3Vjd1uJYRjl+X+Cu5HoyCd +R/1D4QSfkymZ419uyz8gU5nq8jHMnSoGlEGBcjdWIFZWb3s/P3w/tJbCmbKif99IMZP 1l9VrRQn2EFTjWNSjbafOI4VpVTVkRlSQDdDww8e7wRuhhODhXQrTKBIvC1xhzeiC76/ V61g== X-Gm-Message-State: AOPr4FUnINdmzCSfWI9GrSkD8tKvYgFX+ymwlw6B8OpWaF8YNRgeoyQDEigb6yoF4MHoeX/g X-Received: by 10.140.25.242 with SMTP id 105mr15893407qgt.85.1461876986118; Thu, 28 Apr 2016 13:56:26 -0700 (PDT) Received: from xanadu.home ([2607:fa48:6e39:d410:feaa:14ff:fea7:ed77]) by smtp.gmail.com with ESMTPSA id a31sm3367375qga.34.2016.04.28.13.56.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Apr 2016 13:56:24 -0700 (PDT) Date: Thu, 28 Apr 2016 16:56:23 -0400 (EDT) From: Nicolas Pitre To: Arnd Bergmann cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Subject: Re: Failing randconfig builds with CONFIG_TRIM_UNUSED_KSYMS In-Reply-To: <1856264.0h7Es0b6Qr@wuerfel> Message-ID: References: <1856264.0h7Es0b6Qr@wuerfel> 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 Thu, 28 Apr 2016, Arnd Bergmann wrote: > Hi Nico, > > My randconfig build testing has encountered a couple of additional > failures with CONFIG_TRIM_UNUSED_KSYMS=y, both rather rare at > happening once in a few thousand randconfig builds. I have attached > two .config files that presumably refer to different problems I > see on linux-next: > > 0x1A1E54C2_defconfig fails every time with > ERROR: "__aeabi_idivmod" [lib/cordic.ko] undefined! > > Apparently, this is because lib/cordic.ko is the only module using > this symbol (some built-in code uses it) here. Well, the actual explanation is that this module uses only one symbol. And when only one symbol was listed, it got ignored. The fix goes like this: Nicolas diff --git a/scripts/adjust_autoksyms.sh b/scripts/adjust_autoksyms.sh index 5bf538f1ed..3de40db0a1 100755 --- a/scripts/adjust_autoksyms.sh +++ b/scripts/adjust_autoksyms.sh @@ -59,7 +59,7 @@ cat > "$new_ksyms_file" << EOT */ EOT -sed -ns -e '3s/ /\n/gp' "$MODVERDIR"/*.mod | sort -u | +sed -ns -e '3{s/ /\n/g;/^$/!p;}' "$MODVERDIR"/*.mod | sort -u | while read sym; do if [ -n "$CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX" ]; then sym="${sym#_}" > 0xEA8A78CD_defconfig is stranger, as it only sometime breaks when I build > in a newly created object directory or after "make clean", but > not if I retry the build: > > $ rm -rf build/0xEA8A78CD > $ mkdir build/0xEA8A78CD > $ make O=build/0xEA8A78CD 0xEA8A78CD_defconfig > $ make O=build/0xEA8A78CD -skj12 > ERROR: "memory_cgrp_subsys_enabled_key" [fs/ncpfs/ncpfs.ko] undefined! > $ make O=build/0xEA8A78CD -skj12 > $ # SUCCESS I don't understand why you'd get a successful build the second time. I'm able to reproduce, however it fails everytime. This one was less obvious to solve. The construct is: #define SUBSYS(_x) \ DEFINE_STATIC_KEY_TRUE(_x ## _cgrp_subsys_enabled_key); \ DEFINE_STATIC_KEY_TRUE(_x ## _cgrp_subsys_on_dfl_key); \ EXPORT_SYMBOL_GPL(_x ## _cgrp_subsys_enabled_key); \ EXPORT_SYMBOL_GPL(_x ## _cgrp_subsys_on_dfl_key); Duing the build, EXPORT_SYMBOL*() is redefined to anchor the symbol name so a sed script can extract them and feed them to scripts/basic/fixdep. However in this case the preprocessor output had more than one such symbol on a line and the sed script only captured one of them. Therefore the pseudo dependency file for memory_cgrp_subsys_enabled_key didn't get added to kernel/.cgroup.o.cmd. Even when autoksyms.h was updated with that symbol and the dependency file touched, the build system didn't know that kernel/cgroup.c had to be rebuilt. Now fixing this wasn't all that obvious either. I had a really nice sed rule to parse multiple instances per line, but sed regexp can only do greedy matching. I found out how people work around that limitation but that doesn't work well for string delimiters. In the end the best workaround is simple: substitute any ';' with '\n': diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 36e9475395..1f0d41cc73 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -281,7 +281,7 @@ ksym_dep_filter = \ $(CPP) $(call flags_nodeps,a_flags) -D__KSYM_DEPS__ $< ;; \ boot*|build*|*cpp_lds_S|dtc|host*|vdso*) : ;; \ *) echo "Don't know how to preprocess $(1)" >&2; false ;; \ - esac | sed -rn 's/^.*=== __KSYM_(.*) ===.*$$/KSYM_\1/p' + esac | tr ";" "\n" | sed -rn 's/^.*=== __KSYM_(.*) ===.*$$/KSYM_\1/p' cmd_and_fixdep = \ $(echo-cmd) $(cmd_$(1)); \