Commit Graph

82 Commits

Author SHA1 Message Date
Michael Dusan
a502c160cd macho: fix various linker flags
fix drivers: zig {cc,c++}
  - `-dynamiclib` is an alias to `-shared`
  - associate `-dynamiclib` with zig `.shared` semantics

fix drivers: zig {cc,c++,build-lib,build-exe}
  - use `-dynamic` for {exe,dylib}
  - for dylib this fixes a regression
  - for exe this replaces incorrect use of `-static`
2021-03-14 17:26:24 -04:00
LemonBoy
72664df491 std: Deprecate the B and Bi format specifiers
Following #8007 and #8137 let's get rid of the last weird format.
2021-03-07 14:58:45 +02:00
Andrew Kelley
041212a41c zig cc: fix handling of -MM flag
Clang docs say:
> Like -MMD, but also implies -E and writes to stdout by default.

Previously, Zig handled this option by forwarding it directly to Clang,
and disabling depfiles. However this did not adhere to Clang's documented
behavior of these flags.

Now, in addition to being forwarded directly to Clang, `-MM` also
sets c_out_mode = .preprocessor, just like `-E`.

Another issue I noticed is that Zig did not recognize the aliases for
-MG, -MM, or -MMD. The aliases are now recognized.
2021-03-04 18:14:00 -07:00
daurnimator
d4af35b3fe HashMap.put returns !void, not a !bool 2021-02-27 13:11:47 +02:00
Andrew Kelley
e197a03124 zig cc: recognize the -s flag to be "strip" 2021-02-07 14:51:27 -07:00
Michael Dusan
8661a13b74
fix superfluous fmt specifier in update_glibc 2021-02-02 10:00:13 -05:00
Michael Dusan
70a7c14ca6
update update_glibc to format strings with "{s}" 2021-02-01 16:57:41 -05:00
Andrew Kelley
102d954220
Merge pull request #7827 from Snektron/spirv-setup
Stage 2: SPIR-V setup
2021-02-01 12:49:51 -08:00
Tadeo Kondrak
0b5f3c2ef9
Replace @TagType uses, mostly with std.meta.Tag 2021-01-30 22:26:44 +02:00
Andrew Kelley
0d4b6ac741 add LTO support
The CLI gains -flto and -fno-lto options to override the default.
However, the cool thing about this is that the defaults are great! In
general when you use build-exe in release mode, Zig will enable LTO if
it would work and it would help.

zig cc supports detecting and honoring the -flto and -fno-lto flags as
well. The linkWithLld functions are improved to all be the same with
regards to copying the artifact instead of trying to pass single objects
through LLD with -r. There is possibly a future improvement here as
well; see the respective TODOs.

stage1 is updated to support outputting LLVM bitcode instead of machine
code when lto is enabled. This allows LLVM to optimize across the Zig and
C/C++ code boundary.

