aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-10-09 13:20:27 -0400
committerGitHub <noreply@github.com>2018-10-09 13:20:27 -0400
commit9e38a81230bcaefb50fae610c071005449a7abfb (patch)
treef706728a6b853da0b66379539018645df583519b /src/main.cpp
parentd40c4e7c896c5dfed9dd35e8c0d2117f7cf5c53c (diff)
parent81c6f087241b6b7a1c12de72a2061cb02df0f93f (diff)
downloadzig-9e38a81230bcaefb50fae610c071005449a7abfb.tar.gz
zig-9e38a81230bcaefb50fae610c071005449a7abfb.zip
Merge pull request #1647 from ziglang/static-libs
Support building static libraries
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);