Also on real hardware.
There is nothing to comment
Gcc hallo.c
Sometimes you get nothing but "Internal computer bug", sometimes you get a.out
int puts(const char *s);
int main(){
puts("HelloWorld\n");
return 0;
}
CC=gcc
CFLAGS=-O -Wall
all: obj/hallo1 obj/hallo2
obj/hallo1: obj/hallo1.o
@echo -n "linking hallo1 ... "
@mkdir -p obj
@$(CC) -o obj/hallo1 obj/hallo1.o
@echo "done"
obj/hallo2: obj/hallo2.o
@echo -n "linking hallo2 ... "
@mkdir -p obj
@$(CC) -o obj/hallo2 obj/hallo2.o
@echo "done"
obj/hallo1.o: hallo1.c hallo1.h
@echo -n "compiling hallo1 ... "
@mkdir -p obj
@$(CC) $(CFLAGS) -o obj/hallo1.o -c hallo1.c
@echo "done"
obj/hallo2.o: hallo2.c hallo2.h
@echo -n "compiling hallo2 ... "
@mkdir -p obj
@$(CC) $(CFLAGS) -o obj/hallo2.o -c hallo2.c
@echo "done"
clean:
@echo -n "cleaning ... "
@rm -f obj/*
@echo "done"
int puts
(
char *s
);
int main()
{
puts("hAllo\n");
return 0;
}
#include <stdio.h>
int main()
{
printf("hAllo\n");
return 0;
}
for cycle in {0..99}
do
echo "cycle$cycle"
mem_total="`cat /proc/meminfo_total`"
mem_avail="`cat /proc/meminfo_avail`"
mem_ready="`cat /proc/meminfo_ready`"
make clean
echo "mem $mem_ready of $mem_avail of $mem_total"
make obj/hallo2
done
cycle0
cleaning ... done
mem 8436 of 44388 of 59152
compiling hallo1 ... done
linking hallo1 ... done
...
cycle99
cleaning ... done
mem 8188 of 44140 of 59152
compiling hallo1 ... done
linking hallo1 ... done
cycle0
cleaning ... done
mem 8228 of 44168 of 59152
compiling hallo2 ... during RTL pass: cse1
hallo2.c: In function ‘main’:
hallo2.c:8:1: internal compiler error: Bus error
8 | }
| ^
0x15fbeab internal_error(char const*, ...)
???:0
0x74c71b df_insn_rescan(rtx_insn*)
???:0
0x74e373 df_process_deferred_rescans()
???:0
0x736d87 df_finish_pass(bool)
???:0
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://bugs.gentoo.org/> for instructions.
make: *** [Makefile:27: obj/hallo2.o] Error 1
..
cycle1
cleaning ... done
mem 8168 of 44024 of 59152
compiling hallo2 ... done
linking hallo2 ... done
..
cycle19
cleaning ... done
mem 8484 of 44340 of 59152
compiling hallo2 ... during RTL pass: reload
hallo2.c: In function ‘main’:
hallo2.c:8:1: internal compiler error: Bus error
8 | }
| ^
0x15fbeab internal_error(char const*, ...)
???:0
0x74ddaf df_update_entry_block_defs()
???:0
0x74e07b df_update_entry_exit_and_calls()
???:0
0x74e547 df_process_deferred_rescans()
???:0
0x736d87 df_finish_pass(bool)
???:0
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://bugs.gentoo.org/> for instructions.
make: *** [Makefile:27: obj/hallo2.o] Error 1
gcc randomly crashes with "bus error, internal compiler error"
Randomness is troubling. It could be faulty RAM.
"Out of memory error".
swapon /dev/sda2
Adding 131068k swap on /dev/s. Priority:-xtents:1 acro131068k
function check_result()
{
local test="$?"
local ans
if [ "$test" == "0" ]
then
ans="success"
echo "$ans"
else
ans="failure"
echo "$ans"
exit 0
fi
}
for cycle in {0..99}
do
echo "cycle$cycle"
mem_total="`cat /proc/meminfo_total`"
mem_avail="`cat /proc/meminfo_avail`"
mem_ready="`cat /proc/meminfo_ready`"
make clean
echo "mem $mem_ready of $mem_avail of $mem_total"
sync
sync
sync
echo 3 > /proc/sys/vm/drop_caches
sync
sync
sync
make obj/hallo2
check_result
done
CC=gcc
CFLAGS=-std=c89 -O -Wall -freport-bug
MAKEOPTS=-j1
all: obj/hallo1 obj/hallo2
obj/hallo1: obj/hallo1.o
@echo -n "linking hallo1 ... "
@mkdir -p obj
@$(CC) -o obj/hallo1 obj/hallo1.o
@echo "done"
obj/hallo2: obj/hallo2.o
@echo -n "linking hallo2 ... "
@mkdir -p obj
@$(CC) -o obj/hallo2 obj/hallo2.o
@echo "done"
obj/hallo1.o: hallo1.c hallo1.h
@echo -n "compiling hallo1 ... "
@mkdir -p obj
@$(CC) $(CFLAGS) -o obj/hallo1.o -c hallo1.c
@echo "done"
obj/hallo2.o: hallo2.c hallo2.h
@echo -n "compiling hallo2 ... "
@mkdir -p obj
@$(CC) $(CFLAGS) -o obj/hallo2.o -c hallo2.c
@echo "done"
# Stop after the preprocessing stage
# do not run the compiler proper.
# The output is in the form of preprocessed source code
# which is sent to the standard output.
obj/hallo1.txt: hallo1.c hallo1.h
@echo -n "expanding hallo1 ... "
@mkdir -p obj
@$(CC) $(CFLAGS) -o obj/hallo1.txt -E hallo1.c
@echo "done"
obj/hallo2.txt: hallo2.c hallo2.h
@echo -n "expanding hallo2 ... "
@mkdir -p obj
@$(CC) $(CFLAGS) -o obj/hallo2.txt -E hallo2.c
@echo "done"
clean:
@echo -n "cleaning ... "
@rm -f obj/*
@echo "done"
cycle22
cleaning ... done
mem 17784 of 45964 of 59152
compiling hallo2 ... during RTL pass: reload
hallo2.c: In function ‘main’:
hallo2.c:11:1: internal compiler error: Bus error
11 | }
| ^
0x15fbeab internal_error(char const*, ...)
???:0
0x74ddaf df_update_entry_block_defs()
???:0
0x74e07b df_update_entry_exit_and_calls()
???:0
0x74e547 df_process_deferred_rescans()
???:0
0x736d87 df_finish_pass(bool)
???:0
Please submit a full bug report, with preprocessed source.
Please include the complete backtrace with any bug report.
See <https://bugs.gentoo.org/> for instructions.
The bug is not reproducible, so it is likely a hardware or OS problem.
make: *** [Makefile:22: obj/hallo1.o] Error 1
success
"Out of memory error".The kernel shouldn't warn something on the console?
# gcc-config -l 1
[1] mipsel-unknown-linux-gnu-4.1.2
[2] mipsel-unknown-linux-gnu-12 *
I wonder ... why the kernel does'n t just use the swap?
Your best bet instead of trying to work around it is to cross-compile, IMHO.
But otherwise, can you not just use Qemu to compile, and allocate a shitload of RAM to the virtual machine?
checking for armv5tel-softfloat-linux-gnueabi-gcc... armv5tel-softfloat-linux-gnueabi-gcc
checking for C compiler default output... configure: error: C compiler cannot create executables
/usr/lib/gcc/mipsel-unknown-linux-gnu/4.1.2/../../../../mipsel-unknown-linux-gnu/bin/ld: dwarf_sig8_hash.c:(.text+0xadc): undefined reference to `__sync_fetch_and_sub_4'
/usr/lib/gcc/mipsel-unknown-linux-gnu/4.1.2/../../../../mipsel-unknown-linux-gnu/bin/ld: libdw_pic.a(libdw_alloc.os): in function `__libdw_alloc_tail':
libdw_alloc.c:(.text+0x40c): undefined reference to `__sync_fetch_and_add_4'
collect2: ld returned 1 exit status
Code: [Select]libdw_alloc.c:(.text+0x40c): undefined reference to `__sync_fetch_and_add_4'
__sync_fetch_and_add_4:
sync
loop:
ll v0,0(a0)
addu at,v0,a1
sc at,0(a0)
beqz at,loop
nop
sync
jr ra
int main(void) {
volatile int a = 1;
int b = __sync_fetch_and_add(&a, 2);
return a * b;
}
You do need 4.8 with libatomic (-latomic) for 64-bit atomics (__atomic_..._8()), though.
# mipsel-unknown-linux-gnu-gcc-4.1.2 test_gcc_mips_sync_fetch_and_add_4.c -o test_gcc_mips_sync_fetch_and_add_4.c
/usr/lib/gcc/mipsel-unknown-linux-gnu/4.1.2/../../../../mipsel-unknown-linux-gnu/bin/ld: /tmp/ccEfV3mL.o: in function `main':
test_gcc_mips_sync_fetch_and_add_4.c:(.text+0x34): undefined reference to `__sync_fetch_and_add_4'
collect2: ld returned 1 exit status
(your c testing code)2023-03-22--08-44-20---2023-03-22--10-43-17 - [ dev-libs/elfutils ] - failure - root@dev2.40.0/4.1.2
/usr/lib/gcc/mipsel-unknown-linux-gnu/4.1.2/../../../../mipsel-unknown-linux-gnu/bin/ld: dwarf_sig8_hash.c:(.text+0xadc): undefined reference to `__sync_fetch_and_sub_4'
/usr/lib/gcc/mipsel-unknown-linux-gnu/4.1.2/../../../../mipsel-unknown-linux-gnu/bin/ld: libdw_pic.a(libdw_alloc.os): in function `__libdw_alloc_tail':
libdw_alloc.c:(.text+0x40c): undefined reference to `__sync_fetch_and_add_4'
collect2: ld returned 1 exit status
2023-03-22--19-45-37---2023-03-22--21-30-49 - [ dev-util/strace ] - success - root@dev2.40.0/4.1.2
***use_flags, dev-util/strace: (-aio -elfutils -perl -selinux -static -unwind)
-COMMON_FLAGS="-O2 -march=mips2 -mabi=32 -mplt -pipe"
+COMMON_FLAGS="-O2 -march=mips2 -mabi=32 -pipe"
-mplt is NOT supported by gcc v4.1.2/usr/lib/gcc/mipsel-unknown-linux-gnu/12/libgcc_s.so.1
/usr/lib/gcc/mipsel-unknown-linux-gnu/12/libgcc.a
sync_fetch_and_add is there