89 Commits

Author SHA1 Message Date
Alex Rønne Petersen
8af82621d7
compiler: Improve the handling of unwind table levels.
The goal here is to support both levels of unwind tables (sync and async) in
zig cc and zig build. Previously, the LLVM backend always used async tables
while zig cc was partially influenced by whatever was Clang's default.
2024-12-11 00:10:15 +01:00
Alex Rønne Petersen
baf60426d4
std.Target: Rename amdgpu module to amdgcn.
This was an inconsistency left over from c825b567b26c475e058e074e5d22af006854fab6.
2024-11-02 10:44:14 +01:00
Maciej 'vesim' Kuliński
feaee2ba17 cc: Add support for -Wp, 2024-09-17 23:54:04 -07:00
Alex Rønne Petersen
95bb53653d zig cc: Support -rtlib=none for disabling compiler-rt. 2024-09-09 10:47:35 -07:00
mlugg
0fe3fd01dd
std: update std.builtin.Type fields to follow naming conventions
The compiler actually doesn't need any functional changes for this: Sema
does reification based on the tag indices of `std.builtin.Type` already!
So, no zig1.wasm update is necessary.

This change is necessary to disallow name clashes between fields and
decls on a type, which is a prerequisite of #9938.
2024-08-28 08:39:59 +01:00
Andrew Kelley
26d2a7960e default "trace pc guard" coverage off
* Add -f(no-)sanitize-coverage-trace-pc-guard CLI flag which defaults to
  off. This value lowers to TracePCGuard = true (LLVM backend) and -Xclang
  -fsanitize-coverage-trace-pc-guard. These settings are not
  automatically included with -ffuzz.
* Add `Build.Step.Compile` flag for sanitize_coverage_trace_pc_guard
  with appropriate documentation.
* Add `zig cc` integration for the respective flags.
* Avoid crashing in ELF linker code when -ffuzz -femit-llvm-ir used
  together.
2024-07-23 17:30:53 -07:00
Andrew Kelley
f47824f24d std: restructure child process namespace 2024-05-26 09:31:55 -07:00
Andrew Kelley
21f1e76efe zig cc: update clang CLI data to LLVM 18
release/18.x branch, commit 78b99c73ee4b96fe9ce0e294d4632326afb2db42
2024-05-08 19:37:28 -07:00
Elaine Gibson
add74427b9 mingw: support -municode 2024-03-27 10:05:57 +00:00
Jakub Konka
92deebcd66 cli+build: handle -ObjC flag and route it to MachO linker 2024-02-02 22:00:16 +01:00
Jan Philipp Hafer
fd2239bde9 child_process + Build: rename exec to run + all related code
Justification: exec, execv etc are unix concepts and portable version
should be called differently.

