Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2673305pxa; Mon, 17 Aug 2020 16:13:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwT2pD9+ejCulpAXq5dvXaOiwD7InGlaVzIk2a4wB/JLYcCVlCpqDfNtv3plL/vFG3Cwvxy X-Received: by 2002:a17:906:38c7:: with SMTP id r7mr18065722ejd.118.1597706007655; Mon, 17 Aug 2020 16:13:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597706007; cv=none; d=google.com; s=arc-20160816; b=Li8smkQ/uzzpXdJuXrSstBmMKPaKjBFMU2zYMEAzVVqJYMzRjBBFaoGIUXM0H6G3zQ 2eMnFzvM/fyOy3yCqx4lVSPlBMK6TvuI7Oth5k29YjPNuNVjo4elEDk38orAzp/1oHLS +z380nEQuMbZ83RfQryMwCr1JlFDhRvrNTp7D99RWg/GGB8Qh70RAGeapsSQJjIDofv3 515LND45fbseR+mhwFNyBjljHnito/I5wYKmD1hzCqsACvjdyEonr6QXb8/UycaJnZ0F Dgk/YvwU0q2RZchsZTw8r9f+zpfqXvQTWnYQ794ecajwQvyRpW9JTgC4jnmZ6IlQ++AV sq9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=kIk9FUx7DIlhGhFIt2N6cpuJCia592mQ/iQfMoiZ3iE=; b=aqlewmvLVIRZXcENciykg4c3/cdf4iUodIoFVP/1ygvRS+OoixVDOFG8Dvgy0GuNcD D27js+hIybzEXot/TYy0dqExGRiaw8du0p36w7s3BPvZn1gg40tNKuiGakna3F0+G/S7 Gx3TKIpecCIZgRD7SlYBSslOgWqBWy+VL6ZekwAU1LbjT5u0NrkykxiPhIRIoX0juzyG VDVSk+MjE54cfjQ+pad7M2Oi/17Pjo2H/dDc3aFzAbh0g+dQd2qf6Sa/+cJPnCmKq1Ui r/9/sH93uQvYjUlAjDJh0rx0C8LCwjEZg8SE302bTtu+gbqf/1Cb2JoCXgMJNhL7bWd9 jejg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=gQoHfUpb; 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=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ot7si12044816ejb.747.2020.08.17.16.13.04; Mon, 17 Aug 2020 16:13:27 -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=@google.com header.s=20161025 header.b=gQoHfUpb; 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=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729332AbgHQWCl (ORCPT + 99 others); Mon, 17 Aug 2020 18:02:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729308AbgHQWCf (ORCPT ); Mon, 17 Aug 2020 18:02:35 -0400 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7AE6C061345 for ; Mon, 17 Aug 2020 15:02:34 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id z10so11900218qvm.0 for ; Mon, 17 Aug 2020 15:02:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=kIk9FUx7DIlhGhFIt2N6cpuJCia592mQ/iQfMoiZ3iE=; b=gQoHfUpbLM0sDU/kmKlEItWnjMkZ07La/np9HovfFux6Z2VP9+/zZrQWA4ecIjJgvq dnD+gK0MB87V5MirFehxDF/9Y0qyw5jGSnVPfhphz46yfpH/a+RlENfRfPyt87lKvXNt 3M8YGTf9geBnYZq62BRsxzKcJtfiB7A2JPR7UVcm63uyarEjTgfrxkjaTulCAKeb73LZ exzQUda0T8aom4mtZLMJVL/LVK8eWeJNZoH1geb6HQxDryALTxFmCJwMm+oFzaxPCUpi A0f2OynWzgOjSsioBKP8o4nkCzdHdYSkPkC8fIcVqpZ5VTuRGrg4J4X3JxxkwMH7CMgJ uOEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=kIk9FUx7DIlhGhFIt2N6cpuJCia592mQ/iQfMoiZ3iE=; b=TfLt4MsWHX1QImTInJ9sUgxspyktEjInxoG+tGLEhCOzgpUtz00rb7i4kwJmAr6zjq pBnza3gXnD7rdfXlhADo06xUmGF3cVgaW+p6mafWbqJlTrrbRa4sTDASq2MhlEWf/YAR tbpu82q4z5ajov0NJ5aU80p1OymqBc+rc7wSJ1OoPMg1M2xUpHcpdpUvu1LmfgymWqae zjCj7Ng8lXP84NRkO/RuAgBwLQUB5FkGB1VQJzY0CbqnIfmyRx/skx4OLd9qHDBGza3L aIcQI2lIUjDwsV8BmrsfUuRO16i6LKuNTmn7vNsWLrklXHscXvrmmyLN7sN2K6sznwK6 fNeA== X-Gm-Message-State: AOAM5315Jw089BSsVluzXK5BpMPD6RSRPinkRE7woTqouiiYFcfDB1hu 5/8lVLE3wQr9MAIGTEaW3wBhkoc1udxLZc854NY= X-Received: by 2002:ad4:470f:: with SMTP id k15mr16321629qvz.216.1597701753768; Mon, 17 Aug 2020 15:02:33 -0700 (PDT) Date: Mon, 17 Aug 2020 15:02:12 -0700 In-Reply-To: <20200817220212.338670-1-ndesaulniers@google.com> Message-Id: <20200817220212.338670-5-ndesaulniers@google.com> Mime-Version: 1.0 References: <20200817220212.338670-1-ndesaulniers@google.com> X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog Subject: [PATCH 4/4] x86: don't build CONFIG_X86_32 as -ffreestanding From: Nick Desaulniers To: Masahiro Yamada , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov Cc: Michal Marek , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Kees Cook , Tony Luck , Dmitry Vyukov , Michael Ellerman , Joe Perches , Joel Fernandes , Daniel Axtens , Arvind Sankar , Andy Shevchenko , Alexandru Ardelean , Yury Norov , x86@kernel.org, "H . Peter Anvin" , Ard Biesheuvel , "Paul E . McKenney" , Daniel Kiper , Bruce Ashfield , Marco Elver , Vamshi K Sthambamkadi , Andi Kleen , Linus Torvalds , "=?UTF-8?q?D=C3=A1vid=20Bolvansk=C3=BD?=" , Eli Friedman , Nick Desaulniers Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org -ffreestanding typically inhibits "libcall optimizations" where calls to certain library functions can be replaced by the compiler in certain cases to calls to other library functions that may be more efficient. This can be problematic for embedded targets that don't provide full libc implementations. -ffreestanding inhibits all such optimizations, which is the safe choice, but generally we want the optimizations that are performed. The Linux kernel does implement a fair amount of libc routines. Instead of -ffreestanding (which makes more sense in smaller images like kexec's purgatory image), prefer -fno-builtin-* flags to disable the compiler from emitting calls to functions which may not be defined. If you see a linkage failure due to a missing symbol that's typically defined in a libc, and not explicitly called from the source code, then the compiler may have done such a transform. You can either implement such a function (ie. in lib/string.c) or disable the transform outright via -fno-builtin-* flag (where * is the name of the library routine, ie. -fno-builtin-bcmp). i386_defconfig build+boot tested with GCC and Clang. Removes a pretty old TODO from the codebase. Fixes: 6edfba1b33c7 ("x86_64: Don't define string functions to builtin") Suggested-by: Arvind Sankar Signed-off-by: Nick Desaulniers --- arch/x86/Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 4346ffb2e39f..2383a96cf4fd 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -80,9 +80,6 @@ ifeq ($(CONFIG_X86_32),y) # CPU-specific tuning. Anything which can be shared with UML should go here. include arch/x86/Makefile_32.cpu KBUILD_CFLAGS += $(cflags-y) - - # temporary until string.h is fixed - KBUILD_CFLAGS += -ffreestanding else BITS := 64 UTS_MACHINE := x86_64 -- 2.28.0.220.ged08abb693-goog