wc-duck / datalibrary

Open Source Data Library for data serialization.
Other
42 stars 8 forks source link

Unable to compile tests on Linux (Ubuntu 16.10) #55

Closed zeyelth closed 7 years ago

zeyelth commented 7 years ago

Could be something wrong with my setup, but this is what I get from a clean directory:

workdir$ git clone https://github.com/wc-duck/datalibrary
...

workdir$ git clone https://github.com/matricks/bam.git
...

workdir$ cd bam/

workdir/bam$ ./make_unix.sh
compiling using gcc...
/tmp/ccHhCuEn.o: In function `os_tmpname':
loslib.c:(.text+0x29d): warning: the use of `tmpnam' is dangerous, better use `mkstemp'

workdir/bam$ cd ../datalibrary/

workdir/datalibrary$ gcc --version
gcc (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO                                            
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

workdir/datalibrary$ ../bam/bam compiler=gcc platform=linux_x86_64 config=debug -r sc
compiler used "gcc"
[ 1/65] [1] c tool/dl_pack/getopt/getopt.c
[ 2/65] [2] c++ src/dl_alloc.cpp
[ 3/65] [3] c++ src/dl_reflect.cpp
[ 4/65] [4] c++ src/dl_typelib_write_c_header.cpp
[ 5/65] [5] c++ src/dl_typelib_read_bin.cpp
[ 6/65] [6] c++ src/dl_txt_pack.cpp
[ 7/65] [7] c++ src/dl_convert.cpp
[ 8/65] [8] c++ src/dl.cpp
[ 9/65] [2] c++ src/dl_txt_unpack.cpp
[10/65] [1] c++ src/dl_util.cpp
[11/65] [3] c++ src/dl_typelib_write_txt.cpp
[12/65] [4] c++ src/dl_patch_ptr.cpp
[13/65] [1] c++ src/dl_typelib_write_bin.cpp
[14/65] [8] c++ src/dl_typelib_read_txt.cpp
[15/65] [5] c++ tool/dl_tlc/dltlc.cpp
[16/65] [3] c++ external/gtest/src/gtest-all.cc
[17/65] [1] c++ src/dl_alloc.cpp
[18/65] [2] c++ src/dl_reflect.cpp
[19/65] [4] c++ src/dl_typelib_write_c_header.cpp
[20/65] [6] c++ src/dl_typelib_read_bin.cpp
[21/65] [1] c++ src/dl_txt_pack.cpp
[22/65] [2] c++ src/dl_convert.cpp
[23/65] [6] c++ src/dl.cpp
[24/65] [4] c++ src/dl_txt_unpack.cpp
[25/65] [8] c++ src/dl_util.cpp
[26/65] [5] c++ src/dl_typelib_write_txt.cpp
[27/65] [7] lib local/linux_x86_64/gcc/debug/libdl.a
ar: `u' modifier ignored since `D' is the default (see `U')
[28/65] [7] link local/linux_x86_64/gcc/debug/dltlc
[29/65] [8] c++ src/dl_patch_ptr.cpp
[30/65] [4] c++ src/dl_typelib_write_bin.cpp
[31/65] [1] c++ src/dl_typelib_read_txt.cpp
[32/65] [6] c++ tool/dl_pack/dl_pack.cpp
[33/65] [7] tlc local/generated/unittest2.h
[34/65] [7] tlc local/generated/unittest.h
[35/65] [7] tlc local/generated/dlbench.bin
[36/65] [7] tlc local/generated/small.bin
[37/65] [7] tlc local/generated/unittest2.bin
[38/65] [7] tlc local/generated/unittest2.bin.h
[39/65] [7] tlc local/generated/unittest.bin
[40/65] [4] tlc local/generated/dlbench.bin.h
[41/65] [8] tlc local/generated/dlbench.h
[42/65] [7] tlc local/generated/unittest.bin.h
[43/65] [5] tlc local/generated/unittest.bin.h
[44/65] [4] tlc local/generated/small.bin.h
[45/65] [4] c tests/dl_test_valid_c.c
[46/65] [6] link local/linux_x86_64/gcc/debug/dl_pack
[47/65] [7] c++ tests/dl_tests_string.cpp
[48/65] [5] c++ tests/dl_tests_typelib.cpp
In file included from tests/dl_test_valid_c.c:1:0:
local/generated/unittest2.h:66:26: error: ‘vec3_test’ undeclared here (not in a function)
 DL_STATIC_ASSERT( sizeof(vec3_test) == 12, "size of external type vec3_test do not match what was specified in tld." );
                          ^