Do no touch non-Zig code. Adjust error names as well, if associated.
Closes #5853.
2023-10-22 14:47:20 -04:00
Jakub Konka
8b4e3b6aee comp: add support for -fdata-sections 2023-10-04 11:21:56 -07:00
mlugg
f26dda2117 all: migrate code to new cast builtin syntax
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-24 16:56:39 -07:00
Eric Joldasov
50339f595a all: zig fmt and rename "@XToY" to "@YFromX"
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-19 12:34:42 -07:00
Josh Wolfe
32cb9462ff
std: Support user-provided jsonParse method. Unify json.Parser and json.parse* (#15705) 2023-06-19 11:21:37 -04:00
Ali Chraghi
3db3cf7790 std.sort: add pdqsort and heapsort 2023-05-23 17:55:59 -07:00
Josh Wolfe
018b743c7a
std: Rewrite low-level json api to support streaming (#15602) 2023-05-13 14:31:53 -04:00
Andrew Kelley
ceff278202 fixes to the previous commit
* CompileStep: Avoid calling producesPdbFile() to determine whether the
   option should be respected. If the user asks for it, put it on the
   command line and let the Zig CLI deal with it appropriately.
 * Make the namespace of `std.dwarf.Format.dwarf32` no longer have a
   redundant "dwarf" in it.
 * Add `zig cc` integration for `-gdwarf32` and `-gdwarf64`.
 * Toss in a bonus bug fix for `-gdwarf-2`, `-gdwarf-3`, etc.
 * Avoid using default init values for struct fields unnecessarily.
 * Add missing cache hash addition for the new option.
2023-04-20 15:17:07 -07:00
Andrew Kelley
c22a30ac99 zig cc: handle the -r flag
This makes -r treated the same as -c which is to output an object file.
Zig's ELF linker code already handles multiple object files into an
object file with the -r flag to LLD.

closes #11683
2023-04-08 15:48:27 -04:00
Andrew Kelley
f289277599 Merge remote-tracking branch 'origin/master' into llvm16 2023-04-05 22:05:31 -07:00
Jakub Konka
a88c0b4d08 link: handle -u flag in all linkers
Also clean up parsing of linker args - reuse `ArgsIterator`.

In MachO, ensure we add every symbol marked with `-u` as undefined
before proceeding with symbol resolution. Additionally, ensure those
symbols are never garbage collected.

MachO entry_in_dylib test: pass `-u _my_main` when linking executable
so that it is not incorrectly garbage collected by the linker.
2023-04-01 14:22:44 +02:00
Andrew Kelley
b5b634e4e8 Merge remote-tracking branch 'origin/master' into llvm16 2023-02-19 10:20:19 -07:00
Andrew Kelley
aeaef8c0ff update std lib and compiler sources to new for loop syntax 2023-02-18 19:17:21 -07:00
Andrew Kelley
56311b8bbb update clang options data to LLVM 16 2023-01-26 16:49:49 -07:00
Motiejus Jakštys
6b3f59c3a7 zig run/cc: recognize "-x language"
This commit adds support for "-x language" for a couple of hand-picked
supported languages. There is no reason the list of supported languages
to not grow (e.g. add "c-header"), but I'd like to keep it small at the
start.

Alternative 1
-------------

I first tried to add a new type "Language", and then add that to the
`CSourceFile`. But oh boy what a change it turns out to be. So I am
keeping myself tied to FileExt and see what you folks think.

Alternative 2
-------------

I tried adding `Language: ?[]const u8` to `CSourceFile`. However, the
language/ext, whatever we want to call it, still needs to be interpreted
in the main loop: one kind of handling for source files, other kind of
handling for everything else.

Test case
---------

*standalone.c*

    #include <iostream>

    int main() {
        std::cout << "elho\n";
    }

Compile and run:

    $ ./zig run -x c++ -lc++ standalone.c
    elho
    $ ./zig c++ -x c++ standalone.c -o standalone && ./standalone
    elho

Fixes #10915
2023-01-13 21:38:11 -05:00
Jakub Konka
e9e804edc8 Add missing clang opts: -install_name and -undefined 2022-12-18 15:52:51 +01:00
Andrew Kelley
4f9345d20b Revert "adding static and dynamic ZigEquivalent
enums so that we can branch to set `link_mode` properly when we iterate
over the clang arguments. also replaced `dynamic` flag in
clang_options_data.zig with proper definition similarly to `static`."

This reverts commit 6af0eeb58d1d220d407ce4c463eaeb25b35f2761.

This change needs more careful consideration. It regressed
zig-bootstrap due to cmake passing `-static -lkernel32` and zig failing
with error.UnableToStaticLink.

See https://github.com/ziglang/zig-bootstrap/issues/134
2022-10-18 14:16:07 -07:00
cod1r
6af0eeb58d adding static and dynamic ZigEquivalent enums so that we can branch to set link_mode properly when we iterate over the clang arguments. also replaced dynamic flag in clang_options_data.zig with proper definition similarly to static. 2022-10-13 13:12:17 +02:00
Andrew Kelley
de7270028d Merge remote-tracking branch 'origin/master' into llvm15 2022-08-29 14:10:59 -07:00
Andrew Kelley
c0b7f20893 stage2: implement stack protectors
This is one of the final remaining TODOs for the LLVM backend.
2022-08-19 03:41:13 -07:00
Jakub Konka
a0ec07fdec cc: add support for -M flag 2022-08-08 14:26:10 +02:00
Jakub Konka
80c9d3f3b1 update update_clang_options.zig to latest formatting changes 2022-08-08 14:25:45 +02:00
Andrew Kelley
d631bfe060 update clang CLI options to LLVM 15 2022-08-02 19:43:38 -07:00
Andrew Kelley
2b99182e25 stage2: cleanups to --compress-debug-sections
* make the setting in the linker backend be non-optional; by this time
   all defaults are supposed to be resolved.
 * integrate with `zig cc`
 * change the CLI parsing to match C compiler parsing, allowing
   `--compress-debug-sections` alone to choose a default encoding of
   zlib.
2022-07-11 14:18:56 -07:00
Andrew Kelley
2ee864ca5e CLI: add support for -fno-builtin 2022-07-05 15:21:20 -07:00
Jakub Konka
5735ce39ae clang: parse --verbose flag as -v 2022-07-03 09:43:01 +02:00
Jakub Konka
7cc4176448 clang: add Zig equivalent for -headerpad_max_install_names cli flag 2022-06-29 17:21:32 +02:00
Jakub Konka
c2c1998269 clang: update cmdline options to include weak libs and frameworks
Clang accepts `-weak-lx`, `-weak_library x` and `-weak_framework x`.
2022-06-28 21:16:23 +02:00
Andrew Kelley
d3648cc030 zig cc: integrate with -fstack-check, -fno-stack-check 2022-03-04 18:10:37 -07:00
Andrew Kelley
fd6d1fe015 stage2: improvements to entry point handling
* rename `entry` to `entry_symbol_name` for the zig build API
 * integrate with `zig cc` command line options
 * integrate with COFF linking with LLD
 * integrate with self-hosted ELF linker
 * don't put it in the hash for MachO since it is ignored
2022-01-19 11:41:08 -07:00
Jakub Konka
6d9c02a54f
zig cc: integration with sysroot arg (#10568)
Prior to this change, even if the use specified the sysroot on the
compiler line like so

```
zig cc --sysroot=/path/to/sdk
```

it would only be used as a prefix to include paths and not as a prefix
for `zig ld` linker.
2022-01-11 12:41:26 -05:00
Lee Cannon
1093b09a98
allocgate: renamed getAllocator function to allocator 2021-11-30 23:32:47 +00:00
Lee Cannon
75548b50ff
allocgate: stage 1 and 2 building 2021-11-30 23:32:47 +00:00
Andrew Kelley
b097545a5f zig cc: honor all -m and -mno- CPU feature flags
closes #9196
2021-11-26 19:59:33 -07:00
Andrew Kelley
96e5f661bd zig cc: add -fcolor-diagnostics and -fcaret-diagnostics integration
Closes #6290
2021-11-21 17:07:18 -07:00
Andrew Kelley
ceeb230c23 zig cc: add -ffunction-sections integration
Also update to latest LLVM 13 command line options.

See #6290
2021-11-21 17:01:07 -07:00
Lee Cannon
b15d6b2a34 Add build.zig and command line flags 2021-10-16 21:55:51 +01:00
Andrew Kelley
d11f42c2b2 zig cc: support -S and -emit-llvm CLI parameters
closes #6425
2021-09-16 16:39:04 -07:00
Andrew Kelley
e41e75a486 stage2: update for new usingnamespace semantics 2021-09-01 17:54:07 -07:00
Jacob G-W
9fffffb07b fix code broken from previous commit 2021-06-21 17:03:03 -07:00