https://bugs.openldap.org/show_bug.cgi?id=9215
Bug ID: 9215 Summary: Embedded _XOPEN_SOURCE breaks Solaris build [regression] Product: OpenLDAP Version: unspecified Hardware: All OS: All Status: UNCONFIRMED Severity: normal Priority: --- Component: libraries Assignee: bugs@openldap.org Reporter: grapvar@gmail.com Target Milestone: ---
The commit [2020-03-26 57b7003 | thr_posix.c: fix implicit function declaration for 'pthread_setconcurrency']
introduced in the bug 8676, comment 8:
--- a/libraries/libldap_r/thr_posix.c +++ b/libraries/libldap_r/thr_posix.c @@ -15,4 +15,6 @@ */
+#define _XOPEN_SOURCE 500 /* For pthread_setconcurrency() on glibc */
#include "portable.h"
breaks build on Solaris (likely any version; irrelevant compiling options omitted):
| cc ... -c ../../../libraries/libldap_r/thr_posix.c -o .libs/thr_posix.o | "/usr/include/sys/feature_tests.h", line 354: #error: "Compiler or options invalid for pre-UNIX 03 X/Open applications and pre-2001 POSIX applications"
The system headers bear in mind:
"If you are using c99-compatible compiler ..."
and we all are using such compilers in 2020, isn't it?
"... and want to use X/Open CAE, it must be at least Issue 6"
i.e., not the Issue 5 (_XOPEN_SOURCE=500).
This part of system headers came from the times when Solaris was Sun yet. Given the long respectful history of Sun's commitment to standard conformance, I trust this assertion.
The problem, however, is not an incorrect X/Open version this patch employs.
1st of all, this patch is a system-specific hack, that targets not even GNU-based systems, but, I suppose, specifically, GNU linux, maybe, even specific version and distro. E.g., there are no problems with pthread_setconcurrency() visibility on Solaris.
2nd of all, the influence of configuration macros _XOPEN_SOURCE, _POSIX_SOURCE, _POSIX_C_SOURCE, _XOPEN_VERSION, _XOPEN_SOURCE_EXTENDED, __EXTENSIONS__ etc is very system- and compiler- specific, and embedding these macros directly in a source is likely to cause problems.
I believe the best course of action is to put a test in autoconf to check what is the best way to achieve pthread_setconcurrency() visibility on any given system.
https://bugs.openldap.org/show_bug.cgi?id=9215
Quanah Gibson-Mount quanah@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |2.5.0 Status|UNCONFIRMED |CONFIRMED Ever confirmed|0 |1 Keywords| |OL_2_5_REQ
--- Comment #1 from Quanah Gibson-Mount quanah@openldap.org --- Thanks for the report.
Can you please update your user information with your real name as well?
https://bugs.openldap.org/show_bug.cgi?id=9215
--- Comment #2 from Howard Chu hyc@openldap.org --- Frankly it's stupid that glibc doesn't publish the declaration by default, after all these years that it has been implemented.
In this case I'd rather just put an appropriate #ifdef around it, since this issue only affects a single declaration in a single source file.
https://bugs.openldap.org/show_bug.cgi?id=9215
--- Comment #3 from Konstantin Andreev grapvar@gmail.com --- Standard selection macros may alter system API, e.g. (pseudocode)
#if (_POSIX_C_SOURCE >= 200112L) && ! _GNU_SOURCE int strerror_r( ... // XSI else char *strerror_r( ... // GNU
It may be preferable to provide the same standard selection macros to all source files to be sure they share the same and consistent system view.
https://bugs.openldap.org/show_bug.cgi?id=9215
--- Comment #4 from Ryan Tandy ryan@openldap.org --- I kind of like the suggestion from https://lwn.net/Articles/592882/: "In my experience, you define _GNU_SOURCE on Linux, and on every other system, leave well enough alone."
https://bugs.openldap.org/show_bug.cgi?id=9215
--- Comment #5 from Ryan Tandy ryan@openldap.org --- Confirmed on Solaris 10, but Solaris 11 seems to be fine with it as-is.
https://bugs.openldap.org/show_bug.cgi?id=9215
Ryan Tandy ryan@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|CONFIRMED |IN_PROGRESS
--- Comment #6 from Ryan Tandy ryan@openldap.org --- https://git.openldap.org/openldap/openldap/-/merge_requests/50
https://bugs.openldap.org/show_bug.cgi?id=9215
Ryan Tandy ryan@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords|OL_2_5_REQ | Status|IN_PROGRESS |RESOLVED Resolution|--- |TEST
--- Comment #7 from Ryan Tandy ryan@openldap.org --- Commits: e9543da9 by Ryan Tandy at 2020-04-23T13:19:33-07:00 ITS#9215 Define _XOPEN_SOURCE for glibc only
https://bugs.openldap.org/show_bug.cgi?id=9215
--- Comment #8 from Konstantin Andreev grapvar@gmail.com --- (In reply to Ryan Tandy from comment #5)
Confirmed on Solaris 10, but Solaris 11 seems to be fine with it as-is.
This hit me on
$ cat /etc/release Oracle Solaris 11.3 X86 Copyright (c) 1983, 2015, Oracle and/or its affiliates. All rights reserved. Assembled 06 October 2015
Have you built openldap on Solaris 11 with the old gcc that does not set __STDC__ properly?
(In reply to Ryan Tandy from comment #7)
Commits: e9543da9 by Ryan Tandy at 2020-04-23T13:19:33-07:00 ITS#9215 Define _XOPEN_SOURCE for glibc only
Works for me.
https://bugs.openldap.org/show_bug.cgi?id=9215
--- Comment #9 from Ryan Tandy ryan@openldap.org --- (In reply to Konstantin Andreev from comment #8)
Have you built openldap on Solaris 11 with the old gcc that does not set __STDC__ properly?
Solaris 11.4, Solaris Studio 12.6. Did not try gcc yet.
(In reply to Ryan Tandy from comment #7)
Commits: e9543da9 by Ryan Tandy at 2020-04-23T13:19:33-07:00 ITS#9215 Define _XOPEN_SOURCE for glibc only
Works for me.
Great. Thanks for confirming!
https://bugs.openldap.org/show_bug.cgi?id=9215
--- Comment #10 from Quanah Gibson-Mount quanah@openldap.org --- • 4a50fa74 by Ryan Tandy at 2020-04-27T20:06:52+00:00 ITS#9215 Fix previous commit
https://bugs.openldap.org/show_bug.cgi?id=9215
--- Comment #11 from Konstantin Andreev grapvar@gmail.com --- (In reply to Quanah Gibson-Mount from comment #10)
• 4a50fa74 by Ryan Tandy at 2020-04-27T20:06:52+00:00 ITS#9215 Fix previous commit
You made a new bug. This:
#ifndef _GNU_SOURCE #define _GNU_SOURCE 1 /* For pthread_setconcurrency() on glibc */ #endif
defines _GNU_SOURCE on any system, even not GNU.
Maybe what you wanted to do is
#ifndef __GLIBC__ #define _GNU_SOURCE 1 /* For pthread_setconcurrency() on glibc */ #endif
?
https://bugs.openldap.org/show_bug.cgi?id=9215
--- Comment #12 from Quanah Gibson-Mount quanah@openldap.org --- • fd23680a by Howard Chu at 2020-04-28T16:33:41+01:00 ITS#9215 fix for glibc again
https://bugs.openldap.org/show_bug.cgi?id=9215
--- Comment #13 from Ryan Tandy ryan@openldap.org --- (In reply to Konstantin Andreev from comment #11)
You made a new bug. This:
#ifndef _GNU_SOURCE #define _GNU_SOURCE 1 /* For pthread_setconcurrency() on glibc */ #endif
defines _GNU_SOURCE on any system, even not GNU.
I thought that should have been harmless, as it's documented as "specific to Linux (glibc)". In any case it should be done properly now. Thanks Howard for figuring out a better solution.
https://bugs.openldap.org/show_bug.cgi?id=9215
Quanah Gibson-Mount quanah@openldap.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |VERIFIED Resolution|TEST |FIXED