16250 Commits

Author SHA1 Message Date
John Schmidt
23d148e5c7 debug: fix edge cases in macOS debug symbol lookup
This commit fixes two related things:

1. If the loop goes all the way through the slice without a match, on
   the last iteration `mid == symbols.len - 1` which causes
   `&symbols[mid + 1]` to be out of bounds. End one step before that
   instead.

2. If the address we're looking for is greater than the address of the
   last symbol in the slice, we now match it to that symbol. Previously,
   we would miss this case since we only matched if the address was _in
   between_ the address of two symbols.
2022-02-02 22:06:32 -07:00
Jonathan Marler
eace6906ce remove __muloti4 from libc++
fixes https://github.com/ziglang/zig/issues/10719

compiler_rt already provides __muloti4 but libc++ is also providing it and when linking libc++ it causes a crash on my windows x86_64 machine.
2022-02-02 22:04:42 -07:00
Jakub Konka
ac3ac255a2 Merge pull request #10404 from ominitay/iterator
std: Fix using `fs.Dir.Iterator` twice
2022-02-02 22:04:36 -07:00
Jean Dao
69f46cab55 fix argsAlloc buffer size
The buffer `buf` contains N (= `slice_sizes.len`) slices followed by the
N null-terminated arguments. The N null-terminated arguments are stored
in the `contents` array list. Thus, `buf` size should be:
    @sizeOf([]u8) * slice_sizes.len + contents_slice.len

Instead of:
    @sizeOf([]u8) * slice_sizes.len + contents_slice.len + slice_sizes.len

This bug was found thanks to the gpa allocator which checks if freed
size matches allocated sizes for large allocations.
2022-02-02 22:04:02 -07:00
Andrew Kelley
452c35656e ci: azure: update to newer msys2 release 2022-02-02 22:03:55 -07:00
Jonathan S
a24f4d8da4 Fix overflow in std.math.isNormal when applied to -Inf or a negative NaN 2022-02-02 22:03:47 -07:00
John Schmidt
5762b6d218 std.fmt: fix out-of-bounds array write in float printing
This commit fixes an out of bounds write that can occur when
formatting certain float values. The write messes up the stack and
causes incorrect results, segfaults, or nothing at all, depending on the
optimization mode used.

The `errol` function writes the digits of the float into `buffer`
starting from index 1, leaving index 0 untouched, and returns `buffer[1..]`
and the exponent. This is because `roundToPrecision` relies on index 0 being
unused in case the rounding adds a digit (e.g rounding 999.99
to 1000.00). When this happens, pointer arithmetic is used
[here](0e6d2184ca/lib/std/fmt/errol.zig (L61-L65))
to access index 0 and put the ones digit in the right place.

However, `errol3u` contains two special cases: `errolInt` and `errolFixed`,
which return from the function early. For these two special cases
index 0 was never reserved, and the return value contains `buffer`
instead of `buffer[1..]`. This causes the pointer arithmetic in
`roundToPrecision` to write out of bounds, which in the case of
`std.fmt.formatFloatDecimal` messes up the stack and causes undefined behavior.

The fix is to move the slicing of `buffer` to `buffer[1..]` from `errol3u`
to `errol` so that both the default and the special cases operate on the sliced
buffer.
2022-02-02 22:01:47 -07:00
John Schmidt
8b5e4af78e fmt: handle doc comments on struct members
Closes https://github.com/ziglang/zig/issues/10443.
2022-02-02 22:01:38 -07:00
Andrew Kelley
aad6ef1fc3 glibc: version-gate _DYNAMIC_STACK_SIZE_SOURCE
This is a patch to glibc features.h which makes
_DYNAMIC_STACK_SIZE_SOURCE undefined unless the version is >= 2.34.

This feature was introduced with glibc 2.34 and without this patch, code
built against these headers but then run on an older glibc will end up
making a call to sysconf() that returns -1 for the value of SIGSTKSZ
and MINSIGSTKSZ.

