aboutsummaryrefslogtreecommitdiff
path: root/lib/std/start.zig
AgeCommit message (Collapse)Author
2021-07-11stage2 plan9: add aarch64 supportJacob G-W
2021-07-08stage2: include enough inline asm support for more plan9 syscallsJacob G-W
Also make the exit more correct by exiting 0 rather than random stuff on the stack.
2021-07-08plan9 linker: produce an object file that can actually work!!!Jacob G-W
2021-06-30fix start code for WebAssemblyAndrew Kelley
2021-06-30Add support for WASI reactor in pure Zig-exe. (#9178)Takeshi Yoneda
* Add command line help for "-mexec-model" * Define WasmExecModel enum in std.builtin. * Drop the support for the old crt1.o in favor of crt1-command.o Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2021-06-19std: Fix PIE startup sequenceLemonBoy
* Don't skip the TLS initialization (Fixes #9083) * Add a test case where a PIE program is built and run * Refactor the common initialization code in the Linux startup sequence.
2021-05-28start.zig: intentional silent failure when cannot increase stack sizeAndrew Kelley
2021-05-20Run `zig fmt` on src/ and lib/std/Isaac Freund
This replaces callconv(.Inline) with the more idiomatic inline keyword.
2021-05-15Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgenAndrew Kelley
Conflicts: * build.zig * src/Compilation.zig * src/codegen/spirv/spec.zig * src/link/SpirV.zig * test/stage2/darwin.zig - this one might be problematic; start.zig looks for `main` in the root source file, not `_main`. Not sure why there is an underscore there in master branch.
2021-05-13start.zig: export main with strong linkageJakub Konka
Unmarks `_main` as weak symbol making it global (the entire linked program) in scope.
2021-05-08Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgenAndrew Kelley
Conflicts: * lib/std/os/linux/tls.zig * test/behavior/align.zig * test/behavior/atomics.zig * test/behavior/vector.zig
2021-05-07std: start code on linux when -lc also expands stack sizeAndrew Kelley
See #8708
2021-05-07std: start code increases stack size as appropriate on linuxAndrew Kelley
closes #8708
2021-05-06Sema: implement `@typeInfo` for functionsAndrew Kelley
The goal is to get start code to be able to inspect the calling convention of `main` in order to determine whether to export a main for libc to call, or to allow the root source file to do it.
2021-05-04std: Initial bringup for Linux on Thumb2LemonBoy
There are some small problems here and there, mostly due to the pointers having the lsb set and disrupting the fn alignment tests and the `@FrameSize` implementation.
2021-05-03Sema: implement ExportOptions support in `@export`Andrew Kelley
Also fix switch blocks not emitting their AIR code.
2021-05-02stage2: make struct field analysis lazyAndrew Kelley
This commit breaks struct field analysis; will be fixed in a future commit.
2021-04-30start.zig: unconditionally import the root source fileAndrew Kelley
stage1 did this by accident by unconditionally semantically analyzing std.builtin.panic, which imports the root source file to look for a panic handler override. But stage2 is smarter; it will only semantically analyze std.builtin.panic if any panic calls are emitted. So for very simple compilations, the root source file was being ignored, even if it contained `export` functions in it.
2021-04-15stage2 start.zig: slight simplificationAndrew Kelley
fewer required language features to allow this to work
2021-04-15std: change `@import("builtin")` to `std.builtin`Andrew Kelley
2021-04-10Initialize the ppc stack frame correctlyBenjamin Feng
2021-04-10_start assembly for ppcBenjamin Feng
2021-04-08stage2: blaze the trail for std lib integrationAndrew Kelley
This branch adds "builtin" and "std" to the import table when using the self-hosted backend. "builtin" gains one additional item: ``` pub const zig_is_stage2 = true; // false when using stage1 backend ``` This allows the std lib to do conditional compilation based on detecting which backend is being used. This will be removed from builtin as soon as self-hosted catches up to feature parity with stage1. Keep a sharp eye out - people are going to be tempted to abuse this. The general rule of thumb is do not use `builtin.zig_is_stage2`. However this commit breaks the rule so that we can gain limited start.zig support as we incrementally improve the self-hosted compiler. This commit also implements `fullyQualifiedNameHash` and related functionality, which effectively puts all Decls in their proper namespaces. `fullyQualifiedName` is not yet implemented. Stop printing "todo" log messages for test decls unless we are in test mode. Add "previous definition here" error notes for Decl name collisions. This commit does not bring us yet to a newly passing test case. Here's what I'm working towards: ```zig const std = @import("std"); export fn main() c_int { const a = std.fs.base64_alphabet[0]; return a - 'A'; } ``` Current output: ``` $ ./zig-cache/bin/zig build-exe test.zig test.zig:3:1: error: TODO implement more analyze elemptr zig-cache/lib/zig/std/start.zig:38:46: error: TODO implement structInitExpr ty ``` So the next steps are clear: * Sema: improve elemptr * AstGen: implement structInitExpr
2021-02-10Convert inline fn to callconv(.Inline) everywhereTadeo Kondrak
2021-01-02std: Use {s} instead of {} when printing stringsLemonBoy
2020-12-31Year++Frank Denis
2020-12-18std.crypto.random: introduce fork safetyAndrew Kelley
Everybody gets what they want! * AT_RANDOM is completely ignored. * On Linux, MADV_WIPEONFORK is used to provide fork safety. * On pthread systems, `pthread_atfork` is used to provide fork safety. * For systems that do not have the capability to provide fork safety, the implementation falls back to calling getrandom() every time. * If madvise is unavailable or returns an error, or pthread_atfork fails for whatever reason, it falls back to calling getrandom() every time. * Applications may choose to opt-out of fork safety. * Applications may choose to opt-in to unconditionally calling getrandom() for every call to std.crypto.random.fillFn. * Added `std.meta.globalOption`. * Added `std.os.madvise` and related bits. * Bumped up the size of the main thread TLS buffer. See the comment there for justification. * Simpler hot path in TLS initialization.
2020-12-18take advantage of std.os.linux.getauxvalAndrew Kelley
2020-12-18std: tlcsprng: cleanups & improvementsAndrew Kelley
* get rid of the pointless fences * make seed_len 16 instead of 32, which is accurate since it was already padding the rest anyway; now we do 1 pad instead of 2. * secureZero to clear the AT_RANDOM auxval * add a flag root source files can use to disable the start code. This is in case people want to opt out of the initialization when they don't depend on it.
2020-12-18memory fences to make sure TLS init happensAndrew Kelley
2020-12-18start code: overwrite AT_RANDOM after we use itAndrew Kelley
2020-12-18std: introduce a thread-local CSPRNG for general useAndrew Kelley
std.crypto.random * cross platform, even freestanding * can't fail. on initialization for some systems requires calling os.getrandom(), in which case there are rare but theoretically possible errors. The code panics in these cases, however the application may choose to override the default seed function and then handle the failure another way. * thread-safe * supports the full Random interface * cryptographically secure * no syscall required to initialize on Linux (AT_RANDOM) * calls arc4random on systems that support it `std.crypto.randomBytes` is removed in favor of `std.crypto.random.bytes`. I moved some of the Random implementations into their own files in the interest of organization. stage2 no longer requires passing a RNG; instead it uses this API. Closes #6704
2020-11-24make start code more versatileAndrew Kelley
* 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-22Merge branch 'piepiepie' of https://github.com/LemonBoy/zig into pieAndrew Kelley
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-19Merge pull request #6829 from tadeokondrak/error-unsupported-callconvVeikka Tuominen
stage1: Compile error instead of falling back to C for unsupported cc
2020-11-19Add builtin.Signedness, use it instead of is_signedTadeo Kondrak
2020-11-19Update code to not use unsupported calling conventions for targetTadeo Kondrak
2020-11-16start.zig: call wWinMain with root's typeJonathan Marler
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-09Windows TLS startup symbols are already provided by libcrt when linking ↵Alexandros Naskos
against libc
2020-10-27starting_stack_ptr -> argc_argv_ptr to reflect actual useKoakuma
2020-10-25Zero %i6 to terminate backchainKoakuma
2020-10-24Fix sparc64 argument loadingKoakuma
2020-10-24Add sp loadingKoakuma
2020-10-22Fix Compiler Error When Using wWinMain Entry-PointDixiE
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-19std: Minor changes to startup codeLemonBoy
* 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-17fix compilation error when building with io_mode eventedAndrew Kelley
The merge of #5613 introduced a regression when building with io_mode evented, fixed in this commit. closes #6715
2020-10-15fixups regarding windows wide stringsAndrew Kelley
* 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-15Merge branch '5002-fix-entrypoint-with-winmain' of ↵Andrew Kelley
https://github.com/AnthonyYoManz/zig into AnthonyYoManz-5002-fix-entrypoint-with-winmain
2020-09-18std: start: use std.log instead of stderrAndrew Kelley
When main returns an error code.
2020-09-10Merge pull request #5527 from shawnanastasio/ppc64leAndrew Kelley
Implement support for powerpc64{,le}