wichtounet/thor-os

Newer version of GCC

CodeLongAndProsper90 opened this issue · 20 comments

Hello. I am trying to build this on Ubuntu 19.10, Eoan Ermine, using GCC 9.2.0. Is there any way that Thor OS can be ported to a more modern version of GCC?

Hi,

Did you try building a cross compiler like indicated on the wiki https://github.com/wichtounet/thor-os/wiki/Cross-Compiler?

I remember there was a problem with GCC 6, but I do not know if that it still the case.

If you have an error compiling with GCC 9.2, let me know and I will try to update the procedure. I have the same compiler on my Gentoo, so I can maybe give it another try this weekend.

The problem is that compiling glibc fails due to a race condition, so I have to -j1, and then it give the output:

Command:

$ make all-target-libgcc CFLAGS_FOR_TARGET="-mcmodel=large"

Output:

g++ -c  -DIN_GCC_FRONTEND -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings   -DHAVE_CONFIG_H -I. -Icp -I../../gcc-4.8.2/gcc -I../../gcc-4.8.2/gcc/cp -I../../gcc-4.8.2/gcc/../include -I../../gcc-4.8.2/gcc/../libcpp/include  -I../../gcc-4.8.2/gcc/../libdecnumber -I../../gcc-4.8.2/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc-4.8.2/gcc/../libbacktrace    ../../gcc-4.8.2/gcc/cp/except.c -o cp/except.o
In file included from ./tm.h:21,
                 from ../../gcc-4.8.2/gcc/cp/except.c:27:
