mirror of
https://github.com/odin-lang/Odin.git
synced 2026-10-09 22:32:13 -04:00
[windows-cross-compile] initial commit
This commit is contained in:
1 parent
395920130e
commit
8a62dfdf7f
11 files changed
+82
-44
No files matched your search
@@ -2,7 +2,7 @@
|
||||
#+private
|
||||
package runtime
|
||||
|
||||
foreign import bcrypt "system:Bcrypt.lib"
|
||||
foreign import bcrypt "system:bcrypt.lib"
|
||||
foreign import kernel32 "system:Kernel32.lib"
|
||||
|
||||
_HAS_RAND_BYTES :: true
|
||||
@@ -87,4 +87,4 @@ _rand_bytes :: proc "contextless" (dst: []byte) {
|
||||
|
||||
_exit :: proc "contextless" (code: int) -> ! {
|
||||
ExitProcess(u32(code))
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#+build windows
|
||||
package sys_windows
|
||||
|
||||
foreign import bcrypt "system:Bcrypt.lib"
|
||||
foreign import bcrypt "system:bcrypt.lib"
|
||||
|
||||
BCRYPT_USE_SYSTEM_PREFERRED_RNG: DWORD : 0x00000002
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#+build windows
|
||||
package sys_windows
|
||||
|
||||
foreign import gdi32 "system:Gdi32.lib"
|
||||
foreign import gdi32 "system:Gdi32.Lib"
|
||||
|
||||
@(default_calling_convention="system")
|
||||
foreign gdi32 {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#+build windows
|
||||
package sys_windows
|
||||
|
||||
foreign import shell32 "system:Shell32.lib"
|
||||
foreign import shell32 "system:shell32.lib"
|
||||
|
||||
@(default_calling_convention="system")
|
||||
foreign shell32 {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
package sys_windows
|
||||
|
||||
import "base:intrinsics"
|
||||
foreign import user32 "system:User32.lib"
|
||||
foreign import user32 "system:User32.Lib"
|
||||
|
||||
@(default_calling_convention="system")
|
||||
foreign user32 {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#+build windows
|
||||
package sys_windows
|
||||
|
||||
foreign import winmm "system:Winmm.lib"
|
||||
foreign import winmm "system:WinMM.Lib"
|
||||
|
||||
MMRESULT :: UINT
|
||||
|
||||
|
||||
+64
-26
@@ -131,13 +131,21 @@ gb_internal i32 linker_stage(LinkerData *gen) {
|
||||
return result;
|
||||
}
|
||||
|
||||
bool is_cross_linking = false;
|
||||
bool is_android = false;
|
||||
|
||||
if (build_context.cross_compiling && (build_context.different_os || selected_subtarget != Subtarget_Default)) {
|
||||
bool is_windows_cross = false;
|
||||
if (build_context.cross_compiling && build_context.different_os && build_context.metrics.os == TargetOs_windows) {
|
||||
if (build_context.linker_choice != Linker_lld) {
|
||||
gb_printf_err("Cannot link for Windows without LLD (%.*s %.*s)\n",
|
||||
LIT(target_os_names[build_context.metrics.os]),
|
||||
LIT(target_arch_names[build_context.metrics.arch])
|
||||
);
|
||||
build_context.keep_object_files = true;
|
||||
}
|
||||
is_windows_cross = true;
|
||||
goto try_cross_linking;
|
||||
} else if (build_context.cross_compiling && (build_context.different_os || selected_subtarget != Subtarget_Default)) {
|
||||
switch (selected_subtarget) {
|
||||
case Subtarget_Android:
|
||||
is_cross_linking = true;
|
||||
is_android = true;
|
||||
goto try_cross_linking;
|
||||
default:
|
||||
@@ -156,7 +164,7 @@ try_cross_linking:;
|
||||
bool is_windows = build_context.metrics.os == TargetOs_windows;
|
||||
#else
|
||||
String section_name = str_lit("ld-link");
|
||||
bool is_windows = false;
|
||||
bool is_windows = is_windows_cross;
|
||||
#endif
|
||||
|
||||
bool is_osx = build_context.metrics.os == TargetOs_darwin;
|
||||
@@ -250,13 +258,27 @@ try_cross_linking:;
|
||||
obj_format = str_lit("win32");
|
||||
#endif
|
||||
|
||||
#if defined(GB_SYSTEM_WINDOWS)
|
||||
char nasm_path[4096] = {0};
|
||||
gb_snprintf_va(
|
||||
nasm_path,
|
||||
gb_count_of(nasm_path) - 1,
|
||||
"%.*s\\bin\\nasm\\windows\\nasm.exe",
|
||||
LIT(build_context.ODIN_ROOT),
|
||||
);
|
||||
#else
|
||||
const char *nasm_path = gb_get_env("ODIN_NASM_PATH", permanent_allocator());
|
||||
if (nasm_path == nullptr) {
|
||||
nasm_path = "nasm";
|
||||
}
|
||||
#endif
|
||||
result = system_exec_command_line_app("nasm",
|
||||
"\"%.*s\\bin\\nasm\\windows\\nasm.exe\" \"%.*s\" "
|
||||
"\"%s\" \"%.*s\" "
|
||||
"-f \"%.*s\" "
|
||||
"-o \"%.*s\" "
|
||||
"%.*s "
|
||||
"",
|
||||
LIT(build_context.ODIN_ROOT), LIT(asm_file),
|
||||
nasm_path, LIT(asm_file),
|
||||
LIT(obj_format),
|
||||
LIT(obj_file),
|
||||
LIT(build_context.extra_assembler_flags)
|
||||
@@ -327,27 +349,43 @@ try_cross_linking:;
|
||||
|
||||
switch (build_context.linker_choice) {
|
||||
case Linker_lld:
|
||||
result = system_exec_command_line_app("msvc-lld-link",
|
||||
"\"%.*s\\bin\\lld-link\" %s -OUT:\"%.*s\" %s "
|
||||
"/nologo /incremental:no /opt:ref /subsystem:%.*s "
|
||||
"%.*s "
|
||||
"%.*s "
|
||||
"%s "
|
||||
"%s "
|
||||
"",
|
||||
LIT(build_context.ODIN_ROOT), object_files, LIT(output_filename),
|
||||
link_settings,
|
||||
LIT(windows_subsystem_names[build_context.ODIN_WINDOWS_SUBSYSTEM]),
|
||||
LIT(build_context.link_flags),
|
||||
LIT(build_context.extra_linker_flags),
|
||||
lib_str,
|
||||
lld_lto_flags
|
||||
);
|
||||
{
|
||||
#if defined(GB_SYSTEM_WINDOWS)
|
||||
char linker_path[4096] = {0};
|
||||
gb_snprintf(
|
||||
linker_path,
|
||||
gb_count_of(buf) - 1,
|
||||
"%.*s\\bin\\lld-link",
|
||||
LIT(build_context.ODIN_ROOT)
|
||||
);
|
||||
#else
|
||||
const char *linker_path = gb_get_env("ODIN_LLD_PATH", permanent_allocator());
|
||||
if (linker_path == nullptr) {
|
||||
linker_path = "lld-link";
|
||||
}
|
||||
#endif
|
||||
result = system_exec_command_line_app("lld-link",
|
||||
"\"%s\" %s -OUT:\"%.*s\" %s "
|
||||
"/nologo /incremental:no /opt:ref /subsystem:%.*s "
|
||||
"%.*s "
|
||||
"%.*s "
|
||||
"%s "
|
||||
"%s "
|
||||
"",
|
||||
linker_path, object_files, LIT(output_filename),
|
||||
link_settings,
|
||||
LIT(windows_subsystem_names[build_context.ODIN_WINDOWS_SUBSYSTEM]),
|
||||
LIT(build_context.link_flags),
|
||||
LIT(build_context.extra_linker_flags),
|
||||
lib_str,
|
||||
lld_lto_flags
|
||||
);
|
||||
|
||||
if (result) {
|
||||
return result;
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Linker_radlink:
|
||||
result = system_exec_command_line_app("msvc-rad-link",
|
||||
"\"%.*s\\bin\\radlink\" %s -OUT:\"%.*s\" %s "
|
||||
|
||||
Vendored
+2
-2
@@ -6,13 +6,13 @@ when ODIN_OS == .Windows {
|
||||
foreign import ENet {
|
||||
"lib/enet64.lib",
|
||||
"system:Ws2_32.lib",
|
||||
"system:Winmm.lib",
|
||||
"system:WinMM.Lib",
|
||||
}
|
||||
} else {
|
||||
foreign import ENet {
|
||||
"lib/enet.lib",
|
||||
"system:Ws2_32.lib",
|
||||
"system:Winmm.lib",
|
||||
"system:WinMM.Lib",
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Vendored
+1
-1
@@ -11,7 +11,7 @@ when ODIN_OS == .Windows {
|
||||
} else {
|
||||
foreign import lib {
|
||||
"portmidi_s.lib",
|
||||
"system:Winmm.lib",
|
||||
"system:WinMM.Lib",
|
||||
"system:Advapi32.lib",
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+4
-4
@@ -103,10 +103,10 @@ when ODIN_OS == .Windows {
|
||||
@(extra_linker_flags="/NODEFAULTLIB:" + ("msvcrt" when RAYLIB_SHARED else "libcmt"))
|
||||
foreign import lib {
|
||||
"windows/raylibdll.lib" when RAYLIB_SHARED else "windows/raylib.lib" ,
|
||||
"system:Winmm.lib",
|
||||
"system:Gdi32.lib",
|
||||
"system:User32.lib",
|
||||
"system:Shell32.lib",
|
||||
"system:WinMM.Lib",
|
||||
"system:Gdi32.Lib",
|
||||
"system:User32.Lib",
|
||||
"system:shell32.lib",
|
||||
}
|
||||
} else when ODIN_OS == .Linux {
|
||||
when ODIN_ARCH == .arm64 {
|
||||
|
||||
Vendored
+4
-4
@@ -123,10 +123,10 @@ when ODIN_OS == .Windows {
|
||||
@(extra_linker_flags="/NODEFAULTLIB:" + ("msvcrt" when RAYLIB_SHARED else "libcmt"))
|
||||
foreign import lib {
|
||||
"../windows/raylibdll.lib" when RAYLIB_SHARED else "../windows/raylib.lib" ,
|
||||
"system:Winmm.lib",
|
||||
"system:Gdi32.lib",
|
||||
"system:User32.lib",
|
||||
"system:Shell32.lib",
|
||||
"system:WinMM.Lib",
|
||||
"system:Gdi32.Lib",
|
||||
"system:User32.Lib",
|
||||
"system:shell32.lib",
|
||||
}
|
||||
} else when ODIN_OS == .Linux {
|
||||
when ODIN_ARCH == .arm64 {
|
||||
|
||||
Reference in new issue
Block a user