local/generated/unittest.h:41:63: note: in definition of macro ‘DL_STATIC_ASSERT’
 #        define DL_STATIC_ASSERT( cond, msg ) _Static_assert( cond, msg )
                                                               ^~~~
local/generated/unittest2.h:66:19: error: expression in static assertion is not an integer
 DL_STATIC_ASSERT( sizeof(vec3_test) == 12, "size of external type vec3_test do not match what was specified in tld." );
                   ^
local/generated/unittest.h:41:63: note: in definition of macro ‘DL_STATIC_ASSERT’
 #        define DL_STATIC_ASSERT( cond, msg ) _Static_assert( cond, msg )
                                                               ^~~~
local/generated/unittest2.h:67:30: error: expected specifier-qualifier-list before ‘vec3_test’
 DL_STATIC_ASSERT( DL_ALIGNOF(vec3_test) == 4, "alignment of external type vec3_test do not match what was specified in tld." );
                              ^
local/generated/unittest.h:41:63: note: in definition of macro ‘DL_STATIC_ASSERT’
 #        define DL_STATIC_ASSERT( cond, msg ) _Static_assert( cond, msg )
                                                               ^~~~
local/generated/unittest2.h:67:19: note: in expansion of macro ‘DL_ALIGNOF’
 DL_STATIC_ASSERT( DL_ALIGNOF(vec3_test) == 4, "alignment of external type vec3_test do not match what was specified in tld." );
                   ^~~~~~~~~~
local/generated/unittest.h:21:51: error: ‘struct <anonymous>’ has no member named ‘x’
 #    define DL_ALIGNOF(type) ((sizeof(type) > 1)? offsetof(struct { char c; type x; }, x) : 1)
                                                   ^
local/generated/unittest.h:41:63: note: in definition of macro ‘DL_STATIC_ASSERT’
 #        define DL_STATIC_ASSERT( cond, msg ) _Static_assert( cond, msg )
                                                               ^~~~
local/generated/unittest2.h:67:19: note: in expansion of macro ‘DL_ALIGNOF’
 DL_STATIC_ASSERT( DL_ALIGNOF(vec3_test) == 4, "alignment of external type vec3_test do not match what was specified in tld." );
                   ^~~~~~~~~~
local/generated/unittest.h:21:30: error: expression in static assertion is not an integer
 #    define DL_ALIGNOF(type) ((sizeof(type) > 1)? offsetof(struct { char c; type x; }, x) : 1)
                              ^
local/generated/unittest.h:41:63: note: in definition of macro ‘DL_STATIC_ASSERT’
 #        define DL_STATIC_ASSERT( cond, msg ) _Static_assert( cond, msg )
                                                               ^~~~
local/generated/unittest2.h:67:19: note: in expansion of macro ‘DL_ALIGNOF’
 DL_STATIC_ASSERT( DL_ALIGNOF(vec3_test) == 4, "alignment of external type vec3_test do not match what was specified in tld." );
                   ^~~~~~~~~~
[49/65] [8] c++ benchmark/dlbench.cpp
local/generated/unittest2.h:68:38: error: expected expression before ‘)’ token
 DL_STATIC_ASSERT( sizeof(((vec3_test*) 0)->x) == 4, "sizeof of member vec3_test::x in external type do not match what was specified in tld." );
                                      ^
local/generated/unittest.h:41:63: note: in definition of macro ‘DL_STATIC_ASSERT’
 #        define DL_STATIC_ASSERT( cond, msg ) _Static_assert( cond, msg )
                                                               ^~~~
