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) {...@@ -528,9 +528,6 @@ static const char *build_musl(CodeGen *parent) {
528 Buf noextbasename = BUF_INIT;528 Buf noextbasename = BUF_INIT;
529 Buf dirbasename = BUF_INIT;529 Buf dirbasename = BUF_INIT;
530 Buf before_arch_dir = BUF_INIT;530 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
535 auto source_it = source_table.entry_iterator();532 auto source_it = source_table.entry_iterator();
536 for (;;) {533 for (;;) {
...@@ -543,31 +540,37 @@ static const char *build_musl(CodeGen *parent) {...@@ -543,31 +540,37 @@ static const char *build_musl(CodeGen *parent) {
543 os_path_split(src_file, &dirname, &basename);540 os_path_split(src_file, &dirname, &basename);
544 os_path_extname(&basename, &noextbasename, nullptr);541 os_path_extname(&basename, &noextbasename, nullptr);
545 os_path_split(&dirname, &before_arch_dir, &dirbasename);542 os_path_split(&dirname, &before_arch_dir, &dirbasename);
543
544 bool is_arch_specific = false;
545 // Architecture-specific implementations are under a <arch>/ folder.
546 if (is_musl_arch_name(buf_ptr(&dirbasename))) {546 if (is_musl_arch_name(buf_ptr(&dirbasename))) {
547 // We find these by explicitly looking for overrides.547 // Not the architecture we're compiling for.
548 continue;548 if (strcmp(buf_ptr(&dirbasename), target_musl_arch_name) != 0)
549 continue;
550 is_arch_specific = true;
549 }551 }
550 // Look for an arch specific override.552
551 buf_resize(&override_c, 0);553 if (!is_arch_specific) {
552 buf_resize(&override_s, 0);554 Buf override_path = BUF_INIT;
553 buf_resize(&override_S, 0);555
554556 // Look for an arch specific override.
555 buf_appendf(&override_c, "%s" OS_SEP "%s" OS_SEP "%s.c",557 buf_resize(&override_path, 0);
556 buf_ptr(&dirname), target_musl_arch_name, buf_ptr(&noextbasename));558 buf_appendf(&override_path, "%s" OS_SEP "%s" OS_SEP "%s.s",
557 buf_appendf(&override_s, "%s" OS_SEP "%s" OS_SEP "%s.s",559 buf_ptr(&dirname), target_musl_arch_name, buf_ptr(&noextbasename));
558 buf_ptr(&dirname), target_musl_arch_name, buf_ptr(&noextbasename));560 if (source_table.maybe_get(&override_path) != nullptr)
559 buf_appendf(&override_S, "%s" OS_SEP "%s" OS_SEP "%s.S",561 continue;
560 buf_ptr(&dirname), target_musl_arch_name, buf_ptr(&noextbasename));562
561563 buf_resize(&override_path, 0);
562 if (source_table.maybe_get(&override_c) != nullptr) {564 buf_appendf(&override_path, "%s" OS_SEP "%s" OS_SEP "%s.S",
563 src_file = &override_c;565 buf_ptr(&dirname), target_musl_arch_name, buf_ptr(&noextbasename));
564 src_kind = (src_kind == MuslSrcAsm) ? MuslSrcNormal : src_kind;566 if (source_table.maybe_get(&override_path) != nullptr)
565 } else if (source_table.maybe_get(&override_s) != nullptr) {567 continue;
566 src_file = &override_s;568
567 src_kind = MuslSrcAsm;569 buf_resize(&override_path, 0);
568 } else if (source_table.maybe_get(&override_S) != nullptr) {570 buf_appendf(&override_path, "%s" OS_SEP "%s" OS_SEP "%s.c",
569 src_file = &override_S;571 buf_ptr(&dirname), target_musl_arch_name, buf_ptr(&noextbasename));
570 src_kind = MuslSrcAsm;572 if (source_table.maybe_get(&override_path) != nullptr)
573 continue;
571 }574 }
572575
573 Buf *full_path = buf_sprintf("%s" OS_SEP "libc" OS_SEP "%s",576 Buf *full_path = buf_sprintf("%s" OS_SEP "libc" OS_SEP "%s",