* [PATCH RESEND] tools/mm: fix undefined reference to pthread_once
@ 2023-08-28 12:21 Xie XiuQi
2023-08-28 12:58 ` Matthew Wilcox
0 siblings, 1 reply; 5+ messages in thread
From: Xie XiuQi @ 2023-08-28 12:21 UTC (permalink / raw)
To: akpm; +Cc: irogers, acme, linux-mm, linux-kernel
From: Xie XiuQi <xiexiuqi@huawei.com>
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>
Acked-by: Ian Rogers <irogers@google.com>
---
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RESEND] tools/mm: fix undefined reference to pthread_once
2023-08-28 12:21 [PATCH RESEND] tools/mm: fix undefined reference to pthread_once Xie XiuQi
@ 2023-08-28 12:58 ` Matthew Wilcox
2023-08-31 1:13 ` Xie XiuQi
0 siblings, 1 reply; 5+ messages in thread
From: Matthew Wilcox @ 2023-08-28 12:58 UTC (permalink / raw)
To: Xie XiuQi; +Cc: akpm, irogers, acme, linux-mm, linux-kernel
On Mon, Aug 28, 2023 at 08:21:57PM +0800, Xie XiuQi wrote:
> 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
Is this the right fix? I'm pretty sure you're suppose to use -pthread
in CFLAGS in case there are other things the compiler/linker/whatever
need.
'-pthread'
Define additional macros required for using the POSIX threads
library. You should use this option consistently for both
compilation and linking. This option is supported on GNU/Linux
targets, most other Unix derivatives, and also on x86 Cygwin and
MinGW targets.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RESEND] tools/mm: fix undefined reference to pthread_once
2023-08-28 12:58 ` Matthew Wilcox
@ 2023-08-31 1:13 ` Xie XiuQi
2023-08-31 2:25 ` Matthew Wilcox
0 siblings, 1 reply; 5+ messages in thread
From: Xie XiuQi @ 2023-08-31 1:13 UTC (permalink / raw)
To: Matthew Wilcox
Cc: akpm, irogers, acme, linux-mm, linux-kernel, Yang Yingliang
Hi,
On 2023/8/28 20:58, Matthew Wilcox wrote:
> On Mon, Aug 28, 2023 at 08:21:57PM +0800, Xie XiuQi wrote:
>> 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
>
> Is this the right fix? I'm pretty sure you're suppose to use -pthread
> in CFLAGS in case there are other things the compiler/linker/whatever
> need.
>
Thanks for your comment. I'll fix it and send v2.
> '-pthread'
> Define additional macros required for using the POSIX threads
> library. You should use this option consistently for both
> compilation and linking. This option is supported on GNU/Linux
> targets, most other Unix derivatives, and also on x86 Cygwin and
> MinGW targets.
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RESEND] tools/mm: fix undefined reference to pthread_once
2023-08-31 1:13 ` Xie XiuQi
@ 2023-08-31 2:25 ` Matthew Wilcox
2023-08-31 2:57 ` Xie XiuQi
0 siblings, 1 reply; 5+ messages in thread
From: Matthew Wilcox @ 2023-08-31 2:25 UTC (permalink / raw)
To: Xie XiuQi; +Cc: akpm, irogers, acme, linux-mm, linux-kernel, Yang Yingliang
On Thu, Aug 31, 2023 at 09:13:24AM +0800, Xie XiuQi wrote:
> Hi,
>
> On 2023/8/28 20:58, Matthew Wilcox wrote:
> > On Mon, Aug 28, 2023 at 08:21:57PM +0800, Xie XiuQi wrote:
> >> 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
> >
> > Is this the right fix? I'm pretty sure you're suppose to use -pthread
> > in CFLAGS in case there are other things the compiler/linker/whatever
> > need.
> >
>
> Thanks for your comment. I'll fix it and send v2.
You added it to LDFLAGS, not CFLAGS.
> > '-pthread'
> > Define additional macros required for using the POSIX threads
> > library. You should use this option consistently for both
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > compilation and linking. This option is supported on GNU/Linux
^^^^^^^^^^^^^^^^^^^^^^^
> > targets, most other Unix derivatives, and also on x86 Cygwin and
> > MinGW targets.
> >
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RESEND] tools/mm: fix undefined reference to pthread_once
2023-08-31 2:25 ` Matthew Wilcox
@ 2023-08-31 2:57 ` Xie XiuQi
0 siblings, 0 replies; 5+ messages in thread
From: Xie XiuQi @ 2023-08-31 2:57 UTC (permalink / raw)
To: Matthew Wilcox
Cc: akpm, irogers, acme, linux-mm, linux-kernel, Yang Yingliang
Hi,
On 2023/8/31 10:25, Matthew Wilcox wrote:
> On Thu, Aug 31, 2023 at 09:13:24AM +0800, Xie XiuQi wrote:
>> Hi,
>>
>> On 2023/8/28 20:58, Matthew Wilcox wrote:
>>> On Mon, Aug 28, 2023 at 08:21:57PM +0800, Xie XiuQi wrote:
>>>> 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
>>>
>>> Is this the right fix? I'm pretty sure you're suppose to use -pthread
>>> in CFLAGS in case there are other things the compiler/linker/whatever
>>> need.
>>>
>>
>> Thanks for your comment. I'll fix it and send v2.
>
> You added it to LDFLAGS, not CFLAGS.
Sorry, it's my fault. I'll add it to CFALGS:
CFLAGS += -Wall -Wextra -I../lib/ -pthread
>
>>> '-pthread'
>>> Define additional macros required for using the POSIX threads
>>> library. You should use this option consistently for both
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>> compilation and linking. This option is supported on GNU/Linux
> ^^^^^^^^^^^^^^^^^^^^^^^
>>> targets, most other Unix derivatives, and also on x86 Cygwin and
>>> MinGW targets.
>>>
>>
>>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-08-31 2:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-28 12:21 [PATCH RESEND] tools/mm: fix undefined reference to pthread_once Xie XiuQi
2023-08-28 12:58 ` Matthew Wilcox
2023-08-31 1:13 ` Xie XiuQi
2023-08-31 2:25 ` Matthew Wilcox
2023-08-31 2:57 ` Xie XiuQi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox