Merge remote-tracking branch 'origin/master' into llvm8
This commit is contained in:
@@ -7724,8 +7724,11 @@ static Error define_builtin_compile_vars(CodeGen *g) {
|
||||
|
||||
Buf digest = BUF_INIT;
|
||||
buf_resize(&digest, 0);
|
||||
if ((err = cache_hit(&cache_hash, &digest)))
|
||||
return err;
|
||||
if ((err = cache_hit(&cache_hash, &digest))) {
|
||||
// Treat an invalid format error as a cache miss.
|
||||
if (err != ErrorInvalidFormat)
|
||||
return err;
|
||||
}
|
||||
|
||||
// We should always get a cache hit because there are no
|
||||
// files in the input hash.
|
||||
@@ -7890,7 +7893,7 @@ static void init(CodeGen *g) {
|
||||
}
|
||||
|
||||
static void detect_dynamic_linker(CodeGen *g) {
|
||||
if (g->dynamic_linker_path != nullptr)
|
||||
if (g->dynamic_linker_path != nullptr || g->is_static)
|
||||
return;
|
||||
const char *standard_ld_path = target_dynamic_linker(g->zig_target);
|
||||
if (standard_ld_path == nullptr)
|
||||
@@ -7942,22 +7945,22 @@ static void detect_libc(CodeGen *g) {
|
||||
if (g->libc != nullptr || g->libc_link_lib == nullptr)
|
||||
return;
|
||||
|
||||
if (g->zig_target->os == OsLinux && target_abi_is_gnu(g->zig_target->abi)) {
|
||||
// we have glibc headers and can build glibc start files from source
|
||||
if (g->is_static && g->out_type == OutTypeExe) {
|
||||
fprintf(stderr, "glibc does not support static linking\n");
|
||||
exit(1);
|
||||
}
|
||||
if (g->zig_target->os == OsLinux && target_abi_is_gnu(g->zig_target->abi) &&
|
||||
g->is_static && g->out_type == OutTypeExe)
|
||||
{
|
||||
fprintf(stderr, "glibc does not support static linking\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Buf libc_include_dir = BUF_INIT;
|
||||
os_path_join(g->zig_lib_dir, buf_create_from_str("libc" OS_SEP "include"), &libc_include_dir);
|
||||
if (target_can_build_libc(g->zig_target)) {
|
||||
const char *generic_name = target_libc_generic_name(g->zig_target);
|
||||
|
||||
Buf *arch_include_dir = buf_sprintf("%s" OS_SEP "libc" OS_SEP "include" OS_SEP "%s-%s-%s",
|
||||
buf_ptr(g->zig_lib_dir), target_arch_name(g->zig_target->arch),
|
||||
target_os_name(g->zig_target->os), target_abi_name(g->zig_target->abi));
|
||||
|
||||
Buf *generic_include_dir = buf_sprintf("%s" OS_SEP "libc" OS_SEP "include" OS_SEP "generic-glibc",
|
||||
buf_ptr(g->zig_lib_dir));
|
||||
Buf *generic_include_dir = buf_sprintf("%s" OS_SEP "libc" OS_SEP "include" OS_SEP "generic-%s",
|
||||
buf_ptr(g->zig_lib_dir), generic_name);
|
||||
|
||||
g->libc_include_dir_len = 2;
|
||||
g->libc_include_dir_list = allocate<Buf*>(2);
|
||||
@@ -8011,11 +8014,14 @@ static void detect_libc(CodeGen *g) {
|
||||
} else if ((g->out_type == OutTypeExe || (g->out_type == OutTypeLib && !g->is_static)) &&
|
||||
!target_is_darwin(g->zig_target))
|
||||
{
|
||||
// Currently darwin is the only platform that we can link libc on when not compiling natively,
|
||||
// without a cross compiling libc kit.
|
||||
fprintf(stderr,
|
||||
"Cannot link against libc for non-native OS '%s' without providing a libc installation file.\n"
|
||||
"See `zig libc --help` for more details.\n", target_os_name(g->zig_target->os));
|
||||
"Zig is unable to provide a libc for the chosen target '%s-%s-%s'.\n"
|
||||
"The target is non-native, so Zig also cannot use the native libc installation.\n"
|
||||
"Choose a target which has a libc available, or provide a libc installation text file.\n"
|
||||
"See `zig libc --help` for more details.\n",
|
||||
target_arch_name(g->zig_target->arch),
|
||||
target_os_name(g->zig_target->os),
|
||||
target_abi_name(g->zig_target->abi));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@@ -8342,12 +8348,14 @@ static void gen_c_object(CodeGen *g, Buf *self_exe_path, CFile *c_file) {
|
||||
Buf digest = BUF_INIT;
|
||||
buf_resize(&digest, 0);
|
||||
if ((err = cache_hit(cache_hash, &digest))) {
|
||||
if (err == ErrorCacheUnavailable) {
|
||||
// already printed error
|
||||
} else {
|
||||
fprintf(stderr, "unable to check cache when compiling C object: %s\n", err_str(err));
|
||||
if (err != ErrorInvalidFormat) {
|
||||
if (err == ErrorCacheUnavailable) {
|
||||
// already printed error
|
||||
} else {
|
||||
fprintf(stderr, "unable to check cache when compiling C object: %s\n", err_str(err));
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
bool is_cache_miss = (buf_len(&digest) == 0);
|
||||
if (is_cache_miss) {
|
||||
@@ -8993,7 +9001,10 @@ void codegen_print_timing_report(CodeGen *g, FILE *f) {
|
||||
}
|
||||
|
||||
void codegen_add_time_event(CodeGen *g, const char *name) {
|
||||
g->timing_events.append({os_get_time(), name});
|
||||
OsTimeStamp timestamp = os_timestamp_monotonic();
|
||||
double seconds = (double)timestamp.sec;
|
||||
seconds += ((double)timestamp.nsec) / 1000000000.0;
|
||||
g->timing_events.append({seconds, name});
|
||||
}
|
||||
|
||||
static void add_cache_pkg(CodeGen *g, CacheHash *ch, ZigPackage *pkg) {
|
||||
@@ -9090,8 +9101,10 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {
|
||||
cache_list_of_file(ch, g->link_objects.items, g->link_objects.length);
|
||||
|
||||
buf_resize(digest, 0);
|
||||
if ((err = cache_hit(ch, digest)))
|
||||
return err;
|
||||
if ((err = cache_hit(ch, digest))) {
|
||||
if (err != ErrorInvalidFormat)
|
||||
return err;
|
||||
}
|
||||
|
||||
if (ch->manifest_file_path != nullptr) {
|
||||
g->caches_to_release.append(ch);
|
||||
|
||||
Reference in New Issue
Block a user