Commit Graph

27722 Commits

Author SHA1 Message Date
Jakub Konka
6b617afe2a macho: resolve synthetic symbols 2024-01-24 12:34:39 +01:00
Jakub Konka
8a1311733b macho: resolve symbols and mark files live 2024-01-24 12:34:39 +01:00
Jakub Konka
b8f67d7985 macho: init InternalObject and add forced undefined globals 2024-01-24 12:34:39 +01:00
Jakub Konka
8c7a34ae68 macho: prep for dylib deps (no resolution yet) 2024-01-24 12:34:39 +01:00
Jakub Konka
c023b762cd macho: parse tbds 2024-01-24 12:34:38 +01:00
Jakub Konka
d153bc2f0c macho: parse dylibs 2024-01-24 12:34:38 +01:00
Jakub Konka
c5e509595a macho: parse archives 2024-01-24 12:34:38 +01:00
Jakub Konka
d05e9c3792 macho: create scaffolding for parsing different input objects 2024-01-24 12:34:38 +01:00
Jakub Konka
0c171afab0 macho: parse an input object file! 2024-01-24 12:34:38 +01:00
Jakub Konka
7588eeccea macho: re-enable --verbose-link 2024-01-24 12:34:38 +01:00
Jakub Konka
dd0addab1f macho: get the ball rolling! 2024-01-24 12:34:38 +01:00
Jakub Konka
2f94dc939e macho: copy over new implementation sources from zld 2024-01-24 12:34:38 +01:00
Andrew Kelley
92211135f1
Merge pull request #17155 from winterqt/ignore-nix-ldflags-linkage-directives
std.zig.system.NativePaths: ignore linkage directives in `NIX_LDFLAGS`
2024-01-24 00:01:23 -08:00
Andrew Kelley
9d5a133f18 Revert "Don't assume a write if an operand is not in function parameters"
This reverts commit 2ab78937dd.

Premature merge - apologies for the disruption.

Reopens #15685
Reopens #17580
2024-01-23 20:24:58 -07:00
Rahul Prabhu
2ab78937dd Don't assume a write if an operand is not in function parameters
Liveness assumes that if the operand is not in the parameters of
a function call it is being written to, resulting in pointless memcpies.
2024-01-23 18:32:34 -08:00
Krzysztof Wolicki
eff58d6c18 os.windows: Fix error 258 name in Win32Error 2024-01-23 18:06:23 -08:00
Andrew Kelley
f37513aa68 NativePaths: support -L and -l arguments in NIX_LDFLAGS
A slightly more robust parsing of these flags in case of a separate
argument appearing after "-L" in the flags.
2024-01-23 18:01:59 -07:00
Winter
6f3ee587ba std.zig.system.NativePaths: ignore linkage directives in NIX_LDFLAGS
`NIX_LDFLAGS` typically contains just `-rpath` and `-L`, which we already
handle. However, at least one setup hook in Nixpkgs [0] adds a linkage
directive to it. To prevent library paths from being missed (as I've
observed myself with `NIX_LDFLAGS` being `-liconv ...`, making it so that
*all* paths are missed), let's just skip over them.

[0]: 08f615eb1b/pkgs/development/libraries/libiconv/setup-hook.sh
2024-01-23 17:49:25 -07:00
Khang Nguyen Duy
993a83081a std.fmt: fix unecessary deref on user-defined format function
When formatting a pointer to user type, currently it needs to be
dereferenced first, then call `formatType` on the child type.