Closes #10713
2022-02-02 22:01:09 -07:00
Andrew Kelley
b54f6186ac build.zig: fix single-threaded option
Instead of defaulting to false, just keep the option as optional to
communicate default to the build system.

Fixes one problem with building the compiler for single-threaded
targets.
2022-02-02 22:01:04 -07:00
Andrew Kelley
e2f36c292e std: break up some long lines
This makes packaging Zig for Debian slightly easier since it will no
longer trigger a Lintian warning for long lines.
2022-02-02 22:00:55 -07:00
Andrew Kelley
e9d916571a link: ELF, COFF, WASM: honor the "must_link" flag of positionals
Previously only the MachO linker was honoring the flag.
2022-02-02 22:00:38 -07:00
Andrew Kelley
021c1190af stage2: .stub files are yet another c++ source file extension
however .cu files are a superset of c++.
2022-02-02 22:00:16 -07:00
Andrew Kelley
45cd1114f7 stage2: make cuda file extensions a separate enum tag than c++
follow-up to 2f41bd3be438dae2a188cfae3295dc28f4e9d434.
2022-02-02 22:00:12 -07:00
Vesim
d7feeaaa2c fchown: use the 32-bit uid/gid variant of the syscall on 32-bit linux targets 2022-02-02 22:00:06 -07:00
praschke
2b29424efd docs: reorganize @truncate and @intCast for clarity 2022-02-02 22:00:00 -07:00
vnc5
8f89056dc2 fix startup procedure for async WinMain 2022-02-02 21:59:47 -07:00
Philipp Lühmann
e8c4fec1b2 fix precedence in langref or example 2022-02-02 21:59:40 -07:00
Exonorid
ac3d9759ed Added documentation for implicit struct pointer dereferencing 2022-02-02 21:53:00 -07:00
Daniel Saier
922d33e5b9 zig cc: Treat cu files as C++ source files
First step towards #10634.

Treating stub files as C++ allows to use zig c++ as a host
compiler for nvcc.

Treating cu files as C++ allow using zig c++ as a host compiler in
CMake. CMake calls the host compiler with -E on a cu file to identify
the compiler.

Using zig c++ to directly compile CUDA code is untested.
2022-02-02 21:52:52 -07:00
Andrew Kelley
936294e32a Merge pull request #10699 from motiejus/arm64
[linux headers] rename arm64 to aarch64
2022-02-02 21:51:58 -07:00
Andrew Kelley
7e61bdbaa4 zig cc: add --hash-style linker parameter
This is only relevant for ELF files.

I also fixed a bug where passing a zig source file to `zig cc` would
incorrectly punt to clang because it thought there were no positional
arguments.
2022-02-02 21:50:52 -07:00
Josh Hannaford
340bb8198f Update the documentation for std.mem.sliceTo for readability 2022-02-02 21:48:48 -07:00
Andrew Kelley
e37c55bae0 link: Elf, Wasm: forward strip flag when linking with LLD 2022-02-02 21:47:28 -07:00
Andrew Kelley
93545fe74f zig cc: detect more linker args
* --whole-archive, -whole-archive
 * --no-whole-archive, -no-whole-archive
 * -s, --strip-all
 * -S, --strip-debug
