authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2019-06-01 16:59:12+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-04 12:45:02-04:00
log291aaee97773e2f9c40e061410db52ca00f4d651
treebc8490b5f1eff6c85c6b62a4686ef00b80f7fa0f
parentfd771ea9fb8926127b4ecb2793608b04a4430b2d

Stop the musl builder from skipping necessary files

The code assumed that the architecture-specific bits, found in the arch/ subfolder, were only overrides for the generic .c files. Changed the logic to always include the whole architecture-specific implementations and discard the generic ones, this way we won't exclude files with no .c counterpart.

1 files changed, 29 insertions(+), 26 deletions(-)

src/link.cpp+29-26
......@@ -528,9 +528,6 @@ static const char *build_musl(CodeGen *parent) {
528528 Buf noextbasename = BUF_INIT;
529529 Buf dirbasename = BUF_INIT;
530530 Buf before_arch_dir = BUF_INIT;
531 Buf override_c = BUF_INIT;
532 Buf override_s = BUF_INIT;
533 Buf override_S = BUF_INIT;
534531
535532 auto source_it = source_table.entry_iterator();
536533 for (;;) {
......@@ -543,31 +540,37 @@ static const char *build_musl(CodeGen *parent) {
543540 os_path_split(src_file, &dirname, &basename);
544541 os_path_extname(&basename, &noextbasename, nullptr);
545542 os_path_split(&dirname, &before_arch_dir, &dirbasename);
543
544 bool is_arch_specific = false;
545 // Architecture-specific implementations are under a <arch>/ folder.
546546 if (is_musl_arch_name(buf_ptr(&dirbasename))) {
547 // We find these by explicitly looking for overrides.
548 continue;
547 // Not the architecture we're compiling for.
548 if (strcmp(buf_ptr(&dirbasename), target_musl_arch_name) != 0)
549 continue;
550 is_arch_specific = true;
549551 }
550 // Look for an arch specific override.
551 buf_resize(&override_c, 0);
552 buf_resize(&override_s, 0);
553 buf_resize(&override_S, 0);
554
555 buf_appendf(&override_c, "%s" OS_SEP "%s" OS_SEP "%s.c",
556 buf_ptr(&dirname), target_musl_arch_name, buf_ptr(&noextbasename));
557 buf_appendf(&override_s, "%s" OS_SEP "%s" OS_SEP "%s.s",
558 buf_ptr(&dirname), target_musl_arch_name, buf_ptr(&noextbasename));
559 buf_appendf(&override_S, "%s" OS_SEP "%s" OS_SEP "%s.S",
560 buf_ptr(&dirname), target_musl_arch_name, buf_ptr(&noextbasename));
561
562 if (source_table.maybe_get(&override_c) != nullptr) {
563 src_file = &override_c;
564 src_kind = (src_kind == MuslSrcAsm) ? MuslSrcNormal : src_kind;
565 } else if (source_table.maybe_get(&override_s) != nullptr) {
566 src_file = &override_s;
567 src_kind = MuslSrcAsm;
568 } else if (source_table.maybe_get(&override_S) != nullptr) {
569 src_file = &override_S;
570 src_kind = MuslSrcAsm;
552
553 if (!is_arch_specific) {
554 Buf override_path = BUF_INIT;
555
556 // Look for an arch specific override.
557 buf_resize(&override_path, 0);
558 buf_appendf(&override_path, "%s" OS_SEP "%s" OS_SEP "%s.s",
559 buf_ptr(&dirname), target_musl_arch_name, buf_ptr(&noextbasename));
560 if (source_table.maybe_get(&override_path) != nullptr)
561 continue;
562
563 buf_resize(&override_path, 0);
564 buf_appendf(&override_path, "%s" OS_SEP "%s" OS_SEP "%s.S",
565 buf_ptr(&dirname), target_musl_arch_name, buf_ptr(&noextbasename));
566 if (source_table.maybe_get(&override_path) != nullptr)
567 continue;
568
569 buf_resize(&override_path, 0);
570 buf_appendf(&override_path, "%s" OS_SEP "%s" OS_SEP "%s.c",
571 buf_ptr(&dirname), target_musl_arch_name, buf_ptr(&noextbasename));
572 if (source_table.maybe_get(&override_path) != nullptr)
573 continue;
571574 }
572575
573576 Buf *full_path = buf_sprintf("%s" OS_SEP "libc" OS_SEP "%s",