344 Commits

Author SHA1 Message Date
Alex Rønne Petersen
642cd730c8 link: Accept -Brepro linker option and pass it to LLD.
Enable it by default when building Zig code in release modes.

Contributes to #9432.
2024-07-28 14:37:03 +02:00
Jakub Konka
cba3389d90 macho: redo input file parsing in prep for multithreading 2024-07-22 12:05:56 +02:00
Andrew Kelley
b5f3d12164
Merge pull request #20688 from ziglang/incr-test
introduce a new tool for testing incremental compilation
2024-07-20 13:04:49 -07:00
Jacob Young
2e65244cae dev: fix llvm backend checks 2024-07-20 07:43:40 -04:00
Andrew Kelley
eb4028bf30 add std.fmt.hex
converts an unsigned integer into an array
2024-07-20 01:06:29 -07:00
Jacob Young
4f742c4cfc dev: introduce dev environments that enable compiler feature sets 2024-07-19 22:35:33 -07:00
Jacob Young
166402c16b bootstrap: fix build 2024-07-07 22:59:52 -04:00
Jacob Young
ca02266157 Zcu: pass PerThread to intern pool string functions 2024-07-07 22:59:52 -04:00
Jacob Young
525f341f33 Zcu: introduce PerThread and pass to all the functions 2024-07-07 22:59:52 -04:00
Jacob Young
00da182e68
cbe: fix for export changes 2024-07-04 21:01:42 +01:00
mlugg
2f0f1efa6f
compiler: type.zig -> Type.zig 2024-07-04 21:01:42 +01:00
mlugg
ded5c759f8
Zcu: store LazySrcLoc in error messages
This change modifies `Zcu.ErrorMsg` to store a `Zcu.LazySrcLoc` rather
than a `Zcu.SrcLoc`. Everything else is dominoes.

The reason for this change is incremental compilation. If a failed
`AnalUnit` is up-to-date on an update, we want to re-use the old error
messages. However, the file containing the error location may have been
modified, and `SrcLoc` cannot survive such a modification. `LazySrcLoc`
is designed to be correct across incremental updates. Therefore, we
defer source location resolution until `Compilation` gathers the compile
errors into the `ErrorBundle`.
2024-07-04 21:01:41 +01:00
mlugg
7e552dc1e9
Zcu: rework exports
This commit reworks our representation of exported Decls and values in
Zcu to be memory-optimized and trivially serialized.

All exports are now stored in the `all_exports` array on `Zcu`. An
`AnalUnit` which performs an export (either through an `export`
annotation or by containing an analyzed `@export`) gains an entry into
`single_exports` if it performs only one export, or `multi_exports` if
it performs multiple.

We no longer store a persistent mapping from a `Decl`/value to all
exports of that entity; this state is not necessary for the majority of
the pipeline. Instead, we construct it in `Zcu.processExports`, just
before flush. This does not affect the algorithmic complexity of
`processExports`, since this function already iterates all exports in
the `Zcu`.

The elimination of `decl_exports` and `value_exports` led to a few
non-trivial backend changes. The LLVM backend has been wrangled into a
more reasonable state in general regarding exports and externs. The C
backend is currently disabled in this commit, because its support for
`export` was quite broken, and that was exposed by this work -- I'm
hoping @jacobly0 will be able to pick this up!
2024-07-04 21:01:41 +01:00
Andrew Kelley
0fcd59eada rename src/Module.zig to src/Zcu.zig
This patch is a pure rename plus only changing the file path in
`@import` sites, so it is expected to not create version control
conflicts, even when rebasing.
2024-06-22 22:59:56 -04:00
Andrew Kelley
f97c2f28fd update the codebase for the new std.Progress API 2024-05-27 20:56:48 -07:00
Andrew Kelley
f47824f24d std: restructure child process namespace 2024-05-26 09:31:55 -07:00
Jacob Young
5bbb2f966a link: restore lost passthrough behavior
Fixes bug introduced by 3b5be9fb6e06f6494ca05fb087a2121e220beb3f
2024-05-04 11:03:45 -04:00
Jacob Young
3b5be9fb6e lld: use a response file on NameTooLong 2024-05-03 13:27:04 -07:00
Jacob Young
eb723a4070 Update uses of @fieldParentPtr to use RLS 2024-03-30 20:50:48 -04:00
Jacob Young
e409afb79b Update uses of @fieldParentPtr to pass a pointer type 2024-03-30 20:50:48 -04:00
mlugg
a61def10c6
compiler: eliminate most usages of TypedValue 2024-03-26 13:48:07 +00:00
Andrew Kelley
cd62005f19 extract std.posix from std.os
closes #5019
2024-03-19 11:45:09 -07:00
Tristan Ross
9d70d614ae
std.builtin: make link mode fields lowercase 2024-03-11 07:09:10 -07:00
Dillen Meijboom
377ecc6afb feat: add support for --enable-new-dtags and --disable-new-dtags 2024-03-06 17:52:05 -08:00
Andrew Kelley
a4380a30f5 move zig libc command to be lazily built
part of #19063

This is a prerequisite for doing the same for Resinator.
2024-02-27 22:55:00 -07:00
antlilja
f6d275b14e LLVM: Remove use of LLVM in Builder 2024-02-21 17:53:15 +01:00
Andrew Kelley
0183b44bb1 std.os.windows: add error.UnrecognizedVolume
Thanks to @matklad for finding this additional NTSTATUS possibility when
calling GetFinalPathNameByHandle.
2024-02-16 00:20:57 -08:00
Jakub Konka
92deebcd66 cli+build: handle -ObjC flag and route it to MachO linker 2024-02-02 22:00:16 +01:00
Jakub Konka
ee7a027059 macho: parse dependent dylibs 2024-01-24 12:34:39 +01:00
Xavier Bouchoux
1a98fcd00a zig cc: expose clang precompiled C header support
see https://releases.llvm.org/17.0.1/tools/clang/docs/UsersManual.html#generating-a-pch-file

