#67729 closed defect (fixed)

lzma is broken now with Apple GCC: error: #pragma GCC diagnostic not allowed inside functions

Reported by: barracuda156 Owned by: ryandesign (Ryan Carsten Schmidt)
Priority: Normal Milestone:
Component: ports Version: 2.8.1
Keywords: tiger, leopard, snowleopard Cc:
Port: lzma

Description

../../../../C/LzmaEnc.c: In function ‘SeqOutStreamBuf_Write’:
../../../../C/LzmaEnc.c:2922: error: #pragma GCC diagnostic not allowed inside functions
../../../../C/LzmaEnc.c:2922: error: #pragma GCC diagnostic not allowed inside functions
../../../../C/LzmaEnc.c:2922: error: #pragma GCC diagnostic not allowed inside functions
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_archivers_lzma/lzma/work/compwrap/cc/usr/bin/gcc-4.2 -arch ppc     -O2 -c -Wall -Wextra  -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fPIC   -o _o/LzFindOpt.o ../../../../C/LzFindOpt.c
gnumake: *** [_o/LzmaEnc.o] Error 1

Change History (5)

comment:1 Changed 15 months ago by aeiouaeiouaeiouaeiouaeiouaeiou

Piece of LzmaEnc.c:

static size_t SeqOutStreamBuf_Write(ISeqOutStreamPtr pp, const void *data, size_t size)
{
  Z7_CONTAINER_FROM_VTBL_TO_DECL_VAR_pp_vt_p(CLzmaEnc_SeqOutStreamBuf)
  if (p->rem < size)
  {
    size = p->rem;
    p->overflow = True;
  }
  if (size != 0)
  {
    memcpy(p->data, data, size);
    p->rem -= size;
    p->data += size;
  }
  return size;
}

Piece of 7zTypes.h:

#if defined (__clang__) || defined(__GNUC__)
#define Z7_DIAGNOSCTIC_IGNORE_BEGIN_CAST_QUAL \
  _Pragma("GCC diagnostic push") \
  _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
#define Z7_DIAGNOSCTIC_IGNORE_END_CAST_QUAL \
  _Pragma("GCC diagnostic pop")
#else
#define Z7_DIAGNOSCTIC_IGNORE_BEGIN_CAST_QUAL
#define Z7_DIAGNOSCTIC_IGNORE_END_CAST_QUAL
#endif

#define Z7_CONTAINER_FROM_VTBL_TO_DECL_VAR(ptr, type, m, p) \
  Z7_DIAGNOSCTIC_IGNORE_BEGIN_CAST_QUAL \
  type *p = Z7_CONTAINER_FROM_VTBL(ptr, type, m); \
  Z7_DIAGNOSCTIC_IGNORE_END_CAST_QUAL

#define Z7_CONTAINER_FROM_VTBL_TO_DECL_VAR_pp_vt_p(type) \
  Z7_CONTAINER_FROM_VTBL_TO_DECL_VAR(pp, type, vt, p)

https://stackoverflow.com/a/16555760

I think we should copy the compiler blacklist from 7zip portfile.

Last edited 15 months ago by aeiouaeiouaeiouaeiouaeiouaeiou (previous) (diff)

comment:2 Changed 15 months ago by barracuda156

Ryan, what do you think? It is desirable to have this fixed ASAP, it is a dependency for many ports.

comment:3 Changed 15 months ago by kencu (Ken)

#if defined (__clang__) || defined(__GNUC__)

in insufficient as a test, as only newer gcc versions can support these pragmas inside functions.

Something like this is better (from our cmake patch for Tiger):

#if defined(__GNUC__)
#define GCC_VERSION \
	(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#endif
#if defined(__clang__) || (defined(GCC_VERSION) && (GCC_VERSION >= 40500))
/* gcc diagnostic pragmas available */
# define GCC_DIAGNOSTIC_AVAILABLE
#endif

and then use

if defined(GCC_DIAGNOSTIC_AVAILABLE)

as the test.

comment:4 Changed 15 months ago by kencu (Ken)

or just blacklist gcc versions prior to gcc 4.5, and you won't run into the problem.

but given upstream seems to want to do it right, perhaps they will be interested improving their test.

comment:5 Changed 14 months ago by aeiouaeiouaeiouaeiouaeiouaeiou

Resolution: fixed
Status: assignedclosed

In 31911b6300de8dc7172a712491442f43d3425e2a/macports-ports (master):

lzma: blacklist GCC 3/4

Closes: #67729

Note: See TracTickets for help on using tickets.