45 Commits

Author SHA1 Message Date
MIURA Masahiro
fea016afc0 Fix the color of compiler messages for light-themed terminal. 2017-12-04 19:22:34 +09:00
Andrew Kelley
abff1b6884 windows: use the same libc search within a compilation unit 2017-11-01 23:08:34 -04:00
Dimenus
38f05d4ac5 WIN32: Linking with the CRT at runtime. (#570)
Disclaimer: Forgive me if my format sucks, I've never submitted a PR before!

Fixes: #517 

I added a few things to allow zig to link with the CRT properly both statically and dynamically. In Visual Studio 2017, Microsoft changed how the c-runtime is factored again. With this change, they also added a COM interface to allow you to query the respective Visual Studio instance for two of them. This does that and also falls back on a registry query for 2015 support. If you're using a Visual Studio instance older than 2015, you'll have to use the existing options available with the zig compiler. Changes are listed below along with a general description of the changes.

all_types.cpp:

The separate variables for msvc/kern32 have been removed and all win32 libc directory paths have been combined into a ZigList since we're querying more than two directories and differentiating one from another doesn't matter to lld.

analyze.cpp:

The existing functions were extended to support querying libc libs & libc headers at runtime.

codegen.cpp/hpp:

Microsoft uses the new 'Universal C Runtime' name now. Doesn't matter from a functionality standpoint. I left the compiler switches as is to not introduce any breaking changes.

link.cpp:

We're linking 4 libs and generating another in order to support the UCRT.
Dynamic: msvcrt/d, vcruntime/d, ucrt/d, legacy_stdio_definitions.lib
Static: libcmt/d, libvcruntime/d libucrt/d, legacy_stdio_definitions.lib

main.cpp:

Update function call names.

os.cpp/hpp:

COM/Registry interface for querying Windows UCRT/SDK.

Sources:
[Windows CRT](https://docs.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features)
[VS 2015 Breaking Changes](https://msdn.microsoft.com/en-us/library/bb531344.aspx)
2017-11-01 15:33:14 -04:00
Andrew Kelley
e3ad13e054 fix windows argument parsing 2017-10-15 20:19:15 -04:00
Andrew Kelley
c837ae1707 set stdout and stderr to binary mode on windows 2017-10-15 18:25:39 -04:00
Andrew Kelley
1fe1e6eeaf mingw build: delete unused variable 2017-10-15 14:03:24 -04:00
Andrew Kelley
3c19883493 only SetConsoleTextAttribute to do console colors on windows 2017-10-15 12:15:32 -04:00
Andrew Kelley
ba405ed59b try harder to emit console colors 2017-10-14 20:31:47 -04:00
Andrew Kelley
3af35fc1df fix mingw build 2017-10-03 09:32:38 -04:00
Andrew Kelley
0a4283b38b support terminal colors for cmd.exe and msys pty
See #302
2017-10-02 01:37:05 -04:00
Andrew Kelley
1962c8588f implement standard library path search
closes #463
See #302
2017-10-01 18:30:31 -04:00
Andrew Kelley
09369b6a43 better implementation of os_spawn_process for windows
See #302
2017-09-30 00:43:22 -04:00
Jonathan Marler
7c81cd30de Add support for MSVC 2017-09-11 09:26:26 -06:00
Andrew Kelley
29a418c9d5 progress toward tests passing on MacOS 2017-08-27 00:11:09 -04:00
Andrew Kelley
d8d45908fa building with mingw for windows 2017-05-23 00:26:12 -04:00
Andrew Kelley
a147f06585 zig puts temporary object files in zig-cache folder
See #298
2017-04-28 02:22:12 -04:00
Andrew Kelley
7b0542d08b build system: consolidate duplicate code and more
* add ability to add assembly files when building an exe, obj, or lib
 * add implicit cast from `[N]T` to `?[]const T` (closes #343)
 * remove link_exe and link_lib in favor of allowing build_exe and
   build_lib support no root zig source file
2017-04-26 19:17:05 -04:00
Andrew Kelley
e0050af293 add some timing diagnostics
pass --enable-timing-info to print a nice table like this:

```
                Name       Start         End    Duration     Percent
          Initialize      0.0000      0.0000      0.0000      0.0001
   Semantic Analysis      0.0000      0.0421      0.0420      0.2109
     Code Generation      0.0421      0.0620      0.0200      0.1003
    LLVM Emit Object      0.0620      0.1852      0.1231      0.6180
  Build Dependencies      0.1852      0.1974      0.0122      0.0615
           LLVM Link      0.1974      0.1993      0.0018      0.0093
         Generate .h      0.1993      0.1993      0.0000      0.0000
               Total      0.0000      0.1993      0.1993      1.0000
```
2017-04-25 12:29:25 -04:00
Andrew Kelley
d1e01e43d3 convert assemble and link tests to zig build system 2017-04-19 14:00:12 -04:00
Andrew Kelley
2864359950 zig build system writes template build.zig file when none exists
see #204
2017-04-11 06:14:46 -04:00
Andrew Kelley
11a6550324 fix some -Wconversion errors 2017-04-10 20:02:39 -04:00
Andrew Kelley
3ca027ca82 first pass at zig build system
* `zig build --export [obj|lib|exe]` changed to `zig build_obj`,
   `zig build_lib` and `zig build_exe` respectively.
 * `--name` parameter is optional when it can be inferred from the
   root source filename. closes #207
 * `zig build` now looks for `build.zig` which interacts with
   `std.build.Builder` to describe the targets, and then the zig
   build system prints TODO: build these targets. See #204
 * add `@bitcast` which is mainly used for pointer reinterpret
   casting and make explicit casting not do pointer reinterpretation.
   Closes #290
 * fix debug info for byval parameters
 * sort command line help options
 * `std.debug.panic` supports format string printing
 * add `std.mem.IncrementingAllocator`
 * fix const ptr to a variable with data changing at runtime.
   closes #289
2017-03-31 05:55:41 -04:00
Andrew Kelley
7efa2cd81c add --each-lib-rpath option and corresponding config option
This adds an rpath entry for each used dynamic library directory.
This is necessary on some systems such as NixOS.
2017-03-13 13:11:55 -04:00
Andrew Kelley
4b902b44a2 os: fix file descriptor leak in os_exec
See #182
2016-09-22 10:48:42 -04:00
Andrew Kelley
3239b3cb69 use size_t for indexes
protect against incorrect copies in debug mode
2016-09-19 11:54:01 -04:00
Andrew Kelley
eb83111f02 add debug safety for division
See #149
2016-05-07 19:58:02 -07:00
Andrew Kelley
5e33175517 add @embed_file builtin function 2016-04-18 15:47:21 -07:00
Andrew Kelley
0a0494feb8 fix build error with signed/unsigned 2016-02-19 14:02:36 -07:00
Andrew Kelley
a7b6fa5bee os: implement windows os layer 2016-02-17 19:53:30 -07:00
Andrew Kelley
afa5d1ea12 os: fix ability to compile for windows 2016-02-16 19:55:49 -07:00
Andrew Kelley
194e93a582 add windows os code 2016-02-16 19:42:46 -07:00
Andrew Kelley
11a0644365 basic support for building a test target 2016-02-03 18:02:01 -07:00
Andrew Kelley
650fdded29 fix incorrect loading of files over 8192 bytes 2016-01-28 22:38:18 -07:00
Andrew Kelley
0278468479 upgrade to the libclang C++ API
c_import creates a tmp .h file and parses it with libclang,
reporting any errors found.

See #88
2016-01-27 00:01:49 -07:00
Andrew Kelley
4d45d14b55 use realpath to avoid duplicate imports 2015-12-15 21:48:41 -07:00
Andrew Kelley
f5a3281877 when linking with libc use the C runtime library 2015-12-15 12:44:42 -07:00
Andrew Kelley
139e5ca08f fix reading source from stdin 2015-12-04 14:33:40 -07:00
Andrew Kelley
dfb6682089 add test for bad import 2015-12-01 02:29:21 -07:00
Andrew Kelley
257cf09472 colored error messages that tell the source file 2015-12-01 00:50:11 -07:00
Andrew Kelley
55b8472374 refactor code to prepare for multiple files
verbose compiler output is now behind --verbose flag
2015-11-30 20:00:39 -07:00
Josh Wolfe
00a7936c9f more readable integer constant 2015-11-26 02:48:06 -07:00
Andrew Kelley
763ce1c485 add tests 2015-11-26 01:29:52 -07:00
Andrew Kelley
22421447fb fix the remaining TODOs in the source 2015-11-25 16:36:03 -07:00
Andrew Kelley
ca836191e1 debug information for functions 2015-11-24 19:07:33 -07:00
Andrew Kelley
fefbee166d hello world example working 2015-11-24 13:51:36 -07:00