../../gcc-4.8.2/gcc/config/elfos.h:102:21: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
  102 |    fprintf ((FILE), "%s"HOST_WIDE_INT_PRINT_UNSIGNED"\n",\
      |                     ^
../../gcc-4.8.2/gcc/config/elfos.h:170:24: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
  170 |       fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n",  \
      |                        ^
In file included from ./tm.h:30,
                 from ../../gcc-4.8.2/gcc/cp/except.c:27:
../../gcc-4.8.2/gcc/defaults.h:126:24: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
  126 |       fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n",  \
      |                        ^
In file included from ../../gcc-4.8.2/gcc/cp/except.c:1005:
cfns.gperf:101:1: error: ‘const char* libc_name_p(const char*, unsigned int)’ redeclared inline with ‘gnu_inline’ attribute
cfns.gperf:26:14: note: ‘const char* libc_name_p(const char*, unsigned int)’ previously declared here
cfns.gperf:26:14: warning: inline function ‘const char* libc_name_p(const char*, unsigned int)’ used but never defined
make[1]: *** [Makefile:1058: cp/except.o] Error 1
make[1]: Leaving directory '/home/scott/src/build-gcc/gcc'
make: *** [Makefile:3904: all-gcc] Error 2

Thanks for sharing the error. I am going to try to compile another cross compiler this weekend. If it's not too time-consuming I will update the wiki and let you know.

Well, I tried it again, this time with GCC 7.
The compile works, but now the install fails, for no apparent reason.
make install-gcc

/bin/sh ../gcc-4.8.2/mkinstalldirs /home/scott/opt/cross /home/scott/opt/cross
make[1]: Entering directory '/home/scott/src/build-gcc/fixincludes'
make[1]: *** No rule to make target 'install'.  Stop.
make[1]: Leaving directory '/home/scott/src/build-gcc/fixincludes'
make: *** [Makefile:3329: install-fixincludes] Error 2

Update:

I've also tried with GCC 7 and 5, to no avail.

I have updated the wiki (https://github.com/wichtounet/thor-os/wiki/Cross-Compiler) with new versions. I have tested with GCC 9.2.0. The compilation works, but I do not have enough time to test the OS itself currently.

Can you try again?

I've tried again, installing the dependencies
apt

Reading package lists... Done
Building dependency tree       
Reading state information... Done
g++ is already the newest version (4:9.2.1-3.1ubuntu1).
gcc-multilib is already the newest version (4:9.2.1-3.1ubuntu1).
libmpc-dev is already the newest version (1.1.0-1).
nasm is already the newest version (2.14.02-1).
The following packages were automatically installed and are no longer required:
  atop bmon ccze jp2a libconfuse-common libconfuse2 libio-pty-perl libipc-run-perl
  libtime-duration-perl linux-headers-5.3.0-26 linux-headers-5.3.0-26-generic
  linux-image-5.3.0-26-generic linux-modules-5.3.0-26-generic linux-modules-extra-5.3.0-26-generic
  moreutils python3-newt run-one
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Still the same error.

Still the same error.

Which error?

In file included from ../../gcc-4.8.2/gcc/cp/except.c:1005:
cfns.gperf:101:1: error: ‘const char* libc_name_p(const char*, unsigned int)’ redeclared inline with ‘gnu_inline’ attribute
cfns.gperf:26:14: note: ‘const char* libc_name_p(const char*, unsigned int)’ previously declared here
cfns.gperf:26:14: warning: inline function ‘const char* libc_name_p(const char*, unsigned int)’ used but never defined
make[1]: *** [Makefile:1058: cp/except.o] Error 1
make[1]: Leaving directory '/home/scott/src/build-gcc/gcc'
make: *** [Makefile:3904: all-gcc] Error 2

I have updated the versions of the compiler, not the dependencies that you need.

It worked! But I get an error while compiling thor os
hello@kali:~/thor-os$ make qemu true cd bootloader; make stage1.bin make[1]: Entering directory '/home/hello/thor-os/bootloader' make[1]: 'stage1.bin' is up to date. make[1]: Leaving directory '/home/hello/thor-os/bootloader' cd bootloader; make stage2.bin make[1]: Entering directory '/home/hello/thor-os/bootloader' make[1]: 'stage2.bin' is up to date. make[1]: Leaving directory '/home/hello/thor-os/bootloader' cd init; make make[1]: Entering directory '/home/hello/thor-os/init' make[1]: Nothing to be done for 'default'. make[1]: Leaving directory '/home/hello/thor-os/init' cd kernel; make make[1]: Entering directory '/home/hello/thor-os/kernel' make[1]: Nothing to be done for 'default'. make[1]: Leaving directory '/home/hello/thor-os/kernel' cd tlib; make make[1]: Entering directory '/home/hello/thor-os/tlib' -e \x1b[31;01m[debug]\x1b[0m Compile (tlib) \x1b[35;01msrc/system.cpp\x1b[0m src/system.cpp: In function 'std::expected<long unsigned int> tlib::exec_and_wait(const char*, const std::vector<std::basic_string<char> >&)': src/system.cpp:99:21: warning: moving a local object in a return statement prevents copy elision [-Wpessimizing-move] 99 | return std::move(result); | ~~~~~~~~~^~~~~~~~ src/system.cpp:99:21: note: remove 'std::move' call src/system.cpp: At global scope: src/system.cpp:102:30: error: 'void tlib::reboot(int)' should have been declared inside 'tlib' 102 | void tlib::reboot(int delay=0) { | ^ src/system.cpp:114:32: error: 'void tlib::shutdown(int)' should have been declared inside 'tlib' 114 | void tlib::shutdown(int delay=0){ | ^ make[1]: *** [Makefile:7: debug/src/system.cpp.o] Error 1 make[1]: Leaving directory '/home/hello/thor-os/tlib' make: *** [Makefile:12: tlib/debug/libtlib.a] Error 2

So, what I should do?

@felixthian This should be fixed by the last commit. Try to update the repo, make clean and try again.

Now that I am compiling GCC 9.2.0, I get a new semi-error:

make[3]: Entering directory '/home/scott/src/build-gcc/x86_64-pc-linux-gnu/32/libgcc'
make[3]: *** No rule to make target 'all'.  Stop.
make[3]: Leaving directory '/home/scott/src/build-gcc/x86_64-pc-linux-gnu/32/libgcc'
mv -f sse_resms64.visT sse_resms64.vis
make[2]: *** [Makefile:1210: multi-do] Error 1
make[2]: Leaving directory '/home/scott/src/build-gcc/x86_64-pc-linux-gnu/libgcc'
make[1]: *** [Makefile:127: all-multi] Error 2
make[1]: *** Waiting for unfinished jobs....
mv -f sse_resms64x.visT sse_resms64x.vis
mv -f sse_savms64f.visT sse_savms64f.vis
mv -f sse_resms64f.visT sse_resms64f.vis
make[1]: Leaving directory '/home/scott/src/build-gcc/x86_64-pc-linux-gnu/libgcc'
make: *** [Makefile:18726: all-target-libgcc] Error 2

make -j9 all-target-libgcc CFLAGS_FOR_TARGET="-mcmodel=large"

I think this has something to do with GMP MPC and MPFR not being found, but libgmp-dev, libmpfr-dev and libmpc-dev are installed.

Given the error, it looks like it may be missing some files in libgcc.

You may want to try with -j1 but I do not think this will fix it. I do not have any better idea.

I am currently trying the LFS instructions for GCC, since the LFS version is 9.2.0. I’ll see if the result if different. I think that the instruction in the wiki don’t tell make to build gmp etc.

The problem was, I think, my local toolchain. I upgraded to 9.3.0, and it worked.

Good to hear that it works now :)