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: 8974681 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 204A3BF29F for ; Thu, 28 Apr 2016 20:56:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2644A20270 for ; Thu, 28 Apr 2016 20:56:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 251D2201C0 for ; Thu, 28 Apr 2016 20:56:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753409AbcD1U42 (ORCPT ); Thu, 28 Apr 2016 16:56:28 -0400 Received: from mail-qg0-f42.google.com ([209.85.192.42]:36723 "EHLO mail-qg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753265AbcD1U41 (ORCPT ); Thu, 28 Apr 2016 16:56:27 -0400 Received: by mail-qg0-f42.google.com with SMTP id d90so35095073qgd.3 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=BTccateaHVDUsGGj2Vj2oCJVCLqsqKrvHWVohaz+o3WKQVEx+R8oeGnONT+Lruht3n VQaxAU8z20mRaeVl0kfk8f6tRI9OV+Byk64HW/aB5WQrNQmAd1mT97wHFlA1iraZLzqo gaznd0YEy1pbXlhb6vH9znq8Y6viTRELtpGDPD4/TEfZgYOBNcdryB9gSbCBgZ9oGGSY IhSOUUQNWDJ9nfiGzhyRIOXbx5Cdn5sEb5RxgYiMQO5Q+1DK35SpYDn/2tYMjX3L/oeC I29dKSNnwx1RV5xLwPzexqN9t7yQYr9yEjH6EQI8DwEd5gAgOK6Gb6dXHK4//ovlce1j 3llQ== X-Gm-Message-State: AOPr4FXz83OMeDNCYWmTQZx6PunzpHmfN1kpEx8t+jlt7evTJOI3XOWrPY6EentryZnAlcEx 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-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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)); \