linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Ian Rogers <irogers@google.com>
To: Xie XiuQi <xiexiuqi@huawei.com>
Cc: akpm@linux-foundation.org, acme@redhat.com, linux-mm@kvack.org,
	 linux-kernel@vger.kernel.org, weiyongjun1@huawei.com
Subject: Re: [PATCH] tools/mm: fix undefined reference to pthread_once
Date: Wed, 26 Jul 2023 10:26:48 -0700	[thread overview]
Message-ID: <CAP-5=fV5NZTFM_9+KnKhZKWmnqc223koOioE9O6hzAvPMrxy7g@mail.gmail.com> (raw)
In-Reply-To: <20230725092149.443119-1-xiexiuqi@huawei.com>

On Tue, Jul 25, 2023 at 2:24 AM Xie XiuQi <xiexiuqi@huawei.com> wrote:
>
> Commit 97d5f2e9ee12 ("tools api fs: More thread safety for global
> filesystem variables") introduces pthread_once, so the libpthread
> should be added at link time, or we'll meet the following compile
> error when 'make -C tools/mm':
>
>   gcc -Wall -Wextra -I../lib/ -o page-types page-types.c ../lib/api/libapi.a
>   ~/linux/tools/lib/api/fs/fs.c:146: undefined reference to `pthread_once'
>   ~/linux/tools/lib/api/fs/fs.c:147: undefined reference to `pthread_once'
>   ~/linux/tools/lib/api/fs/fs.c:148: undefined reference to `pthread_once'
>   ~/linux/tools/lib/api/fs/fs.c:149: undefined reference to `pthread_once'
>   ~/linux/tools/lib/api/fs/fs.c:150: undefined reference to `pthread_once'
>   /usr/bin/ld: ../lib/api/libapi.a(libapi-in.o):~/linux/tools/lib/api/fs/fs.c:151:
>   more undefined references to `pthread_once' follow
>   collect2: error: ld returned 1 exit status
>   make: *** [Makefile:22: page-types] Error 1
>
> Fixes: 97d5f2e9ee12 ("tools api fs: More thread safety for global filesystem variables")
> Signed-off-by: Xie XiuQi <xiexiuqi@huawei.com>

Apologies.
Acked-by: Ian Rogers <irogers@google.com>

Alternatively we could #ifdef the behavior, but this way is cleaner imo.

Thanks,
Ian

> ---
>  tools/mm/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/mm/Makefile b/tools/mm/Makefile
> index 6c1da51f4177..9997b2e401ae 100644
> --- a/tools/mm/Makefile
> +++ b/tools/mm/Makefile
> @@ -9,7 +9,7 @@ LIB_DIR = ../lib/api
>  LIBS = $(LIB_DIR)/libapi.a
>
>  CFLAGS += -Wall -Wextra -I../lib/
> -LDFLAGS += $(LIBS)
> +LDFLAGS += $(LIBS) -lpthread
>
>  all: $(TARGETS)
>
> --
> 2.25.1
>


      reply	other threads:[~2023-07-26 17:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-25  9:21 Xie XiuQi
2023-07-26 17:26 ` Ian Rogers [this message]

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='CAP-5=fV5NZTFM_9+KnKhZKWmnqc223koOioE9O6hzAvPMrxy7g@mail.gmail.com' \
    --to=irogers@google.com \
    --cc=acme@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=weiyongjun1@huawei.com \
    --cc=xiexiuqi@huawei.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