inikep / lzbench

lzbench is an in-memory benchmark of open-source LZ77/LZSS/LZMA compressors
885 stars 179 forks source link

Build errors on FreeBSD 11 #38

Closed yurivict closed 6 years ago

yurivict commented 7 years ago
In file included from tornado/Compression.h:11:
tornado/Common.h:45:2: error: "You're compiling for Motorola byte order, but FREEARC_INTEL_BYTE_ORDER was defined."
#error "You're compiling for Motorola byte order, but FREEARC_INTEL_BYTE_ORDER was defined."
 ^
1 error generated.
gmake: *** [Makefile:248: tornado/tor_test.o] Error 1
gmake: *** Waiting for unfinished jobs....
_lzbench/lzbench.cpp:155:13: warning: enumeration value 'MARKDOWN2' not handled in switch [-Wswitch]
    switch (params->textformat)
            ^
_lzbench/lzbench.cpp:664:37: warning: invalid conversion specifier 'Z' [-Wformat-invalid-specifier]
          printf("Seeking to: %llu %Zu %Zu\n", pos, params->chunk_size, insize);
                                   ~^
_lzbench/lzbench.cpp:664:41: warning: invalid conversion specifier 'Z' [-Wformat-invalid-specifier]
          printf("Seeking to: %llu %Zu %Zu\n", pos, params->chunk_size, insize);
                                       ~^
_lzbench/lzbench.cpp:664:53: warning: data argument not used by format string [-Wformat-extra-args]
          printf("Seeking to: %llu %Zu %Zu\n", pos, params->chunk_size, insize);
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~       ^
_lzbench/lzbench.cpp:823:13: error: use of undeclared identifier 'recursive'
            recursive = 1;
            ^
_lzbench/lzbench.cpp:928:5: warning: add explicit braces to avoid dangling else [-Wdangling-else]
    else
    ^
inikep commented 7 years ago

Two solutions:

  1. make DONT_BUILD_TORNADO=1
  2. Try if https://github.com/inikep/lzbench/commit/38ecf5ad8eb1456cf718046ca8080871041153ff fixes the issue
yurivict commented 7 years ago
  1. fixes it
  2. didn' fix it

However, 1. obviously just avoids some place in code, doesn't really fix it.

inikep commented 7 years ago

DONT_BUILD_TORNADO=1 disables the Tornado compressor but you still have about 40 other compressors available :)

What kind of compiler and processor do you have? Is it PowerPC as _BIG_ENDIAN seems to be defined?

yurivict commented 7 years ago

No, I have an average run-of-the-mill intel amd64 processor, little endian.

inikep commented 7 years ago

What kind of compiler do you have? Can you compile printf("_BIG_ENDIAN=%d\n", _BIG_ENDIAN); and provide its output.

inikep commented 7 years ago

Moreover after https://github.com/inikep/lzbench/commit/38ecf5ad8eb1456cf718046ca8080871041153ff the error should be changed from: #error "You're compiling for Motorola byte order, but FREEARC_INTEL_BYTE_ORDER was defined." to: #error "You're compiling for Intel byte order, but FREEARC_MOTOROLA_BYTE_ORDER was defined."

yurivict commented 7 years ago

I have clang-4.0.0

yurivict commented 7 years ago
$ cc -dM -E - | grep -i endian
#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
#define __LITTLE_ENDIAN__ 1
#define __ORDER_BIG_ENDIAN__ 4321
#define __ORDER_LITTLE_ENDIAN__ 1234
#define __ORDER_PDP_ENDIAN__ 3412
yurivict commented 7 years ago
$ cc --version
FreeBSD clang version 4.0.0 (tags/RELEASE_400/final 297347) (based on LLVM 4.0.0)
Target: x86_64-unknown-freebsd11.1
Thread model: posix
InstalledDir: /usr/bin
inikep commented 7 years ago

Can you compile

#include <stdio.h>

int main(void)
{
#ifdef _BIG_ENDIAN
    printf("_BIG_ENDIAN=%d\n", _BIG_ENDIAN);
#else
    printf("_BIG_ENDIAN not defined\n");
#endif
}

and provide its output?

yurivict commented 7 years ago
$ ./x
_BIG_ENDIAN not defined
inikep commented 7 years ago

The message "You're compiling for Motorola byte order, but FREEARC_INTEL_BYTE_ORDER was defined." requires _BIG_ENDIAN to be defined as non-zero value: https://github.com/inikep/lzbench/blob/master/tornado/Common.h#L45

I don't see possibility that _BIG_ENDIAN is defined by lzbench. It seems that the issue is that one of your system includes defines _BIG_ENDIAN.

inikep commented 7 years ago

Removing the following 3 lines should allow you to compile tornado: https://github.com/inikep/lzbench/blob/master/tornado/Common.h#L44-L46

yurivict commented 7 years ago

It seems that the issue is that one of your system includes defines _BIG_ENDIAN.

Yes: #define _BIG_ENDIAN 4321

This isn't generally an indication of big-endianness of the system.

This is discussed here https://stackoverflow.com/questions/4239993/determining-endianness-at-compile-time

Practically speaking, if the check is the only a problem on the FreeBSD, you can change this line to:

#if (!defined(__FreeBSD__) && _BIG_ENDIAN_) || (defined(__FreeBSD__) && defined(__LITTLE_ENDIAN__))

Or, to have a correct code, take the check from the above link.

inikep commented 6 years ago

I don't like to change sources of compressors but I had to fix tornado/Common.h: https://github.com/inikep/lzbench/commit/df29c6062ce4062d0ba34cc755bb2c74373cd0a0