27339 Commits

Author SHA1 Message Date
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
c9fe43679f frontend: remove deprecated field from Compilation 2024-01-01 17:51:21 -07:00
Andrew Kelley
6beae6c061 frontend: avoid spurious error when no zcu
use_llvm=false does not always mean there needs to be a zig compiler
backend available. In particular, when there is no zig compilation unit,
use_llvm=false and yet no zig backend will be used to produce code.
2024-01-01 17:51:21 -07:00
Andrew Kelley
951c5b3f67 frontend: fix "any" default resolution ambiguity
In Compilation.create, update the resolved config to account for the
default resolution of the root module. This makes it so that, for
example, reading comp.config.any_non_single_threaded is valid in order
to determine whether any module has single_threaded=false.
2024-01-01 17:51:21 -07:00
Andrew Kelley
b8a8fb927b link.File.Elf: bump 32-bit image_base default to 64K
Now that we always pass --image-base to LLD, including when Zig chooses
the default value, LLD is complaining about 32-bit architectures because
it requires being at least equal to the max page size, which is 64K.
2024-01-01 17:51:21 -07:00
Andrew Kelley
4c07d41b52 CLI: fix logic for zig test error message
When using the build system to do unit testing, it lowers to --mod
arguments which were incorrectly tripping a "zig test requires a source
file argument" error.
2024-01-01 17:51:21 -07:00
Andrew Kelley
b36659c972 fix MachO linking
* fix relationship between createEmpty/open (similar logic as
  607111aa758002bc51914b7dc800b23927c931b8)
* still resolve the start symbol when linking libc because when zig is
  the linker it still needs to know the entry symbol.
* make use_llvm=false when there is no zig compilation unit.
2024-01-01 17:51:21 -07:00
Andrew Kelley
944b0ef518 link.File.Coff: fix relationship between createEmpty/open
similar commit to b0c433c80f2e4edd7b60e444b4ea56dacb727051
2024-01-01 17:51:21 -07:00
Andrew Kelley
98dd4f7847 frontend: skip astgen for builtin.zig
since it's already done ahead of time and always unchanging
2024-01-01 17:51:21 -07:00
Andrew Kelley
4f8a44cd0f compiler: fix UAF when writing builtin.zig 2024-01-01 17:51:21 -07:00
Andrew Kelley
44e2dbe117 fix logic for default entry point
when linking libc, the entry point is within libc.
when producing C code, the entry point is decided when compiling the C
code and does not need to be known up front.

