public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: richard clark <richard.xnu.clark@gmail.com>
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
Date: Thu, 4 Jan 2024 18:18:39 +0000	[thread overview]
Message-ID: <ZZb2f0U4qTWDjCGj@FVFF77S0Q05N.cambridge.arm.com> (raw)
In-Reply-To: <CAJNi4rMHtM=39jzkzwqt++kVpSp0=XfDrVdY94WoW6B34oKwDA@mail.gmail.com>

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
> <richard.xnu.clark@gmail.com> 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
> 

  reply	other threads:[~2024-01-04 18:18 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-02  3:29 richard clark
2024-01-02  8:53 ` richard clark
2024-01-04 18:18   ` Mark Rutland [this message]
2024-01-08  1:28     ` richard clark
2024-01-08 10:51       ` Mark Rutland
2024-01-08 10:56         ` Xi Ruoyao
2024-01-09  2:55           ` richard clark
2024-01-09  3:05             ` Xi Ruoyao
2024-01-09  6:04               ` richard clark
2024-01-09  7:48               ` Segher Boessenkool
2024-01-09  8:09                 ` Xi Ruoyao
2024-01-09  8:26                   ` Segher Boessenkool
2024-01-10  5:59                     ` richard clark
2024-01-10 14:10                       ` Segher Boessenkool
2024-01-11  1:42                         ` richard clark
2024-01-11 11:26                           ` Mark Rutland
2024-01-15  9:23                             ` richard clark
2024-01-09  2:52         ` richard clark

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZZb2f0U4qTWDjCGj@FVFF77S0Q05N.cambridge.arm.com \
    --to=mark.rutland@arm.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=richard.xnu.clark@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).