45 Commits

Author SHA1 Message Date
Andrew Kelley
479f259ea4 make start code more versatile
* always align the stack to 16. I saw an instance on x86_64 linux where
   it was needed.

 * detect at runtime if being interpreted by a dynamic loader and if so
   avoid clobbering the fs register.
2020-11-24 19:51:24 -07:00
Andrew Kelley
55ab50efbd Merge branch 'piepiepie' of https://github.com/LemonBoy/zig into pie
Conflicts:
 lib/std/dynamic_library.zig (fixed in this commit)
 src/all_types.hpp
 src/codegen.cpp
 src/link.cpp
 src/main.cpp

Will manually apply the diffs to these deleted files to the new zig
code in a followup commit.
2020-11-22 12:39:44 -07:00
Veikka Tuominen
cf819b95fe
Merge pull request #6829 from tadeokondrak/error-unsupported-callconv
stage1: Compile error instead of falling back to C for unsupported cc
2020-11-19 19:03:08 +02:00
Tadeo Kondrak
25ec2dbc1e Add builtin.Signedness, use it instead of is_signed 2020-11-19 18:59:21 +02:00
Tadeo Kondrak
c002a5026a
Update code to not use unsupported calling conventions for target 2020-11-19 14:01:07 +02:00
Jonathan Marler
4df75645ce start.zig: call wWinMain with root's type
I have an alternative set of windows bindings I'm working on: https://github.com/marler8997/zig-os-windows.  So I'm declaring my wWinMain function with my own HINSTANCE type rather than the one from std.os.windows.  This change allows start to call wWinMain using any pointer type.
2020-11-16 16:01:18 -08:00
Alexandros Naskos
fc67e5f843 Windows TLS startup symbols are already provided by libcrt when linking against libc 2020-11-09 17:46:46 -05:00
Koakuma
2b87cc7ed3 starting_stack_ptr -> argc_argv_ptr to reflect actual use 2020-10-27 22:46:18 +07:00
Koakuma
5474d43389 Zero %i6 to terminate backchain 2020-10-25 21:51:01 +07:00
Koakuma
792526c0bd Fix sparc64 argument loading 2020-10-24 20:05:36 +07:00
Koakuma
c29da84c0e Add sp loading 2020-10-24 20:01:29 +07:00
DixiE
79ec08fe2f Fix Compiler Error When Using wWinMain Entry-Point
The fix for #6715 introduced a new compiler error when attempting to use
wWinMain as the application entry-point.

The Windows API often relies on implicit casts between signed and
unsigned variables. In this case, wWinMain returns an INT despite the
fact this value is intended to feed into ExitProcess, which expects a
UINT, so I've restored the bitcast from #5613.
2020-10-22 19:50:06 -04:00
LemonBoy
96fe971051 std: Minor changes to startup code
* Smaller startup sequence for ppc64
* Terminate the frame-pointer chain when executing _start
* Make the stack traces work on ppc64
* Make the stack traces coloured on ppc64, some ioctls numbers are
  different and the whole set of constants should be audited.
2020-10-19 15:15:43 +02:00
Andrew Kelley
0011def2b2 fix compilation error when building with io_mode evented
The merge of #5613 introduced a regression when building with io_mode
evented, fixed in this commit.

closes #6715
2020-10-17 15:46:36 -07:00
Andrew Kelley
d87bd3d8af fixups regarding windows wide strings
* remove GetModuleHandleA from kernel32.zig. use of A functions
   considered harmful.
 * make it a compile error to expose WinMain instead of wWinMain. same
   thing.
 * start code declares wWinMainCRTStartup instead of WinMainCRTStartup
   when it has the choice.