Fix the problem by checking for "format" function on not only the type
itself, but also the struct it points to. Add hasMethod to std.meta.
2024-01-23 01:03:45 -08:00
Andrew Kelley
aef1da1634 Sema: use Sema.typeAbiSize rather than Type.abiSize
This resolves the type instead of asserting that the type is resolved,
fixing a crash.
2024-01-23 00:56:52 -08:00
Tristan Ross
c0e0bb385c std.process: return u64 in totalSystemMemory 2024-01-23 00:17:53 -08:00
jacwil
68ea1121fc objcopy ofmt=hex iterates through segments instead of sections 2024-01-22 21:29:21 -08:00
Veikka Tuominen
eeec34ccb6 Sema: implement comptime error return traces 2024-01-22 18:08:56 -08:00
ndbn
9e684e8d1a
Fix wrong if condition for windows (#18637)
Fixes #18594
2024-01-22 15:32:23 -05:00
Littleote
3331c5e7af Free threads in std.Thread.Pool.init only with pool.join
Free the allocated threads in the initialization of a thread pool only with pool.join instead of additionally calling allocator.free causing free to be called twice.

Resolves #18643
2024-01-22 11:24:35 -08:00
Tristan Ross
d0da3d731e std.io: replace readStructBig with readStructEndian 2024-01-22 10:53:27 -08:00
Andrew Kelley
b0c8a3f316
Merge pull request #18644 from ziglang/langref 2024-01-22 02:26:46 -08:00
Andrew Kelley
ce7c66e2d0 langref: make more consistent
* moves some langref into std.builtin doc comments
* use the same way of referencing stuff from std.builtin

closes #16483
2024-01-21 20:39:50 -07:00
Andrew Kelley
1b8e6b8ba9 langref: clean up the table of operators
* remove whitespace
* add column for name
* rename "description" to "remarks"
* clarify bit shift left and bit shift right

closes #17126
2024-01-21 20:31:13 -07:00
Andrew Kelley
f29217ae0c langref: reduce verbosity of string literal section 2024-01-21 20:31:13 -07:00
Andrew Kelley
9be831e15a langref: remove line numbers from code samples
It's unnecessary, more complicated, bloated, and it messes up the table
of operators.
2024-01-21 20:31:13 -07:00
Andrew Kelley
a054c01f5c Revert "langref: add section numbers"
This reverts commit 3542dbf0ea.

I don't like them
2024-01-21 20:31:13 -07:00
Andrew Kelley
e9c7ebe79e langref: simplify Hello World section
reverts f510f38592
2024-01-21 20:31:13 -07:00
Andrew Kelley
6fef362992 Revert "langref: emphasize the use of dereferencing string literals"
This reverts commit 27353bb936.

* unnecessary example
* poor phrasing (avoid "you")
2024-01-21 20:31:13 -07:00
Andrew Kelley
2d9c4792ae std.fmt: clarify the use of "character"
Currently, std.fmt has a misguided, half-assed Unicode implementation
with an ambiguous definition of the word "character". This commit does
almost nothing to mitigate the problem, but it lets me close an open PR.

In the future I will revert 473cb1fd74 as
well as 279607cae5, and redo the whole
std.fmt API, breaking everyone's code and unfortunately causing nearly
every Zig user to have a bad day. std.fmt will go back to only dealing
in bytes, with zero Unicode awareness whatsoever. I suggest a third
party package provide Unicode functionality as well as a more advanced
text formatting function for when Unicode awareness is needed. I have
always suggested this, and I sincerely apologize for merging pull
requests that compromised my stance on this matter.

Most applications should, instead, strive to make their code independent
of Unicode, dealing strictly in encoded UTF-8 bytes, and never attempt
operations such as: substring manipulation, capitalization, alignment,
word replacement, or column number calculations.

Exceptions to this include web browsers, GUI toolkits, and terminals. If
you're not making one of these, any dependency on Unicode is probably a
bug or worse, a poor design decision.

closes #18536
2024-01-21 20:31:13 -07:00
Andrew Kelley
559bbf1cc6 langref: explicitly mention inline combined with multiple cases
closes #18524
2024-01-21 20:31:13 -07:00
Ian Johnson
fdb4eb3056 langref: add information about doctests
This creates a section in the language reference about doctests, which
is currently referenced by Autodoc in a tooltip when displaying a
doctest.

Some advice relevant to writing doctests is included, based on the
discussion on #16472.
2024-01-21 19:28:52 -08:00
Andrew Kelley
ac29303321
Merge pull request #18634 from MrDmitry/bug/ConfigHeader_cmake_neighbors
std.Build.Step.ConfigHeader (cmake): fix offset calculation for multiple substitutions on a single line
2024-01-21 12:45:21 -08:00
Christiano Haesbaert
bf7ebfa67a Handle all errors on std.net.Ipv4address.resolveIP
The following test fails since NonCanonical is not handled

test "foo" {
    std.net.Ip4Address.resolveIp("1.1.1.1", 0) catch unreachable;
}

/usr/lib/zig/std/net.zig:240:60: error: switch must handle all possibilities
        if (parse(name, port)) |ip4| return ip4 else |err| switch (err) {
                                                           ^~~~~~
/usr/lib/zig/std/net.zig:240:60: note: unhandled error value: 'error.NonCanonical'
referenced by:
    test.foo: src/dhcp.zig:383:23
2024-01-21 11:20:03 +02:00
MrDmitry
e72f1d5ae7 Extend test cases
Add tests for:
- packed neighboring variables
- separated neighboring variables
- mixed types of neighboring variables
2024-01-21 03:18:37 -05:00
MrDmitry
2dfec13ef0 Fix last_index after variable substitution
Iterative passes should start at the end of the previous substitution
2024-01-21 03:16:09 -05:00
Veikka Tuominen
2e7d28dd0d Sema: replace uses of toUnsignedInt with toUnsignedIntAdvanced
During semantic analysis the value may be an unresolved lazy value
which makes using `toUnsignedInt` invalid.

Add assertions to detect similar issues in the future.

Closes #18624
2024-01-20 12:21:05 -08:00
Andrew Kelley
10aff67502
Merge pull request #18596 from ypsvlq/mingw
mingw-w64: add missing CRT sources
2024-01-20 12:01:33 -08:00
David Rubin
1b8f7e46fa
AstGen: detect duplicate field names
This logic was previously in Sema, which was unnecessary complexity, and meant the issue was not detected unless the declaration was semantically analyzed. This commit finishes the work which 941090d started.

Resolves: #17916
2024-01-20 17:23:47 +00:00
Andrew Kelley
5c4cb60f4f
Merge pull request #18622 from ziglang/zig-mod-edge-case
build system: better handle modules that do not have a zig root source file
2024-01-20 03:22:02 -08:00
expikr
b729a3f008
std.math: make hypot infer type from argument (#17910)
using peer type resolution
2024-01-20 01:32:07 -05: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
hdert
314533c28b std/math/pow: Fix #18553, isOddInteger: Return false if float value is greater than 1 << 53 (see comment), add test cases 2024-01-19 22:00:04 -08:00
Andrew Kelley
2dea375450 std.Build.Compile: handle modules sans root source files
Uses the new `-M[name][=src]` CLI syntax to omit the source when the
module does not have a zig root source file.

Only some kinds of link objects imply that this should happen.
2024-01-19 22:28:07 -07:00
Andrew Kelley
29cce62a25 CLI: introduce -M; deprecate --mod
I changed my mind on how the CLI for Zig modules should work. I don't
like that `--mod` takes 2 parameters. Instead let's swing all the way in
the other direction: `-M[name][=src]`

This is shorter (Zig CLI invocations are long enough already), avoids
the double parameter edge case, and supports the concept of omitting the
source file part of the argument, which was already wanted for `-Mstd`.
The legacy way to encode that was `--mod std ''` - awkward!

Undocumented support for `--mod` remains so that this branch does not
need a zig1.wasm update. The next time that file is updated, support for
`--mod` can be dropped.

Importantly, this commit also adds support for modules that do not have
a root zig source file. In such case, it sets root to cwd and
root_src_path to empty string, and only sets have_zcu to true if a
module is provided with a root zig source file.
2024-01-19 22:26:13 -07:00