From 2de53592a1d84a1476f662e20d7339d25d4716fe Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 3 Oct 2020 23:15:45 -0700 Subject: [PATCH] stage1: better value for builtin.link_mode Now it is Dynamic unless -DZIG_STATIC=on is passed to cmake. This partially addresses #6469. --- CMakeLists.txt | 3 +++ src/stage1/codegen.cpp | 2 +- src/stage1/config.h.in | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a3c7f9057..eff05feac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,6 +63,9 @@ endif() if(ZIG_STATIC) set(ZIG_STATIC_LLVM "on") + set(ZIG_LINK_MODE "Static") +else() + set(ZIG_LINK_MODE "Dynamic") endif() string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_LIBC_LIB_DIR_ESCAPED "${ZIG_LIBC_LIB_DIR}") diff --git a/src/stage1/codegen.cpp b/src/stage1/codegen.cpp index 2fc85b42f..194e5e38f 100644 --- a/src/stage1/codegen.cpp +++ b/src/stage1/codegen.cpp @@ -8815,7 +8815,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) { buf_append_str(contents, "/// Deprecated: use `std.Target.current.cpu.arch.endian()`\n"); buf_append_str(contents, "pub const endian = Target.current.cpu.arch.endian();\n"); buf_appendf(contents, "pub const output_mode = OutputMode.Obj;\n"); - buf_appendf(contents, "pub const link_mode = LinkMode.Static;\n"); + buf_appendf(contents, "pub const link_mode = LinkMode.%s;\n", ZIG_LINK_MODE); buf_appendf(contents, "pub const is_test = false;\n"); buf_appendf(contents, "pub const single_threaded = %s;\n", bool_to_str(g->is_single_threaded)); buf_appendf(contents, "pub const abi = Abi.%s;\n", cur_abi); diff --git a/src/stage1/config.h.in b/src/stage1/config.h.in index 8c147e7d6..e95e9e8ce 100644 --- a/src/stage1/config.h.in +++ b/src/stage1/config.h.in @@ -21,5 +21,6 @@ #define ZIG_CLANG_LIBRARIES "@CLANG_LIBRARIES@" #define ZIG_LLVM_CONFIG_EXE "@LLVM_CONFIG_EXE@" #define ZIG_DIA_GUIDS_LIB "@ZIG_DIA_GUIDS_LIB_ESCAPED@" +#define ZIG_LINK_MODE "@ZIG_LINK_MODE@" #endif