closes #2845
2021-01-23 18:18:07 -07:00
Robin Voetter
fd33530aef SPIR-V: Spec generator 2021-01-19 15:28:17 +01:00
Julian Maingot
384ccaa27a stage2: use %type not @type for libc stubs
Missed a couple places last time so just doing the rest.
2021-01-18 11:04:33 -08:00
Andrew Kelley
5b2a79848c stage2: cleanups regarding red zone CLI flags
* 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-11 22:07:21 -07:00
Jay Petacat
a9b505fa77 Reduce use of deprecated IO types
Related: #4917
2021-01-07 23:48:58 -08:00
xackus
0a6ba6f666 gdb pretty printers for slices and optionals 2020-12-23 20:21:47 +02:00
g-w1
51a904677c
update depreciated code (#7502)
* `zig env`:

* fix depreciated interface, update outStream -> writer
* make code more readable by updating `anytype` -> `std.fs.File.Writer`
2020-12-23 13:01:29 +02:00
Isaac Freund
343249efd8 stage2: use %type not @type for libc stubs
Apparently ARM uses @ for comments. Everything seems to accept % here
though.
2020-12-13 23:19:23 -05:00
Andrew Kelley
4fd27719b4
Merge pull request #7406 from ifreund/dyn-musl2
stage2: support dynamically linking musl libc
2020-12-12 18:46:07 -05:00
Isaac Freund
307d98dc35
stage2: support dynamically linking musl libc 2020-12-13 00:40:35 +01:00
Andrew Kelley
6b7ddfbafe glibc: do not provide -lcrypt
glibc is dropping this functionality moving forward.

This is a partial revert of commit
97c0e1cc41
2020-12-12 12:42:33 -07:00
Andrew Kelley
97c0e1cc41 glibc: additionally provide -lcrypt
also remove redundant "util" string matching.
2020-12-08 13:17:57 -05:00
Andrew Kelley
abc717f203 modernize the PIE patch for the latest master branch
This is the part of #3960 that has to be rewritten to apply to latest
master branch code.
2020-11-22 17:28:11 -07:00
LemonBoy
8eaaa905f7
stage2: Make zig cc more verbose (#7166)
* stage2: Make zig cc more verbose

Make `zig cc` print more info from Clang itself and from our own linker
invocation, this is needed for CMake to properly discover all the
include directories and library search paths.

Closes #7110

* Update `update_clang_options`

* Typo fixes

Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>
2020-11-19 23:30:16 +01:00
Veikka Tuominen
6d5b76a75d
Merge pull request #7005 from jshholland/deprecate-span
Remove ArrayList.span
2020-11-18 13:14:48 +02:00
Josh Holland
c25b157dda remove deprecated uses of ArrayList.span 2020-11-07 11:15:44 +00:00
Andrew Kelley
008dd90f1f update process_headers tool 2020-11-06 13:51:33 -07:00
redj
c0b2813e04
tools/update_clang_options: add zig run usage example. fix src-self-hosted path. (#6635)
* tools/update_clang_options: fix src-self-hosted path now simply src.

* tools/update_clang_options: add zig run usage example.
2020-10-09 23:09:36 -04:00
xavier
eb33394d14 notice more kinds of optimization flags and debug flags
Closes #6091
2020-10-07 18:43:05 -04:00
Andrew Kelley
a337046832 stage2: properly handle zig cc used as a preprocessor
This cleans up how the CLI parses and handles -E, -S, and -c.
Compilation explicitly acknowledges when it is being used to do C
preprocessing.

-S is properly translated to -fno-emit-bin -femit-asm but Compilation
does not yet handle -femit-asm.

There is not yet a mechanism for skipping the linking step when there is
only a single object file, and so to make this work we have to do a file
copy in link.flush() to copy the file from zig-cache into the output
directory.
2020-09-25 20:52:02 -07:00
Andrew Kelley
eeadd55d15 fix tools/process_headers.zig regression
When upgrading to the new std lib HashMap API, the process_headers code
regressed because something that was supposed to be a pointer ended up
being a copy of a value. This resulted in the modification of a field
not being picked up.

Also switch from Sha256 to Blake3 while we're at it.
2020-08-30 21:24:41 -07:00
Jan200101
9605e5363b update update_glibc and process_headers to latest zig 2020-08-22 16:38:03 +03:00
Frank Denis
3edace34d3 Update tools/process_headers.zig 2020-08-21 00:57:29 +02:00
Frank Denis
6f9ea9eaef Breaking: sort std/crypto functions into categories
Instead of having all primitives and constructions share the same namespace,
they are now organized by category and function family.

Types within the same category are expected to share the exact same API.
2020-08-20 23:02:05 +02:00
joachimschmidt557
900a897e90 Update tools/process_headers.zig to latest zig 2020-08-10 21:09:23 -04:00
Cassidy Dingenskirchen
57f1ed5325 Fix a few std.sort.sort invocations 2020-06-12 13:33:31 -04:00
xackus
79bf4003da stage1: add ZigList gdb pretty printing 2020-05-07 12:43:22 -04:00
Andrew Kelley
52db13738b
zig cc looks for native include directories unless -nostdinc
closes #4938
2020-04-04 14:58:24 -04:00
Andrew Kelley
d02838b71a
add libutil to zig's glibc support 2020-04-04 14:43:51 -04:00
Andrew Kelley
e89c42655c
Merge pull request #4868 from xackus/new-arraylist-api
new ArrayList API
2020-04-03 22:31:15 -04:00
Ryan Liptak
08a9ab4d8c Update all remaining uses of &outStream().stream 2020-04-03 12:12:23 -04:00
Andrew Kelley
f8cc6a1917
zig cc: fix ambiguity with -MT
In an MSVC context, `-MT` means
"Use static run-time"
and it is a flag with no parameter.

On POSIX it means
"Specify name of main file output in depfile"
and it is "joined or separate".

The former was interfering with the latter. Now, the MT flag is required
to be specified with a `/` to disambiguate: `/MT`.
2020-04-02 21:15:36 -04:00
Andrew Kelley
c4b3c84b3f
zig cc: support -F and -framework 2020-04-02 15:59:48 -04:00
Andrew Kelley
e4edc6d118
zig cc: respect -MF -MV -MD options
Zig disables its caching and forwards these args when any are provided.

see #4784
2020-04-02 15:47:27 -04:00
xackus
7a28c644aa new ArrayList API: fix everything else 2020-04-02 16:12:08 +02:00
Andrew Kelley
4848b28ec8
zig cc: detect -mcpu, -march, -mtune
However these are all treated like zig's -mcpu parameter.

See #4784
2020-04-01 18:06:04 -04:00
Rejean Loyer
2b6dfdd3d4 zig cc: add support for -L linker arguments 2020-04-01 17:21:11 -04:00
Andrew Kelley
783f73c7e3
zig cc properly handles -S flag and .ll, .bc extensions 2020-04-01 16:01:06 -04:00
Andrew Kelley
cfedd3aca2
revert detection of rtti and exceptions
This caused link errors in c++ code because it was not correct to pass
these flags to child codegens. And that was the only reason to detect
these flags. Otherwise we can safely rely on non-explicitly-detected
flag forwarding.
2020-03-30 17:42:30 -04:00
Andrew Kelley
9e7ae06249
std lib API deprecations for the upcoming 0.6.0 release
See #3811
2020-03-30 14:23:22 -04:00
Ryan Liptak
874b4618ca zig cc: Add support for -z
This is only the first step; it makes zig cc recognize -z and append it to the linker args, but the linker arg parsing doesn't support -z yet so it will just give the warning 'unsupported linker arg: -z'
2020-03-28 00:35:54 -07:00