Received: by 2002:a05:7412:8d11:b0:fa:4934:9f with SMTP id bj17csp422141rdb; Mon, 15 Jan 2024 01:23:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IF3mbu5jFze8MdWyNqtH89N4iHVxovXwh55nk0/H7PhzGKniKTQ3Hq8eSYXdY/fWQqR4eIH X-Received: by 2002:a05:620a:800f:b0:783:6438:32c with SMTP id ee15-20020a05620a800f00b007836438032cmr430078qkb.71.1705310637450; Mon, 15 Jan 2024 01:23:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705310637; cv=none; d=google.com; s=arc-20160816; b=MOd2oNmO53P2VM8/RvkMbTZgLIIRvBNW2L1jGJw2Pr+knngX49iahCJ8FU1I4VKvyb EGZDARa5eGUBcu79zZbhh+94ScrRolUzzkcDKGdM+MvjHvKi6jPHMgH883O1LukIWjup a16iWtTckIdzVDlvzwDf9tHHHO+xInMV8woJ9dHATSEIiM52aoYi+kAT5Kmr41w+tDxh er6R8hnKs5nxA3y//EmaoiDFvqxVGS0dKrgFep9xGrae3tlH70knOy/hGvq4NofFhcvw AjJfVdTW4rVY8coxHGzdsui/NELT0Q3dUcrOm/KfKbWBq/x0ZvO2dTFrsgUtVprhuSge RaYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=rcYPhRGd43b7CefS4mS1BKKH4ql6RBhdXWhyItNiInQ=; fh=CYAHjdarofMEiuwwFmrvwR497luntx66WL0Tel/Mfzc=; b=Ib22FJYLqvBWA+vIZAJzctpw62ffGQlN25I0MEXb4rRVSh4/3aOoOoGJC4F91rtqWA /jkHxromuyps1kXP2+S5kwEAQCQRuvTmVraH6rNnHLPBCR+khpS3IlL7VaPifWyv0t1i NbXYkS7cLGLuKesFvEWBlZQ2D/0rR5vrBYRgzaMnyxoIrwTaIc1YAhIyBSK82H13ymqW rHOkzKruG45mbmXZ28C/yC4mjosbe8xy1xwR/ByIG7+tM7OzP9+315TVa/nVzbavPc8x mQYFFPr8Nlo6bPxNw2IDla3run4Q8lKmImYpAUzFqmdnvGGnHupIEpdYAXYx7OYc+oFV Bw1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QXGm8akh; spf=pass (google.com: domain of linux-kernel+bounces-25789-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25789-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u15-20020a05620a084f00b007835c8089adsi1881262qku.248.2024.01.15.01.23.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 01:23:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25789-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QXGm8akh; spf=pass (google.com: domain of linux-kernel+bounces-25789-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25789-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id F1C551C21453 for ; Mon, 15 Jan 2024 09:23:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D0FEEAF2; Mon, 15 Jan 2024 09:23:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QXGm8akh" Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C666F4E3 for ; Mon, 15 Jan 2024 09:23:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-40e80046263so650925e9.2 for ; Mon, 15 Jan 2024 01:23:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705310597; x=1705915397; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=rcYPhRGd43b7CefS4mS1BKKH4ql6RBhdXWhyItNiInQ=; b=QXGm8akhWEgQgOgEnFYLpSCfAm69nd9/XgSfUGBwQ/26p9GN6IYNOFQiAensuENPdi Eqr4YvNFNVZCI2T0X37Y1a9UeIOQisi5oB5v0UcVdKPkdxA6z+iZmVii+pLps7XBN4FK FsLABLWEeDjTeSZMdrxRmTc7OcMJfn+5gGMW9FDSpJbDq2pK9SKMy1tB6YXQcljNKiOq +tZk4lLrB7TEMRPufugWKIBZYguFFsQJJBt8pc0iUFkr7rFzSl6DIco3TnhmN/fKYJXr 4nBKRF2rg9Bth+HiwNb19iKn6DtqueegvPS7QV/49yDxo9pmzcROgaFSx5Uq3FLX8I9B KrsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705310597; x=1705915397; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rcYPhRGd43b7CefS4mS1BKKH4ql6RBhdXWhyItNiInQ=; b=S3lm/hd/tzaq9EgkSjorTHJIwdZB+rjJIAGQVZdCWzPxJn4thX2jIBkIbAjAE3sAT7 HDvKMvLRpE1M/QUF7lBC9zTeojFN4PY2wkviSJVywSepKBo6e3NkbyzgVhOFrby4W5YY rin4YDtJEE8AMl+K6QUHKRQEoU2LZPs8MCMIEMemVLKNSDtzTJ6uTwmZkDvz7kAMg/Aw yJXl69yjfG5xedPRIS3cr52Kq/263uzMHcXJx4LyEqDwca38lVXSmsu9+WEgK27bud7N BfGWn5iPi9abPMymMARp0wvUxvaINqWp0+CDWx2nKU36zXw3tGnTTtd+0M/+k/c0oOdU gQyw== X-Gm-Message-State: AOJu0YwaUC5jZmVVzpWoKPpDzMbj+CDoJKpgNfkCR5YvSvl84Akc4Qdk dSyvyLjmFI666+xzwRlwS20/DIEDUS/b42fhJoPDDtRKqr0= X-Received: by 2002:a05:600c:3151:b0:40e:67a9:5d1d with SMTP id h17-20020a05600c315100b0040e67a95d1dmr2277573wmo.149.1705310597141; Mon, 15 Jan 2024 01:23:17 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <9aef98eed96ed32962ce90499291cb30ad5e3e14.camel@xry111.site> <20240109074843.GI19790@gate.crashing.org> <4ee8067e72028b070d92e10fa33ddde3a498cb48.camel@xry111.site> <20240109082647.GJ19790@gate.crashing.org> <20240110141005.GL19790@gate.crashing.org> In-Reply-To: From: richard clark Date: Mon, 15 Jan 2024 17:23:05 +0800 Message-ID: Subject: Re: undefined reference to `__aarch64_cas4_sync' error on arm64 native build To: Mark Rutland Cc: Segher Boessenkool , Xi Ruoyao , gcc-help@gcc.gnu.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Mark, On Thu, Jan 11, 2024 at 7:26=E2=80=AFPM Mark Rutland = wrote: > > On Thu, Jan 11, 2024 at 09:42:40AM +0800, richard clark wrote: > > On Wed, Jan 10, 2024 at 10:12=E2=80=AFPM Segher Boessenkool > > wrote: > > > > > > On Wed, Jan 10, 2024 at 01:59:53PM +0800, richard clark wrote: > > > > A ported driver in linux kernel calls '__sync_val_compare_and_swap'= , > > > > > > That is a builtin function. It does not necessarily expand to an act= ual > > > function call. aarch64 will typically expand it to inline code. > > > > > native gcc version: > > gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 > > cross-compiler gcc version: > > aarch64-linux-gnu-gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 > > > > Interesting, the same '__sync_val_compare_and_swap' in the .c file > > will be 'U __aarch64_cas4_sync' in the .o file compiled by native, > > will be 't __cmpxchg_case_mb_32' in the .o file compiled by > > aarch64-linux-gnu-gcc... don't know what the reason is > > The __cmpxchg_case_mb_32() function is kernel code from > arch/arm64/include/asm/cmpxchg.h, so I do not believe that's being genera= ted by > the compiler from __sync_val_compare_and_swap(). > > Are you certain that's being built from the exact same C file? > > Are you able to share the code in question? Where has it come from in the= first > place? > Ah, double check and the misleading info about the native and cross compiler, the native gcc(Ubuntu 11.4.0-1ubuntu1~22.04) and the cross-compiler - aarch64-linux-gnu-gcc(Ubuntu 11.4.0-1ubuntu1~22.04) will generate the same link error, but the cross-compiler - aarch64-buildroot-linux-gnu-gcc. (aarch64-buildroot-linux-gnu-gcc.br_real (Buildroot 2020.08) 9.3.0) will not generate the link error, I believe it should be as you said, the aarch64-buildroot-linux-gnu-gcc doesn't enable '-moutline-atomics' by default. > > Thanks, > Mark.