-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Support Android NDK #3331
Support Android NDK #3331
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1653,15 +1653,25 @@ static void construct_linker_job_elf(LinkJob *lj) { | |
soname = buf_sprintf("lib%s.so.%" ZIG_PRI_usize, buf_ptr(g->root_out_name), g->version_major); | ||
} | ||
|
||
if (target_requires_pie(g->zig_target) && !is_dyn_lib && g->libc != nullptr) { | ||
lj->args.append("-pie"); | ||
} | ||
|
||
lj->args.append("-o"); | ||
lj->args.append(buf_ptr(&g->output_file_path)); | ||
|
||
if (lj->link_in_crt) { | ||
const char *crt1o; | ||
if (g->zig_target->os == OsNetBSD) { | ||
crt1o = "crt0.o"; | ||
} else if (target_is_android(g->zig_target)) { | ||
crt1o = "crtbegin_dynamic.o"; | ||
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. Instead of the logic below, shouldn't it be here? if (g->have_dynamic_link) {
crt1o = "crtbegin_dynamic.o";
} else {
crt1o = "crtbegin_static.o";
} Then the other logic remains unchanged: } else if (!g->have_dynamic_link) {
crt1o = "crt1.o";
} |
||
} else if (!g->have_dynamic_link) { | ||
crt1o = "crt1.o"; | ||
if (target_is_android(g->zig_target)) { | ||
crt1o = "crtbegin.o"; | ||
} else { | ||
crt1o = "crt1.o"; | ||
} | ||
} else { | ||
crt1o = "Scrt1.o"; | ||
} | ||
|
@@ -1767,22 +1777,28 @@ static void construct_linker_job_elf(LinkJob *lj) { | |
if (g->libc != nullptr) { | ||
if (!g->have_dynamic_link) { | ||
lj->args.append("--start-group"); | ||
lj->args.append("-lgcc"); | ||
lj->args.append("-lgcc_eh"); | ||
if (!target_is_android(g->zig_target)) { | ||
lj->args.append("-lgcc"); | ||
lj->args.append("-lgcc_eh"); | ||
} | ||
lj->args.append("-lc"); | ||
lj->args.append("-lm"); | ||
lj->args.append("--end-group"); | ||
} else { | ||
lj->args.append("-lgcc"); | ||
lj->args.append("--as-needed"); | ||
lj->args.append("-lgcc_s"); | ||
lj->args.append("--no-as-needed"); | ||
if (!target_is_android(g->zig_target)) { | ||
lj->args.append("-lgcc"); | ||
lj->args.append("--as-needed"); | ||
lj->args.append("-lgcc_s"); | ||
lj->args.append("--no-as-needed"); | ||
} | ||
lj->args.append("-lc"); | ||
lj->args.append("-lm"); | ||
lj->args.append("-lgcc"); | ||
lj->args.append("--as-needed"); | ||
lj->args.append("-lgcc_s"); | ||
lj->args.append("--no-as-needed"); | ||
if (!target_is_android(g->zig_target)) { | ||
lj->args.append("-lgcc"); | ||
lj->args.append("--as-needed"); | ||
lj->args.append("-lgcc_s"); | ||
lj->args.append("--no-as-needed"); | ||
} | ||
} | ||
|
||
if (g->zig_target->os == OsFreeBSD) { | ||
|
@@ -1805,7 +1821,9 @@ static void construct_linker_job_elf(LinkJob *lj) { | |
} | ||
|
||
// crt end | ||
if (lj->link_in_crt && target_libc_needs_crti_crtn(g->zig_target)) { | ||
if (target_is_android(g->zig_target) && g->libc != nullptr) { | ||
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. What's the reasoning for I think you want |
||
lj->args.append(get_libc_crt_file(g, "crtend_android.o")); | ||
} else if (lj->link_in_crt && target_libc_needs_crti_crtn(g->zig_target)) { | ||
lj->args.append(get_libc_crt_file(g, "crtn.o")); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.