Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#40541 closed defect (fixed)

clamav-0.98 build fails with redefinition of typedef 'Byte'

Reported by: gnw3 Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: ports Version: 2.2.0
Keywords: Cc: danielluke (Daniel J. Luke), mndavidoff (Monte Davidoff), bitpup
Port: clamav

Description

I have Snow Leopard. The relevant section of the log is:

:info:build   CC     libclamav_la-htmlnorm.lo
:info:build In file included from 7z/LzmaDec.h:7,
:info:build                  from lzma_iface.h:26,
:info:build                  from upx.c:59:
:info:build 7z/Types.h:58: error: redefinition of typedef 'Byte'
:info:build /opt/local/include/zconf.h:368: error: previous declaration of 'Byte' was here

from 7z/Types.h:58:

typedef unsigned char Byte;

from /opt/local/include/zconf.h:367-369:

#if !defined(__MACTYPES__)
typedef unsigned char  Byte;  /* 8 bits */
#endif

Workaround: replace Byte with SZByte in the 7z directory:

for f in $(port dir clamav)/work/clamav-0.98/libclamav/7z/*.[ch] ; do 
  sudo sed -i -e 's/Byte/SZByte/g' $f
done

With this change, the build completes and clamscan is able to process .7z archives.

Attachments (1)

main.log (75.8 KB) - added by gnw3 11 years ago.
main.log for failed build

Download all attachments as: .zip

Change History (8)

Changed 11 years ago by gnw3

Attachment: main.log added

main.log for failed build

comment:1 Changed 11 years ago by mndavidoff (Monte Davidoff)

Cc: md14-macports@… added

Cc Me!

comment:2 Changed 11 years ago by bitpup

Cc: wheeltong@… added

Cc Me!

comment:3 Changed 11 years ago by danielluke (Daniel J. Luke)

Yeah, I mentioned this on the macports-dev mailing list just to see if anyone had other thoughts on it. If you can provide a patch for the libclamav/7z/*.[ch] files, that's probably what we'll want to do (for now). Otherwise I'll try to generate one as soon as I can.

It would probably be worthwhile to report this upstream as well (and if you do so, please make a note of it here and include a link or the bug number if possible).

Thanks!

comment:4 Changed 11 years ago by gnw3

I gather that the zlib typedef for Byte isn't causing problems for other ports.

C11 allows multiple (consistent!) typedefs, so this issue is really with Apple's old gcc version. Unless clamav builds on other platforms encounter the problem, macports should try to use clamav-0.98 "as is".

I tried building clamav-0.98 in a "stand-alone" configuration.

1) using Apple gcc and zlib: the build did not encounter the problem, so it is macports' zlib that conflicts with clamav's libclamav/7z. I didn't run the check for this build and some further investigation is needed to determine why the multiple typedef doesn't occur (, and run checks to make sure the build actually works!).

2) using macports' clang and zlib:

The clamav-0.98 configure script uses -Wl,-rpath=... so needs editing to support zlib in /opt/local. With this configuration the build succeeds with a warning:

$ CC=/opt/local/bin/clang CXX=/opt/local/bin/clang++ \
  CPPFLAGS='-I/opt/local/include' \
  LDFLAGS='-L/opt/local/lib' \
  ./configure --prefix=/opt/clamav.net --with-zlib=/opt/local --enable-check
[...]
configure: Summary of detected features follows
              OS          : darwin10.8.0
              pthreads    : yes ()
configure: Summary of miscellaneous  features
              check       : -L/opt/local/lib -lcheck -R/opt/local/lib
              fanotify    : yes
              fdpassing   : 1
              IPv6        : yes
configure: Summary of optional tools
              clamdtop    : -L/opt/local/lib -lncurses -R/opt/local/lib (auto)
              milter      : yes (disabled)
configure: Summary of engine performance features)
              release mode: yes
              jit         : yes (auto)
              mempool     : yes
configure: Summary of engine detection features
              autoit_ea06 : yes
              bzip2       : ok
              zlib        : /opt/local
              unrar       : yes

This build fails some checks:

3 of 12 tests failed
(1 test was not run)
See unit_tests/test-suite.log
Please report to http://bugs.clamav.net/

The log has:

  CC     libclamav_la-upx.lo
In file included from upx.c:59:
In file included from ./lzma_iface.h:26:
In file included from ./7z/LzmaDec.h:7:
./7z/Types.h:58:23: warning: redefinition of typedef 'Byte' is a C11 feature [-Wtype
def-redefinition]
typedef unsigned char Byte;
                      ^
/opt/local/include/zconf.h:368:24: note: previous definition is here
typedef unsigned char  Byte;  /* 8 bits */
                       ^
1 warning generated.

The checks that fail:

=============================================
   ClamAV devel: unit_tests/test-suite.log   
=============================================

3 of 12 tests failed.  (1 test was not run).  

.. contents:: :depth: 2


FAIL: check5_clamd_vg.sh (exit: 109)
====================================

Killing stuck clamd!

FAIL: check6_clamd_vg.sh (exit: 109)
====================================

Running suite(s): clamd
100%: Checks: 77, Failures: 0, Errors: 0
Killing stuck clamd!

SKIP: check7_clamd_hg.sh (exit: 77)
===================================


FAIL: check8_clamd_hg.sh (exit: 42)
===================================

comment:5 Changed 11 years ago by danielluke (Daniel J. Luke)

Yes, you should address some of that (failing tests) with upstream, probably. The macports port fixes the bad rpath syntax (and I filed a bug report upstream about it). It looks like 10.7 and newer (with clang) don't have a problem building without modifying one of the Byte typdefs, so we can conditionally apply a patch on Darwin 8/9 (10.5 and 10.6). Really - the best thing you can do to make this faster is to upload a patch with your clamav 7z Byte typedef renames [or you can wait for me to make a patch and update the port].

comment:6 Changed 11 years ago by danielluke (Daniel J. Luke)

Resolution: fixed
Status: newclosed

patched in r111554

comment:7 Changed 11 years ago by danielluke (Daniel J. Luke)

and r111557 (missed darwin10 block before since I was testing on 10.5/darwin9)

Note: See TracTickets for help on using tickets.