aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
AgeCommit message (Collapse)Author
2020-09-17delete all stage1 c++ code not directly related to compiling stage2Andrew Kelley
Deleted 16,000+ lines of c++ code, including: * an implementation of blake hashing * the cache hash system * compiler.cpp * all the linking code, and everything having to do with building glibc, musl, and mingw-w64 * much of the stage1 compiler internals got slimmed down since it now assumes it is always outputting an object file. More stuff: * stage1 is now built with a different strategy: we have a tiny zig0.cpp which is a slimmed down version of what stage1 main.cpp used to be. Its only purpose is to build stage2 zig code into an object file, which is then linked by the host build system (cmake) into stage1. zig0.cpp uses the same C API that stage2 now has access to, so that stage2 zig code can call into stage1 c++ code. - stage1.h is - stage2.h is - stage1.zig is the main entry point for the Zig/C++ hybrid compiler. It has the functions exported from Zig, called in C++, and bindings for the functions exported from C++, called from Zig. * removed the memory profiling instrumentation from stage1. Abandon ship! * Re-added the sections to the README about how to build stage2 and stage3. * stage2 now knows as a comptime boolean whether it is being compiled as part of stage1 or as stage2. - TODO use this flag to call into stage1 for compiling zig code. * introduce -fdll-export-fns and -fno-dll-export-fns and clarify its relationship to link_mode (static/dynamic) * implement depending on LLVM to detect native target cpu features when LLVM extensions are enabled and zig lacks CPU feature detection for that target architecture. * C importing is broken, will need some stage2 support to function again.
2020-09-12Merge remote-tracking branch 'origin/master' into stage2-zig-ccAndrew Kelley
Master branch added in the concept of library versioning being optional to main.cpp. It will need to be re-added into this branch before merging back into master.
2020-09-11std, stage1: make shared library versioning optionalIsaac Freund
This commit changes the behavior of stage1 to emit libfoo.so instead of libfoo.so.0.0.0 when none of the --ver-major, --ver-minor, or --ver-patch flags are set. It also makes it possible to create unversioned shared libraries using the zig build system, changing the version parameter of addSharedLibrary() to a tagged union.
2020-09-09stage2: compiling C objects with clangAndrew Kelley
* add target_util.zig which has ported code from src/target.cpp * Module gains an arena that owns memory used during initialization that has the same lifetime as the Module. Useful for constructing file paths and lists of strings that have mixed lifetimes. - The Module memory itself is allocated in this arena. init/deinit are modified to be create/destroy. - root_name moves to the arena and no longer needs manual free * implement the ability to invoke `zig clang` as a subprocess - there are lots of TODOs that should be solved before merging * Module now requires a Random object and zig_lib_dir * Module now requires a path to its own executable or any zig executable that can do `zig clang`. * Wire up more CLI options. * Module creates "zig-cache" directory and "tmp" and "o" subdirectories ("h" is created by the cache_hash) * stubbed out some of the things linker code needs to do with TODO prints * delete dead code for computing compiler id. the previous commit eliminated the need for it. * add `zig translate-c` CLI option but it's not fully hooked up yet. It should be possible for this to be fully wired up before merging this branch. * `zig targets` now uses canonical data for available_libcs
2020-09-09start moving `zig cc` to stage2Andrew Kelley
* build.zig: repair the ability to link against llvm, clang, and lld * move the zig cc arg parsing logic to stage2 - the preprocessor flag is still TODO - the clang arg iterator code is improved to use slices instead of raw pointers because it no longer has to deal with an extern struct. * clean up error printing with a `fatal` function and use log API for messages rather than std.debug.print * add support for more CLI options to stage2 & update usage text - hooking up most of these new options is TODO * clean up the way libc and libc++ are detected via command line options. target information is used to determine if any of the libc candidate names are chosen. * add native library directory detection * implement the ability to invoke clang from stage2 * introduce a build_options.have_llvm so we can comptime branch on whether LLVM is linked in or not.
2020-08-17simplify `zig info` and rename it to `zig env`Andrew Kelley
also add version to it
2020-08-17add `zig info` commandSergey Poznyak
2020-06-08Add option for overriding the stack sizeJakub Konka
This commit adds a `--stack [size]` link-time option to zig compiler allowing the user to override the default stack size set for the specified executable/library format. This is currently limited to ELF, COFF and Wasm however (i.e., Mach-O is excluded).
2020-04-26add CLI option -Bsymbolic for binding global references locallyAndrew Kelley
2020-04-15CC: fix binary dupe with no -oLayne Gustafson
2020-04-14cli: add `c++` subcommand to --help menuAndrew Kelley
closes #5034
2020-04-12Zig treats -lstdc++ identically to -lc++Andrew Kelley
Thanks to Michael Dusan for figuring out what was happening here. closes #5012
2020-04-06zig cc: recognize a few more linker optionsAndrew Kelley
* `--major-image-version` * `--minor-image-version` * `--stack`
2020-04-04zig cc looks for native include directories unless -nostdincAndrew Kelley
closes #4938
2020-04-04remove `zig BUILD_INFO` hackAndrew Kelley
Rather than stuffing configuration information into the Zig binary, the build script reads it from config.h. This solves a problem for package maintainers and improves the use case of deterministic builds. closes #3758
2020-04-03zig cc: add -allow-shlib-undefined aliasAndrew Kelley
2020-04-02zig cc: support more linker argsAndrew Kelley
2020-04-02zig cc: support --version-script linker argAndrew Kelley
See #4784
2020-04-02zig cc: support -F and -frameworkAndrew Kelley
2020-04-02zig cc: respect -MF -MV -MD optionsAndrew Kelley
Zig disables its caching and forwards these args when any are provided. see #4784
2020-04-01zig cc: detect -mcpu, -march, -mtuneAndrew Kelley
However these are all treated like zig's -mcpu parameter. See #4784
2020-04-01zig cc: add support for -L linker argumentsRejean Loyer
2020-04-01zig cc properly handles -S flag and .ll, .bc extensionsAndrew Kelley
2020-03-30revert detection of rtti and exceptionsAndrew Kelley
This caused link errors in c++ code because it was not correct to pass these flags to child codegens. And that was the only reason to detect these flags. Otherwise we can safely rely on non-explicitly-detected flag forwarding.
2020-03-29linking against c++ does not trigger system library directoriesAndrew Kelley
2020-03-29zig cc: -O0 also counts as debug modeAndrew Kelley
2020-03-28zig cc: Add support for -zRyan Liptak
This is only the first step; it makes zig cc recognize -z and append it to the linker args, but the linker arg parsing doesn't support -z yet so it will just give the warning 'unsupported linker arg: -z'
2020-03-27zig cc: Add support for -Xlinker, --for-linker, --for-linker=Ryan Liptak
2020-03-28Merge pull request #4835 from squeek502/export-dynamicAndrew Kelley
-rdynamic/--export-dynamic fixes
2020-03-27zig cc: Add --export-dynamic linker flag supportRyan Liptak
2020-03-27zig c++: get it working with musl and mingw-w64Andrew Kelley
2020-03-26ability to compile c++ hello world with `zig c++`Andrew Kelley
closes #4786
2020-03-25improved handling of native system directoriesAndrew Kelley
* `-isystem` instead of `-I` for system include directories fixes a problem with native system directories interfering with zig's bundled libc. * separate Stage2Target.is_native into Stage2Target.is_native_os and Stage2Target.is_native_cpu.
2020-03-25zig cc: add detection for `-###`Andrew Kelley
it turns on --verbose-cc and --verbose-link
2020-03-25zig cc: freestanding target implies -nostdlibAndrew Kelley
2020-03-25zig cc: support -T linker script optionAndrew Kelley
2020-03-24Merge remote-tracking branch 'origin/llvm10'Andrew Kelley
LLVM 10 was released today
2020-03-23zig cc: detect dynamic linker argumentAndrew Kelley
2020-03-23zig cc: recognize .S and .C as source file extensionsAndrew Kelley
2020-03-22Merge remote-tracking branch 'origin/master' into llvm10Andrew Kelley
2020-03-22Merge remote-tracking branch 'origin/master' into llvm10Andrew Kelley
2020-03-21zig cc: detect optimization and debug flagsAndrew Kelley
2020-03-21zig cc: better support for the preprocessor option (-E)Andrew Kelley
2020-03-21rename "passthrough" → "driver_punt"Michael Dusan
- punt when `-E` is supplied - punt when `-S` is supplied
2020-03-21zig cc: support .cc and .cxx extensionsAndrew Kelley
2020-03-21zig cc improvementsAndrew Kelley
* The generated options data file is sorted now in a way that makes sure longer prefixes are first. This prevents collisions with some parameters. * Add support for `-fPIC`, `-fno-PIC`, `-nostdlib`, `-shared`, `-rdynamic`, `-Wl,-soname`, `-Wl,-rpath` * Better support for `-o`. * Disable generating h files * Shared library support. * Better positional argument support.
2020-03-21ability to use `zig cc` as a drop-in C compilerAndrew Kelley
The basics are working
2020-03-20"generate .h files" feature is no longer supported in stage1Andrew Kelley
2020-03-19Merge remote-tracking branch 'origin/master' into llvm10Andrew Kelley
2020-03-13zig build system: correctly handle multiple output artifactsAndrew Kelley
Previously the zig build system incorrectly assumed that the only build artifact was a binary. Now, when you enable the cache, only the output dir is printed to stdout, and the zig build system iterates over the files in that directory, copying them to the output directory. To support this change: * Add `std.os.renameat`, `std.os.renameatZ`, and `std.os.renameatW`. * Fix `std.os.linux.renameat` not compiling due to typos. * Deprecate `std.fs.updateFile` and `std.fs.updateFileMode`. * Add `std.fs.Dir.updateFile`, which supports using open directory handles for both the source and destination paths, as well as an options parameter which allows overriding the mode. * Update `std.fs.AtomicFile` to support operating based on an open directory handle. Instead of `std.fs.AtomicFile.init`, use `std.fs.Dir.atomicFile`. * `std.fs.AtomicFile` deinit() better handles the situation when the rename fails but the temporary file still exists, by still attempting to remove the temporary file. * `std.fs.Dir.openFileWindows` is moved to `std.os.windows.OpenFileW`. * `std.os.RenameError` gains the error codes `NoDevice`, `SharingViolation`, and `PipeBusy` which have been observed from Windows. Closes #4733