diff mbox

[libbacktrace] : Fix compilation on CentOS 5.8

Message ID CAFULd4ZjVS4k+5jCLoRj5xeuHAN6JuTiEpHXWj-mPzBCxbewBg@mail.gmail.com
State New
Headers show

Commit Message

Uros Bizjak Sept. 18, 2012, 9:09 a.m. UTC
Hello!

CentOS 5.8 uses glibc version 2.5 that needs _GNU_SOURCE defined to use strnlen.

2012-09-18  Uros Bizjak  <ubizjak@gmail.com>

	* dwarf.c: Define _GNU_SOURCE.

Tested on CentOS x86_64-pc-linux-gnu. OK for mainline?

Uros.

Comments

Richard Biener Sept. 18, 2012, 9:16 a.m. UTC | #1
On Tue, Sep 18, 2012 at 11:09 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> Hello!
>
> CentOS 5.8 uses glibc version 2.5 that needs _GNU_SOURCE defined to use strnlen.

Hm, shouldn't libiberty contain a xstrnlen?  I bet strnlen isn't available
everywhere.

Richard.

> 2012-09-18  Uros Bizjak  <ubizjak@gmail.com>
>
>         * dwarf.c: Define _GNU_SOURCE.
>
> Tested on CentOS x86_64-pc-linux-gnu. OK for mainline?
>
> Uros.
>
> Index: dwarf.c
> ===================================================================
> --- dwarf.c     (revision 191413)
> +++ dwarf.c     (working copy)
> @@ -30,6 +30,8 @@
>  IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
>  POSSIBILITY OF SUCH DAMAGE.  */
>
> +#define _GNU_SOURCE
> +
>  #include "config.h"
>
>  #include <errno.h>
Uros Bizjak Sept. 18, 2012, 9:25 a.m. UTC | #2
On Tue, Sep 18, 2012 at 11:16 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:

>> CentOS 5.8 uses glibc version 2.5 that needs _GNU_SOURCE defined to use strnlen.
>
> Hm, shouldn't libiberty contain a xstrnlen?  I bet strnlen isn't available
> everywhere.

I didn't find it in the sources.  OTOH, mmapio.c already defines
_GNU_SOURCE for some reason, so I just follow this approach.

Uros.
Richard Biener Sept. 18, 2012, 9:49 a.m. UTC | #3
On Tue, Sep 18, 2012 at 11:25 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Tue, Sep 18, 2012 at 11:16 AM, Richard Guenther
> <richard.guenther@gmail.com> wrote:
>
>>> CentOS 5.8 uses glibc version 2.5 that needs _GNU_SOURCE defined to use strnlen.
>>
>> Hm, shouldn't libiberty contain a xstrnlen?  I bet strnlen isn't available
>> everywhere.
>
> I didn't find it in the sources.  OTOH, mmapio.c already defines
> _GNU_SOURCE for some reason, so I just follow this approach.

I said it _should_ contain xstrnlen, not that it does ;)  I suppose
Ian should have
used strlen or added xstrnlen to libiberty.

Richard.

> Uros.
Ian Lance Taylor Sept. 18, 2012, 2:08 p.m. UTC | #4
On Tue, Sep 18, 2012 at 2:25 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Tue, Sep 18, 2012 at 11:16 AM, Richard Guenther
> <richard.guenther@gmail.com> wrote:
>
>>> CentOS 5.8 uses glibc version 2.5 that needs _GNU_SOURCE defined to use strnlen.
>>
>> Hm, shouldn't libiberty contain a xstrnlen?  I bet strnlen isn't available
>> everywhere.
>
> I didn't find it in the sources.  OTOH, mmapio.c already defines
> _GNU_SOURCE for some reason, so I just follow this approach.

mmapio.c uses _GNU_SOURCE so that getpagesize is available on GNU/Linux systems.

I'll fix the strnlen issue some other way.

Ian
Andreas Schwab Sept. 18, 2012, 2:23 p.m. UTC | #5
Ian Lance Taylor <iant@google.com> writes:

> mmapio.c uses _GNU_SOURCE so that getpagesize is available on GNU/Linux systems.

That should be available by default (which includes BSD things) unless
the namespace has been restricted in some other way.

There's of course also the POSIX way of using sysconf(_SC_PAGESIZE).

Andreas.
Ian Lance Taylor Sept. 18, 2012, 4:07 p.m. UTC | #6
On Tue, Sep 18, 2012 at 7:08 AM, Ian Lance Taylor <iant@google.com> wrote:
>
> I'll fix the strnlen issue some other way.

I committed a pair of patches, to libiberty and libbacktrace, that
should fix the problem.

Let me know if it is still present.

Sorry for the difficulty.

Ian
Joseph Myers Sept. 18, 2012, 4:08 p.m. UTC | #7
On Tue, 18 Sep 2012, Uros Bizjak wrote:

> Index: dwarf.c
> ===================================================================
> --- dwarf.c     (revision 191413)
> +++ dwarf.c     (working copy)
> @@ -30,6 +30,8 @@
>  IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
>  POSSIBILITY OF SUCH DAMAGE.  */
> 
> +#define _GNU_SOURCE

I think AC_USE_SYSTEM_EXTENSIONS is preferred to defining _GNU_SOURCE in 
individual source files.
Ian Lance Taylor Sept. 18, 2012, 4:37 p.m. UTC | #8
On Tue, Sep 18, 2012 at 9:08 AM, Joseph S. Myers
<joseph@codesourcery.com> wrote:
>
> I think AC_USE_SYSTEM_EXTENSIONS is preferred to defining _GNU_SOURCE in
> individual source files.

Thanks for the pointer.  I have committed this patch after bootstrap
and libbacktrace test on x86_64-unknown-linux-gnu.

Ian


2012-09-18  Ian Lance Taylor  <iant@google.com>

	* configure.ac: Add AC_USE_SYSTEM_EXTENSIONS.
	* mmapio.c: Don't define _GNU_SOURCE.
	* configure, config.h.in: Rebuild.
diff mbox

Patch

Index: dwarf.c
===================================================================
--- dwarf.c     (revision 191413)
+++ dwarf.c     (working copy)
@@ -30,6 +30,8 @@ 
 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 POSSIBILITY OF SUCH DAMAGE.  */

+#define _GNU_SOURCE
+
 #include "config.h"

 #include <errno.h>