local/generated/unittest2.h:68:19: error: expression in static assertion is not an integer
 DL_STATIC_ASSERT( sizeof(((vec3_test*) 0)->x) == 4, "sizeof of member vec3_test::x in external type do not match what was specified in tld." );
                   ^
local/generated/unittest.h:41:63: note: in definition of macro ‘DL_STATIC_ASSERT’
 #        define DL_STATIC_ASSERT( cond, msg ) _Static_assert( cond, msg )
                                                               ^~~~
local/generated/unittest2.h:69:28: error: expected specifier-qualifier-list before ‘vec3_test’
 DL_STATIC_ASSERT( offsetof(vec3_test, x) == 0, "offset of member vec3_test::x in external type do not match what was specified in tld." );
                            ^
local/generated/unittest.h:41:63: note: in definition of macro ‘DL_STATIC_ASSERT’
 #        define DL_STATIC_ASSERT( cond, msg ) _Static_assert( cond, msg )
                                                               ^~~~
local/generated/unittest2.h:69:19: error: expression in static assertion is not an integer
 DL_STATIC_ASSERT( offsetof(vec3_test, x) == 0, "offset of member vec3_test::x in external type do not match what was specified in tld." );
                   ^
local/generated/unittest.h:41:63: note: in definition of macro ‘DL_STATIC_ASSERT’
 #        define DL_STATIC_ASSERT( cond, msg ) _Static_assert( cond, msg )
                                                               ^~~~
local/generated/unittest2.h:70:38: error: expected expression before ‘)’ token
 DL_STATIC_ASSERT( sizeof(((vec3_test*) 0)->y) == 4, "sizeof of member vec3_test::y in external type do not match what was specified in tld." );
                                      ^
local/generated/unittest.h:41:63: note: in definition of macro ‘DL_STATIC_ASSERT’
 #        define DL_STATIC_ASSERT( cond, msg ) _Static_assert( cond, msg )
                                                               ^~~~
local/generated/unittest2.h:70:19: error: expression in static assertion is not an integer
 DL_STATIC_ASSERT( sizeof(((vec3_test*) 0)->y) == 4, "sizeof of member vec3_test::y in external type do not match what was specified in tld." );
                   ^
local/generated/unittest.h:41:63: note: in definition of macro ‘DL_STATIC_ASSERT’
 #        define DL_STATIC_ASSERT( cond, msg ) _Static_assert( cond, msg )
                                                               ^~~~
local/generated/unittest2.h:71:28: error: expected specifier-qualifier-list before ‘vec3_test’
 DL_STATIC_ASSERT( offsetof(vec3_test, y) == 4, "offset of member vec3_test::y in external type do not match what was specified in tld." );
                            ^
local/generated/unittest.h:41:63: note: in definition of macro ‘DL_STATIC_ASSERT’
 #        define DL_STATIC_ASSERT( cond, msg ) _Static_assert( cond, msg )
                                                               ^~~~
local/generated/unittest2.h:71:19: error: expression in static assertion is not an integer
 DL_STATIC_ASSERT( offsetof(vec3_test, y) == 4, "offset of member vec3_test::y in external type do not match what was specified in tld." );
                   ^
local/generated/unittest.h:41:63: note: in definition of macro ‘DL_STATIC_ASSERT’
 #        define DL_STATIC_ASSERT( cond, msg ) _Static_assert( cond, msg )
                                                               ^~~~
local/generated/unittest2.h:72:38: error: expected expression before ‘)’ token
 DL_STATIC_ASSERT( sizeof(((vec3_test*) 0)->z) == 4, "sizeof of member vec3_test::z in external type do not match what was specified in tld." );
                                      ^
local/generated/unittest.h:41:63: note: in definition of macro ‘DL_STATIC_ASSERT’
 #        define DL_STATIC_ASSERT( cond, msg ) _Static_assert( cond, msg )
                                                               ^~~~