2020-10-15 19:37:55 -07:00
Andrew Kelley
c7c38e7279 Merge branch '5002-fix-entrypoint-with-winmain' of https://github.com/AnthonyYoManz/zig into AnthonyYoManz-5002-fix-entrypoint-with-winmain 2020-10-15 18:22:12 -07:00
Andrew Kelley
333b12a8f9 std: start: use std.log instead of stderr
When main returns an error code.
2020-09-18 01:58:16 -07:00
Andrew Kelley
2315331d23
Merge pull request #5527 from shawnanastasio/ppc64le
Implement support for powerpc64{,le}
2020-09-10 15:56:27 -04:00
Peter Spiess-Knafl
eca20b5e03 Fix compile when using EFI target (Fixes #6275) 2020-09-07 20:40:11 +03:00
Vexu
09c861b829
update rest of tests 2020-09-04 22:49:14 +03:00
Vexu
1df0f3ac24
update uses of deprecated type field access 2020-09-03 18:10:40 +03:00
Asherah Connor
dc7608da97 ensure main return type is not i8
Avoids a compile error from start.zig:

	/home/kivikakk/zig/build/lib/zig/std/start.zig:265:28: error:
	expected type 'u8', found 'i8'
			    return result;
				   ^
	/home/kivikakk/zig/build/lib/zig/std/start.zig:265:28: note:
	unsigned 8-bit int cannot represent all possible signed 8-bit
	values
			    return result;
2020-08-27 15:03:56 +03:00
Andrew Kelley
4a69b11e74 add license header to all std lib files
add SPDX license identifier
copyright ownership is zig contributors
2020-08-20 16:07:04 -04:00
Anthony Arian
3658dd5e89 Merge branch 'master' of https://github.com/ziglang/zig into 5002-fix-entrypoint-with-winmain 2020-07-20 10:25:54 +01:00
Shawn Anastasio
51fcf949f9 Implement std.start for powerpc64le
This is a bit hacky since we end up doing more than just grabbing
the stack pointer in the inline assembly block. Ideally _start would
be implemented in pure asm for powerpc64le, but this will do for now.

Still to be implemented is powerpc, powerpc64, and powerpc64 (ELFv2)
support. The latter will just require correctly determing target ABI
for powerpc64 and enabling the existing powerpc64le implementation for
it.
2020-07-01 16:13:14 -05:00
Alexandros Naskos
50b70bd77f @asyncCall now requires an argument tuple 2020-06-24 14:07:39 +03:00
Anthony Arian
5e48ed4a8d Implement WinMain Callers that Pass Valid Params 2020-06-15 22:46:16 +01:00
Tadeo Kondrak
6745a6f6f6
zig fmt 2020-05-05 09:38:02 -06:00
Timon Kruiper
c829f2f7b7 Add mips support to standard library 2020-04-24 15:28:55 -04:00
LemonBoy
d788b0cd8b std: Minor changes to TLS handling
* Always allocate an info block per-thread so that libc can store
  important stuff there.
* Respect ABI-mandated alignment in more places.
* Nicer code, use slices/pointers instead of raw addresses whenever
  possible.
2020-03-28 11:20:38 -04:00
Andrew Kelley
f7f563ea53
Revert "Merge pull request #4807 from LemonBoy/tls-touchups"
This reverts commit ee6fda2297bf75432b8d7115ec4c60c213535bbe, reversing
changes made to f313ab18aecea1ade0b6a90d671352a641ad351a.

This caused a test failure:

```
behavior.misc.test "behavior-arm-linux-none-Debug-bare-multi thread local variable"...test failure
/home/vsts/work/1/s/lib/std/testing.zig:191:14: 0x4608f in std.testing.expect (test)
    if (!ok) @panic("test failure");
             ^
/home/vsts/work/1/s/test/stage1/behavior/misc.zig:616:11: 0x53e93 in behavior.misc.test "behavior-arm-linux-none-Debug-bare-multi thread local variable" (test)
    expect(S.t == 1235);
          ^
```
2020-03-25 21:12:24 -04:00
LemonBoy
a34f67aa66 std: Minor changes to TLS handling
* Always allocate an info block per-thread so that libc can store
  important stuff there.
* Respect ABI-mandated alignment in more places.
* Nicer code, use slices/pointers instead of raw addresses whenever
  possible.
2020-03-25 12:08:50 +01:00
Andrew Kelley
3a2c490889 "generate .h files" feature is no longer supported in stage1 2020-03-20 18:33:36 -04:00
Nick Erdmann
92beb13914 std/os/uefi: status reform 2020-03-12 23:23:12 +01:00
Andrew Kelley
4616af0ca4
introduce operating system version ranges as part of the target
* re-introduce `std.build.Target` which is distinct from `std.Target`.
   `std.build.Target` wraps `std.Target` so that it can be annotated as
   "the native target" or an explicitly specified target.
 * `std.Target.Os` is moved to `std.Target.Os.Tag`. The former is now a
   struct which has the tag as well as version range information.
 * `std.elf` gains some more ELF header constants.
 * `std.Target.parse` gains the ability to parse operating system
   version ranges as well as glibc version.
 * Added `std.Target.isGnuLibC()`.
 * self-hosted dynamic linker detection and glibc version detection.
   This also adds the improved logic using `/usr/bin/env` rather than
   invoking the system C compiler to find the dynamic linker when zig
   is statically linked. Related: #2084
   Note: this `/usr/bin/env` code is work-in-progress.
 * `-target-glibc` CLI option is removed in favor of the new `-target`
   syntax. Example: `-target x86_64-linux-gnu.2.27`

closes #1907
2020-02-28 14:51:53 -05:00
Andrew Kelley
936d0b18b1
update std lib to integrate with libc for environ
closes #3511
2020-02-22 15:59:13 -05:00
Jared Miller
b55bc5eb26 Add wWinMain and wWinMainCRTStartup to fix #4376 2020-02-07 22:52:40 -05:00
LemonBoy
fa52c9e36e Small cleanups 2020-01-19 00:11:45 +01:00
Andrew Kelley
5e345ff0ee
Merge pull request #3955 from LemonBoy/fix-1528
Pointer arithmetic affects the alignment factor
2020-01-09 13:53:56 -05:00
LemonBoy
5ab5de89c0 New @export() handling
Use a struct as second parameter to be future proof (and also allows to
specify default values for the parameters)

Closes #2679 as it was just a matter of a few lines of code.
2020-01-09 13:43:06 -05:00
LemonBoy
e134e6c994 Pointer arithmetic affects the alignment factor
Closes #1528
2020-01-08 20:03:03 +01:00
Andrew Kelley
53913acaf7
zig fmt and update extern fn to callconv(.C) 2020-01-06 15:34:50 -05:00
LemonBoy
563d9ebfe5 Implement the callconv() annotation 2020-01-02 18:53:16 +01:00
LemonBoy
333eec557f Initial support for static PIE executables 2019-12-21 17:34:05 +01:00
Andrew Kelley
fff3c1fff4
un-special-case startup code in the std lib
Previously, the compiler had special logic to determine whether to
include the startup code, which was in `std/special/start.zig`. Now,
the file is moved to `std/start.zig`, and there is no special logic
in the compiler. Instead, the standard library unconditionally imports
the `start.zig` file, which then has a `comptime` block that does the
logic of determining what, if any, start symbols to export. Instead of
`start.zig` being in its own special package, it is just another normal
file that is part of the standard library.

`std.builtin.TestFn` is now part of the standard library rather than
specially generated by the compiler.
2019-12-12 18:33:44 -05:00