aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-10-09 12:18:09 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-10-09 13:16:50 -0400
commit6b93495792678bd00a6205967bb2704a9a35e9c7 (patch)
tree9dd12653140fd7943c7d09dce22b0367a0caa73c /src/main.cpp
parent5a3c02137e6a15d3b8c1fb3595d55003ea44139a (diff)
downloadzig-6b93495792678bd00a6205967bb2704a9a35e9c7.tar.gz
zig-6b93495792678bd00a6205967bb2704a9a35e9c7.zip
more efficient builtin library code generation
* introduce --disable-pic option which can generally be allowed to be the default. compiler_rt.a and builtin.a get this option when you build a static executable. * compiler_rt and builtin libraries are not built for build-lib --static * posix_spawn instead of fork/execv * disable the error limit on LLD. Fixes the blank lines printed
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index f9df802cb3..5e827b5ba6 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -47,6 +47,7 @@ static int print_full_usage(const char *arg0) {
" --cache-dir [path] override the cache directory\n"
" --cache [auto|off|on] build in global cache, print out paths to stdout\n"
" --color [auto|off|on] enable or disable colored error messages\n"
+ " --disable-pic disable Position Independent Code for libraries\n"
" --emit [asm|bin|llvm-ir] emit a specific file format as compilation output\n"
" -ftime-report print timing diagnostics\n"
" --libc-include-dir [path] directory where libc stdlib.h resides\n"
@@ -386,6 +387,7 @@ int main(int argc, char **argv) {
size_t ver_minor = 0;
size_t ver_patch = 0;
bool timing_info = false;
+ bool disable_pic = false;
const char *cache_dir = nullptr;
CliPkg *cur_pkg = allocate<CliPkg>(1);
BuildMode build_mode = BuildModeDebug;
@@ -556,6 +558,8 @@ int main(int argc, char **argv) {
each_lib_rpath = true;
} else if (strcmp(arg, "-ftime-report") == 0) {
timing_info = true;
+ } else if (strcmp(arg, "--disable-pic") == 0) {
+ disable_pic = true;
} else if (strcmp(arg, "--test-cmd-bin") == 0) {
test_exec_args.append(nullptr);
} else if (arg[1] == 'L' && arg[2] != 0) {
@@ -849,6 +853,14 @@ int main(int argc, char **argv) {
buf_out_name = buf_create_from_str("run");
}
CodeGen *g = codegen_create(zig_root_source_file, target, out_type, build_mode, get_zig_lib_dir());
+ if (disable_pic) {
+ if (out_type != OutTypeLib || !is_static) {
+ fprintf(stderr, "--disable-pic only applies to static libraries");
+ return EXIT_FAILURE;
+ }
+ g->disable_pic = true;
+ }
+
g->enable_time_report = timing_info;
buf_init_from_str(&g->cache_dir, cache_dir ? cache_dir : default_zig_cache_name);
codegen_set_out_name(g, buf_out_name);