Bug#742148: shapelib: FTBFS on powerpc (Both BIG_ENDIAN and LITTLE_ENDIAN defined!

Francesco P. Lovergine frankie at debian.org
Wed Mar 26 12:24:27 UTC 2014


While I accepted the patch a few minutes ago, indeed I seriously now doubt that
the fix is correct.

It seems to me that in the original program the LITTLE_ENDIAN should be
intended as a static build-time definition for the host where the program is built.

So the NAN definition should be intended instead as nan(). That's because
the shapefile format is endianess-independent and shapelib reads/writes fields on the
basis of the host platform to respect the format. So the NAN should be
intended as the *host* NaN format, indeed (to be translated in the shp format NaN, i.e. little endian). 
That poses a problem on the pcc architecture for instance: __nan_bytes will be not the 
correct NaN value and will result as a big endian in the file.

See http://dl.maptools.org/dl/shapelib/shapefile.pdf for format.

Do you agree?


On Wed, Mar 26, 2014 at 10:53:17AM +0100, Cyril Brulebois wrote:
> Control: tag -1 patch
> 
> Julien Cristau <jcristau at debian.org> (2014-03-19):
> > Source: shapelib
> > Version: 1.3.0-2
> > Severity: serious
> > Justification: fails to build from source (but built successfully in the past)
> > 
> > Hi,
> > 
> > your package no longer builds on powerpc:
> > > cc -g -I.. -I/sbuild-nonexistent/bld/include -DPROJ4 -D_LITTLE_ENDIAN -DDEBUG -DDEBUG2  shpdxf.c ../shpopen.o ../dbfopen.o ../safileio.o  -o shpdxf
> > > In file included from /usr/include/endian.h:36:0,
> > >                  from /usr/include/powerpc-linux-gnu/bits/waitstatus.h:64,
> > >                  from /usr/include/stdlib.h:42,
> > >                  from shpdxf.c:40:
> > > /usr/include/powerpc-linux-gnu/bits/endian.h:26:4: error: #error Both BIG_ENDIAN and LITTLE_ENDIAN defined!
> > >  #  error Both BIG_ENDIAN and LITTLE_ENDIAN defined!
> > >     ^
> > > make[2]: *** [shpdxf] Error 1
> > 
> > See
> > https://buildd.debian.org/status/fetch.php?pkg=shapelib&arch=powerpc&ver=1.3.0-2&stamp=1395181820
> > 
> > Cheers,
> > Julien
> 
> Here's a patch; confirmed by first reproducing the FTBFS on partch, and
> then seeing it go away once it's applied.
> 
> Mraw,
> KiBi.

> diff -Nru shapelib-1.3.0/debian/changelog shapelib-1.3.0/debian/changelog
> --- shapelib-1.3.0/debian/changelog	2014-03-18 22:47:55.000000000 +0100
> +++ shapelib-1.3.0/debian/changelog	2014-03-26 10:52:01.000000000 +0100
> @@ -1,3 +1,12 @@
> +shapelib (1.3.0-2.1) UNRELEASED; urgency=medium
> +
> +  * Non-maintainer upload.
> +  * Fix FTBFS on powerpc by prefixing _{BIG,LITTLE}_ENDIAN with
> +    LIBSHAPE. (Names starting with an underscore are reserved.)
> +    (Closes: #742148)
> +
> + -- Cyril Brulebois <kibi at debian.org>  Wed, 26 Mar 2014 10:38:30 +0100
> +
>  shapelib (1.3.0-2) unstable; urgency=medium
>  
>    * Moved to DEP5 copyright format and annotated double licensing,
> diff -Nru shapelib-1.3.0/debian/patches/0006-Fix-FTBFS-avoid-clash-with-_ENDIAN-defines.patch shapelib-1.3.0/debian/patches/0006-Fix-FTBFS-avoid-clash-with-_ENDIAN-defines.patch
> --- shapelib-1.3.0/debian/patches/0006-Fix-FTBFS-avoid-clash-with-_ENDIAN-defines.patch	1970-01-01 01:00:00.000000000 +0100
> +++ shapelib-1.3.0/debian/patches/0006-Fix-FTBFS-avoid-clash-with-_ENDIAN-defines.patch	2014-03-26 10:52:12.000000000 +0100
> @@ -0,0 +1,39 @@
> +Description: Avoid clashing with _*_ENDIAN.
> +Author: Cyril Brulebois <kibi at debian.org>
> +
> +Defining _{LITTLE,BIG}_ENDIAN is a bad idea since it can clash with
> +architecture-specific #define's. So prefix those with LIBSHAPE to
> +avoid name clashing.
> +---
> +Origin: Debian
> +Bug-Debian: http://bugs.debian.org/742148
> +Last-Update: 2014-03-26
> +
> +--- a/contrib/Makefile
> ++++ b/contrib/Makefile
> +@@ -2,8 +2,8 @@
> + #LINKOPT	=	/usr/local/lib/libdbmalloc.a
> + #CFLAGS	=	-g
> + 
> +-# Endian: define either _LITTLE_ENDIAN or _BIG_ENDIAN
> +-ENDIAN	=	-D_LITTLE_ENDIAN
> ++# Endian: define either LIBSHAPE_LITTLE_ENDIAN or LIBSHAPE_BIG_ENDIAN
> ++ENDIAN	=	-DLIBSHAPE_LITTLE_ENDIAN
> + 
> + CFLAGS	=	-g -I.. -I$(HOME)/bld/include -DPROJ4 $(ENDIAN) -DDEBUG -DDEBUG2 
> + 
> +--- a/contrib/my_nan.h
> ++++ b/contrib/my_nan.h
> +@@ -26,10 +26,10 @@
> + 
> + /* IEEE Not A Number.  */
> + 
> +-#ifdef _BIG_ENDIAN
> ++#ifdef LIBSHAPE_BIG_ENDIAN
> + #  define	__nan_bytes		{ 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 }
> + #endif
> +-#ifdef _LITTLE_ENDIAN
> ++#ifdef LIBSHAPE_LITTLE_ENDIAN
> + #  define	__nan_bytes		{ 0, 0, 0, 0, 0, 0, 0xf8, 0x7f }
> + #endif
> + 
> diff -Nru shapelib-1.3.0/debian/patches/series shapelib-1.3.0/debian/patches/series
> --- shapelib-1.3.0/debian/patches/series	2014-03-18 22:47:55.000000000 +0100
> +++ shapelib-1.3.0/debian/patches/series	2014-03-26 10:38:26.000000000 +0100
> @@ -2,3 +2,4 @@
>  0003-Properly-use-libtool.patch
>  0004-Dynamically-link-the-shp-binaries-to-libshp.patch
>  0005-Stop-setting-CFLAGS-and-PREFIX-in-the-Makefile.patch
> +0006-Fix-FTBFS-avoid-clash-with-_ENDIAN-defines.patch




> _______________________________________________
> Pkg-grass-devel mailing list
> Pkg-grass-devel at lists.alioth.debian.org
> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel


-- 
Francesco P. Lovergine



More information about the Pkg-grass-devel mailing list