Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp81000rdd; Mon, 8 Jan 2024 18:52:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IHBSO9xN5Gb+PdVe4WFuc3sOqpuGlC+t1a5np8bw54i9c6T6nyTH4EDxJ94dW9It+Ceat2u X-Received: by 2002:a05:622a:14ce:b0:429:76cc:902b with SMTP id u14-20020a05622a14ce00b0042976cc902bmr7231618qtx.7.1704768764591; Mon, 08 Jan 2024 18:52:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704768764; cv=none; d=google.com; s=arc-20160816; b=lVLlN2gICFVDFt7heoDJlSNTO+FKZLIlf0rD3XrMxmAjXctEfKYJrfRHPGweuCiWZ/ F9XIueOY1V5YGhpyD/NsVtW1oy+g0eIEy/0IXeYu5RuDDmGWf2Ag4MAT87dZP7bhLhel 3U2tCVlkC4z2Cnb9bCiDlxqTY/x10C0++OKVvAOl9M14lRsG1aNC7H66s00KZwWd1A2n pXnBWeUXm61HVU5+8dklgmJTDST4YcyX5llmZUBRX0Zz1o49YGEfPctxGjRXX7/09gat 3Q4dlHM11nhdts/hK+UX7iAUgW1UjoLxc1BKOoAbWIQoZVk2R40okMLenY8lHbAD8XHp lALw== 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=vtP9R9o0Xcb1u/9MkTI25+GODlHbNvxDpBYnEktijiw=; fh=UdB0m562Z+wQ3Qj30x3kgJQ26LHZlnL3l1NYdYCfTUk=; b=qwsAubVFpKRaEsmLC3u9nXDzA+AkKMkBNcjI05AzJ//aHcdIQxL177U+2B+1aDEbIB UuZheybM9UcdUm6SjURkFNHaWKaXHes8LK5dMpVsS8p3fZPdo6bxsciMLwcXZuunFFUM MVNRL6psttyj9/NvsCzI9+FQkJNImcnQJ2I7LrLydrvP1gLUH0O0muwbSPz5M9VWd/dK 5wlixgHjQsjj9sznB2E6fBX1oG3MmadCni+NWF2aS16oKbF3MTCXTOsRhSX2tXyQJJVP nK+WhdTtTNQFf1TaYtQyNQd5fmptsfqjcRecZi/lR6VB+zyjAlJNOrmlC1XF6vSsH1la Pngw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=gyRzwz9L; spf=pass (google.com: domain of linux-kernel+bounces-20298-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20298-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (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 h10-20020ac8584a000000b004299a70ceb1si1177983qth.381.2024.01.08.18.52.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 18:52:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20298-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=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=gyRzwz9L; spf=pass (google.com: domain of linux-kernel+bounces-20298-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20298-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (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 598351C2326A for ; Tue, 9 Jan 2024 02:52:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BCE3B33CA; Tue, 9 Jan 2024 02:52:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gyRzwz9L" Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 6862228F1 for ; Tue, 9 Jan 2024 02:52:36 +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-wr1-f51.google.com with SMTP id ffacd0b85a97d-3366ddd1eddso2626889f8f.0 for ; Mon, 08 Jan 2024 18:52:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704768754; x=1705373554; 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=ppkSdH3z1kt6voFQDn4E9SzAVclK+/ku7jNGmWCT8sQ=; b=gyRzwz9LE+fPAvkEvZyWjAP6Dc3kYo8wwA22+g26K96Q2T/4SOSni+e0fy5EPgHo9Y ZGUOMh8/E2QqUijbWZRJtgQ4yqmAg4TBiVHy7JYfy45qeb4CytUOGs88U+jdnAJR97Pl U5CGiLZnXt44XJw3kRPzEbT+/cfFbyY0BoVvQAHw2x2GCOYE7eSEA9ZMgkshKp5//qvC Y4R3q233q2MBsi785ulbCIT59IuYOAvTGRH3fBwzEQm+JDHWVbgxtJX1MOg3qwkI777y ELkHLNbF7rMeyj0onuk5Yv5Vh8zfeP268aGD9yNga1yG9hwtfEwr+6d959pk8z+U5FCc BVog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704768754; x=1705373554; 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=ppkSdH3z1kt6voFQDn4E9SzAVclK+/ku7jNGmWCT8sQ=; b=xFCxUHCYwF5d5tNdqSLb9/phJG37VigLwkz8DPu2d6vVaadx3JsWIaEx12fvaxn6+P K81OSWFeMoA/PEpfelhGAnUw87SPFvf8yFJS9fZqbfUh+SVSzMDfkZEHXoUalXZftzXe TzRxaZ/ma0sxchvzaC0ZwfOoG5PzMT8c/gtbTEupPB6e1Qa6WjwgS4oLwrRak6TzsvCI Kp59cnfchfWXxYj5nOFCjTnom5WtwCj5hALIiVqCz35P3OCVxNt/GdsZnfZIlRsJzFvL CiXxEsNf+PU2FPZ+BgU6wEr68PKMlhfmoIfqSnESBP/N/ovk7Cg04GVl3mQc2FsbdafN +y5w== X-Gm-Message-State: AOJu0YxGS+BA9/SL8ouKKnw1hZG/am1k2a/SgETq9nNqZMiX5jq2zoHp n1x/wJxWJosH33YI5vxeYWss5ZE42nP1EuwIXWw= X-Received: by 2002:a05:6000:dc9:b0:337:57da:4a9b with SMTP id dw9-20020a0560000dc900b0033757da4a9bmr86668wrb.187.1704768754315; Mon, 08 Jan 2024 18:52:34 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: In-Reply-To: From: richard clark Date: Tue, 9 Jan 2024 10:52:23 +0800 Message-ID: Subject: Re: undefined reference to `__aarch64_cas4_sync' error on arm64 native build To: Mark Rutland Cc: 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 On Mon, Jan 8, 2024 at 6:51=E2=80=AFPM Mark Rutland = wrote: > > This is due to a difference in default options between the two compilers;= the > kernel isn't linked against libc in either case. > > Your native compiler evidently has -moutline-atomics enabled in its defau= lt > options. With that enabled, the builtin atomics generate calls to out-of-= line > functions which the kernel itself does not provide, and hence those resul= t in a > link-time error. > > Your cross-compiler evidently does not have -moutline-atomics enabled in = its > default options. Without that enabled, the builtin atomics generate inlin= e > atomic instructions rather than function calls. Since these don't depend = on > external functions there's no link-time error. > > If you pass 'mno-outline-atomics' to your native compiler, the problem sh= ould > disappear. > Right, this should be the root cause, just pass 'mno-outline-atomics' to my native compiler, the kernel link time issue doesn't show. But, I test a userland application with '__sync_val_compare_and_swap' used, for the 'aarch64-linux-gnu-gcc test.c', the 'nm a.out' will output: .. 0000000000000960 t __aarch64_cas4_sync 0000000000011011 B __aarch64_have_lse_atomics .. From the above output, seems the cross compiler has '-moutline-atomics' enabled by default, also with 'aarch64-linux-gnu-gcc -mno-outline-atomics test.c', the 'nm a.out' doesn't show the '_aarch64_cas4_sync'. The same result for the native build for the same test.c, this result can't explain why the cross-compile linux kernel will not generate the link time error,... > > Mark.