Message ID | 20230828122157.1541087-1-xiexiuqi@huaweicloud.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [RESEND] tools/mm: fix undefined reference to pthread_once | expand |
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.
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. >
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. > > > >
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. >>> >> >>
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)