Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp202250rdd; Tue, 9 Jan 2024 01:03:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IH6KGt3MPTrP5ful2774P3gkopBUbZsyJ5eI9jksbflS8AK+m7pw5Jej6pcVnMIyrLi2cLA X-Received: by 2002:a05:6a20:9747:b0:199:ebd9:c5db with SMTP id hs7-20020a056a20974700b00199ebd9c5dbmr802909pzc.43.1704791013101; Tue, 09 Jan 2024 01:03:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704791013; cv=none; d=google.com; s=arc-20160816; b=fLuuaPryOtwn5BuBYafz8HV90Q8kkSMIj+XfVzugxd4wqW9Jyj5kIuwNkcv2oVMwYX BZ6lgdOpEmXOIl8p5hJKn5VktmR83FYMyzc28JW8xd9a+MqLJ8o8PrJtRmbM2JJ0FsUf OsiGzyGleAroy5j2XhUMoDlvqS/yr7B92CghkngD4htdwkWvD5yaVxnt6PeSiO+GuPty MgchjW1FH24xH8hBzaQLpidUnWSj9PRbQDBoLzgcv5d9vaJHx+VS4ooUg40hwqjOX8wH ZYumBcCBTouJo0raeUu/OiUo5QzR9uSlt8MVI/IijQQdvqYga5NNpwLoELT6lyglidP+ OjTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date; bh=Xz4D8VbwK37BpTA3Xw0vT/SsGu28H3zXNpIYSH5sj2U=; fh=RFoyDDwxfmEUunhFhmt6lU6e2yzzLizxK3WBeCCeiFM=; b=ynq0Z+6IH56F32K7PmY1rAiirvu9u3YdNa+VJY/989F+OPts6PNmwVgXBmeEYWAb1T 197lGTV53onuFL7OohIdn3f6s03Tbv7P6ljgxwgX6JTFJ1fU0oauDB6rF0wSQ1tebQtq csTusJ2l5CWyxDOgeY+RN1u3CLagDFpNlo1dQZz0xwmiQ41W/209jWQ3AYYEsx6b5Dwd L5vzojllSz324J6bNrUKFn9yvMcVG/N+NEjPJDfxELnq5JVJjz2IHXrOE6BVYqYcbuQ6 teHeSD8LPFtL7vCSTLGbOGLwZvWXkEzh8oR5fI3Ec18ulXLWbXyEeiRtArcGlAclWABI cNyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-20609-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20609-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h26-20020aa786da000000b006d9b11edaf1si1151339pfo.268.2024.01.09.01.03.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 01:03:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20609-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-20609-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20609-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 48270B26C46 for ; Tue, 9 Jan 2024 08:46:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7C49D2555A; Tue, 9 Jan 2024 08:42:51 +0000 (UTC) Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 08A446FD2 for ; Tue, 9 Jan 2024 08:42:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 4097miYa016493; Tue, 9 Jan 2024 01:48:44 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 4097mh2R016492; Tue, 9 Jan 2024 01:48:43 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Tue, 9 Jan 2024 01:48:43 -0600 From: Segher Boessenkool To: Xi Ruoyao Cc: richard clark , Mark Rutland , gcc-help@gcc.gnu.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: undefined reference to `__aarch64_cas4_sync' error on arm64 native build Message-ID: <20240109074843.GI19790@gate.crashing.org> References: <9aef98eed96ed32962ce90499291cb30ad5e3e14.camel@xry111.site> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9aef98eed96ed32962ce90499291cb30ad5e3e14.camel@xry111.site> User-Agent: Mutt/1.4.2.3i On Tue, Jan 09, 2024 at 11:05:57AM +0800, Xi Ruoyao via Gcc-help wrote: > But the Linux kernel cannot use neither libc.so nor libgcc.a. I have built Linux using libgcc for many years. It is as easy as +LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) +libs-y += $(LIBGCC) > (I know > some non-Linux kernel developers are overusing libgcc.a for kernels, but > IMO this is just wrong and Linux developers also do not do this. If the > Linux kernel needs a symbol from libgcc the developers just provide > their own implementation.) Yes, and often they have fallen behind. When they eventually catch up they usually just copy the GCC code anyway. Originally the only reasonable argument for not linking against libgcc was so kernel code would not accidentally use double-length divisions. There are other simple ways to have all uses of __divti3 and similar create link errors, so that is not really a good argument. libgcc is an essential part of the compiler. For most targets, for most code, GCC will not generate function calls, there usually are faster (or smaller) things it can do, but it still is necessary to have libgcc for more uncommon things. Using a partial copy of it, behind the times, and maybe even incompatible, is not a great idea. Segher