mailing list of musl libc
 help / color / mirror / code / Atom feed
* build fail with message "error: redefinition of 'index' as different kind of symbol"
@ 2019-07-30 15:31 Jeeyong Um
  2019-07-30 15:50 ` Rich Felker
  0 siblings, 1 reply; 4+ messages in thread
From: Jeeyong Um @ 2019-07-30 15:31 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 1256 bytes --]

Hello.
I have a question about building musl with `_BSD_SOURCE` definition.

`src/time/__tz.c` has static variable named by `index` (line 25) and
include `string.h` header file (line 5).
5  #include <string.h>
25 static const unsigned char *zi, *trans, *index, *types, *abbrevs,
*abbrevs_end;

By the way, `include/string.h` includes `strings.h` when _BSD_SOURCE is
defined (line 57).
56 #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
57 #include <strings.h>
58 #endif

`include/strings.h` has a function named by `index` too (line 19).
13 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) ||
defined(_POSIX_SOURCE) \
14  || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \
15  || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
16 int bcmp (const void *, const void *, size_t);
17 void bcopy (const void *, void *, size_t);
18 void bzero (void *, size_t);
19 char *index (const char *, int);
20 char *rindex (const char *, int);
21 #endif

Is it possible to build musl with _BSD_SOURCE definition in this case?
Even though `static` modifier limits the scope of variable to the file, the
conflict between `index` of `strings.h` and `index` of `__tz.c` seems
unavoidable.
Please let me know if you find any mistakes here.

Regards,
Jeeyong Um

[-- Attachment #2: Type: text/html, Size: 1784 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: build fail with message "error: redefinition of 'index' as different kind of symbol"
  2019-07-30 15:31 build fail with message "error: redefinition of 'index' as different kind of symbol" Jeeyong Um
@ 2019-07-30 15:50 ` Rich Felker
  2019-07-30 16:09   ` Jeeyong Um
  0 siblings, 1 reply; 4+ messages in thread
From: Rich Felker @ 2019-07-30 15:50 UTC (permalink / raw)
  To: musl

On Wed, Jul 31, 2019 at 12:31:17AM +0900, Jeeyong Um wrote:
> Hello.
> I have a question about building musl with `_BSD_SOURCE` definition.
> 
> `src/time/__tz.c` has static variable named by `index` (line 25) and
> include `string.h` header file (line 5).
> 5  #include <string.h>
> 25 static const unsigned char *zi, *trans, *index, *types, *abbrevs,
> *abbrevs_end;
> 
> By the way, `include/string.h` includes `strings.h` when _BSD_SOURCE is
> defined (line 57).
> 56 #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
> 57 #include <strings.h>
> 58 #endif
> 
> `include/strings.h` has a function named by `index` too (line 19).
> 13 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) ||
> defined(_POSIX_SOURCE) \
> 14  || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \
> 15  || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
> 16 int bcmp (const void *, const void *, size_t);
> 17 void bcopy (const void *, void *, size_t);
> 18 void bzero (void *, size_t);
> 19 char *index (const char *, int);
> 20 char *rindex (const char *, int);
> 21 #endif
> 
> Is it possible to build musl with _BSD_SOURCE definition in this case?
> Even though `static` modifier limits the scope of variable to the file, the
> conflict between `index` of `strings.h` and `index` of `__tz.c` seems
> unavoidable.
> Please let me know if you find any mistakes here.

The musl source files assume the default feature test macros provided
by their makefile, -D_XOPEN_SOURCE=700 which also includes POSIX base,
no extensions. Extensions by their nature bring into the namespace
things that might conflict with valid code.

If -D_BSD_SOURCE is getting into the build for musl, it likely means
you have a larger build system problem, like injecting it into CFLAGS
for every package you build. This might be making some "spurious"
problems go away, but it very well could create others. It would be
much better to fix whatever prompted you to do this to begin with. If
that's not practical, at least remove it from your build for musl.

Rich


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: build fail with message "error: redefinition of 'index' as different kind of symbol"
  2019-07-30 15:50 ` Rich Felker
@ 2019-07-30 16:09   ` Jeeyong Um
  2019-07-30 16:11     ` Rich Felker
  0 siblings, 1 reply; 4+ messages in thread
From: Jeeyong Um @ 2019-07-30 16:09 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 2420 bytes --]

I see. I had better check whether build with (-D_XOPEN_SOURCE=700)
satisfies my requirements first before using extensions.
Thank you for your prompt reply. :)

2019년 7월 31일 (수) 오전 12:51, Rich Felker <dalias@libc.org>님이 작성:

