Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2947726ybt; Sat, 4 Jul 2020 01:53:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+7VBco3VMfFXPmJQgVj4CX2mHIXq7HYORtjKNDuJIOYklhXZz0zpuzGVLVYhfVNG7xZ6U X-Received: by 2002:a05:6402:1605:: with SMTP id f5mr47435850edv.8.1593852806844; Sat, 04 Jul 2020 01:53:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593852806; cv=none; d=google.com; s=arc-20160816; b=g1ATejq+SnJA02TvZ3ahMRU+G1tjjT+Adj85SYWpSTRNIdZY+JMCX1yCFRw0o45Oqz GBjl8pQfgC1ki8G4Gmx0KKz7ZoiDjaykn5RZMgGWCN0bApclAlDwbTzFW/KXjkcGVOf2 1THh+f5GehZl1veG/x8dxaCcaN/TgbjuKrReSzksiN0G8nR6sH0sVGGdPBJlrrn60Y15 Pg10cAakhzn/nE6YgDDbiHtXnNcY2shb019awwMhC5cXqI6vaYHZyOSJvBvvzuDkSJkF yRhah+US5chHwHx1hXea2wIvfMnv+rqQfieGkXzI2sJGdIB99n+KK3XsSLWNlwfkspYx DkPQ== 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=VwOjxo+AYrnIugDfwLwRdUzbVsmnTWEdefeWvuTDVmc=; b=izfYXhKekDKyj4NQFFVBnlxmATvT/dhhxuJK5NQsy0XHg+3SeqiAXWsCGrhuGhbRS1 FkxfG0F+WgJzcP0ZhryWIV1QOb5KXdiqLj4xeXubsNzhohR0a8cIb79/NcRiQbXnMqgh YhSZXxBVMUrD9Q+ej57TasLXj/8/i0Yl3cB8qXZJP7/Hu56yZtwxTEPYVelJg4pEYedY lk2Djtq5NpYdLG8/A2Tnn9FuzYikfsgxMKQbXi/DUPAlpadNOhx8IwQDtBLOB24Sb/l/ xjp5CZ8EVLMr2Nmd9iT83h1OrOBn0NUk27NxNCWckWVlihhqPRqSSdiwi2oSPh2w5zPz qnSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b="g+dH1d/P"; 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 d18si8460541ejm.684.2020.07.04.01.52.44; Sat, 04 Jul 2020 01:53:26 -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="g+dH1d/P"; 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 S1727082AbgGDIwe (ORCPT + 99 others); Sat, 4 Jul 2020 04:52:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726157AbgGDIwe (ORCPT ); Sat, 4 Jul 2020 04:52:34 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B12ACC061794 for ; Sat, 4 Jul 2020 01:52:33 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id f139so36404291wmf.5 for ; Sat, 04 Jul 2020 01:52:33 -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=VwOjxo+AYrnIugDfwLwRdUzbVsmnTWEdefeWvuTDVmc=; b=g+dH1d/PFd20ixl7FsBGTfs3j7Y9QoCZDBDayErBIX0wTDCFA72uArnuQl8kKjy3FC gg5prSYGe1M/TdA6rApF1FQmwhI1i2ylfNHCtSCHvBh4tKhPjfdfOWjb+9LS781wd265 dcOXOWnlRnbona/kVOTImz6keVcM9jPw6pBNw= 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=VwOjxo+AYrnIugDfwLwRdUzbVsmnTWEdefeWvuTDVmc=; b=aEvpW0A/zVaUlGQTo+ah1qLQe5EtKfLNvQY2Cz4QCPjrMo7vgvOEOHuA+sduVIUOuV GXr7f0IKRyvUV+1IuXe3+Cp14cSzHZjhrTiB8V0w8NaaI5mbGH3PRto4k1pfEY98oQUu d/VTc+UGt+53Ia/oO0F7PAmfto2qlj/DYwKSLmIswMO7f9qyC8t1WEwfyChAdkCFAtAT UBApyH2hN1D4tdnFhxZisaCszOPZjqfMUe+5ay8x8eg6nQ+vexSxUOvRnQuDApvhEV8o c2bE2UXJjYxt3+Ksdak7X3wnatOQLb09zcv6/fKv8GGQFnQMxSaZs7GglTkVHPpueoaj G6JQ== X-Gm-Message-State: AOAM533adsilRwurVsmVsbUmLWWmVt6dhrB5HBNnKB+Tx98YGSdba2Ck 8vDBsa/sLOxb+wGDu8/TtXpZ4A== X-Received: by 2002:a7b:cf10:: with SMTP id l16mr40618406wmg.93.1593852752398; Sat, 04 Jul 2020 01:52:32 -0700 (PDT) Received: from localhost.localdomain (88-144-169-139.host.pobb.as13285.net. [88.144.169.139]) by smtp.gmail.com with ESMTPSA id a22sm15195915wmb.4.2020.07.04.01.52.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 01:52:31 -0700 (PDT) From: Ignat Korchagin To: jdike@addtoit.com, richard@nod.at, anton.ivanov@cambridgegreys.com, brendanhiggins@google.com, linux-um@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Ignat Korchagin , kernel-team@cloudflare.com Subject: [PATCH v2 1/3] um/kconfig: introduce CC_CAN_LINK_STATIC_NO_RUNTIME_DEPS Date: Sat, 4 Jul 2020 09:52:11 +0100 Message-Id: <20200704085213.444645-2-ignat@cloudflare.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200704085213.444645-1-ignat@cloudflare.com> References: <20200704085213.444645-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 --- 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 a46aa8f3174d..717a3ada765e 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) -static $(m64-flag)) if 64BIT default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) -static $(m32-flag)) +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) -static -Xlinker --fatal-warnings $(m64-flag)) if 64BIT + default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) -static -Xlinker --fatal-warnings $(m32-flag)) + 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