forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 150
Win64 LLP64 ABI support with cross-compiler tooling #630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
xdqi
wants to merge
7
commits into
lkl:master
Choose a base branch
from
xdqi:lkl-win64
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
86ce55a
lkl: add cross-compiler wrapper, custom linker, and jmp_buf
xdqi baaf3c6
lkl: add --image-base=0x10000 for Win64 PE builds
xdqi b202b7b
lkl: fix LLP64 ABI with __lkl_long_t typedef for Win64
xdqi b951be6
lkl: add SPDX tag to gcc wrapper and fix coding style
xdqi af3b0e9
lkl: rename __lkl_long_t/__lkl_ulong_t to lkl_long_t/lkl_ulong_t
xdqi 2a90ef7
lkl: include lkl_long.h in lkl.h for lkl_long_t definition
xdqi fec8f7a
lkl: update i686-w64-mingw32 binutils for mingw32 PE support
xdqi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | ||
| #ifndef _ASM_UAPI_LKL_LONG_H | ||
| #define _ASM_UAPI_LKL_LONG_H | ||
|
|
||
| /* | ||
| * __lkl_long_t / __lkl_ulong_t: pointer-width integer types for the | ||
| * LKL cross-world interface (host_ops, syscall dispatch, UAPI structs). | ||
| * | ||
| * These must be the same size on both sides of the kernel<->host boundary: | ||
| * - Kernel side (LP64 native GCC with -mabi=ms): long = 8 bytes | ||
| * - Host side (LLP64 MinGW-w64): long = 4 bytes, need long long | ||
| * - Host side (LP64 Linux/Cygwin/macOS): long = 8 bytes | ||
| * | ||
| * The headers_install.py script replaces all 'long' in generated user | ||
| * headers with these types to ensure ABI compatibility across data models. | ||
| */ | ||
| #if defined(_WIN64) && !defined(__LP64__) | ||
| /* LLP64: MinGW-w64 x64 user-space */ | ||
| typedef long long __lkl_long_t; | ||
| typedef unsigned long long __lkl_ulong_t; | ||
| #else | ||
| /* LP64: kernel side, Linux, Cygwin, macOS, or any ILP32 system */ | ||
| typedef long __lkl_long_t; | ||
| typedef unsigned long __lkl_ulong_t; | ||
| #endif | ||
|
|
||
| #endif /* _ASM_UAPI_LKL_LONG_H */ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,10 +106,12 @@ endef | |
|
|
||
| define nt_host | ||
| $(call set_autoconf_var,NT,y) | ||
| $(call set_kernel_config,INIT_STACK_ALL_ZERO,n) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this needed?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's used to make my old Cygwin GCC 11 happy. We can remove it if we maintain our own newer Cygwin cross compiler. |
||
| KOPT = "KALLSYMS_EXTRA_PASS=1" | ||
| KOPT += "HOSTCFLAGS=-Wno-char-subscripts" | ||
| KOPT += "HOSTLDFLAGS=-s" | ||
| LDLIBS += -lws2_32 | ||
| LDFLAGS += -Wl,--image-base,0x10000 | ||
| EXESUF := .exe | ||
| SOSUF := .dll | ||
| CFLAGS += -Iinclude/mingw32 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| x86_64-w64-mingw32-gcc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #!/bin/bash | ||
| # Shim: routes kernel code to cygwin cross-gcc, user-space to mingw-gcc. | ||
| # Cygwin-gcc: LP64 (long=64-bit), direct PE/COFF output, no Wine needed. | ||
| # Mingw-gcc: LLP64 (long=32-bit), standard Win64 libraries. | ||
| # The LKL API header uses __lkl_long_t (always 64-bit) to bridge the difference. | ||
| REAL_MINGW_GCC="/usr/bin/x86_64-w64-mingw32-gcc" | ||
| CYGWIN_GCC="/usr/bin/x86_64-pc-cygwin-gcc" | ||
| LKL_BIN_DIR="$(cd "$(dirname "$0")" && pwd)" | ||
|
|
||
| # Kernel code → cygwin-gcc (LP64) | ||
| for arg in "$@"; do | ||
| if [[ "$arg" == "-D__KERNEL__" ]]; then | ||
| exec "$CYGWIN_GCC" "$@" | ||
| fi | ||
| done | ||
|
|
||
| # User-space: use mingw-gcc with patched ld via specs | ||
| SPECS="$LKL_BIN_DIR/.lkl-linker.specs" | ||
| if [[ ! -f "$SPECS" ]]; then | ||
| printf '*linker:\n%s/x86_64-w64-mingw32-ld\n' "$LKL_BIN_DIR" > "$SPECS" | ||
| fi | ||
| exec "$REAL_MINGW_GCC" -specs="$SPECS" "$@" |
|
xdqi marked this conversation as resolved.
|
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.