chillancezen / ZeldaOS

32bit OS/kernel built from scratch with POSIX.1 compliance
BSD 3-Clause "New" or "Revised" License
28 stars 2 forks source link

Errors while compiling (Manjaro, arch-based) #2

Open lunaneff opened 4 years ago

lunaneff commented 4 years ago

I'm getting these errors while compiling on Manjaro, which is arch-based. What could be the issue?

$ LC_ALL=C ZELDA=/WIN_D/Laurin/Dev/C/ZeldaOS make app_install
[ACTION] start to install application packages.
make[1]: Entering directory '/WIN_D/Laurin/Dev/C/ZeldaOS/application/cat'
[CC] cat:main.c
[LD] cat:cat
ld: /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/libc/libc.a(lib_a-signal.o): in function `signal':
signal.c:(.text+0x271): multiple definition of `signal'; /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/syscall_inventory0.o:/WIN_D/Laurin/Dev/C/ZeldaOS/runtime/syscall_inventory0.c:25: first defined here
ld: /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/libc/libc.a(lib_a-stack_protector.o): in function `__stack_chk_fail':
stack_protector.c:(.text+0xbd): undefined reference to `_exit'
make[1]: *** [/WIN_D/Laurin/Dev/C/ZeldaOS/mk/Makefile.application:26: cat] Error 1
make[1]: Leaving directory '/WIN_D/Laurin/Dev/C/ZeldaOS/application/cat'
make[1]: Entering directory '/WIN_D/Laurin/Dev/C/ZeldaOS/application/dummy'
[CC] dummy:main.c
[LD] dummy:dummy
ld: /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/libc/libc.a(lib_a-signal.o): in function `signal':
signal.c:(.text+0x271): multiple definition of `signal'; /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/syscall_inventory0.o:/WIN_D/Laurin/Dev/C/ZeldaOS/runtime/syscall_inventory0.c:25: first defined here
ld: /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/libc/libc.a(lib_a-stack_protector.o): in function `__stack_chk_fail':
stack_protector.c:(.text+0xbd): undefined reference to `_exit'
make[1]: *** [/WIN_D/Laurin/Dev/C/ZeldaOS/mk/Makefile.application:26: dummy] Error 1
make[1]: Leaving directory '/WIN_D/Laurin/Dev/C/ZeldaOS/application/dummy'
make[1]: Entering directory '/WIN_D/Laurin/Dev/C/ZeldaOS/application/kill'
[CC] kill:main.c
[LD] kill:kill
ld: /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/libc/libc.a(lib_a-signal.o): in function `signal':
signal.c:(.text+0x271): multiple definition of `signal'; /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/syscall_inventory0.o:/WIN_D/Laurin/Dev/C/ZeldaOS/runtime/syscall_inventory0.c:25: first defined here
ld: /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/libc/libc.a(lib_a-stack_protector.o): in function `__stack_chk_fail':
stack_protector.c:(.text+0xbd): undefined reference to `_exit'
make[1]: *** [/WIN_D/Laurin/Dev/C/ZeldaOS/mk/Makefile.application:26: kill] Error 1
make[1]: Leaving directory '/WIN_D/Laurin/Dev/C/ZeldaOS/application/kill'
make[1]: Entering directory '/WIN_D/Laurin/Dev/C/ZeldaOS/application/ls'
[CC] ls:main.c
[LD] ls:ls
ld: /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/libc/libc.a(lib_a-signal.o): in function `signal':
signal.c:(.text+0x271): multiple definition of `signal'; /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/syscall_inventory0.o:/WIN_D/Laurin/Dev/C/ZeldaOS/runtime/syscall_inventory0.c:25: first defined here
ld: /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/libc/libc.a(lib_a-stack_protector.o): in function `__stack_chk_fail':
stack_protector.c:(.text+0xbd): undefined reference to `_exit'
make[1]: *** [/WIN_D/Laurin/Dev/C/ZeldaOS/mk/Makefile.application:26: ls] Error 1
make[1]: Leaving directory '/WIN_D/Laurin/Dev/C/ZeldaOS/application/ls'
make[1]: Entering directory '/WIN_D/Laurin/Dev/C/ZeldaOS/application/ps'
[CC] ps:main.c
[LD] ps:ps
ld: /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/libc/libc.a(lib_a-signal.o): in function `signal':
signal.c:(.text+0x271): multiple definition of `signal'; /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/syscall_inventory0.o:/WIN_D/Laurin/Dev/C/ZeldaOS/runtime/syscall_inventory0.c:25: first defined here
ld: /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/libc/libc.a(lib_a-stack_protector.o): in function `__stack_chk_fail':
stack_protector.c:(.text+0xbd): undefined reference to `_exit'
make[1]: *** [/WIN_D/Laurin/Dev/C/ZeldaOS/mk/Makefile.application:26: ps] Error 1
make[1]: Leaving directory '/WIN_D/Laurin/Dev/C/ZeldaOS/application/ps'
make[1]: Entering directory '/WIN_D/Laurin/Dev/C/ZeldaOS/application/shell'
[CC] shelld:hyrule_castle.c
[LD] shelld:shelld
ld: /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/libc/libc.a(lib_a-signal.o): in function `signal':
signal.c:(.text+0x271): multiple definition of `signal'; /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/syscall_inventory0.o:/WIN_D/Laurin/Dev/C/ZeldaOS/runtime/syscall_inventory0.c:25: first defined here
ld: /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/libc/libc.a(lib_a-stack_protector.o): in function `__stack_chk_fail':
stack_protector.c:(.text+0xbd): undefined reference to `_exit'
make[1]: *** [/WIN_D/Laurin/Dev/C/ZeldaOS/mk/Makefile.application:26: shelld] Error 1
make[1]: Leaving directory '/WIN_D/Laurin/Dev/C/ZeldaOS/application/shell'
make[1]: Entering directory '/WIN_D/Laurin/Dev/C/ZeldaOS/application/tinyvm'
[CC] tinyvm:tvm_program.c
[CC] tinyvm:tvm_lexer.c
[CC] tinyvm:tvm.c
[CC] tinyvm:tvm_htab.c
[CC] tinyvm:tvm_memory.c
[CC] tinyvm:tvm_preprocessor.c
[CC] tinyvm:tvm_parser.c
[CC] tinyvm:tvm_file.c
[CC] tinyvm:tvmi.c
[LD] tinyvm:tinyvm
ld: /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/libc/libc.a(lib_a-signal.o): in function `signal':
signal.c:(.text+0x271): multiple definition of `signal'; /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/syscall_inventory0.o:/WIN_D/Laurin/Dev/C/ZeldaOS/runtime/syscall_inventory0.c:25: first defined here
ld: /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/libc/libc.a(lib_a-stack_protector.o): in function `__stack_chk_fail':
stack_protector.c:(.text+0xbd): undefined reference to `_exit'
make[1]: *** [/WIN_D/Laurin/Dev/C/ZeldaOS/mk/Makefile.application:26: tinyvm] Error 1
make[1]: Leaving directory '/WIN_D/Laurin/Dev/C/ZeldaOS/application/tinyvm'
make[1]: Entering directory '/WIN_D/Laurin/Dev/C/ZeldaOS/application/uname'
[CC] uname:main.c
[LD] uname:uname
ld: /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/libc/libc.a(lib_a-signal.o): in function `signal':
signal.c:(.text+0x271): multiple definition of `signal'; /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/syscall_inventory0.o:/WIN_D/Laurin/Dev/C/ZeldaOS/runtime/syscall_inventory0.c:25: first defined here
ld: /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/libc/libc.a(lib_a-stack_protector.o): in function `__stack_chk_fail':
stack_protector.c:(.text+0xbd): undefined reference to `_exit'
make[1]: *** [/WIN_D/Laurin/Dev/C/ZeldaOS/mk/Makefile.application:26: uname] Error 1
make[1]: Leaving directory '/WIN_D/Laurin/Dev/C/ZeldaOS/application/uname'
make[1]: Entering directory '/WIN_D/Laurin/Dev/C/ZeldaOS/application/userland_init'
[CC] userland_init:userland_init.c
[LD] userland_init:userland_init
ld: /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/libc/libc.a(lib_a-signal.o): in function `signal':
signal.c:(.text+0x271): multiple definition of `signal'; /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/syscall_inventory0.o:/WIN_D/Laurin/Dev/C/ZeldaOS/runtime/syscall_inventory0.c:25: first defined here
ld: /WIN_D/Laurin/Dev/C/ZeldaOS/runtime/libc/libc.a(lib_a-stack_protector.o): in function `__stack_chk_fail':
stack_protector.c:(.text+0xbd): undefined reference to `_exit'
make[1]: *** [/WIN_D/Laurin/Dev/C/ZeldaOS/mk/Makefile.application:26: userland_init] Error 1
make[1]: Leaving directory '/WIN_D/Laurin/Dev/C/ZeldaOS/application/userland_init'
make: *** [Makefile:13: app_install] Error 2
$ LC_ALL=C ZELDA=/WIN_D/Laurin/Dev/C/ZeldaOS make
[CC] x86/pit.c
[CC] x86/interrupt.c
In file included from ./x86/include/interrupt.h:6,
                 from x86/interrupt.c:5:
