Commit graph

3218 commits

Author SHA1 Message Date
LemonBoy
6f220bb7ca std: explicitly cast indices to usize
This is needed for platforms where usize=u16, eg. MSP430.
2020-12-09 16:48:41 +01:00
LemonBoy
afd491c07e compiler-rt: Fix compilation of clzsi for armv6 targets 2020-12-09 16:48:02 +01:00
LemonBoy
518168edb2 compiler-rt: Avoid exposing atomic builtins when not supported
Let's a void any kind of compilation/LLVM errors for niche targets such
as AVR/MSP430 or ARM v6m. By not exporting any atomic builtin anymore
the user is free to provide their own implementation (that disable the
IRQs) or to provide the --single-threaded switch and forget about this.
2020-12-09 16:33:53 +01:00
Vexu
7e30e83900
small fixes and zig fmt 2020-12-09 13:54:26 +02:00
Vexu
be71994fb1
zig fmt: improve var decl initializer formatting 2020-12-09 13:47:22 +02:00
Andrew Kelley
4592fd26b9 add std.testing.expectStringEndsWith 2020-12-08 21:59:24 -07:00
xackus
21550bb7cd std.json: unreachable -> expect in tests 2020-12-08 19:16:17 -05:00
antlilja
c796c4528e Add option to override default stack size in build system. 2020-12-08 16:18:16 -05:00
Nathanaël Courant
81890e30e2 Fix general purpose allocator incorrectly modifying total_requested_bytes in some cases 2020-12-08 15:53:34 -05:00
Andrew Kelley
5a65caa2a3 ability to build stage1 using only a zig tarball
The main idea here is that there are now 2 ways to get a stage1 zig
binary:

 * The cmake path. Requirements: cmake, system C++ compiler, system
   LLVM, LLD, Clang libraries, compiled by the system C++ compiler.

 * The zig path. Requirements: a zig installation, system LLVM, LLD,
   Clang libraries, compiled by the zig installation.

Note that the former can be used to now take the latter path.

Removed config.h.in and config.zig.in. The build.zig script no longer is
coupled to the cmake script.

cmake no longer tries to determine the zig version. A build with cmake
will yield a stage1 zig binary that reports 0.0.0+zig0. This is going to
get reverted.

`zig build` now accepts `-Dstage1` which will build the stage1 compiler,
and put the stage2 backend behind a feature flag.

build.zig is simplified to only support the use case of enabling LLVM
support when the LLVM, LLD, and Clang libraries were built by zig. This
part is probably sadly going to have to get reverted to make package
maintainers happy.

Zig build system addBuildOption supports a couple new types.