2022-02-02 21:46:28 -07:00
Meghan
8ed432fe3c std.crypto.random: Randoms are no longer passed by reference 2022-02-02 21:46:22 -07:00
Andrew Kelley
148b963a60 Merge pull request #10584 from ziglang/macho-rustc-fixes
zld: a couple of fixes which result in better rustc support
2022-02-02 21:45:44 -07:00
Sizhe Zhao
b713ce0249 Avoid duplicate TLS startup symbols 2022-02-02 21:25:40 -07:00
Pablo Santiago Blum de Aguiar
4d5a598599 readUntilDelimiter*: read only if buffer not full
Ref.: #9594
2022-02-02 21:25:03 -07:00
fifty-six
aa8112c847 std/fs: Support XDG_DATA_HOME
This is generally used for user-specific data on linux, with the
default being ~/.local/share
2022-02-02 21:24:40 -07:00
joachimschmidt557
3d52a322ab std: Add some missing termios types to c/linux.zig and os.zig 2022-02-02 21:23:34 -07:00
Andrew Kelley
af844d865f stage1: remove the "referenced here" error note
It's generally noise. The parts where it is useful will need to be
redone to not be annoying for the general case.
2022-02-02 21:22:57 -07:00
Jakub Konka
252fb642d5 macho: do not write out ZEROFILL physically to file
Prior to this change, `__DATA,__bss` and `__DATA,__thread_bss` would
get actually, physically written out to the output file, unnecessarily
filling the output file with 0s.
2022-02-02 21:22:15 -07:00
Daniel Saier
dcbab17b62 glibc: fix passing of __GNU_MINOR__
This was originally introduced in 4d48948b526337947ef59a83f7dbc81b70aa5723
but broken immediately afterwards in c8af00c66e8b6f62e4dd6ac4d86a3de03e9ea354.
2022-02-02 21:19:42 -07:00
C-BJ
881e507ac5 Update CONTRIBUTING.md
Delete unavailable content!
2022-02-02 21:19:36 -07:00
Andrew Kelley
18fabd99cc Merge pull request #10475 from lithdew/master
lld: allow for entrypoint symbol name to be set
2022-02-02 21:19:18 -07:00
John Schmidt
afd1f7ed47 Implement segfault handler for macOS x86_64 2022-02-02 21:18:45 -07:00
riverbl
2ac7aefe2f stage2: do not interpret identifier containing underscores (eg: u3_2) as int primitive type 2022-02-02 21:17:25 -07:00
johnLate
bb9399cc5d Fix os.rusage when linking with c library on Linux
Fixes ziglang#10543 on Linux.
2022-02-02 21:17:15 -07:00
riverbl
bc90a2a083 translate-c: Fix issues translating macro define of hex float constant
* Fix incorrect result when the first digit after the decimal point is not 0-9 - eg 0x0.ap0
* Fix compiler panic when the number starts with `0X` with a capital `X` - eg 0X0p0
* Fix compiler panic when the number has a decimal point immediately after `0x` - eg 0x.0p0
2022-02-02 21:15:15 -07:00
Jakub Konka
1e6de105c8 Merge branch 'Jarred-Sumner-patch-1' 2022-02-02 21:14:59 -07:00
Jakub Konka
385b7e4808 Merge pull request #10576 from schmee/macos-resolve-ip
Use libc if_nametoindex for macOS when parsing IPs
2022-02-02 21:12:24 -07:00
Jakub Konka
57d7ad9172 macho: code signature needs to be 16 bytes aligned 2022-02-02 21:10:23 -07:00
Andrew Kelley
e67e15a29a Merge pull request #10587 from xxxbxxx/master
restore compatibility with glibc<=2.33 for global initializers
2022-02-02 21:10:05 -07:00
Marc Tiehuis
06ae13fe35 stage1: fix bigint_init_bigfloat for single-limb negative floats
Fixes #10592.
2022-02-02 21:09:36 -07:00
Jakub Konka
dafbc6eb25 Merge branch 'Luukdegram-linker-eport-symbols' 2022-01-12 12:01:32 -07:00
Andrew Kelley
6f49233ac6 Merge pull request #10572 from Luukdegram/wasm-linker-stack
Stage2: wasm-linker - Place stack at the beginning of the linear memory
2022-01-12 12:00:03 -07:00
riverbl
bb8eef8d24 translate-c: Fix macro define of float constant using scientific notation
Fixes compiler attempting to use null value when translating macro define of float constant using scientific notation with no decimal point
2022-01-12 11:59:30 -07:00
afranchuk
511990c83b Fix a bug in std.Thread.Condition and add a basic Condition test. (#10538)
* Fix FUTEX usage in std.Thread.Condition - It was using an old name.
2022-01-12 11:59:09 -07:00
Andrew Kelley
9fa55ae777 Merge pull request #10566 from fifty-six/master
std.os.uefi improvements/fixes
2022-01-12 11:59:02 -07:00