Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7876954rdb; Thu, 4 Jan 2024 10:19:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IEyTdeazBy0D2palXMG6U1OL11bqHahZlY+OVdOr9sX3XaF6j0iWwMFTbFTBeFfFuI/mdi9 X-Received: by 2002:a05:6e02:1caa:b0:35f:e3e4:a38b with SMTP id x10-20020a056e021caa00b0035fe3e4a38bmr870075ill.2.1704392340245; Thu, 04 Jan 2024 10:19:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704392340; cv=none; d=google.com; s=arc-20160816; b=elX3uK/UIC9LXuQQ5UcBkDFSqbBBK1DOMoNVUp2mWRbV2jDTxyboPP3LPbGvgVvmGB qvQaZGRxJurbZyQtZzD2x2vLM3I/91/MNpWjG65C4xul1J2/MU8t5HVOOxuxsctWPm1V sI58QGpH5F+9ZOS7OEws29nuGC7ecmPMKuS/n5npbM2NDpq6PEATsbMw0BWrurccAKJT Gv/UKkKRQzLRKJ7ODeyN/w/RpLUkVsVksgXMD8mfxos5598JmgjNN7uk9lzGcxh5eWrs Jt5Z5YbgFeGgQWFvpxlQ0HGUmexICRVuv+e/xOyhcTfMM2O3b3UDDUMTDz85p8zsdNte R3UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date; bh=Xelr9LxMePPH0TlNk8uEQVD9ck62dzt6EC+a7+ogReo=; fh=0lJHN/erCokOs+4Idc3m0EJ3QvrDMhz3SAWrB8jywfs=; b=e35YXswE5qfJQVIGnQhAmlhoM336ijuH4b7jFtPBOaDSYWiG7UrawtRyFVxKGUUe7+ BbGJn0QqlfI2EMK5xoSh2v8yQc/xgUD58o5eFR49gp9LA+YTeI90hRSMwIeOX4DEhiN1 kdI3uKgfqk27Sgp4pm1/LtEccbb7tY+BMvJmr6gcwd+GHH/EmGYmqX54jM+ysdXWAO0S 81DPm3CN6kpeLrejcReoLPW03yOOcLNqn5nPKCfa9dgJBIPlYqPtoQFOAx88qjSl0jzO VpKo86FTmp/8igJr987segO9yoF2Vy1+rw7OAfimkHzH84Nj3BAmTUjyy5Mn3wmhPnVD Tubg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-17082-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17082-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id z35-20020a630a63000000b005cd920f5228si13862825pgk.500.2024.01.04.10.18.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 10:19:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17082-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-17082-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17082-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 9B267B2434F for ; Thu, 4 Jan 2024 18:18:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5339928DDA; Thu, 4 Jan 2024 18:18:50 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 41FBC28DCC for ; Thu, 4 Jan 2024 18:18:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 791CFC15; Thu, 4 Jan 2024 10:19:31 -0800 (PST) Received: from FVFF77S0Q05N.cambridge.arm.com (FVFF77S0Q05N.cambridge.arm.com [10.1.29.139]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D4AFE3F5A1; Thu, 4 Jan 2024 10:18:44 -0800 (PST) Date: Thu, 4 Jan 2024 18:18:39 +0000 From: Mark Rutland To: richard clark Cc: 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: References: 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, Jan 02, 2024 at 04:53:53PM +0800, richard clark wrote: > Ah, the driver is trying to use the native gcc built atomic ops like: > __sync_val_compare_and_swap, but it seems the native aarch64 doesn't > provide these builtin atomic primitives while they are in the cross > compile toolchain. > The issue can be resolved by replacing the > **__sync_val_compare_and_swap** with **atomic_cmpxchg**. Yup, that's the right thing to do; drivers *shouldn't* use the builtins directly, and *should* use the kernel's native atomic*() API. > But don't know why the native aarch64 toolchain doesn't have those > builtin atomic functions... I suspect this is down to your toolchain enabling -moutline-atomics by default; that expands the builtins into calls to out-of-line functions. I suspect your cross-compile toolchain doesn't enable that by default. As above, since nothing should be using the builtins, we don't implement out-of-line versions nor do we override the option. Mark. > On Tue, Jan 2, 2024 at 11:29 AM richard clark > wrote: > > > > Hi, > > > > I have a strong power arm64 box, and the linux distro is ubuntu 22.04, > > the native gcc version is: > > > > $ gcc --version > > gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 > > Copyright (C) 2021 Free Software Foundation, Inc. > > This is free software; see the source for copying conditions. There is NO > > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > > > > It will abort the kernel build with the complaint by 'make Image': > > ld: Unexpected GOT/PLT entries detected! > > ld: Unexpected run-time procedure linkages detected! > > ld: ID map text too big or misaligned > > ld: drivers/net/nvidia_eth.o: in function `osi_lock_irq_enabled': > > osi_hal.c:(.text+0x3cc): undefined reference to `__aarch64_cas4_sync' > > ... > > > > But the cross-compile with aarch64-linux-gnu-gcc on the x86 box > > doesn't show the above error message. > > Any comments/suggestions? Thanks very much! > > > > Richard >