The biggest reason to make this change is that the zig path is an
attractive option for doing compiler development work on Windows. It
allows people to work on the compiler without having MSVC installed,
using only a .zip file that contains Zig + LLVM/LLD/Clang libraries.
2020-12-07 17:27:09 -07:00
Luna
5f7b97e84c add AddressFamilyNotSupported to SendError 2020-12-07 16:40:03 -05:00
xackus
85dc039632 std.c: freeing null is a no-op 2020-12-07 16:33:27 -05:00
LemonBoy
fd8fa55129
std: Add a few helpers for matching ascii strings (#7300)
* startsWithIgnoreCase
* endsWithIgnoreCase
2020-12-04 15:27:28 -05:00
LemonBoy
ac443b941d std: Restore file locking test on Windows
Make it even more robust wrt timing problems.

Closes #7010
2020-12-04 12:24:50 -08:00
Isaac Yonemoto
fd18252a71 makes the implementation public 2020-12-03 15:14:59 -08:00
Isaac Yonemoto
a2cd9dc3bd
Gpa mutex configurable (#7234)
* makes the mutex for the gpa configurable

* fixed logic, added test

* updates docstring; pushes logic to one place, better duck-type
2020-12-03 15:49:35 -05:00
Miles Alan
7bbd369fbb std/event: Fix import path for WaitGroup 2020-12-03 12:43:55 -08:00
Jakub Konka
a8e543bd6b
Merge pull request #7280 from leecannon/master
Add `readUntilDelimiterOrEofArrayList` & `readUntilDelimiterOrEofAlloc`
2020-12-03 21:03:48 +01:00
Lee Cannon
f598245836 Make zig fmt happy with multiline arguments for readAllArrayListAligned 2020-12-03 10:24:49 +00:00
LemonBoy
cb63ecd6e9 std: Add nosuspend around stderr.print calls 2020-12-02 16:34:51 -08:00
Vexu
d4c167f3cd std.build: addBuildOption special handling for SemanticVersion 2020-12-02 16:33:27 -08:00
Andrew Kelley
f842327147
Merge pull request #7277 from LemonBoy/thread-posix
std: make the use of pthread_join POSIX-compliant
2020-12-02 13:47:40 -08:00
Mathieu Guay-Paquet
4c8632e244 fix the tinyest typo 2020-12-02 19:08:25 +02:00
Lee Cannon
76f3921544 Add readUntilDelimiterOrEofArrayList & readUntilDelimiterOrEofAlloc 2020-12-02 12:55:54 +00:00
LemonBoy
f8cef32f27 std: make the use of pthread_join POSIX-compliant
Applications supplying their own custom stack to pthread_create are not
allowed to free the allocated memory after pthread_join returns as,
according to the specification, the thread is not guaranteed to be dead
after the join call returns.

Avoid this class of problems by avoiding the use of a custom stack
altogether, let pthread handle its own resources.

Allocations made on the child stack are now done on the C heap.

Thanks @semarie for noticing the problem on OpenBSD and suggesting a
fix.

Closes #7275
2020-12-02 10:59:35 +01:00
daurnimator
db0cb54f4e
Localhost is special (#6955)
* std: always return loopback address when looking up localhost

* std: also return Ipv6 loopback

* std: remove commented out obsolete code
2020-12-01 19:13:59 -05:00
Andrew Kelley
c7028ce0c6 COFF linking: fix incorrectly passing .dll instead of .lib
commit 9d1816111d used the "output path"
as the path for passing shared library artifact paths to the Zig CLI.
For Windows, this was incorrect because it would pass the .dll instead
of the .lib file. This commit passes the "output lib path" instead,
which makes it pass the .lib path in case of a .dll on Windows.

This way the linker does not complain and say, "bad file type. Did you
specify a DLL instead of an import library?"
2020-12-01 11:28:44 -07:00
Isaac Freund
92ec24f77c std/os: remove unneeded error from accept errorset
POSIX compliant fnctl cannot return EPERM when getting/setting the given
flags. See the specification here:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/fcntl.html
2020-11-30 20:00:26 -08:00
Andrew Kelley
9d1816111d build system: pass dyn lib artifacts as positionals 2020-11-30 18:12:00 -07:00
Alexandros Naskos
f7d0a32045 Switched OBJECT_NAME_INVALID handling to unreachable in faccessatW 2020-11-30 18:08:27 -07:00
Alexandros Naskos
beb9d33d6d Disallow absolute paths passed as system libraries
Added OBJECT_NAME_INVALID handling in faccessatW
2020-11-30 18:08:27 -07:00
Andrew Kelley
ff9798eb26 rework the bundle compiler-rt feature
* it is now -fcompiler-rt and -fno-compiler-rt to override the (quite
   reasonable) default of bundling compiler-rt only for executables and
   dynamic libraries.
   - the build.zig API is still called bundle_compiler_rt however it is
     now an optional bool instead of a bool. leaving it as `null` means
     to use the compiler default.
 * renamed some internal identifiers to make the source more readable
 * additionally support -fcompiler-rt when doing build-obj for ELF files
   since that target already supports linking multiple objects into one.
   - includes an error message when attempting this for non-ELF. in the
     future this could additionally be supported with a more advanced
     implementation that does not rely on the linker.
 * properly populate the linker cache hash
2020-11-30 16:35:00 -07:00
Andrew Kelley
50a336fff8 move std.SegmentedList to the std-lib-orphanage
I spent a long time working on this data structure, and I still think
it's a neat idea, but it has no business being in the std lib.

I'm aware of the few remaining references to SegmentedList that exist in
the std lib, but they are dead code, and so I'm leaving the dead
references as a clue that the code is dead. Cleaning up dead code will
be a separate effort that involves code coverage tools to make sure we
find it all.

std-lib-orphanage commit: 2c36a7894c689ecbaf63d5f489bb0c68773410c4

closes #7190
2020-11-30 13:04:26 -07:00
Jonathan Marler
b587a42233 add std.os.shutdown function for sockets 2020-11-30 11:25:03 -08:00
Michael Freundorfer
baa075ac8c Fix WindowsDynLib.openW trying to strip the \??\ prefix when it does not exist 2020-11-30 11:12:33 -08:00
Rageoholic
0369b65082
Switch to using unicode when parsing the command line on windows (#7241)
* Switch to using unicode when parsing the command line on windows

* Apply changes by LemonBoy and *hopefully* fix tests on MIPs

Co-authored-by: LemonBoy <LemonBoy@users.noreply.github.com>

* Fix up next and skip

* Move comment to more relevant place

Co-authored-by: LemonBoy <LemonBoy@users.noreply.github.com>
2020-11-30 13:47:01 -05:00
Jonathan Marler
b8f09f773a fix memory leak in BufMap 2020-11-30 10:40:16 -08:00
Jonathan Marler
48660371a2 std.meta: add assumeSentinel 2020-11-29 10:36:02 -08:00
Andrew Kelley
e701ac1a51
Merge pull request #7237 from koachan/sparc64-longdouble_fork
Add "long double" mapping and implement fork() on Linux/sparc64
2020-11-29 10:33:43 -08:00
LemonBoy
89ee4b8621 std: Avoid deadlock in the signal handler
stderr_mutex may still be held when we reach the signal handler, grab
our own stderr handle to print the error messages and avoid deadlocking.

Closes #7247
2020-11-29 10:31:06 -08:00
Koakuma
f10bff9ffb Add a comment to explain the fork return values on sparc64 2020-11-28 13:24:24 +07:00
christian-stephen
abc729a5f9 Add readAllArrayListAligned to Reader which can accept an arbitrary alignment 2020-11-27 17:00:50 -08:00
Andrew Kelley
9e4360c335
Merge pull request #7198 from LemonBoy/freebsd-lock
std: Fix file locking logic for BSD targets
2020-11-27 14:35:30 -08:00
Koakuma
41c40f4bbe Fix fork() on Linux/sparc64
fork() on Linux/sparc64 seems to return its result in two registers,
with %o0 always holding the current process' PID, and the parent/child
status returned in %o1. Add some glue code to convert those into
the libc-style return value.
2020-11-27 23:02:22 +07:00
Jakub Konka
a6e93da717 stage2 macho: generate a code sig (not valid yet) 2020-11-26 11:50:09 +01:00
Jakub Konka
9dcf7ee9c9 stage2 macho: add info about __TEXT segment 2020-11-26 11:50:09 +01:00
Jakub Konka
79381dc4fb stage2 macho: add empty CodeDirectory blob 2020-11-26 11:50:09 +01:00
Jakub Konka
e8dd62accd stage2 macho: fix incorrect rebase 2020-11-26 11:50:09 +01:00
Jakub Konka
1bec531cf2 stage2 MachO: add source version load cmd 2020-11-26 11:50:09 +01:00
Jakub Konka
72310db1da stage2 MachO: add min OS version load cmd 2020-11-26 11:50:09 +01:00