Tests failed
vtereshkov@Vasiliy-Acer:~/xcc$ sudo make test
make CC=../xcc -C libsrc
make[1]: Entering directory '/home/vtereshkov/xcc/libsrc'
make[1]: Nothing to be done for 'libs'.
make[1]: Leaving directory '/home/vtereshkov/xcc/libsrc'
make -C tests clean && make -C tests all && \
make test-libs
make[1]: Entering directory '/home/vtereshkov/xcc/tests'
rm -rf table_test util_test parser_test initializer_test print_type_test \
valtest dvaltest fvaltest link_test \
a.out tmp* *.o mandelbrot.ppm \
*.wasm
make[1]: Leaving directory '/home/vtereshkov/xcc/tests'
make[1]: Entering directory '/home/vtereshkov/xcc/tests'
cc -otable_test -ansi -std=c11 -Wall -Wextra -Werror -Wold-style-definition -Wno-missing-field-initializers -Wno-typedef-redefinition -Wno-empty-body -I../src/cc/frontend -I../src/util -D_POSIX_C_SOURCE=200809L table_test.c ../src/util/table.c
## NameTable
table: OK: 11
cc -outil_test -ansi -std=c11 -Wall -Wextra -Werror -Wold-style-definition -Wno-missing-field-initializers -Wno-typedef-redefinition -Wno-empty-body -I../src/cc/frontend -I../src/util -D_POSIX_C_SOURCE=200809L util_test.c ../src/util/util.c ../src/util/table.c
## Util
vector: OK: 15
sb: OK: 4
escape: OK: 1
is_fullpath: OK: 5
join_paths: OK: 22
change_ext: OK: 4
cc -oparser_test -ansi -std=c11 -Wall -Wextra -Werror -Wold-style-definition -Wno-missing-field-initializers -Wno-typedef-redefinition -Wno-empty-body -I../src/cc/frontend -I../src/util -D_POSIX_C_SOURCE=200809L parser_test.c ../src/cc/frontend/parser_expr.c ../src/cc/frontend/lexer.c ../src/cc/frontend/parser.c ../src/cc/frontend/initializer.c ../src/cc/frontend/fe_misc.c ../src/cc/frontend/type.c ../src/cc/frontend/ast.c ../src/cc/frontend/var.c ../src/util/util.c ../src/util/table.c
## Parser
parse_full_type: OK: 22
cc -oinitializer_test -DNO_MAIN_DUMP_EXPR -ansi -std=c11 -Wall -Wextra -Werror -Wold-style-definition -Wno-missing-field-initializers -Wno-typedef-redefinition -Wno-empty-body -I../src/cc/frontend -I../src/util -D_POSIX_C_SOURCE=200809L initializer_test.c ../src/cc/frontend/parser.c ../src/cc/frontend/parser_expr.c ../src/cc/frontend/lexer.c ../src/cc/frontend/initializer.c ../src/cc/frontend/fe_misc.c ../src/cc/frontend/var.c ../src/cc/frontend/type.c ../src/cc/frontend/ast.c ../src/util/util.c ../src/util/table.c ../src/_debug/dump_expr.c
## Initializer
flatten: OK: 19
cc -o print_type_test -ansi -std=c11 -Wall -Wextra -Werror -Wold-style-definition -Wno-missing-field-initializers -Wno-typedef-redefinition -Wno-empty-body -I../src/cc/frontend -I../src/util -D_POSIX_C_SOURCE=200809L print_type_test.c ../src/cc/frontend/type.c ../src/util/util.c ../src/util/table.c
## Print type
print_type: OK: 26
## cpptest
Basic: OK: 23
If: OK: 19
Macro: OK: 21
Concat: OK: 14
Stringify: OK: 2
Error: OK: 8
Run: OK: 4
## test.sh
Compile=[../xcc], Run=[ ./tmp.cJCRnaj6YJ]
Basic 1: data-bss alignment./test.sh: line 47: ./tmp.cJCRnaj6YJ: cannot execute binary file: Exec format error
FAILED: 0 expected, but 126
Basic 2: cast array to pointer./test.sh: line 47: ./tmp.cJCRnaj6YJ: cannot execute binary file: Exec format error
FAILED: 44 expected, but 126
Basic 3: variable definition overwrite./test.sh: line 47: ./tmp.cJCRnaj6YJ: cannot execute binary file: Exec format error
FAILED: 123 expected, but 126
Basic 8: direct addressing./test.sh: line 47: ./tmp.cJCRnaj6YJ: cannot execute binary file: Exec format error
FAILED: 99 expected, but 126
Basic 9: restrict for array in funparam./test.sh: line 47: ./tmp.cJCRnaj6YJ: cannot execute binary file: Exec format error
FAILED: 83 expected, but 126
ERROR: 5/9
Struct: OK: 9
Bitfield: OK: 6
Initializer: OK: 20
Function 10: no return in main./test.sh: line 47: ./tmp.cJCRnaj6YJ: cannot execute binary file: Exec format error
FAILED: 0 expected, but 126
Function 17: infinite loop and exit./test.sh: line 47: ./tmp.cJCRnaj6YJ: cannot execute binary file: Exec format error
FAILED: 77 expected, but 126
Function 18: multiple prototype./test.sh: line 47: ./tmp.cJCRnaj6YJ: cannot execute binary file: Exec format error
FAILED: 22 expected, but 126
ERROR: 3/18
Error 58: allow switch break after block./test.sh: line 47: ./tmp.cJCRnaj6YJ: cannot execute binary file: Exec format error
FAILED: 21 expected, but 126
Error 59: use goto to skip first./test.sh: line 47: ./tmp.cJCRnaj6YJ: cannot execute binary file: Exec format error
FAILED: 54 expected, but 126
Error 80: typedef and var in other scope./test.sh: line 47: ./tmp.cJCRnaj6YJ: cannot execute binary file: Exec format error
FAILED: 123 expected, but 126
ERROR: 3/90
Error line no: OK: 6
make[1]: *** [Makefile:93: test-sh] Error 3
make[1]: Leaving directory '/home/vtereshkov/xcc/tests'
make: *** [Makefile:135: test] Error 2
@vtereshkov Could you tell me your environment? (OS, CPU)
Ubuntu 20.04 (WSL), x86-64.
@vtereshkov I'm not sure, but googled "cannot execute binary file: Exec format error", it caused by WSL? I'm sorry I couldn't help you.
Here is an example program test1.c:
int main()
{
return 42;
}
If I run
gcc test1.c -o test1gcc
./xcc test1.c -o test1xcc
I get the following two binaries: test1.zip
The GCC version runs as expected, can be disassembled with objdump, etc. The XCC version fails with the Exec format error and produces no output with objdump.
I have compiled the return 42 source code on my environment (Ubuntu/WSL2, x86-64),
and get exactly same binary file as test1xcc.
I'm not sure why it cannot run on your environment.
$ file test1xcc
test1xcc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, no section header
$ objdump -a test1xcc
test1xcc: file format elf64-x86-64
test1xcc
$ uname -a
Linux RTX 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
I get no disassembly output from objdump -d test1xcc, while objdump -d test1gcc is OK.
Also, when I upload test1xcc to http://www.sunshine2k.de/coding/javascript/onlineelfviewer/onlineelfviewer.html, I see the Invalid ELF file status. The GCC version is again OK.
I was not able to reproduce the problem, I'm sorry I couldn't help you but I will close the issue.