| author | |
| committer | |
| log | 800a4a6cebf363c8ba3d1fcfff55db8bfb71f731 |
| tree | 566a2b9995048fb457bda97db04f8d5d5c5d50be |
| parent | fc88d36daea40b69690186730ae7f2a5296585a9 |
This allows us to create a build of self-hosted with LLVM extensions
enabled but without the stage1 backend.5 files changed, 36 insertions(+), 29 deletions(-)
BRANCH_TODO+6-7| ... | ... | @@ -1,5 +1,10 @@ |
| 1 | * --main-pkg-path | |
| 2 | * add CLI support for a way to pass extra flags to c source files | |
| 3 | * musl | |
| 4 | * support rpaths in ELF linker code | |
| 5 | * implement proper parsing of LLD stderr/stdout and exposing compile errors | |
| 6 | * tests passing with -Dskip-non-native | |
| 1 | 7 | * windows CUSTOMBUILD : error : unable to build compiler_rt: FileNotFound [D:\a\1\s\build\zig_install_lib_files.vcxproj] |
| 2 | * separate libzigcpp.a and libzigstage1.a so that we can do non-stage1 builds | |
| 3 | 8 | * repair @cImport |
| 4 | 9 | * make sure zig cc works |
| 5 | 10 | - using it as a preprocessor (-E) |
| ... | ... | @@ -13,23 +18,17 @@ |
| 13 | 18 | * -fno-emit-asm (default) do not output .s (assembly code)\n" |
| 14 | 19 | * -femit-llvm-ir produce a .ll file with LLVM IR\n" |
| 15 | 20 | * -fno-emit-llvm-ir (default) do not produce a .ll file with LLVM IR\n" |
| 16 | * support rpaths in ELF linker code | |
| 17 | * add CLI support for a way to pass extra flags to c source files | |
| 18 | * musl | |
| 19 | 21 | * mingw-w64 |
| 20 | 22 | * MachO LLD linking |
| 21 | 23 | * COFF LLD linking |
| 22 | 24 | * WASM LLD linking |
| 23 | * --main-pkg-path | |
| 24 | 25 | * skip LLD caching when bin directory is not in the cache (so we don't put `id.txt` into the cwd) |
| 25 | 26 | (maybe make it an explicit option and have main.zig disable it) |
| 26 | 27 | * audit the CLI options for stage2 |
| 27 | 28 | * audit the base cache hash |
| 28 | * implement proper parsing of LLD stderr/stdout and exposing compile errors | |
| 29 | 29 | * implement proper parsing of clang stderr/stdout and exposing compile errors |
| 30 | 30 | * On operating systems that support it, do an execve for `zig test` and `zig run` rather than child process. |
| 31 | 31 | * restore error messages for stage2_add_link_lib |
| 32 | * update std/build.zig to use new CLI | |
| 33 | 32 | |
| 34 | 33 | * support cross compiling stage2 with `zig build` |
| 35 | 34 | * implement proper compile errors for failing to build glibc crt files and shared libs |
CMakeLists.txt+21-13| ... | ... | @@ -89,7 +89,7 @@ if(APPLE AND ZIG_WORKAROUND_4799) |
| 89 | 89 | list(APPEND LLVM_LIBRARIES "-Wl,${CMAKE_PREFIX_PATH}/lib/libPolly.a" "-Wl,${CMAKE_PREFIX_PATH}/lib/libPollyPPCG.a" "-Wl,${CMAKE_PREFIX_PATH}/lib/libPollyISL.a") |
| 90 | 90 | endif() |
| 91 | 91 | |
| 92 | set(ZIG_CPP_LIB_DIR "${CMAKE_BINARY_DIR}/zig_cpp") | |
| 92 | set(ZIG_CPP_LIB_DIR "${CMAKE_BINARY_DIR}/zigcpp") | |
| 93 | 93 | |
| 94 | 94 | # Handle multi-config builds and place each into a common lib. The VS generator |
| 95 | 95 | # for example will append a Debug folder by default if not explicitly specified. |
| ... | ... | @@ -260,7 +260,7 @@ set(ZIG0_SOURCES |
| 260 | 260 | "${CMAKE_SOURCE_DIR}/src/stage1/zig0.cpp" |
| 261 | 261 | ) |
| 262 | 262 | |
| 263 | set(ZIG_SOURCES | |
| 263 | set(STAGE1_SOURCES | |
| 264 | 264 | "${CMAKE_SOURCE_DIR}/src/stage1/analyze.cpp" |
| 265 | 265 | "${CMAKE_SOURCE_DIR}/src/stage1/ast_render.cpp" |
| 266 | 266 | "${CMAKE_SOURCE_DIR}/src/stage1/bigfloat.cpp" |
| ... | ... | @@ -392,21 +392,19 @@ if(ZIG_TEST_COVERAGE) |
| 392 | 392 | set(EXE_LDFLAGS "${EXE_LDFLAGS} -fprofile-arcs -ftest-coverage") |
| 393 | 393 | endif() |
| 394 | 394 | |
| 395 | add_library(zig_cpp STATIC ${ZIG_SOURCES} ${ZIG_CPP_SOURCES}) | |
| 396 | set_target_properties(zig_cpp PROPERTIES | |
| 395 | add_library(zigcpp STATIC ${ZIG_CPP_SOURCES}) | |
| 396 | set_target_properties(zigcpp PROPERTIES | |
| 397 | 397 | COMPILE_FLAGS ${EXE_CFLAGS} |
| 398 | 398 | ) |
| 399 | 399 | |
| 400 | target_link_libraries(zig_cpp LINK_PUBLIC | |
| 401 | opt_c_util | |
| 402 | ${SOFTFLOAT_LIBRARIES} | |
| 400 | target_link_libraries(zigcpp LINK_PUBLIC | |
| 403 | 401 | ${CLANG_LIBRARIES} |
| 404 | 402 | ${LLD_LIBRARIES} |
| 405 | 403 | ${LLVM_LIBRARIES} |
| 406 | 404 | ${CMAKE_THREAD_LIBS_INIT} |
| 407 | 405 | ) |
| 408 | 406 | if(ZIG_WORKAROUND_POLLY_SO) |
| 409 | target_link_libraries(zig_cpp LINK_PUBLIC "-Wl,${ZIG_WORKAROUND_POLLY_SO}") | |
| 407 | target_link_libraries(zigcpp LINK_PUBLIC "-Wl,${ZIG_WORKAROUND_POLLY_SO}") | |
| 410 | 408 | endif() |
| 411 | 409 | |
| 412 | 410 | add_library(opt_c_util STATIC ${OPTIMIZED_C_SOURCES}) |
| ... | ... | @@ -414,16 +412,26 @@ set_target_properties(opt_c_util PROPERTIES |
| 414 | 412 | COMPILE_FLAGS "${OPTIMIZED_C_FLAGS}" |
| 415 | 413 | ) |
| 416 | 414 | |
| 415 | add_library(zigstage1 STATIC ${STAGE1_SOURCES}) | |
| 416 | set_target_properties(zigstage1 PROPERTIES | |
| 417 | COMPILE_FLAGS ${EXE_CFLAGS} | |
| 418 | LINK_FLAGS ${EXE_LDFLAGS} | |
| 419 | ) | |
| 420 | target_link_libraries(zigstage1 LINK_PUBLIC | |
| 421 | opt_c_util | |
| 422 | ${SOFTFLOAT_LIBRARIES} | |
| 423 | zigcpp | |
| 424 | ) | |
| 417 | 425 | if(NOT MSVC) |
| 418 | target_link_libraries(zig_cpp LINK_PUBLIC ${LIBXML2}) | |
| 426 | target_link_libraries(zigstage1 LINK_PUBLIC ${LIBXML2}) | |
| 419 | 427 | endif() |
| 420 | 428 | |
| 421 | 429 | if(ZIG_DIA_GUIDS_LIB) |
| 422 | target_link_libraries(zig_cpp LINK_PUBLIC ${ZIG_DIA_GUIDS_LIB}) | |
| 430 | target_link_libraries(zigstage1 LINK_PUBLIC ${ZIG_DIA_GUIDS_LIB}) | |
| 423 | 431 | endif() |
| 424 | 432 | |
| 425 | 433 | if(MSVC OR MINGW) |
| 426 | target_link_libraries(zig_cpp LINK_PUBLIC version) | |
| 434 | target_link_libraries(zigstage1 LINK_PUBLIC version) | |
| 427 | 435 | endif() |
| 428 | 436 | |
| 429 | 437 | add_executable(zig0 ${ZIG0_SOURCES}) |
| ... | ... | @@ -431,7 +439,7 @@ set_target_properties(zig0 PROPERTIES |
| 431 | 439 | COMPILE_FLAGS ${EXE_CFLAGS} |
| 432 | 440 | LINK_FLAGS ${EXE_LDFLAGS} |
| 433 | 441 | ) |
| 434 | target_link_libraries(zig0 zig_cpp) | |
| 442 | target_link_libraries(zig0 zigstage1) | |
| 435 | 443 | |
| 436 | 444 | if(MSVC) |
| 437 | 445 | set(ZIG1_OBJECT "${CMAKE_BINARY_DIR}/zig1.obj") |
| ... | ... | @@ -487,7 +495,7 @@ set_target_properties(zig PROPERTIES |
| 487 | 495 | COMPILE_FLAGS ${EXE_CFLAGS} |
| 488 | 496 | LINK_FLAGS ${EXE_LDFLAGS} |
| 489 | 497 | ) |
| 490 | target_link_libraries(zig "${ZIG1_OBJECT}" zig_cpp) | |
| 498 | target_link_libraries(zig "${ZIG1_OBJECT}" zigstage1) | |
| 491 | 499 | if(MSVC) |
| 492 | 500 | target_link_libraries(zig ntdll.lib) |
| 493 | 501 | elseif(MINGW) |
build.zig+2-2| ... | ... | @@ -270,7 +270,7 @@ fn fileExists(filename: []const u8) !bool { |
| 270 | 270 | fn addCppLib(b: *Builder, lib_exe_obj: anytype, cmake_binary_dir: []const u8, lib_name: []const u8) void { |
| 271 | 271 | lib_exe_obj.addObjectFile(fs.path.join(b.allocator, &[_][]const u8{ |
| 272 | 272 | cmake_binary_dir, |
| 273 | "zig_cpp", | |
| 273 | "zigcpp", | |
| 274 | 274 | b.fmt("{}{}{}", .{ lib_exe_obj.target.libPrefix(), lib_name, lib_exe_obj.target.staticLibSuffix() }), |
| 275 | 275 | }) catch unreachable); |
| 276 | 276 | } |
| ... | ... | @@ -352,7 +352,7 @@ fn findLLVM(b: *Builder, llvm_config_exe: []const u8) !LibraryDep { |
| 352 | 352 | fn configureStage2(b: *Builder, exe: anytype, ctx: Context, need_cpp_includes: bool) !void { |
| 353 | 353 | exe.addIncludeDir("src"); |
| 354 | 354 | exe.addIncludeDir(ctx.cmake_binary_dir); |
| 355 | addCppLib(b, exe, ctx.cmake_binary_dir, "zig_cpp"); | |
| 355 | addCppLib(b, exe, ctx.cmake_binary_dir, "zigcpp"); | |
| 356 | 356 | assert(ctx.lld_include_dir.len != 0); |
| 357 | 357 | exe.addIncludeDir(ctx.lld_include_dir); |
| 358 | 358 | { |
lib/std/build/translate_c.zig+1-2| ... | ... | @@ -72,8 +72,7 @@ pub const TranslateCStep = struct { |
| 72 | 72 | try argv_list.append("translate-c"); |
| 73 | 73 | try argv_list.append("-lc"); |
| 74 | 74 | |
| 75 | try argv_list.append("--cache"); | |
| 76 | try argv_list.append("on"); | |
| 75 | try argv_list.append("--enable-cache"); | |
| 77 | 76 | |
| 78 | 77 | if (!self.target.isNative()) { |
| 79 | 78 | try argv_list.append("-target"); |
src/zig_clang.cpp+6-5| ... | ... | @@ -13,7 +13,6 @@ |
| 13 | 13 | * 3. Prevent C++ from infecting the rest of the project. |
| 14 | 14 | */ |
| 15 | 15 | #include "zig_clang.h" |
| 16 | #include "list.hpp" | |
| 17 | 16 | |
| 18 | 17 | #if __GNUC__ >= 8 |
| 19 | 18 | #pragma GCC diagnostic push |
| ... | ... | @@ -2186,7 +2185,7 @@ ZigClangASTUnit *ZigClangLoadFromCommandLine(const char **args_begin, const char |
| 2186 | 2185 | // Take ownership of the err_unit ASTUnit object so that it won't be |
| 2187 | 2186 | // free'd when we return, invalidating the error message pointers |
| 2188 | 2187 | clang::ASTUnit *unit = ast_unit ? ast_unit : err_unit.release(); |
| 2189 | ZigList<Stage2ErrorMsg> errors = {}; | |
| 2188 | Stage2ErrorMsg *errors = nullptr; | |
| 2190 | 2189 | |
| 2191 | 2190 | for (clang::ASTUnit::stored_diag_iterator it = unit->stored_diag_begin(), |
| 2192 | 2191 | it_end = unit->stored_diag_end(); it != it_end; ++it) |
| ... | ... | @@ -2204,7 +2203,10 @@ ZigClangASTUnit *ZigClangLoadFromCommandLine(const char **args_begin, const char |
| 2204 | 2203 | |
| 2205 | 2204 | llvm::StringRef msg_str_ref = it->getMessage(); |
| 2206 | 2205 | |
| 2207 | Stage2ErrorMsg *msg = errors.add_one(); | |
| 2206 | *errors_len += 1; | |
| 2207 | errors = reinterpret_cast<Stage2ErrorMsg*>(realloc(errors, sizeof(Stage2ErrorMsg) * *errors_len)); | |
| 2208 | if (errors == nullptr) abort(); | |
| 2209 | Stage2ErrorMsg *msg = &errors[*errors_len - 1]; | |
| 2208 | 2210 | memset(msg, 0, sizeof(*msg)); |
| 2209 | 2211 | |
| 2210 | 2212 | msg->msg_ptr = (const char *)msg_str_ref.bytes_begin(); |
| ... | ... | @@ -2242,8 +2244,7 @@ ZigClangASTUnit *ZigClangLoadFromCommandLine(const char **args_begin, const char |
| 2242 | 2244 | } |
| 2243 | 2245 | } |
| 2244 | 2246 | |
| 2245 | *errors_ptr = errors.items; | |
| 2246 | *errors_len = errors.length; | |
| 2247 | *errors_ptr = errors; | |
| 2247 | 2248 | |
| 2248 | 2249 | return nullptr; |
| 2249 | 2250 | } |