x86/interrupt.c: In function 'compound_interrupt_handler':
x86/interrupt.c:87:47: error: converting a packed 'struct list_elem' pointer (alignment 1) to a 'struct linked_handler' pointer (alignment 4) may result in an unaligned pointer value [-Werror=address-of-packed-member]
   87 |         lhandler = CONTAINER_OF(_list, struct linked_handler, list);
      |                                               ^~~~~~~~~~~~~~
./lib/include/types.h:41:52: note: in definition of macro 'OFFSET_OF'
   41 | #define OFFSET_OF(structure, field) ((int32_t)(&(((structure *)0)->field)))
      |                                                    ^~~~~~~~~
x86/interrupt.c:87:20: note: in expansion of macro 'CONTAINER_OF'
   87 |         lhandler = CONTAINER_OF(_list, struct linked_handler, list);
      |                    ^~~~~~~~~~~~
In file included from ./x86/include/interrupt.h:7,
                 from x86/interrupt.c:5:
./lib/include/list.h:11:8: note: defined here
   11 | struct list_elem {
      |        ^~~~~~~~~
In file included from x86/interrupt.c:5:
./x86/include/interrupt.h:92:8: note: defined here
   92 | struct linked_handler {
      |        ^~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [mk/Makefile.kernel:30: x86/interrupt.o] Error 1
chillancezen commented 4 years ago

1.did you follow the order to build all the objects?

#ZELDA=/path/to/ZeldaOS/ make runtime_install
#ZELDA=/path/to/ZeldaOS/ make app_install
#ZELDA=/path/to/ZeldaOS/ make drive
#ZELDA=/path/to/ZeldaOS/ make 

the oder to build the project matters a lot.]

  1. issue of this kind is not expected, I did never see them before, what's the version of your gcc? my testbed has gcc 4.8.5

could you try a different host with Centos7 installed ?

thanks, Jie

chillancezen commented 4 years ago

by doing #ZELDA=/path/to/ZeldaOS/ make runtime_install. it generates system call wrappers in syscall_inventory0.c and c runtime entry crt0.c. there should be no symbol conflicts if we compile them with gcc flags -nostdlib -fno-builtin.

lunaneff commented 4 years ago

I followed the order and have GCC 9.2.0 on my machine. I'll try using a CentOS 7 VM

lunaneff commented 4 years ago

Compiling on the VM seemed to work, I'll write the ISO to a USB drive and try on real hardware

lunaneff commented 4 years ago

Trying on real hardware doesn't work, maybe because both devices I've tried on are 64 bit?

lunaneff commented 4 years ago

I was able to boot it with qemu

chillancezen commented 4 years ago

Trying on real hardware doesn't work, maybe because both devices I've tried on are 64 bit?

once I booted on real server, I am not sure the latest version could work for bare metal server. did you see the splash window? if so, the boot device works fine while the kernel does not.

if kernel doesn't work, we have to plug a serial port cable to observe what's happening. you can also increase the logging verbosity here: https://github.com/chillancezen/ZeldaOS/blob/master/zelda_config.h#L12

regards.

lunaneff commented 4 years ago

Both of my PCs didn't detect the USB as boot device, so I didn't even get into GRUB

On Tue, Nov 12, 2019, 02:23 Jie Zheng notifications@github.com wrote:

Trying on real hardware doesn't work, maybe because both devices I've tried on are 64 bit?

once I booted on real server, I am not sure the latest version could work for bare metal server. did you see the splash window? if so, the boot device works fine while the kernel does not.

if kernel doesn't work, we have to plug a serial port cable to observe what's happening. you can also increase the logging verbosity here: https://github.com/chillancezen/ZeldaOS/blob/master/zelda_config.h#L12

regards.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/chillancezen/ZeldaOS/issues/2?email_source=notifications&email_token=AHEZH54UPANUVTCY2UR5OJTQTIARBA5CNFSM4JLU7K2KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDYWJKI#issuecomment-552690857, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHEZH54KULXCTQ55JZA4MHLQTIARBANCNFSM4JLU7K2A .

chillancezen commented 4 years ago

Both of my PCs didn't detect the USB as boot device, so I didn't even get into GRUB On Tue, Nov 12, 2019, 02:23 Jie Zheng @.***> wrote: Trying on real hardware doesn't work, maybe because both devices I've tried on are 64 bit? once I booted on real server, I am not sure the latest version could work for bare metal server. did you see the splash window? if so, the boot device works fine while the kernel does not. if kernel doesn't work, we have to plug a serial port cable to observe what's happening. you can also increase the logging verbosity here: https://github.com/chillancezen/ZeldaOS/blob/master/zelda_config.h#L12 regards. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#2?email_source=notifications&email_token=AHEZH54UPANUVTCY2UR5OJTQTIARBA5CNFSM4JLU7K2KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDYWJKI#issuecomment-552690857>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHEZH54KULXCTQ55JZA4MHLQTIARBANCNFSM4JLU7K2A .

oh, I see, I think you need a legacy BIOS bootabe machine instead of newer UEFI only machine.
I once booted the image on my macbook pro, it failed due to no BIOS support.

lunaneff commented 4 years ago

Maybe I can enable legacy boot in my firmware, otherwise it may be possible to install UEFI GRUB