fixes a false positive "error: unknown target entry point" when using
-ofmt=c.
2024-01-01 17:51:21 -07:00
Andrew Kelley
1edcea9ec8 link.Wasm: fix relationship between createEmpty/open 2024-01-01 17:51:21 -07:00
Andrew Kelley
981166e33f link.Elf: truncate=true in createEmpty 2024-01-01 17:51:21 -07:00
Andrew Kelley
4d28db7329 Zcu: mark outdated decl handling as unreachable from only_c builds
This way we don't drag in linker code into only_c builds that doesn't
need to be there.
2024-01-01 17:51:21 -07:00
Andrew Kelley
edccd68adf Package.Module: fix typo in default red-zone setting
oops, this was supposed to return true, not false.
2024-01-01 17:51:21 -07:00
Andrew Kelley
41ab64c3eb Compilation.Config.resolve: explicit error set
Some logic has comptime-known conditions, causing the inferred error set
to be different on different compiler build configurations.
2024-01-01 17:51:21 -07:00
Andrew Kelley
8cf2cfc52c update bootstrap scripts to new zig CLI
Now they use the new --mod --dep parameters.
2024-01-01 17:51:21 -07:00
Andrew Kelley
24eec48f60 CLI: update main usage text
* Organize and reword some stuff
* Add missing usage for `zig reduce`
2024-01-01 17:51:21 -07:00
Andrew Kelley
9141e1a29c CLI: fix logic for sending output file path
via the compiler protocol
2024-01-01 17:51:21 -07:00
Andrew Kelley
e12e296306 CLI: fix not respecting module remappings 2024-01-01 17:51:21 -07:00
Andrew Kelley
3262e9ccee zig build: fix logic for extracting executable file from Compilation 2024-01-01 17:51:21 -07:00
Andrew Kelley
3b36c4d0b3 zig build: pass resolved_target to Module.create
it's now required to pass this for the root module
2024-01-01 17:51:21 -07:00
Andrew Kelley
056f04c1ff CLI: rename clang_argv to cc_argv
The args apply to Aro as well.
2024-01-01 17:51:21 -07:00
Andrew Kelley
fad35835aa CLI: better error messages for bad args 2024-01-01 17:51:20 -07:00
Andrew Kelley
76c4781578 std.Build.Step.Options: update unit test to new API 2024-01-01 17:51:20 -07:00
Andrew Kelley
529d01c2ba resolve error tracing logic at module creation time
rather than checking multiple conditions in Sema
2024-01-01 17:51:20 -07:00
Andrew Kelley
8944dea23f CLI: fix regressed logic for any_dyn_libs
This value needs access to the fully resolved set of system libraries,
which required restructuring a bunch of CLI logic.
2024-01-01 17:51:20 -07:00
Andrew Kelley
db2ca2ca00 CLI: mark any_dyn_libs=true when encountering a shared object 2024-01-01 17:51:20 -07:00
Andrew Kelley
ca77c3bacc std.Build.Step.Compile: restore previous step name
Print using the target query rather than the resolved target. This makes
it print "native" when compiling for the native target.
2024-01-01 17:51:20 -07:00
Andrew Kelley
4b667e7362 fix compilations without zig compilation units 2024-01-01 17:51:20 -07:00
Andrew Kelley
fe87bae7e3 frontend: fix handling of special builtin module
it's allocated differently and imported differently
2024-01-01 17:51:20 -07:00
Andrew Kelley
90cc408c14 fix --show-builtin when no positional argument is provided 2024-01-01 17:51:20 -07:00
Andrew Kelley
38f2172b0a fix memory leak in addModuleTableToCacheHash 2024-01-01 17:51:20 -07:00
Andrew Kelley
a3ff4d9b45 fix entry symbol name on mips 2024-01-01 17:51:20 -07:00
Andrew Kelley
2d2a18831e linker: rename intermediary_basname to zcu_object_sub_path 2024-01-01 17:51:20 -07:00
Andrew Kelley
9b98d33d0b Compilation: don't store arena until it's done being used 2024-01-01 17:51:20 -07:00
Andrew Kelley
f256431838 fix compilation errors when enabling llvm 2024-01-01 17:51:20 -07:00
Andrew Kelley
57afdfc8fa compilation: fix build artifact communication from sub-compilation
in whole cache mode, build artifacts are communicated by accessing the
whole cache information, for which there is a helper method called
toCrtFile
2024-01-01 17:51:20 -07:00
Andrew Kelley
b1fc3fe1c4 Elf: fix invalid free of path field
It's now arena-allocated so no need to free it with gpa
2024-01-01 17:51:20 -07:00
Andrew Kelley
e3409c0bce Elf: fix createEmpty not creating the file 2024-01-01 17:51:20 -07:00
Andrew Kelley
0be97b5ae3 fix population of builtin.zig not making the parent dir 2024-01-01 17:51:20 -07:00
Andrew Kelley
d71e6273b6 std.fs.Dir.atomicFile: provide an option for make path
It's useful for the API to support creating the parent directory.
2024-01-01 17:51:20 -07:00
Andrew Kelley
9715936472 Compilation: oops! used comp before init 2024-01-01 17:51:20 -07:00
Andrew Kelley
b6dd5ad357 MachO: rip out the caching mechanism
This is redundant with CacheMode.whole which caches everything,
including linking output. Linker code does not need to concern itself
with caching like this.
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
4629708787 linker: fix some allocator references 2024-01-01 17:51:20 -07:00
Andrew Kelley
48d5861f92 fix more compilation errors introduced by this branch 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