From cf46cd5f2b0f87430185c5d89056321d16f42d58 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 15 Aug 2017 07:16:22 -0400 Subject: [PATCH] organize file path of compiler_rt --- CMakeLists.txt | 2 +- src/link.cpp | 27 ++++++++++++++----- .../index.zig} | 0 3 files changed, 21 insertions(+), 8 deletions(-) rename std/special/{compiler_rt.zig => compiler_rt/index.zig} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 03197a43c7..380c617e17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -311,7 +311,7 @@ install(FILES "${CMAKE_SOURCE_DIR}/std/special/bootstrap.zig" DESTINATION "${ZIG install(FILES "${CMAKE_SOURCE_DIR}/std/special/build_file_template.zig" DESTINATION "${ZIG_STD_DEST}/special") install(FILES "${CMAKE_SOURCE_DIR}/std/special/build_runner.zig" DESTINATION "${ZIG_STD_DEST}/special") install(FILES "${CMAKE_SOURCE_DIR}/std/special/builtin.zig" DESTINATION "${ZIG_STD_DEST}/special") -install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt.zig" DESTINATION "${ZIG_STD_DEST}/special") +install(FILES "${CMAKE_SOURCE_DIR}/std/special/compiler_rt/index.zig" DESTINATION "${ZIG_STD_DEST}/special/compiler_rt") install(FILES "${CMAKE_SOURCE_DIR}/std/special/test_runner.zig" DESTINATION "${ZIG_STD_DEST}/special") install(FILES "${CMAKE_SOURCE_DIR}/std/special/zigrt.zig" DESTINATION "${ZIG_STD_DEST}/special") diff --git a/src/link.cpp b/src/link.cpp index 1e44d908fb..f031084409 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -31,11 +31,7 @@ static const char *get_libc_static_file(CodeGen *g, const char *file) { return buf_ptr(out_buf); } -static Buf *build_o(CodeGen *parent_gen, const char *oname) { - Buf *source_basename = buf_sprintf("%s.zig", oname); - Buf *full_path = buf_alloc(); - os_path_join(parent_gen->zig_std_special_dir, source_basename, full_path); - +static Buf *build_o_raw(CodeGen *parent_gen, const char *oname, Buf *full_path) { ZigTarget *child_target = parent_gen->is_native_target ? nullptr : &parent_gen->zig_target; CodeGen *child_gen = codegen_create(full_path, child_target, OutTypeObj, parent_gen->build_mode); @@ -65,6 +61,23 @@ static Buf *build_o(CodeGen *parent_gen, const char *oname) { return output_path; } +static Buf *build_o(CodeGen *parent_gen, const char *oname) { + Buf *source_basename = buf_sprintf("%s.zig", oname); + Buf *full_path = buf_alloc(); + os_path_join(parent_gen->zig_std_special_dir, source_basename, full_path); + + return build_o_raw(parent_gen, oname, full_path); +} + +static Buf *build_compiler_rt(CodeGen *parent_gen) { + Buf *dir_path = buf_alloc(); + os_path_join(parent_gen->zig_std_special_dir, buf_create_from_str("compiler_rt"), dir_path); + Buf *full_path = buf_alloc(); + os_path_join(dir_path, buf_create_from_str("index.zig"), full_path); + + return build_o_raw(parent_gen, "compiler_rt", full_path); +} + static const char *get_exe_file_extension(CodeGen *g) { if (g->zig_target.os == ZigLLVM_Win32) { return ".exe"; @@ -263,7 +276,7 @@ static void construct_linker_job_elf(LinkJob *lj) { Buf *builtin_o_path = build_o(g, "builtin"); lj->args.append(buf_ptr(builtin_o_path)); - Buf *compiler_rt_o_path = build_o(g, "compiler_rt"); + Buf *compiler_rt_o_path = build_compiler_rt(g); lj->args.append(buf_ptr(compiler_rt_o_path)); } @@ -401,7 +414,7 @@ static void construct_linker_job_coff(LinkJob *lj) { Buf *builtin_o_path = build_o(g, "builtin"); lj->args.append(buf_ptr(builtin_o_path)); - Buf *compiler_rt_o_path = build_o(g, "compiler_rt"); + Buf *compiler_rt_o_path = build_compiler_rt(g); lj->args.append(buf_ptr(compiler_rt_o_path)); } diff --git a/std/special/compiler_rt.zig b/std/special/compiler_rt/index.zig similarity index 100% rename from std/special/compiler_rt.zig rename to std/special/compiler_rt/index.zig