fix: cross-compilation for android on linux

add `-nodefaultlibs` when cross-linking for android to prevent clang from linking with libgcc

check build mode first before calling `init_android_values` to prevent printing a message
that tells the user to set `-android-keystore` if its not set and build mode is exe
This commit is contained in:
IllusionMan1212
2025-04-05 02:18:06 +02:00
parent 19e056a806
commit 44950d5f37
2 changed files with 26 additions and 25 deletions

View File

@@ -143,7 +143,7 @@ gb_internal i32 linker_stage(LinkerData *gen) {
LIT(target_arch_names[build_context.metrics.arch])
);
#endif
} else if (build_context.cross_compiling && build_context.different_os) {
} else if (build_context.cross_compiling) {
switch (selected_subtarget) {
case Subtarget_Android:
is_cross_linking = true;
@@ -840,6 +840,7 @@ try_cross_linking:;
if (is_android) {
link_command_line = gb_string_append_fmt(link_command_line, " --target=aarch64-linux-android%d ", ODIN_ANDROID_API_LEVEL);
link_command_line = gb_string_appendc(link_command_line, " -nodefaultlibs");
}
link_command_line = gb_string_appendc(link_command_line, " -Wno-unused-command-line-argument ");
link_command_line = gb_string_appendc(link_command_line, object_files);