Skip to content

Commit

Permalink
Stop the musl builder from skipping necessary files
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
LemonBoy authored and andrewrk committed Jun 4, 2019
1 parent fd771ea commit 291aaee
Showing 1 changed file with 29 additions and 26 deletions.
55 changes: 29 additions & 26 deletions src/link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,9 +528,6 @@ static const char *build_musl(CodeGen *parent) {
Buf noextbasename = BUF_INIT;
Buf dirbasename = BUF_INIT;
Buf before_arch_dir = BUF_INIT;
Buf override_c = BUF_INIT;
Buf override_s = BUF_INIT;
Buf override_S = BUF_INIT;

auto source_it = source_table.entry_iterator();
for (;;) {
Expand All @@ -543,31 +540,37 @@ static const char *build_musl(CodeGen *parent) {
os_path_split(src_file, &dirname, &basename);
os_path_extname(&basename, &noextbasename, nullptr);
os_path_split(&dirname, &before_arch_dir, &dirbasename);

bool is_arch_specific = false;
// Architecture-specific implementations are under a <arch>/ folder.
if (is_musl_arch_name(buf_ptr(&dirbasename))) {
// We find these by explicitly looking for overrides.
continue;
// Not the architecture we're compiling for.
if (strcmp(buf_ptr(&dirbasename), target_musl_arch_name) != 0)
continue;
is_arch_specific = true;
}
// Look for an arch specific override.
buf_resize(&override_c, 0);
buf_resize(&override_s, 0);
buf_resize(&override_S, 0);

buf_appendf(&override_c, "%s" OS_SEP "%s" OS_SEP "%s.c",
buf_ptr(&dirname), target_musl_arch_name, buf_ptr(&noextbasename));
buf_appendf(&override_s, "%s" OS_SEP "%s" OS_SEP "%s.s",
buf_ptr(&dirname), target_musl_arch_name, buf_ptr(&noextbasename));
buf_appendf(&override_S, "%s" OS_SEP "%s" OS_SEP "%s.S",
buf_ptr(&dirname), target_musl_arch_name, buf_ptr(&noextbasename));

if (source_table.maybe_get(&override_c) != nullptr) {
src_file = &override_c;
src_kind = (src_kind == MuslSrcAsm) ? MuslSrcNormal : src_kind;
} else if (source_table.maybe_get(&override_s) != nullptr) {
src_file = &override_s;
src_kind = MuslSrcAsm;
} else if (source_table.maybe_get(&override_S) != nullptr) {
src_file = &override_S;
src_kind = MuslSrcAsm;

if (!is_arch_specific) {
Buf override_path = BUF_INIT;

// Look for an arch specific override.
buf_resize(&override_path, 0);
buf_appendf(&override_path, "%s" OS_SEP "%s" OS_SEP "%s.s",
buf_ptr(&dirname), target_musl_arch_name, buf_ptr(&noextbasename));
if (source_table.maybe_get(&override_path) != nullptr)
continue;

buf_resize(&override_path, 0);
buf_appendf(&override_path, "%s" OS_SEP "%s" OS_SEP "%s.S",
buf_ptr(&dirname), target_musl_arch_name, buf_ptr(&noextbasename));
if (source_table.maybe_get(&override_path) != nullptr)
continue;

buf_resize(&override_path, 0);
buf_appendf(&override_path, "%s" OS_SEP "%s" OS_SEP "%s.c",
buf_ptr(&dirname), target_musl_arch_name, buf_ptr(&noextbasename));
if (source_table.maybe_get(&override_path) != nullptr)
continue;
}

Buf *full_path = buf_sprintf("%s" OS_SEP "libc" OS_SEP "%s",
Expand Down

0 comments on commit 291aaee

Please sign in to comment.