Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1268325ybh; Sun, 19 Jul 2020 14:03:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuyWQd3hkutLV/3Ez15LCY0MvUPMwTOcgfT+ygoD9LQ141mH68/72ePmL2qhaZY5CP1Wf2 X-Received: by 2002:a17:906:c1c3:: with SMTP id bw3mr19025414ejb.8.1595192589973; Sun, 19 Jul 2020 14:03:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595192589; cv=none; d=google.com; s=arc-20160816; b=O6oFVfnJrod0w672IHz8ESHQrdoAEbgJFG9cYiUav5gjRC8vfKLLQLM2gUIgQMPXne FFFYPmv/WqLOS7eXgl8Sh5mfjaSk8yncDMxK89NSyI2E3q4IKxyisV+WFQJxCV76Wyhi I7/etBeRMDySUjQzEUV+hzTs9cHsfiPeIuUsI7FjtgcZWSsSwpyCctKx8G9mgKNyVYpQ 1TACOS2JY3TEOiT/S33k0xwOqupharhRzRzQ9cnDveHTBBT/q60Sh5GmFS/PxA/AlqXI M9ck7BbtZMB0Ry/9Uc4tqzhuBsA+wg8KkA5fnuBGbpkpcz1KkqBBdXXCQaCGuGm5t/CH CSMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AB7aSgKZXEiLixC1bE1ZYkp9PgBC2tt87UCkWirjmZc=; b=ZkHmjs7QpDg+wj+w510fQc41D3vE9EXjw2eebzZS1PYjRTnURu/UJ1gHx6CnljPwzA vW6VxNWreOtWRoohXcqoaNCdriGqxWLwhhqKl5ax73LXx1em+YZK5AZ5yEIBTr9dhd/g lQnFT9c3S0VdmXPZgPglD3t6HvcuoR4JULyU4KKeIttlCFFtkzpaa16ZxjVKVHAW6lfh FpNdLnRBHP3P7UViHmtka+EB0sKHk9nuzrf6KPqh0msLKVIwI+MaLes1dDet3f4/5kBw 1EzLkuRfbdsYdtkxvcPMqoBW7lrVEljtHfQipWzojO/boF2FFUENTIcNZYPKhnGRcUq3 v5rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=YGqE2kBo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h16si9527876ejb.456.2020.07.19.14.02.45; Sun, 19 Jul 2020 14:03:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=YGqE2kBo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726598AbgGSVCk (ORCPT + 99 others); Sun, 19 Jul 2020 17:02:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726073AbgGSVCj (ORCPT ); Sun, 19 Jul 2020 17:02:39 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1046AC0619D2 for ; Sun, 19 Jul 2020 14:02:39 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id a15so966745wrh.10 for ; Sun, 19 Jul 2020 14:02:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AB7aSgKZXEiLixC1bE1ZYkp9PgBC2tt87UCkWirjmZc=; b=YGqE2kBoO0fMgIKHmN7Hv1yUFgWMl6rnvOn2kmMuwq10ORWq63SUxQgm28U39wXDwP 7khSKwtwrQWhqXVkmGtGoi98Y5OCiyMEtgTTvIXdptqtyI1hgCrANIQYdcZQa+TayMNI 4qN7jlqjejPMH88o8dpdzwTtuDqT6iM4AAyYk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AB7aSgKZXEiLixC1bE1ZYkp9PgBC2tt87UCkWirjmZc=; b=i0fViEGtm8OyKipbCGttOM6RDyf+9GKjtE3aAsPoOCMF5Z0QQvK9B2pVC71muOCznJ Ivoa9g1H5UCsQDkuA7dfBzG0Ne9vWAQE4YKxxkKAHcJqGW7VCciHWLzilISD0az1S6vC /1Ppsh+kFkDH7UmRbhODoC1DY2lobYnaYlRhwCbMHVatn7UXBcjsHZif/djRJz28p6fL 8EGuTJy6tva8UZZ5z7kli4Jmri5r+URUPPhHwoPTCxAbCXG0EerP8biIzABgqYTumymC RVnEovEX3FhU6pU4iXul4H/8LegfiLbVmtWmKVjjEL/AvOxkEBmLNF4kFzHIE/cxfL2T Vvpw== X-Gm-Message-State: AOAM531V8H9zaLjkkhXsYOfCL95gLR865Ayuu+KfgcWokqQDq+c3hK5z CyubiG0T0aSrQDzLmfbLyEY/ng== X-Received: by 2002:a5d:4051:: with SMTP id w17mr18555406wrp.183.1595192557557; Sun, 19 Jul 2020 14:02:37 -0700 (PDT) Received: from localhost.localdomain ([88.144.89.224]) by smtp.gmail.com with ESMTPSA id l15sm27408453wro.33.2020.07.19.14.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jul 2020 14:02:36 -0700 (PDT) From: Ignat Korchagin To: jdike@addtoit.com, richard@nod.at, anton.ivanov@cambridgegreys.com, brendanhiggins@google.com, masahiroy@kernel.org, linux-um@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Ignat Korchagin , kernel-team@cloudflare.com Subject: [PATCH v4 1/3] um/kconfig: introduce CC_CAN_LINK_STATIC_NO_RUNTIME_DEPS Date: Sun, 19 Jul 2020 22:02:20 +0100 Message-Id: <20200719210222.2811-2-ignat@cloudflare.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200719210222.2811-1-ignat@cloudflare.com> References: <20200719210222.2811-1-ignat@cloudflare.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For statically linked UML build it is important to take into account the standard C-library implementation. Some implementations, notably glibc have caveats: even when linked statically, the final program might require some runtime dependencies, if certain functions are used within the code. Consider the following program: int main(void) { getpwent(); return 0; } Compiling this program and linking statically with glibc produces the following warning from the linker: /usr/sbin/ld: /tmp/ccuthw1o.o: in function `main': test.c:(.text+0x5): warning: Using 'getpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking We will use the flag to detect such C-library implementation build time and possibly disable static linking for UML to avoid producing a binary with unexpected behaviour and dependencies. Signed-off-by: Ignat Korchagin Reviewed-by: Brendan Higgins Tested-by: Brendan Higgins --- init/Kconfig | 6 ++++++ scripts/cc-can-link.sh | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/init/Kconfig b/init/Kconfig index 0498af567f70..0a1ec56c9f33 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -57,6 +57,12 @@ config CC_CAN_LINK_STATIC default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m64-flag) -static) if 64BIT default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m32-flag) -static) +config CC_CAN_LINK_STATIC_NO_RUNTIME_DEPS + bool + depends on UML && CC_CAN_LINK_STATIC + default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m64-flag) -static -Xlinker --fatal-warnings) if 64BIT + default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m32-flag) -static -Xlinker --fatal-warnings) + config CC_HAS_ASM_GOTO def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC)) diff --git a/scripts/cc-can-link.sh b/scripts/cc-can-link.sh index 6efcead31989..e5011a46103e 100755 --- a/scripts/cc-can-link.sh +++ b/scripts/cc-can-link.sh @@ -2,10 +2,11 @@ # SPDX-License-Identifier: GPL-2.0 cat << "END" | $@ -x c - -o /dev/null >/dev/null 2>&1 -#include +#include +#include int main(void) { - printf(""); + getpwent(); return 0; } END -- 2.20.1