syntax examples:
`zig cc -x c-header test.h -o test.pch`
`zig cc -include-pch test.pch main.c`

`zig c++ -x c++-header test.h -o test.pch`
`zig c++ -include-pch test.pch main.cpp`
2024-01-19 22:05:09 -08:00
Jan200101
8707555c0b compiler: move each_lib_rpath to frontend
Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2024-01-14 16:16:00 -07:00
dhash
9bb6430318 Add support for --(no-)undefined-version
Co-authored-by: Motiejus Jakštys <motiejus@jakstys.lt>
Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>
Co-authored-by: Samuel Cantero <scanterog@gmail.com>
Co-authored-by: Giorgos Georgiou <giorgos.georgiou@datadoghq.com>
Co-authored-by: Carl Åstholm <carl@astholm.se>
2024-01-09 17:24:11 +01:00
Andrew Kelley
d5c1e7f7b1 link: accept the update arena in flush
This branch introduced an arena allocator for temporary allocations in
Compilation.update. Almost every implementation of flush() inside the
linker code was already creating a local arena that had the lifetime of
the function call. This commit passes the update arena so that all those
local ones can be deleted, resulting in slightly more efficient memory
usage with every compilation update.

While at it, this commit also removes the Compilation parameter from the
linker flush function API since a reference to the Compilation is now
already stored in `link.File`.
2024-01-01 19:49:08 -07:00
Andrew Kelley
b8674910d4 restore -fno-emit-bin -femit-llvm-ir functionality
Now, link.File will always be null when -fno-emit-bin is specified, and
in the case that LLVM artifacts are still required, the Zcu instance has
an LlvmObject.
2024-01-01 19:49:08 -07:00
Andrew Kelley
6509c492ad move misc_errors from linker to Compilation
So that they can be referenced by getAllErrorsAlloc(). Fixes missing
compile errors.
2024-01-01 19:49:07 -07:00
Andrew Kelley
372b407740 move eh_frame_hdr from link.File to Compilation
since it's accessed by Compilation. fixes an invalid check of
bin_file==null
2024-01-01 19:49:07 -07:00
Andrew Kelley
435b74acd6 move force_undefined_symbols into Compilation
This field is needed by Compilation regardless of whether a link file is
instantiated.

Fixes an invalid check for bin_file=null.
2024-01-01 19:49:07 -07:00
Andrew Kelley
524dc756b3 Compilation: several branch regression fixes
* move wasi_emulated_libs into Compilation
  - It needs to be accessed from Compilation, which needs to potentially
    build those artifacts.
* Compilation: improve error reporting for two cases
  - the setMiscFailure mechanism is handy - let's use it!
* fix one instance of incorrectly checking for emit_bin via
  `comp.bin_file != null`. There are more instances of this that need to
  be fixed in a future commit.
* fix renameTmpIntoCache not handling the case where it needs to make
  the "o" directory in the zig-cache directory.
  - while I'm at it, simplify the logic for handling the fact that
    Windows returns error.AccessDenied rather than
    error.PathAlreadyExists for failure to rename a directory over
    another one.
* fix missing cache hash additions
  - there are still more to add in a future commit -
    addNonIncrementalStuffToCacheManifest is called when bin_file is
    always null, and then it incorrectly checks if bin_file is non-null
    and only then adds a bunch of stuff to the cache hash. It needs to
    instead add to the cache hash based on lf_open_opts.
2024-01-01 17:51:21 -07:00
Andrew Kelley
57562c8d50 compiler: push entry symbol name resolution into the linker
This is necessary because on COFF, the entry symbol name is not known
until the linker has looked at the set of global symbol names to
determine which of the four possible main entry points is present.
2024-01-01 17:51:21 -07:00
Andrew Kelley
2d2a18831e linker: rename intermediary_basname to zcu_object_sub_path 2024-01-01 17:51:20 -07:00
Andrew Kelley
2047a6b82d fix remaining compile errors except one 2024-01-01 17:51:20 -07:00
Andrew Kelley
638db680f4 move dll_export_fns and rdynamic to Compilation.Config 2024-01-01 17:51:20 -07:00
Andrew Kelley
b54ad93175 update codegen.llvm references to bin_file.options 2024-01-01 17:51:19 -07:00
Andrew Kelley
c49957dbe8 fix a round of compile errors caused by this branch 2024-01-01 17:51:19 -07:00
Andrew Kelley
f54471b54c compiler: miscellaneous branch progress
implement builtin.zig file population for all modules rather than
assuming there is only one global builtin.zig module.

move some fields from link.File to Compilation
move some fields from Module to Compilation

compute debug_format in global Compilation config resolution

wire up C compilation to the concept of owner modules

make whole cache mode call link.File.createEmpty() instead of
link.File.open()
2024-01-01 17:51:19 -07:00
Andrew Kelley
769dea6e37 Compilation: redo whole vs incremental logic in create and update 2024-01-01 17:51:19 -07:00
Andrew Kelley
33cdf33b95 compiler: update many references to bin_file.options 2024-01-01 17:51:19 -07:00
Andrew Kelley
41a8f5aec3 remove parent_compilation_link_libc 2024-01-01 17:51:19 -07:00
Andrew Kelley
0789e91eeb linkers: update references to "options" field 2024-01-01 17:51:19 -07:00
Andrew Kelley
3b6cb257df update image_base references 2024-01-01 17:51:19 -07:00