aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
AgeCommit message (Collapse)Author
2023-09-22Merge pull request #17069 from squeek502/resinatorAndrew Kelley
Add a `.rc` -> `.res` compiler to the Zig compiler
2023-09-17rc compilation: Use MSVC includes if present, fallback to mingwRyan Liptak
The include directories used when preprocessing .rc files are now separate from the target, and by default will use the system MSVC include paths if the MSVC + Windows SDK are present, otherwise it will fall back to the MinGW includes distributed with Zig. This default behavior can be overridden by the `-rcincludes` option (possible values: any (the default), msvc, gnu, or none). This behavior is useful because Windows resource files may `#include` files that only exist with in the MSVC include dirs (e.g. in `<MSVC install directory>/atlmfc/include` which can contain other .rc files, images, icons, cursors, etc). So, by defaulting to the `any` behavior (MSVC if present, MinGW fallback), users will by default get behavior that is most-likely-to-work. It also should be okay that the include directories used when compiling .rc files differ from the include directories used when compiling the main binary, since the .res format is not dependent on anything ABI-related. The only relevant differences would be things like `#define` constants being different values in the MinGW headers vs the MSVC headers, but any such differences would likely be a MinGW bug.
2023-09-17Disallow .rc/.res files unless the object format is coffRyan Liptak
2023-09-17Add a .rc -> .res compiler to the Zig compilerRyan Liptak
2023-09-15package manager: write deps in a flat format, eliminating the FQN conceptmlugg
The new `@depedencies` module contains generated code like the following (where strings like "abc123" represent hashes): ```zig pub const root_deps = [_]struct { []const u8, []const u8 }{ .{ "foo", "abc123" }, }; pub const packages = struct { pub const abc123 = struct { pub const build_root = "/home/mlugg/.cache/zig/blah/abc123"; pub const build_zig = @import("abc123"); pub const deps = [_]struct { []const u8, []const u8 }{ .{ "bar", "abc123" }, .{ "name", "ghi789" }, }; }; }; ``` Each package contains a build root string, the build.zig import, and a mapping from dependency names to package hashes. There is also such a mapping for the root package dependencies. In theory, we could now remove the `dep_prefix` field from `std.Build`, since its main purpose is now handled differently. I believe this is a desirable goal, as it doesn't really make sense to assign a single FQN to any package (because it may appear in many different places in the package hierarchy). This commit does not remove that field, as it's used non-trivially in a few places in the build runner and compiler tests: this will be a future enhancement. Resolves: #16354 Resolves: #17135
2023-09-14Add -includes option to zig libcRyan Liptak
Prints the detected libc include paths for the target and exits
2023-08-21frontend: directly pass resolved frameworks container to the linkerJakub Konka
We can infer the framework name from the included resolved framework path. Fix hash implementation, and bump linker hash value from 9 to 10.
2023-08-20frontend: move framework path resolution from the linker to frontendJakub Konka
2023-08-20macho: we no longer need to resolve framework dirs against sysrootJakub Konka
2023-08-18comp: forward -iframework/-iframeworkwithsysroot paths to the backendJakub Konka
2023-08-18cc: disambiguate includes with sysroot in ClangSearchSanitizerJakub Konka
This noninvasive change improves warning messages for mixing up paths between `-iwithsysroot` and `-iframeworkwithsysroot`.
2023-08-09change uses of std.builtin.Mode to OptimizeMode (#16745)Zachary Raineri
std.builtin.Mode is deprecated.
2023-08-04Fix typo: headerpat -> headerpadJeremy Volkman
2023-08-03CLI: fix a typo that made static/dynamic do the oppositeAndrew Kelley
2023-08-03darwin: pass -iframework to clang for system frameworksAndrew Kelley
2023-08-03CLI: add native paths only if ABI is also nativeAndrew Kelley
2023-08-03std.zig.system.darwin: fix redundant namesAndrew Kelley
2023-08-03zig libc: restore functionality on macOSAndrew Kelley
Regressed in 2006add8496c47804ee3b6c562f420871cb4ea0a. References to native_darwin_sdk are no longer kept in the frontend. Instead the darwin SDK is detected as part of NativePaths and as part of LibCInstallation.
2023-08-03std.zig.system.NativePaths: simplify and integrate with Darwin SDKAndrew Kelley
2023-08-03CLI: reduce code size bloatAndrew Kelley
Make a bunch of ArrayList objects use arena instead of gpa, eliminating the `defer` expressions, which reduces code size of zig1.wasm by 1%
2023-08-03CLI: delete redundant logic and use null instead of undefAndrew Kelley
The `null` value here was missed in 0a4d4eb252a73555a568a532902951a13284d2ef. I hope it is the cause of the CI failures on Windows. The fact that libc++ depends on libc is not important for the CLI and Compilation.create already handles that logic.
2023-08-03CLI: add -search_paths_first_static to complete the APIAndrew Kelley
There was no previous way to set preferred mode static, search strategy paths_first.
2023-08-03CLI: revert -l behaviorAndrew Kelley
chicken out and make -l match the status quo behavior, where it looks for dynamic libraries and then falls back to static libraries. library resolution is still done in the CLI now though, and these options are added: -search_static_first Search for static libs in all library search paths, then dynamic libs. -search_dylibs_only Only search for dynamic libs. -search_static_only Only search for static libs. this matches the already existing options below: -search_paths_first For each library search path, check for dynamic lib then static lib before proceeding to next path. -search_dylibs_first Search for dynamic libs in all library search So, it is still possible to get the strict behavior by passing `-search_dylibs_only` or `-search_static_only`. This commit also makes -dynamic and -static affect the preferred link mode and search strategy.
2023-08-03CLI: Windows: system DLLs no longer trigger native paths detectionAndrew Kelley
2023-08-03CLI: adjust order of operations of system librariesAndrew Kelley
First, system_libs are collected into a list. This is the same as before. Next, system_libs are filtered into external_system_libs, which is the same list but without any libc, compiler_rt, etc. At this point, if there are any external system libs, native library directory paths are detected and added to lib_dirs. Finally, extern_system_libs are filtered into resolved_system_libs, which has full paths to all of the libraries. This is the list passed into Compilation. This makes the required changes noted by @ifreund in the code review for this branch.
2023-08-03CLI: remove --ambiguous-static-libraryAndrew Kelley
Reverts 6232e63ca4460a953ca8453a6f7583eb910e87c8, but keeps the usage text cleanup. Let's resist adding this as long as possible.
2023-08-03CLI: add --ambiguous-static-libraryAndrew Kelley
I hate this, gonna revert it in the next commit
2023-08-03frontend: fix linking to Windows DLLs as system libsAndrew Kelley
2023-08-03compiler: resolve library paths in the frontendAndrew Kelley
search_strategy is no longer passed to Compilation at all; instead it is used in the CLI code only. When using Zig CLI mode, `-l` no longer has the ability to link statically; use positional arguments for this. The CLI has a small abstraction around library resolution handling which is used to remove some code duplication regarding static libraries, as well as handle the difference between zig cc CLI mode and zig CLI mode. Thanks to this, system libraries are now included in the cache hash, and thus changes to them will correctly cause cache misses. In the future, lib_dirs should no longer be passed to Compilation at all, because it is a frontend-only concept. Previously, -search_paths_first and -search_dylibs_first were Darwin-only arguments; they now work the same for all targets. Same thing with --sysroot. Improved the error reporting for failure to find a system library. An example error now looks like this: ``` $ zig build-exe test.zig -lfoo -L. -L/a -target x86_64-macos --sysroot /home/andy/local error: unable to find Dynamic system library 'foo' using strategy 'no_fallback'. search paths: ./libfoo.tbd ./libfoo.dylib ./libfoo.so /home/andy/local/a/libfoo.tbd /home/andy/local/a/libfoo.dylib /home/andy/local/a/libfoo.so /a/libfoo.tbd /a/libfoo.dylib /a/libfoo.so ``` closes #14963
2023-08-01CLI: stop special-casing LLVM, LLD, and ClangAndrew Kelley
Before: -fLLVM, -fLLD, -fClang, -flibLLVM -fno-LLVM, -fno-LLD, -fno-Clang, -fno-libLLVM After: -fllvm, -flld, -fclang, -flibllvm -fno-llvm, -fno-lld, -fno-clang, -fno-libllvm
2023-07-28package manager: don't show progress indicator on dumb terminalsmlugg
This mirrors the behavior of the progress indicator for the actual compilation. Not doing this was causing sporadic CI failures due to the (non-existent) fetches taking long enough to appear in stderr.
2023-07-26Add --verbose-generic-instances to provide visibility on the number of ↵kcbanner
generic function instantiations
2023-07-25Package: add progress indicator for package fetchingmlugg
2023-07-24zig fmt: make `--exclude` work on filesIan Johnson
Closes #16178
2023-07-24CLI: delete dead option -femit-analysisAndrew Kelley
This used to do something with the old autodocs system. Now it does nothing.
2023-07-22move installation logic to the build script where it belongsAndrew Kelley
* build.zig: introduce `-Dflat` option which makes the installation match what we want to ship for our download tarballs. This allows deleting a bunch of shell script logic from the CI. - for example it puts the executable directly in prefix/zig rather than prefix/bin/zig and it additionally includes prefix/LICENSE. * build.zig: by default also install std lib documentation to doc/std/ - this can be disabled by `-Dno-autodocs` similar to how there is already `-Dno-langref`. * build.zig: add `std-docs` and `langref` steps which build and install the std lib autodocs and langref to prefix/doc/std and prefix/doc/langref.html, respectively. * std.Build: implement proper handling of `-femit-docs` using the LazyPath system. This is a breaking change. - this is a partial implementation of #16351 * frontend: fixed the handling of Autodocs with regards to caching and putting the artifacts in the proper location to integrate with the build system. - closes #15864 * CI: delete the logic for autodocs since it is now handled by build.zig and is enabled by default. - in the future we should strive to have nearly all the CI shell script logic deleted in favor of `zig build` commands. * CI: pass `-DZIG_NO_LIB=ON`/`-Dno-lib` except for the one command where we want to actually generate the langref and autodocs. Generating the langref takes 14 minutes right now (why?!) so we don't want to do that more times than necessary. * Autodoc: fixed use of a global variable. It works fine as a local variable instead. - note that in the future we will want to make Autodoc run simultaneously using the job system, but for now the principle of YAGNI dictates that we don't have an init()/deinit() API and instead simply call the function that does the things. * Autodoc: only do it when there are no compile errors
2023-07-19llvm: minor fixesJacob Young
2023-07-19llvm: start tracking more things without relying on the llvm apiJacob Young
2023-06-28ld: support -version-scriptMotiejus Jakštys
gettext uses this version and, surely enough, it is supported by lld
2023-06-26default to single-threaded for WebAssemblyLuuk de Gram
When targeting WebAssembly, we default to building a single-threaded build as threads are still experimental. The user however can enable a multi- threaded build by specifying '-fno-single-threaded'. It's a compile-error to enable this flag, but not also enable shared-memory.
2023-06-26wasm-ld: implement `--export-memory` flagLuuk de Gram
This flag allows the user to force export the memory to the host environment. This is useful when the memory is imported from the host but must also be exported. This is (currently) required to pass the memory validation for runtimes when using threads. In this future this may become an error instead.
2023-06-25Recognize the .res extension and link it as if it were an object fileRyan Liptak
.res files are compiled Windows resource files that get linked into executables/libraries. The linker knows what to do with them, but previously you had to trick Zig into thinking it was an object file (by renaming it to have the .obj extension, for example). After this commit, the following works: zig build-exe main.zig resource.res or, in build.zig: exe.addObjectFile("resource.res"); Closes #6488
2023-06-24all: migrate code to new cast builtin syntaxmlugg
Most of this migration was performed automatically with `zig fmt`. There were a few exceptions which I had to manually fix: * `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten * `@truncate`'s fixup is incorrect for vectors * Test cases are not formatted, and their error locations change
2023-06-24Add support for the "--version" linker argument (#16154)Matteo Briani
closes #15549 Co-authored-by: Matteo Briani <matteo.briani@icvox.com>
2023-06-19all: zig fmt and rename "@XToY" to "@YFromX"Eric Joldasov
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-17std: replace builtin.Version with SemanticVersionr00ster91
2023-06-16zig build: add option to only print failed stepsVeikka Tuominen
The motivating case for this is that currently when a test fails the CI log will include ~5k lines of listing steps that succeeded.
2023-06-16migration: std.math.{min, min3, max, max3} -> `@min` & `@max`r00ster91
2023-06-10CLI: introduce --verbose-intern-poolAndrew Kelley
and stop dumping to stderr without the user's consent.
2023-06-03Merge pull request #15579 from squeek502/mem-delimitersAndrew Kelley
Split `std.mem.split` and `tokenize` into `sequence`, `any`, and `scalar` versions