aboutsummaryrefslogtreecommitdiff
path: root/src/libcxx.zig
AgeCommit message (Collapse)Author
2022-01-02stage2: fix path to cache artifacts in libcxx,Andrew Kelley
libtsan, libunwind, and libcxxabi.
2022-01-02stage2: introduce CacheModeAndrew Kelley
The two CacheMode values are `whole` and `incremental`. `incremental` is what we had before; `whole` is new. Whole cache mode uses everything as inputs to the cache hash; and when a hit occurs it skips everything including linking. This is ideal for when source files change rarely and for backends that do not have good incremental compilation support, for example compiler-rt or libc compiled with LLVM with optimizations on. This is the main motivation for the additional mode, so that we can have LLVM-optimized compiler-rt/libc builds, without waiting for the LLVM backend every single time Zig is invoked. Incremental cache mode hashes only the input file path and a few target options, intentionally relying on collisions to locate already-existing build artifacts which can then be incrementally updated. The bespoke logic for caching stage1 backend build artifacts is removed since we now have a global caching mechanism for when we want to cache the entire compilation, *including* linking. Previously we had to get "creative" with libs.txt and a special byte in the hash id to communicate flags, so that when the cached artifacts were re-linked, we had this information from stage1 even though we didn't actually run it. Now that `CacheMode.whole` includes linking, this extra information does not need to be preserved for cache hits. So although this changeset introduces complexity, it also removes complexity. The main trickiness here comes from the inherent differences between the two modes: `incremental` wants a directory immediately to operate on, while `whole` doesn't know the output directory until the compilation is complete. This commit deals with this problem mostly inside `update()`, where, on a cache miss, it replaces `zig_cache_artifact_directory` with a temporary directory, and then renames it into place once the compilation is complete. Items remaining before this branch can be merged: * [ ] make sure these things make it into the cache manifest: - @import files - @embedFile files - we already add dep files from c but make sure the main .c files make it in there too, not just the included files * [ ] double check that the emit paths of other things besides the binary are working correctly. * [ ] test `-fno-emit-bin` + `-fstage1` * [ ] test `-femit-bin=foo` + `-fstage1` * [ ] implib emit directory copies bin_file_emit directory in create() and needs to be adjusted to be overridden as well. * [ ] make sure emit-h is handled correctly in the cache hash * [ ] Cache: detect duplicate files added to the manifest Some preliminary performance measurements of wall clock time and peak RSS used: stage1 behavior (1077 tests), llvm backend, release build: * cold global cache: 4.6s, 1.1 GiB * warm global cache: 3.4s, 980 MiB stage2 master branch behavior (575 tests), llvm backend, release build: * cold global cache: 0.62s, 191 MiB * warm global cache: 0.40s, 128 MiB stage2 this branch behavior (575 tests), llvm backend, release build: * cold global cache: 0.62s, 179 MiB * warm global cache: 0.27s, 90 MiB
2021-11-30allocgate: renamed getAllocator function to allocatorLee Cannon
2021-11-30allocgate: stage 1 and 2 buildingLee Cannon
2021-11-16libcxx: disable redundant new/delete definitionsAndrew Kelley
which are already provided by libcxxabi
2021-11-04Replace ArrayList.init/ensureTotalCapacity pairs with initCapacityRyan Liptak
Because ArrayList.initCapacity uses 'precise' capacity allocation, this should save memory on average, and definitely will save memory in cases where ArrayList is used where a regular allocated slice could have also be used.
2021-10-16Add build.zig and command line flagsLee Cannon
2021-10-01libcxx: pass -faligned-allocation flag when neededAndrew Kelley
libc++ now requires this flag
2021-10-01libcxx: update to compile with -std=c++20Andrew Kelley
This is required to successfully build libc++.
2021-09-30Merge remote-tracking branch 'origin/master' into llvm13Andrew Kelley
2021-09-19Update all ensureCapacity calls to the relevant non-deprecated versionRyan Liptak
2021-09-01stage2: libcxx: logic for skipping OS-specific filesAndrew Kelley
2021-08-16update libcxx, libcxxabi, libunwind, and tsan to llvm 13 rc1Andrew Kelley
2021-07-23stage2: improvements towards `zig test`Andrew Kelley
* There is now a main_pkg in addition to root_pkg. They are usually the same. When using `zig test`, main_pkg is the user's source file and root_pkg has the test runner. * scanDecl no longer looks for test decls outside the package being tested. honoring `--test-filter` is still TODO. * test runner main function has a void return value rather than `anyerror!void` * Sema is improved to generate better AIR for for loops on slices. * Sema: fix incorrect capacity calculation in zirBoolBr * Sema: add compile errors for trying to use slice fields as an lvalue. * Sema: fix type coercion for error unions * Sema: fix analyzeVarRef generating garbage AIR * C codegen: fix renderValue for error unions with 0 bit payload * C codegen: implement function pointer calls * CLI: fix usage text Adds 4 new AIR instructions: * slice_len, slice_ptr: to get the ptr and len fields of a slice. * slice_elem_val, ptr_slice_elem_val: to get the element value of a slice, and a pointer to a slice. AstGen gains a new functionality: * One of the unused flags of struct decls is now used to indicate structs that are known to have non-zero size based on the AST alone.
2021-06-15fix comments.Takeshi Yoneda
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2021-06-15Add a missing comment.Takeshi Yoneda
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2021-06-15cleanup, and disable threading completely.Takeshi Yoneda
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2021-06-15add various flags/options, and link libcxxabi.Takeshi Yoneda
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2021-06-14c++,wasi: enable libcxx build.Takeshi Yoneda
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2021-06-09CLI: remove --verbose-ast and --verbose-tokenizeAndrew Kelley
closes #9034 These options were listed under the "Debug Options (Zig Compiler Development)" heading. Anything in this section should be considered unstable and can be modified at any time at any developer's discretion.
2021-05-25remove reduntant new/delete implementationxavier
The same code is provided by both libxx and libxxabi, and removed at linktime.
2021-05-23keep statically linked libc++ symbols hidden.xavier
2021-05-23apply -flto and -ffunction-sections when compiling libc++xavier
2021-03-01zig c++: fix compilation that includes any c++ std library fileTimon Kruiper
LLVM 12 included a patch that changed the way availability annotations are specified. We now have to define the _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS flag to make sure that we tell the c++ headers that we don't use visibility annotations. Related LLVM patch: D90843
2021-02-25Merge remote-tracking branch 'origin/master' into llvm12Andrew Kelley
Conflicts: * src/clang.zig * src/llvm.zig - this file got moved to src/llvm/bindings.zig in master branch so I had to put the new LLVM arch/os enum tags into it. * lib/std/target.zig, src/stage1/target.cpp - haiku had an inconsistency with its default target ABI, gnu vs eabi. In this commit we make it gnu in both places to match the latest changes by @hoanga. * src/translate_c.zig
2021-01-11stage2: cleanups regarding red zone CLI flagsAndrew Kelley
* CLI: change to -mred-zone and -mno-red-zone to match gcc/clang. * build.zig: remove the double negative and make it an optional bool. This follows precedent from other flags, allowing the compiler CLI to be the decider of what is default instead of duplicating the default value into the build system code. * Compilation: make it an optional `want_red_zone` instead of a `no_red_zone` bool. The default is decided by a call to `target_util.hasRedZone`. * When creating a Clang command line, put -mred-zone on the command line if we are forcing it to be enabled. * Update update_clang_options.zig with respect to the recent {s}/{} format changes. * `zig cc` integration with red zone preference.
2021-01-11Added support for no red zoneLee Cannon
2020-12-24stage2: re-use compiler runtime libs across opt modes and strip flagAndrew Kelley
Previously Zig would need to recompile runtime libs if you changed the values of --strip or -O. Now, unless the `debug_compiler_runtime_libs` flag is set (which is currently not exposed to the CLI), Zig will always choose ReleaseFast or ReleaseSmall for compiler runtime libraries. When the main application chooses ReleaseFast or ReleaseSmall, that value is propagated to compiler runtime libraries. Otherwise a decision is made based on the target, which is currently ReleaseSmall for freestanding WebAssembly and ReleaseFast for everything else. Ultimately the purpose of this commit is to have Debug and ReleaseSafe builds of applications still get optimized builds of, e.g. libcxx and libunwind, as well as to spend less time unnecessarily rebuilding compiler runtime libraries.
2020-12-24stage2: fix Cache deadlock and build more of TSANAndrew Kelley
* rename is_compiler_rt_or_libc to skip_linker_dependencies and set it to `true` for all sub-Compilations. I believe this resolves the deadlock we were experiencing on Drone CI and on some users' computers. I will remove the CI workaround in a follow-up commit. * enabling TSAN automatically causes the Compilation to link against libc++ even if not requested, because TSAN depends on libc++. * add -fno-rtti flags where appropriate when building TSAN objects. Thanks Firefox317 for pointing this out. * TSAN support: resolve all the undefined symbols. We are still seeing a dependency on __gcc_personality_v0 but will resolve this one in a follow-up commit. * static libs do not try to build libc++ or libc++abi.
2020-12-24WIP start adding support for TSANAndrew Kelley
2020-12-20use kprotty's ThreadPool implementation (v5)Andrew Kelley
2020-12-18std: introduce a thread-local CSPRNG for general useAndrew Kelley
std.crypto.random * cross platform, even freestanding * can't fail. on initialization for some systems requires calling os.getrandom(), in which case there are rare but theoretically possible errors. The code panics in these cases, however the application may choose to override the default seed function and then handle the failure another way. * thread-safe * supports the full Random interface * cryptographically secure * no syscall required to initialize on Linux (AT_RANDOM) * calls arc4random on systems that support it `std.crypto.randomBytes` is removed in favor of `std.crypto.random.bytes`. I moved some of the Random implementations into their own files in the interest of organization. stage2 no longer requires passing a RNG; instead it uses this API. Closes #6704
2020-12-16Update libcxxJakub Konka
llvm commit b2851aea80e5a8f0cfd6c3c5a56a6b00fb28c6b6
2020-12-13stage2: link musl dynamically by default if nativeIsaac Freund
If targeting the native OS and the system libc is musl, link against it dynamically by default.
2020-11-22modernize the PIE patch for the latest master branchAndrew Kelley
This is the part of #3960 that has to be rewritten to apply to latest master branch code.
2020-09-30Merge remote-tracking branch 'origin/master' into llvm11Andrew Kelley
The changes to install_files.h needed to put into src/libcxx.zig
2020-09-26stage2: implement -fno-emit-binAndrew Kelley
we are now passing the cli tests
2020-09-24fix a round of regressions in this branchAndrew Kelley
* Don't try to generate C header files yet since it will only cause a crash saying the feature is unimplemented. * Rename the CLI options for release modes to use the `-O` prefix to match C compiler precedent. Options are now `-ODebug`, `-OReleaseFast`, `-OReleaseSafe`, `-OReleaseSmall`. The optimization mode matches the enum tags of std.builtin.Mode. It is planned to, at some point, rename std.builtin.Mode to std.builtin.OptimizationMode and modify the tags to be lower case to match the style convention. - Update build.zig code to support this new CLI. * update std.zig.binNameAlloc to support an optional Version and update the implementation to correctly deal with dynamic library version suffixes.
2020-09-22stage2: implement using the global cache dirAndrew Kelley
2020-09-21stage2: implement building & linking against libcxx and libcxxabiAndrew Kelley
2020-09-21rename src-self-hosted/ to src/Andrew Kelley