aboutsummaryrefslogtreecommitdiff
path: root/src/link.cpp
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2019-06-01 16:59:12 +0200
committerAndrew Kelley <andrew@ziglang.org>2019-06-04 12:45:02 -0400
commit291aaee97773e2f9c40e061410db52ca00f4d651 (patch)
treebc8490b5f1eff6c85c6b62a4686ef00b80f7fa0f /src/link.cpp
parentfd771ea9fb8926127b4ecb2793608b04a4430b2d (diff)
downloadzig-291aaee97773e2f9c40e061410db52ca00f4d651.tar.gz
zig-291aaee97773e2f9c40e061410db52ca00f4d651.zip
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.
Diffstat (limited to 'src/link.cpp')
-rw-r--r--src/link.cpp55
1 files changed, 29 insertions, 26 deletions
diff --git a/src/link.cpp b/src/link.cpp
index f94b1219f6..fe5a73a52b 100644
--- a/src/link.cpp
+++ b/src/link.cpp
@@ -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 (;;) {
@@ -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",