> On Wed, Jul 31, 2019 at 12:31:17AM +0900, Jeeyong Um wrote:
> > Hello.
> > I have a question about building musl with `_BSD_SOURCE` definition.
> >
> > `src/time/__tz.c` has static variable named by `index` (line 25) and
> > include `string.h` header file (line 5).
> > 5  #include <string.h>
> > 25 static const unsigned char *zi, *trans, *index, *types, *abbrevs,
> > *abbrevs_end;
> >
> > By the way, `include/string.h` includes `strings.h` when _BSD_SOURCE is
> > defined (line 57).
> > 56 #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
> > 57 #include <strings.h>
> > 58 #endif
> >
> > `include/strings.h` has a function named by `index` too (line 19).
> > 13 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) ||
> > defined(_POSIX_SOURCE) \
> > 14  || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \
> > 15  || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
> > 16 int bcmp (const void *, const void *, size_t);
> > 17 void bcopy (const void *, void *, size_t);
> > 18 void bzero (void *, size_t);
> > 19 char *index (const char *, int);
> > 20 char *rindex (const char *, int);
> > 21 #endif
> >
> > Is it possible to build musl with _BSD_SOURCE definition in this case?
> > Even though `static` modifier limits the scope of variable to the file,
> the
> > conflict between `index` of `strings.h` and `index` of `__tz.c` seems
> > unavoidable.
> > Please let me know if you find any mistakes here.
>
> The musl source files assume the default feature test macros provided
> by their makefile, -D_XOPEN_SOURCE=700 which also includes POSIX base,
> no extensions. Extensions by their nature bring into the namespace
> things that might conflict with valid code.
>
> If -D_BSD_SOURCE is getting into the build for musl, it likely means
> you have a larger build system problem, like injecting it into CFLAGS
> for every package you build. This might be making some "spurious"
> problems go away, but it very well could create others. It would be
> much better to fix whatever prompted you to do this to begin with. If
> that's not practical, at least remove it from your build for musl.
>
> Rich
>

[-- Attachment #2: Type: text/html, Size: 2956 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: build fail with message "error: redefinition of 'index' as different kind of symbol"
  2019-07-30 16:09   ` Jeeyong Um
@ 2019-07-30 16:11     ` Rich Felker
  0 siblings, 0 replies; 4+ messages in thread
From: Rich Felker @ 2019-07-30 16:11 UTC (permalink / raw)
  To: musl

On Wed, Jul 31, 2019 at 01:09:19AM +0900, Jeeyong Um wrote:
> I see. I had better check whether build with (-D_XOPEN_SOURCE=700)
> satisfies my requirements first before using extensions.
> Thank you for your prompt reply. :)

When building musl you should just not pass any of these. The sources
expect to be built with the defaults the makefile provides.

If you're not using musl but reusing the source files independently of
musl, then you might need to do other things.

Rich


> 2019년 7월 31일 (수) 오전 12:51, Rich Felker <dalias@libc.org>님이 작성:
> 
> > On Wed, Jul 31, 2019 at 12:31:17AM +0900, Jeeyong Um wrote:
> > > Hello.
> > > I have a question about building musl with `_BSD_SOURCE` definition.
> > >
> > > `src/time/__tz.c` has static variable named by `index` (line 25) and
> > > include `string.h` header file (line 5).
> > > 5  #include <string.h>
> > > 25 static const unsigned char *zi, *trans, *index, *types, *abbrevs,
> > > *abbrevs_end;
> > >
> > > By the way, `include/string.h` includes `strings.h` when _BSD_SOURCE is
> > > defined (line 57).
> > > 56 #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
> > > 57 #include <strings.h>
> > > 58 #endif
> > >
> > > `include/strings.h` has a function named by `index` too (line 19).
> > > 13 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) ||
> > > defined(_POSIX_SOURCE) \
> > > 14  || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE+0 < 200809L) \
> > > 15  || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
> > > 16 int bcmp (const void *, const void *, size_t);
> > > 17 void bcopy (const void *, void *, size_t);
> > > 18 void bzero (void *, size_t);
> > > 19 char *index (const char *, int);
> > > 20 char *rindex (const char *, int);
> > > 21 #endif
> > >
> > > Is it possible to build musl with _BSD_SOURCE definition in this case?
> > > Even though `static` modifier limits the scope of variable to the file,
> > the
> > > conflict between `index` of `strings.h` and `index` of `__tz.c` seems
> > > unavoidable.
> > > Please let me know if you find any mistakes here.
> >
> > The musl source files assume the default feature test macros provided
> > by their makefile, -D_XOPEN_SOURCE=700 which also includes POSIX base,
> > no extensions. Extensions by their nature bring into the namespace
> > things that might conflict with valid code.
> >
> > If -D_BSD_SOURCE is getting into the build for musl, it likely means
> > you have a larger build system problem, like injecting it into CFLAGS
> > for every package you build. This might be making some "spurious"
> > problems go away, but it very well could create others. It would be
> > much better to fix whatever prompted you to do this to begin with. If
> > that's not practical, at least remove it from your build for musl.
> >
> > Rich
> >


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-07-30 16:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-30 15:31 build fail with message "error: redefinition of 'index' as different kind of symbol" Jeeyong Um
2019-07-30 15:50 ` Rich Felker
2019-07-30 16:09   ` Jeeyong Um
2019-07-30 16:11     ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).