local/generated/unittest2.h:72:19: error: expression in static assertion is not an integer
 DL_STATIC_ASSERT( sizeof(((vec3_test*) 0)->z) == 4, "sizeof of member vec3_test::z in external type do not match what was specified in tld." );
                   ^
local/generated/unittest.h:41:63: note: in definition of macro ‘DL_STATIC_ASSERT’
 #        define DL_STATIC_ASSERT( cond, msg ) _Static_assert( cond, msg )
                                                               ^~~~
local/generated/unittest2.h:73:28: error: expected specifier-qualifier-list before ‘vec3_test’
 DL_STATIC_ASSERT( offsetof(vec3_test, z) == 8, "offset of member vec3_test::z in external type do not match what was specified in tld." );
                            ^
local/generated/unittest.h:41:63: note: in definition of macro ‘DL_STATIC_ASSERT’
 #        define DL_STATIC_ASSERT( cond, msg ) _Static_assert( cond, msg )
                                                               ^~~~
local/generated/unittest2.h:73:19: error: expression in static assertion is not an integer
 DL_STATIC_ASSERT( offsetof(vec3_test, z) == 8, "offset of member vec3_test::z in external type do not match what was specified in tld." );
                   ^
local/generated/unittest.h:41:63: note: in definition of macro ‘DL_STATIC_ASSERT’
 #        define DL_STATIC_ASSERT( cond, msg ) _Static_assert( cond, msg )
                                                               ^~~~
bam: 'c tests/dl_test_valid_c.c' error 256
[50/65] [4] c++ tests/dl_tests_union.cpp
[51/65] [2] c++ tests/dl_tests_struct.cpp
[52/65] [1] c++ tests/dl_tests_dl.cpp
[53/65] [6] c++ tests/dl_tests_txt.cpp
[54/65] [8] c++ tests/dl_tests_error.cpp
[55/65] [5] c++ tests/dl_tests_ptr.cpp
[56/65] [8] c++ tests/dl_tests_reflect.cpp
[57/65] [6] c++ tests/dl_tests_bitfield.cpp
[58/65] [7] c++ tests/dl_tests_inline_array.cpp
[59/65] [8] c++ tests/dl_tests_base.cpp
[60/65] [3] lib local/linux_x86_64/gcc/debug/libgtest.a
ar: `u' modifier ignored since `D' is the default (see `U')
[61/65] [3] c++ tests/dl_tests_util.cpp
[62/65] [2] c++ tests/dl_tests_array.cpp
[63/65] [4] link local/linux_x86_64/gcc/debug/dlbench
[64/65] [1] dll local/linux_x86_64/gcc/debug/dlsh.so
[65/65] [2] link local/linux_x86_64/gcc/debug/dl_tests
bam: error: a build step failed
wc-duck commented 7 years ago

Hmm... can't really explain this but you are running a newer version of gcc than both me and the autobuilder so that might be an explaination.

It's hard to say what it might be since I can't try in out myself, but we'll have a chat monday if you haven't fonud out by then.

btw... if you just want it to build you could just comment out the test-c-file for now.

zeyelth commented 7 years ago

Did some tests:

It compiles fine using gcc-4.7 and gcc-4.9, but only if I target 32bit Linux.

gcc-4.* cannot build 64bit:

[32/65] [2] c++ tool/dl_pack/dl_pack.cpp
/usr/bin/ld: local/linux_x86_64/gcc/debug/[33/65] [2] link local/linux_x86_64/gcc/debug/dl_pack
getopt.o: relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
bam: 'link local/linux_x86_64/gcc/debug/dltlc' error 256
/usr/bin/ld: local/linux_x86_64/gcc/debug/getopt.o: relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
bam: 'link local/linux_x86_64/gcc/debug/dl_pack' error 256

It fails to compile using gcc-5.* and up. clang also fails with the same error.

And for completeness' sake, if I rename dl_test_valid_c.c to dl_test_valid_c.cpp it succeeds.

Edit: Test code is not C compliant. Fix in PR.