aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
AgeCommit message (Collapse)Author
2021-01-19SPIR-V: Linking and codegen setupRobin Voetter
2021-01-16stage2: implement error notes and regress -femit-zirAndrew Kelley
* Implement error notes - note: other symbol exported here - note: previous else prong is here - note: previous '_' prong is here * Add Compilation.CObject.ErrorMsg. This object properly converts to AllErrors.Message when the time comes. * Add Compilation.CObject.failure_retryable. Properly handles out-of-memory and other transient failures. * Introduce Module.SrcLoc which has not only a byte offset but also references the file which the byte offset applies to. * Scope.Block now contains both a pointer to the "owner" Decl and the "source" Decl. As an example, during inline function call, the "owner" will be the Decl of the caller and the "source" will be the Decl of the callee. * Module.ErrorMsg now sports a `file_scope` field so that notes can refer to source locations in a file other than the parent error message. * Some instances where a `*Scope` was stored, now store a `*Scope.Container`. * Some methods in the `Scope` namespace were moved to the more specific type, since there was only an implementation for one particular tag. - `removeDecl` moved to `Scope.Container` - `destroy` moved to `Scope.File` * Two kinds of Scope deleted: - zir_module - decl * astgen: properly use DeclVal / DeclRef. DeclVal was incorrectly changed to be a reference; this commit fixes it. Fewer ZIR instructions processed as a result. - declval_in_module is renamed to declval - previous declval ZIR instruction is deleted; it was only for .zir files. * Test harness: friendlier diagnostics when an unexpected set of errors is encountered. * zir_sema: fix analyzeInstBlockFlat by properly calling resolvingInst on the last zir instruction in the block. Compile log implementation: * Write to a buffer rather than directly to stderr. * Only keep track of 1 callsite per Decl. * No longer mutate the ZIR Inst struct data. * "Compile log statement found" errors are only emitted when there are no other compile errors. -femit-zir and support for .zir source files is regressed. If we wanted to support this again, outputting .zir would need to be done as yet another backend rather than in the haphazard way it was previously implemented. For parsing .zir, it was implemented previously in a way that was not helpful for debugging. We need tighter integration with the test harness for it to be useful; so clearly a rewrite is needed. Given that a rewrite is needed, and it was getting in the way of progress and organization of the rest of stage2, I regressed the feature.
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
2021-01-09Merge pull request #7729 from jayschwa/remove-deprecated-streamAndrew Kelley
Remove deprecated stream aliases
2021-01-08Fix system library path detection on linuxxackus
Uses the NativeTargetInfo results instead of std.Target.current.
2021-01-08stage2: Implicitly enable --eh_frame_hdr when compiling c/c++ filesLemonBoy
Matches what Clang/GCC driver do. Closes #7711
2021-01-08Remove deprecated stream aliasesJay Petacat
2021-01-07Reduce use of deprecated IO typesJay Petacat
Related: #4917
2021-01-07Want native headers when linking with frameworksJakub Konka
This PR ensures we use system libc headers and system search paths for framework headers when linking against frameworks and compiling natively on macOS.
2021-01-06stage2: rename and move files related to LLVM backendTimon Kruiper
2021-01-03stage2: remove the Cache deadlock detection codeAndrew Kelley
It's more trouble than it's worth; it didn't even catch the most recent incident because it was across process boundaries anyway.
2021-01-03stage2: fix Cache debug deadlock code memory leakAndrew Kelley
2021-01-02Merge pull request #7647 from ziglang/stage2-comptime-fn-callAndrew Kelley
stage2: comptime function calls and inline function calls
2021-01-02fix 7665:g-w1
only add self exe path when testing
2021-01-02stage2: fix handling compile error in inline fn callAndrew Kelley
* scopes properly inherit inlining information * compile errors of inline function calls are properly attached to the caller rather than the callee. - added a test case for this * --watch still opens a repl if compile errors happen.
2021-01-02convert more {} to {d} and {s}Andrew Kelley
2021-01-02stage2: Use {s} instead of {} when formatting stringsLemonBoy
2021-01-02Fix usage messageSizhe Zhao
2021-01-02Detect native iframework dirs on macOSJakub Konka
This commit adds default search paths for system frameworks on macOS while also adding `-isysroot` for OS versions at least BigSur. Since BigSur (11.0.1), neither headers nor libs exist in standard root locations (`/usr/include`, `/System/Library/Frameworks`). Instead, they are now exclusively part of the installed developer toolchain (either via XCode.app or CLT), and specifying `-isysroot` allows us to keep using universal search paths such as `/System/Library/Frameworks` while only changing the include flag from `-iframework` to `-iframeworkwithsysroot`.
2020-12-29zig test: release Compilation Cache locksAndrew Kelley
before executing child process. This fixes a deadlock when the test wanted to obtain the same lock on compiler_rt.o that was held by the process building the test binary itself.
2020-12-28fix `zig test` with regards to passing parametersAndrew Kelley
2020-12-28zig test: std.testing.zig_exe_path is now availableAndrew Kelley
it will be set to the path of the zig executable which is running `zig test`.
2020-12-28stage2: rename llvm.zig to llvm_bindings.zigTimon Kruiper
Putting functions in this file will create functions like `llvm.function`, and the compiler thinks these are llvm intrinsics.
2020-12-26std: do not call malloc() between fork() and execv()Andrew Kelley
We were violating the POSIX standard which resulted in a deadlock on musl v1.1.24 on aarch64 alpine linux, uncovered with the new ThreadPool usage in the stage2 compiler. std.os execv functions that accept an Allocator parameter are removed because they are footguns. The POSIX standard does not allow calls to malloc() between fork() and execv() and since it is common to both (1) call execv() after fork() and (2) use std.heap.c_allocator, Programmers are encouraged to go through the `std.process` API instead, causing some dissonance when combined with `std.os` APIs. I also slapped a big warning message on all the relevant doc comments.
2020-12-24WIP start adding support for TSANAndrew Kelley
2020-12-23Implement parsing for multi-arg Clang options.Alex Cameron
2020-12-23update depreciated code (#7502)g-w1
* `zig env`: * fix depreciated interface, update outStream -> writer * make code more readable by updating `anytype` -> `std.fs.File.Writer`
2020-12-23Merge pull request #7111 from tetsuo-cpp/emit-hVeikka Tuominen
Implement emit-h
2020-12-23Merge pull request #7476 from ifreund/pkgsVeikka Tuominen
stage2: free Package resources, print package path on --pkg-begin failure
2020-12-23Make sure emit-h is off by default.Alex Cameron
2020-12-23Enable emit-h by default for obj and lib compilation.Alex Cameron
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-17stage2: print package path on --pkg-begin failureIsaac Freund
This makes it much easier for the user to figure out what has gone wrong than dumping an error return trace.
2020-12-17stage2: free Package resourcesIsaac Freund
Without this commit we leak file descriptors and memory
2020-12-16zig cc: default to a.exe on windowsAndrew Kelley
This matches Clang. Thanks to Abner Coimbre for pointing this out.
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-12-11stage2: proper file extension strippingAndrew Kelley
Previously it used mem.split on "." and took the first iterated item. Now it uses fs.path.extension and strips off that number of bytes. Closes #7404
2020-12-10CLI: improved local cache directory logicAndrew Kelley
Previously, when choosing the local cache directory, if there was no root source file, an explicitly chosen path, or other clues, zig would choose cwd + zig-cache/ as the local cache directory. This can be problematic if Zig is invoked with the CWD set to a read-only directory, or a directory unrelated to the actual source files being compiled. In the real world, we see this when using `zig cc` with CGo, which for some reason changes the current working directory to the read-only go standard library path before running the C compiler. This commit conservatively chooses to use the global cache directory as the local cache directory when there is no other reasonable choice, and no longer will rely on the cwd path to choose a local cache directory. As a reminder, the --cache-dir CLI flag and ZIG_LOCAL_CACHE_DIR environment variable are available for overriding the decision. For the zig build system, it will always choose the directory that build.zig is + zig-cache/. Closes #7342
2020-12-10Added global-cache argument to build system + removed extra args.antlilja
* Field global_cache_root was added to Builder struct along with mandatory argument for build_runner.zig. Logic for using the custom global cache was also added. * The arguments --cache-dir and --global-cache-dir are no longer passed directly through to build_runner.zig and are instead only passed through the mandatory cache_root and global_cache_root arguments.
2020-12-09CLI: infer --name based on first C source file or objectAndrew Kelley
Previously, --name would only be inferred if there was exactly 1 C source file or exactly 1 object. Now it will be inferred if there is at least one of either.
2020-12-09Do not keep the build.zig cache manifest file locked.Timon Kruiper
This allows to have multiple instances of `zig build` at the same time. For example when you have a long running `zig build run` and then want to run `zig build somethingelse`.
2020-12-09Fixes #7352 - ignore zig fmt ignore zig-cacheLee Cannon
2020-12-08invoke LLD as a child process rather than a libraryAndrew Kelley
Closes #3825
2020-12-08add support for environment variables to control cache directoriesAndrew Kelley
This commit adds: ZIG_LOCAL_CACHE_DIR corresponding to --cache-dir ZIG_GLOBAL_CACHE_DIR corresponding to --global-cache-dir ZIG_LIB_DIR corresponding to --override-lib-dir The main use case is for `zig cc` where we are bound by clang's CLI options and need alternate channels to pass these configuration options.
2020-12-07Utilize std.fmt.parseUnsigned in main.zig.antlilja
* Remove function parseAnyBaseInt. * Replace calls to parseAnyBaseInt to calls to std.fmt.parseUnsigned with radix 0. * Replace calls to parseInt where the type is unsigned with calls to parseUnsigned. Note that the functionality of these arguments haven't changed, they still retain the original radix specified.
2020-12-03lld+macho: address review commentsJakub Konka
2020-12-02lld+macho: rename final artefact in main.zigJakub Konka
2020-11-30build system: pass dyn lib artifacts as positionalsAndrew Kelley