lkl / linux

Linux kernel source tree
https://lkl.github.io/
Other
814 stars 138 forks source link

Win64 target #25

Open staalmannen opened 8 years ago

staalmannen commented 8 years ago

I played around a bit with cross-compiling to Win64 with mingw-w64 by adding the needed "pe-x86-64" in tools/lkl/Makefile and arch/lkl/Makefile.

"interestingly" it fails in two different ways if I add or don't add select 64BIT if OUTPUT_FORMAT = "pe-x86-64" in arch/lkl/Kbuild

Without it, it fails on the compilation check

define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))

in include/linux/bug.h

With it, it fails on include/linux/tty.h Width of "unused" is longer than its type unused:BITS_PER_LONG - 2

I have tried setting BITS_PER_LONG=32 manually as a KBUILD_CFLAG (which it should be on Win64)

I am guessing that both of these issues is due to Win64 being LLP64 which means that assumptions in compilation checks etc are not always correct. The question is just - what would be the advisable approach - go for 64bit and try to solve the incompatibilities or rather go for 32bit and try to solve incompatibilities?

If someone smarter than me is already working on this I will just drop it :)

tavip commented 8 years ago

The question is just - what would be the advisable approach - go for 64bit and try to solve the incompatibilities or rather go for 32bit and try to solve incompatibilities?

I don't know :) But I think it will require significant changes to support 32bit longs. And we need to do that without too much intrusion in the kernel.

If someone smarter than me is already working on this I will just drop it :)

I don't plan to look into this in the next couple of months.

spoiledsport commented 7 years ago

I am trying to open this one again. I have been able to compile 64bit version in windows using MSYS2. I made very few directed changes in two makefiles and one KConfig file to address missing pe-x86-64. The compilation proceed normally. It generate the vmlinux file.

using the objdump command objdump -f vmlinux

I get vmlinux: file format pe-x86-64 architecture: i386:x86-64, flags 0x00000039: HAS_RELOC, HAS_DEBUG, HAS_SYMS, HAS_LOCALS start address 0x0000000000000000

Looks good. The problem is that linking the dll is failing. I already rollback to binutils 2.6. I am getting the following errors

$ make -C tools/lkl V=1 make: Entering directory '/e/Dev/GitHub/lkl/linux/tools/lkl' make -f /e/Dev/GitHub/lkl/linux/tools/build/Makefile.build dir=lib obj=lkl gcc -shared -o /e/Dev/GitHub/lkl/linux/tools/lkl/liblkl.dll /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o -lws2_32 /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_mkdir': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:464: undefined reference tolkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:464:(.text+0x103): relocation truncated to fit: R_X86_64_PC32 against undefined symbol lkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In functionlkl_sys_mount': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:539: undefined reference to lkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:539:(.text+0x166): relocation truncated to fit: R_X86_64_PC32 against undefined symbollkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_rmdir': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:467: undefined reference tolkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:467:(.text+0x199): relocation truncated to fit: R_X86_64_PC32 against undefined symbol lkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In functionlkl_sys_umount': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:533: undefined reference to lkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:533:(.text+0x214): relocation truncated to fit: R_X86_64_PC32 against undefined symbollkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_nanosleep': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:254: undefined reference tolkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:254:(.text+0x25a): relocation truncated to fit: R_X86_64_PC32 against undefined symbol lkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o:/e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:356: more undefined references tolkl_syscall' follow /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_open': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:356:(.text+0x2d7): relocation truncated to fit: R_X86_64_PC32 against undefined symbollkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_lseek': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:371:(.text+0x39a): relocation truncated to fit: R_X86_64_PC32 against undefined symbollkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_close': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:365:(.text+0x3ea): relocation truncated to fit: R_X86_64_PC32 against undefined symbollkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_getdents64': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:506:(.text+0x47e): relocation truncated to fit: R_X86_64_PC32 against undefined symbollkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_open': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:356:(.text+0x6b9): relocation truncated to fit: R_X86_64_PC32 against undefined symbollkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_read': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:374:(.text+0x6fe): additional relocation overflows omitted from the output /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In functionvirtio_dev_setup': /e/Dev/GitHub/lkl/linux/tools/lkl/lib/virtio.c:529: undefined reference to lkl_get_free_irq' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/virtio.c:550: undefined reference tolkl_is_running' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_virtio_mmio_device_add': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:2: undefined reference tolkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function virtio_dev_setup': /e/Dev/GitHub/lkl/linux/tools/lkl/lib/virtio.c:555: undefined reference tolkl_put_irq' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function virtio_dev_cleanup': /e/Dev/GitHub/lkl/linux/tools/lkl/lib/virtio.c:582: undefined reference tolkl_is_running' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_open': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:356: undefined reference tolkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_write': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:377: undefined reference tolkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_close': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:365: undefined reference tolkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function virtio_dev_cleanup': /e/Dev/GitHub/lkl/linux/tools/lkl/lib/virtio.c:618: undefined reference tolkl_put_irq' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_umount': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:533: undefined reference tolkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function virtio_deliver_irq': /e/Dev/GitHub/lkl/linux/tools/lkl/lib/virtio.c:84: undefined reference tolkl_trigger_irq' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_open': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:356: undefined reference tolkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_read': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:374: undefined reference tolkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_close': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:365: undefined reference tolkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_open': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:356: undefined reference tolkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o: In function lkl_sys_write': /e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:377: undefined reference tolkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o:/e/Dev/GitHub/lkl/linux/tools/lkl/include/lkl/asm/syscall_defs.h:365: more undefined references to `lkl_syscall' follow collect2: error: ld returned 1 exit status make: *** [Makefile:148: /e/Dev/GitHub/lkl/linux/tools/lkl/liblkl.dll] Error 1 make: Leaving directory '/e/Dev/GitHub/lkl/linux/tools/lkl'

