aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
AgeCommit message (Collapse)Author
2019-06-17Remove duplicate exe name with zig runJonathan Marler
2019-06-14expose builtin.strip_debug_infoAndrew Kelley
zig code now can be made aware that it will not have any debug information available at runtime.
2019-05-29main: set subsystem in `zig builtin` when explicitly providedAndrew Kelley
2019-05-28Warn the user if run/test is paired with emit optionsLemonBoy
2019-05-27improve the stack check CLI optionsAndrew Kelley
See #2526
2019-05-13Assemble asm files using CCLemonBoy
Stuffing all the files together and compiling the resulting blob with the main program is a terrible idea. Some files, namely the .S ones, must be run trough the C preprocessor before assembling them (#2437). Beside that the aggregate may be mis-compiled due to the presence of some flags that affect the following code. For example let's consider two files, a.s and b.s a.s ``` fn1: ret .data data1: .word 0 ``` b.s ``` fn2: ret ``` Now, fn1 and fn2 will be both placed in the .text section as intended if the two files are compiled separately. But if we merge them the `.data` flag ends up placing fn2 in the wrong section! This fixes a nasty crash where musl's memset ended up in the non-executable data segment, leading to too many hours of head-scratching.
2019-05-08fix build on macOSAndrew Kelley
Sadly due to a workaround for LLD linker limitations on macOS we cannot put libuserland into an .a file; instead we have to use object files. Again due to linker limitations, bundling compiler_rt.o into another relocatable object also doesn't work. So we're left with disabling stack probing on macOS for the stage1 self-hosted code. These workarounds could all be removed if the macos support in the LLD linker improved, or if Zig project had its own linker that did not have these issues.
2019-05-08add --bundle-compiler-rt function to link optionsAndrew Kelley
and use it when building libuserland.a The self-hosted part of stage1 relies on zig's compiler-rt, and so we include it in libuserland.a. This should potentially be the default, but for now it's behind a linker option. self-hosted translate-c: small progress on translating functions.
2019-05-08stage1: remove unneeded extern functionAndrew Kelley
2019-05-08Implement stack probes for x86/x86_64LemonBoy
Enabled on non-Windows systems only since it already requires stack probes.
2019-05-01main: change --enable-pic and --disable-pic to -fPIC and -fno-PICDong-hee Na
2019-04-29Fix crash due to command line argument parsingMatt Stancliff
zig --help -> ok zig --help --c-source -> ok zig --c-source --help -> crash [fixed] 'i' was being incremented without regard for the 'argc' limit, so we were running off the end of 'argv'.
2019-04-26zig fmt is built directly into stage1 rather than child processAndrew Kelley
Previously, `zig fmt` on the stage1 compiler (which is what we currently ship) would perform what equates to `zig run std/special/fmt_runner.zig` Now, `zig fmt` is implemented with the hybrid zig/C++ strategy outlined by #1964. This means Zig no longer has to ship some of the stage2 .zig files, and there is no longer a delay when running `zig fmt` for the first time.
2019-04-25translate-c: a little closer to self-hosted implementationAndrew Kelley
2019-04-24remove Shebang (#!) supportShawn Landden
Closes: #2165
2019-04-16stage1 is now a hybrid of C++ and ZigAndrew Kelley
This modifies the build process of Zig to put all of the source files into libcompiler.a, except main.cpp and userland.cpp. Next, the build process links main.cpp, userland.cpp, and libcompiler.a into zig1. userland.cpp is a shim for functions that will later be replaced with self-hosted implementations. Next, the build process uses zig1 to build src-self-hosted/stage1.zig into libuserland.a, which does not depend on any of the things that are shimmed in userland.cpp, such as translate-c. Finally, the build process re-links main.cpp and libcompiler.a, except with libuserland.a instead of userland.cpp. Now the shims are replaced with .zig code. This provides all of the Zig standard library to the stage1 C++ compiler, and enables us to move certain things to userland, such as translate-c. As a proof of concept I have made the `zig zen` command use text defined in userland. I added `zig translate-c-2` which is a work-in-progress reimplementation of translate-c in userland, which currently calls `std.debug.panic("unimplemented")` and you can see the stack trace makes it all the way back into the C++ main() function (Thanks LemonBoy for improving that!). This could potentially let us move other things into userland, such as hashing algorithms, the entire cache system, .d file parsing, pretty much anything that libuserland.a itself doesn't need to depend on. This can also let us have `zig fmt` in stage1 without the overhead of child process execution, and without the initial compilation delay before it gets cached. See #1964
2019-04-14organize how the single threaded option is passed aroundAndrew Kelley
2019-04-14wasm: force single threadedShritesh Bhattarai
2019-04-10pass exec_path to zig runShritesh Bhattarai
2019-04-04fix thread local variables for non- position independent codeAndrew Kelley
This fixes comes thanks to Rich Felker from the musl libc project, who gave me this crucial information: "to satisfy the abi, your init code has to write the same value to that memory location as the value passed to the [arch_prctl] syscall" This commit also changes the rules for when to build statically by default. When building objects and static libraries, position independent code is disabled if no libraries will be dynamically linked and the target does not require position independent code. closes #2063
2019-03-31fix zig run to accept executable argsMichael Dusan
The `--` double-hyphen is now used to end further `zig` processing of command line options. All arguments after `--` will be passed on to the executable. eg. `--help` will be passed on. `zig run foo.zig -- --help` closes #2148
2019-03-19zig targets prints the available libcsAndrew Kelley
2019-03-13fix target_requires_pic and reloc_modeAndrew Kelley
disable failing thread local variable test. see #2063
2019-03-13breaking: remove --static; add -dynamicAndrew Kelley
`--static` is no longer an option. Instead, Zig makes things as static as possible by default. `-dynamic` can be used to choose a dynamic library rather than a static one. `--enable-pic` is a new option. Usually it will be enabled automatically, but in the case of build-exe with no dynamic libraries on Linux or freestanding, Zig chooses off by default. closes #1703 closes #1828
2019-03-13zig test respects --output-dir parameterAndrew Kelley
2019-03-08breaking changes to zig build API and improved cachingAndrew Kelley
* in Zig build scripts, getOutputPath() is no longer a valid function to call, unless setOutputDir() was used, or within a custom make() function. Instead there is more convenient API to use which takes advantage of the caching system. Search this commit diff for `exe.run()` for an example. * Zig build by default enables caching. All build artifacts will go into zig-cache. If you want to access build artifacts in a convenient location, it is recommended to add an `install` step. Otherwise you can use the `run()` API mentioned above to execute programs directly from their location in the cache. Closes #330. `addSystemCommand` is available for programs not built with Zig build. * Please note that Zig does no cache evicting yet. You may have to manually delete zig-cache directories periodically to keep disk usage down. It's planned for this to be a simple Least Recently Used eviction system eventually. * `--output`, `--output-lib`, and `--output-h` are removed. Instead, use `--output-dir` which defaults to the current working directory. Or take advantage of `--cache on`, which will print the main output path to stdout, and the other artifacts will be in the same directory with predictable file names. `--disable-gen-h` is available when one wants to prevent .h file generation. * `@cImport` is always independently cached now. Closes #2015. It always writes the generated Zig code to disk which makes debug info and compile errors better. No more "TODO: remember C source location to display here" * Fix .d file parsing. (Fixes the MacOS CI failure) * Zig no longer creates "temporary files" other than inside a zig-cache directory. This breaks the CLI API that Godbolt uses. The suggested new invocation can be found in this commit diff, in the changes to `test/cli.zig`.
2019-03-07fix -mllvm command line option regressionAndrew Kelley
2019-03-07fix regressions on macosAndrew Kelley
2019-03-06cross compile glibc startup filesAndrew Kelley
2019-03-05dynamic linker path is independent from libc installationAndrew Kelley
2019-03-04initial glibc supportAndrew Kelley
2019-03-02compile error for import outside package pathAndrew Kelley
closes #2024 there's a new cli option `--main-pkg-path` which you can use to choose a different root package directory besides the one inferred from the root source file and a corresponding build.zig API: foo.setMainPkgPath(path)
2019-02-28struct types get fully qualified namesAndrew Kelley
and function symbol names become fully qualified
2019-02-28remove namespace type; files are empty structsAndrew Kelley
closes #1047
2019-02-26fix stage1 zig fmt on macosAndrew Kelley
2019-02-26breaking changes to the way targets work in zigAndrew Kelley
* CLI: `-target [name]` instead of `--target-*` args. This matches clang's API. * `builtin.Environ` renamed to `builtin.Abi` - likewise `builtin.environ` renamed to `builtin.abi` * stop hiding the concept of sub-arch. closes #1526 * `zig targets` only shows available targets. closes #438 * include all targets in readme, even those that don't print with `zig targets` but note they are Tier 4 * refactor target.cpp and make the naming conventions more consistent * introduce the concept of a "default C ABI" for a given OS/Arch combo. As a rule of thumb, if the system compiler is clang or gcc then the default C ABI is the gnu ABI.
2019-02-25building DLLs on Windows works betterAndrew Kelley
2019-02-25first class support for compiling C codeAndrew Kelley
New CLI parameter: --c-source [options] [file] It even works with `--cache on` when there are transitive dependencies. Instead of `builder.addCExecutable`, use `builder.addExecutable` and pass `null` for the root source file. Then use `builder.addCSourceFile`, which takes the path to the C code, and a list of C compiler args. Be sure to linkSystemLibrary("c") if you want libc headers to be available. Merge TestStep into LibExeObjStep. That was long overdue.
2019-02-24Merge pull request #2003 from ziglang/zig-ccAndrew Kelley
add `zig cc` command to act like a C compiler
2019-02-24zig cc: work around clang calling GetCommandLine on WindowsAndrew Kelley
2019-02-24add `zig cc` command to act like a C compilerAndrew Kelley
closes #490
2019-02-23fix `zig fmt` arg0 handled incorrectlyAndrew Kelley
2019-02-23better libc detection (#1996)Andrew Kelley
* better libc detection This introduces a new command `zig libc` which prints the various paths of libc files. It outputs them to stdout in a simple text file format that it is capable of parsing. You can use `zig libc libc.txt` to validate a file. These arguments are gone: --libc-lib-dir [path] directory where libc crt1.o resides --libc-static-lib-dir [path] directory where libc crtbegin.o resides --msvc-lib-dir [path] (windows) directory where vcruntime.lib resides --kernel32-lib-dir [path] (windows) directory where kernel32.lib resides Instead we have this argument: --libc [file] Provide a file which specifies libc paths This is used to pass a libc text file (which can be generated with `zig libc`). So it is easier to manage multiple cross compilation environments. `--cache on` now works when linking against libc. `ZigTarget` now has a bool field `is_native` Better error messaging when you try to link against libc or use `@cImport` but the various paths cannot be found. It should also be faster. * save native_libc.txt in zig-cache This avoids having to detect libc at runtime on every invocation.
2019-02-19valgrind client requests for undefined valuesAndrew Kelley
with this change, when you assign undefined, zig emits a few assembly instructions to tell valgrind that the memory is undefined it's on by default for debug builds, and disabled otherwise. only support for linux, darwin, solaris, mingw on x86_64 is currently implemented. --disable-valgrind turns it off even in debug mode. --enable-valgrind turns it on even in release modes. It's always disabled for compiler_rt.a and builtin.a. Adds `@import("builtin").valgrind_support` which lets code know at comptime whether valgrind client requests are enabled. See #1989
2019-02-19remove --no-rosegment workaround now that valgrind bug is fixedAndrew Kelley
See #896 Zig 0.3.0+ and Valgrind 3.14+ do not need the workaround.
2019-02-16bring zig fmt to stage1Andrew Kelley
2019-02-06require running std lib tests coherentlyAndrew Kelley
this should actually improve CI times a bit too See the description at the top of std/os/startup.zig (deleted in this commit) for a more detailed understanding of what this commit does.
2019-02-01introduce --single-threaded build optionAndrew Kelley
closes #1764 This adds another boolean to the test matrix; hopefully it does not inflate the time too much. std.event.Loop does not work with this option yet. See #1908
2018-12-26fixupsAndrew Kelley
2018-12-24fixed formatting in options displaynebulaeonline