Any ideas?

Rondom commented 7 years ago

MSYS2/Cygwin are LP64, so there is no problem there. This issue is about "native" MinGW 64-bit, which is LLP64.

Therefore I think what you are describing is some other issue.

spoiledsport commented 7 years ago

Rondom

MinGW has nothing to do with this. This is MSYS2. The problem is not related to LP64/LLP64. This is related to problems with GCC. I see that this is a common problem with large codebases. I actually changed the build configuration to LD in the Makefile as suggested in many different newsgroups., but that came up with different issues.

I added the link options -mcmodel=large -shared, now I am getting a different set of errors

ld -r -o /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o /e/Dev/GitHub/lkl/linux/tools/lkl/lib/fs.o /e/Dev/GiHub/lkl/linux/tools/lkl/lib/iomem.o /e/Dev/GitHub/lkl/linux/tools/lkl/lib/net.o /e/Dev/GitHub/lkl/linux/tools/lk/lib/jmp_buf.o /e/Dev/GitHub/lkl/linux/tools/lkl/lib/nt-host.o /e/Dev/GitHub/lkl/linux/tools/lkl/lib/utils.o /e/ev/GitHub/lkl/linux/tools/lkl/lib/virtio_blk.o /e/Dev/GitHub/lkl/linux/tools/lkl/lib/virtio.o /e/Dev/GitHub/lkl/inux/tools/lkl/lib/dbg.o /e/Dev/GitHub/lkl/linux/tools/lkl/lib/dbg_handler.o ar -rc /e/Dev/GitHub/lkl/linux/tools/lkl/liblkl.a /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o /e/Dev/GitHub/ll/linux/tools/lkl/lib/lkl.o gcc -shared -o /e/Dev/GitHub/lkl/linux/tools/lkl/liblkl.dll /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o /e/De/GitHub/lkl/linux/tools/lkl/lib/lkl.o -lws2_32 /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o:fs.c:(.rdata$.refptr.lkl_syscall[.refptr.lkl_syscall]+0x0): undefned reference to lkl_syscall' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o:fs.c:(.rdata$.refptr.lkl_put_irq[.refptr.lkl_put_irq]+0x0): undefned reference tolkl_put_irq' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o:fs.c:(.rdata$.refptr.lkl_is_running[.refptr.lkl_is_running]+0x0):undefined reference to lkl_is_running' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o:fs.c:(.rdata$.refptr.lkl_get_free_irq[.refptr.lkl_get_free_irq]+00): undefined reference tolkl_get_free_irq' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl-in.o:fs.c:(.rdata$.refptr.lkl_trigger_irq[.refptr.lkl_trigger_irq]+0x0: undefined reference to lkl_trigger_irq' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o:main.c:(.pdata+0xb478): relocation truncated to fit: rva32 againstexit.text' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o:main.c:(.pdata+0xb47c): relocation truncated to fit: rva32 against exit.text' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o:main.c:(.pdata+0xd8f0): relocation truncated to fit: rva32 againstexit.text' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o:main.c:(.pdata+0xd8f4): relocation truncated to fit: rva32 against exit.text' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o:main.c:(.pdata+0xec4c): relocation truncated to fit: rva32 againstexit.text' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o:main.c:(.pdata+0xec50): relocation truncated to fit: rva32 against exit.text' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o:main.c:(.pdata+0xec58): relocation truncated to fit: rva32 againstexit.text' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o:main.c:(.pdata+0xec5c): relocation truncated to fit: rva32 against exit.text' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o:main.c:(.pdata+0xf1bc): relocation truncated to fit: rva32 againstexit.text' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o:main.c:(.pdata+0xf1c0): relocation truncated to fit: rva32 against `exit.text' /e/Dev/GitHub/lkl/linux/tools/lkl/lib/lkl.o:main.c:(.pdata+0xf1c8): additional relocation overflows omitted fromthe output collect2: error: ld returned 1 exit status make: *** [Makefile:148: /e/Dev/GitHub/lkl/linux/tools/lkl/liblkl.dll] Error 1 make: Leaving directory '/e/Dev/GitHub/lkl/linux/tools/lkl'

spoiledsport commented 7 years ago

I will open a new issue with more clean understanding and explanation

spoiledsport commented 7 years ago

306

Rondom commented 7 years ago

I think there was a misunderstanding. What I meant to say was that your MSYS2-linker-issue is unrelated to this one and is thus better dealt with in a separate issue.