From fb8e681ea8413b233ebc83cc649ab9a166b6d979 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 22 Jan 2020 18:43:30 -0500 Subject: update zig_llvm.h and zig_llvm.cpp to llvm 10 --- src/target.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/target.cpp') diff --git a/src/target.cpp b/src/target.cpp index 82d5467e26..197a2e9f23 100644 --- a/src/target.cpp +++ b/src/target.cpp @@ -21,6 +21,7 @@ static const SubArchList subarch_list_list[] = { SubArchListArm64, SubArchListKalimba, SubArchListMips, + SubArchListPPC, }; static const ZigLLVM_SubArchType subarch_list_arm32[] = { @@ -72,6 +73,10 @@ static const ZigLLVM_SubArchType subarch_list_mips[] = { ZigLLVM_MipsSubArch_r6, }; +static const ZigLLVM_SubArchType subarch_list_ppc[] = { + ZigLLVM_PPCSubArch_spe, +}; + static const ZigLLVM_ArchType arch_list[] = { ZigLLVM_arm, // ARM (little endian): arm, armv.*, xscale ZigLLVM_armeb, // ARM (big endian): armeb @@ -123,6 +128,7 @@ static const ZigLLVM_ArchType arch_list[] = { ZigLLVM_wasm64, // WebAssembly with 64-bit pointers ZigLLVM_renderscript32, // 32-bit RenderScript ZigLLVM_renderscript64, // 64-bit RenderScript + ZigLLVM_ve, // NEC SX-Aurora Vector Engine }; static const ZigLLVM_VendorType vendor_list[] = { @@ -627,6 +633,7 @@ SubArchList target_subarch_list(ZigLLVM_ArchType arch) { case ZigLLVM_wasm64: case ZigLLVM_renderscript32: case ZigLLVM_renderscript64: + case ZigLLVM_ve: return SubArchListNone; } zig_unreachable(); @@ -644,6 +651,8 @@ size_t target_subarch_count(SubArchList sub_arch_list) { return array_length(subarch_list_kalimba); case SubArchListMips: return array_length(subarch_list_mips); + case SubArchListPPC: + return array_length(subarch_list_ppc); } zig_unreachable(); } @@ -664,6 +673,9 @@ ZigLLVM_SubArchType target_subarch_enum(SubArchList sub_arch_list, size_t i) { case SubArchListMips: assert(i < array_length(subarch_list_mips)); return subarch_list_mips[i]; + case SubArchListPPC: + assert(i < array_length(subarch_list_ppc)); + return subarch_list_ppc[i]; } zig_unreachable(); } @@ -726,6 +738,8 @@ const char *target_subarch_name(ZigLLVM_SubArchType subarch) { return "v5"; case ZigLLVM_MipsSubArch_r6: return "r6"; + case ZigLLVM_PPCSubArch_spe: + return "spe"; } zig_unreachable(); } @@ -935,6 +949,7 @@ uint32_t target_arch_pointer_bit_width(ZigLLVM_ArchType arch) { case ZigLLVM_spir64: case ZigLLVM_wasm64: case ZigLLVM_renderscript64: + case ZigLLVM_ve: return 64; } zig_unreachable(); @@ -998,6 +1013,7 @@ uint32_t target_arch_largest_atomic_bits(ZigLLVM_ArchType arch) { case ZigLLVM_spir64: case ZigLLVM_wasm64: case ZigLLVM_renderscript64: + case ZigLLVM_ve: return 64; case ZigLLVM_x86_64: -- cgit v1.2.3 From 800ead2810fa573a7e94979e707a14d4e066ef77 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 23 Jan 2020 17:31:25 -0500 Subject: update target info to llvm 10 the branch builds now --- lib/std/target.zig | 1 + src/target.cpp | 9 +++++---- src/target.hpp | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src/target.cpp') diff --git a/lib/std/target.zig b/lib/std/target.zig index 6593e40700..42cbe6c7fc 100644 --- a/lib/std/target.zig +++ b/lib/std/target.zig @@ -757,6 +757,7 @@ pub const Target = union(enum) { .bpfeb, .sparcv9, .s390x, + .ve, => return 64, } } diff --git a/src/target.cpp b/src/target.cpp index 197a2e9f23..c92ae3732f 100644 --- a/src/target.cpp +++ b/src/target.cpp @@ -202,8 +202,6 @@ static const ZigLLVM_EnvironmentType abi_list[] = { ZigLLVM_CODE16, ZigLLVM_EABI, ZigLLVM_EABIHF, - ZigLLVM_ELFv1, - ZigLLVM_ELFv2, ZigLLVM_Android, ZigLLVM_Musl, ZigLLVM_MuslEABI, @@ -765,6 +763,8 @@ const char *target_subarch_list_name(SubArchList sub_arch_list) { return "Kalimba"; case SubArchListMips: return "Mips"; + case SubArchListPPC: + return "PPC"; } zig_unreachable(); } @@ -1386,6 +1386,7 @@ const char *target_dynamic_linker(const ZigTarget *target) { case ZigLLVM_lanai: case ZigLLVM_renderscript32: case ZigLLVM_renderscript64: + case ZigLLVM_ve: zig_panic("TODO implement target_dynamic_linker for this arch"); } zig_unreachable(); @@ -1515,6 +1516,7 @@ const char *arch_stack_pointer_register_name(ZigLLVM_ArchType arch) { case ZigLLVM_xcore: case ZigLLVM_ppc: case ZigLLVM_ppc64: + case ZigLLVM_ve: zig_panic("TODO populate this table with stack pointer register name for this CPU architecture"); } zig_unreachable(); @@ -1576,6 +1578,7 @@ bool target_is_arm(const ZigTarget *target) { case ZigLLVM_xcore: case ZigLLVM_ppc: case ZigLLVM_ppc64: + case ZigLLVM_ve: return false; } zig_unreachable(); @@ -1814,8 +1817,6 @@ const char *target_libc_generic_name(const ZigTarget *target) { case ZigLLVM_CODE16: case ZigLLVM_EABI: case ZigLLVM_EABIHF: - case ZigLLVM_ELFv1: - case ZigLLVM_ELFv2: case ZigLLVM_Android: case ZigLLVM_MSVC: case ZigLLVM_Itanium: diff --git a/src/target.hpp b/src/target.hpp index 50611bc853..2640c12e78 100644 --- a/src/target.hpp +++ b/src/target.hpp @@ -60,6 +60,7 @@ enum SubArchList { SubArchListArm64, SubArchListKalimba, SubArchListMips, + SubArchListPPC, }; enum TargetSubsystem { -- cgit v1.2.3 From fae6cf09619e7a8e64f61b84cca7d9fcd471262f Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 25 Mar 2020 20:32:40 -0400 Subject: improved handling of native system directories * `-isystem` instead of `-I` for system include directories fixes a problem with native system directories interfering with zig's bundled libc. * separate Stage2Target.is_native into Stage2Target.is_native_os and Stage2Target.is_native_cpu. --- lib/std/zig/cross_target.zig | 15 +++++++++++---- src-self-hosted/stage2.zig | 6 ++++-- src/codegen.cpp | 15 +++++++++------ src/link.cpp | 6 +++--- src/main.cpp | 12 ++++++++++-- src/stage2.cpp | 6 ++++-- src/stage2.h | 3 ++- src/target.cpp | 3 ++- 8 files changed, 45 insertions(+), 21 deletions(-) (limited to 'src/target.cpp') diff --git a/lib/std/zig/cross_target.zig b/lib/std/zig/cross_target.zig index 130e8cdbc1..bea69b3978 100644 --- a/lib/std/zig/cross_target.zig +++ b/lib/std/zig/cross_target.zig @@ -480,12 +480,19 @@ pub const CrossTarget = struct { return Target.libPrefix_cpu_arch_abi(self.getCpuArch(), self.getAbi()); } - pub fn isNative(self: CrossTarget) bool { + pub fn isNativeCpu(self: CrossTarget) bool { return self.cpu_arch == null and (self.cpu_model == .native or self.cpu_model == .determined_by_cpu_arch) and - self.cpu_features_sub.isEmpty() and self.cpu_features_add.isEmpty() and - self.os_tag == null and self.os_version_min == null and self.os_version_max == null and - self.abi == null and self.dynamic_linker.get() == null and self.glibc_version == null; + self.cpu_features_sub.isEmpty() and self.cpu_features_add.isEmpty(); + } + + pub fn isNativeOs(self: CrossTarget) bool { + return self.os_tag == null and self.os_version_min == null and self.os_version_max == null and + self.dynamic_linker.get() == null and self.glibc_version == null; + } + + pub fn isNative(self: CrossTarget) bool { + return self.isNativeCpu() and self.isNativeOs() and self.abi == null; } pub fn zigTriple(self: CrossTarget, allocator: *mem.Allocator) error{OutOfMemory}![:0]u8 { diff --git a/src-self-hosted/stage2.zig b/src-self-hosted/stage2.zig index 03cdcc5b08..cd0956cae3 100644 --- a/src-self-hosted/stage2.zig +++ b/src-self-hosted/stage2.zig @@ -898,7 +898,8 @@ const Stage2Target = extern struct { abi: c_int, os: c_int, - is_native: bool, + is_native_os: bool, + is_native_cpu: bool, glibc_or_darwin_version: ?*Stage2SemVer, @@ -1166,7 +1167,8 @@ const Stage2Target = extern struct { .os_builtin_str = os_builtin_str_buffer.toOwnedSlice().ptr, .cache_hash = cache_hash_slice.ptr, .cache_hash_len = cache_hash_slice.len, - .is_native = cross_target.isNative(), + .is_native_os = cross_target.isNativeOs(), + .is_native_cpu = cross_target.isNativeCpu(), .glibc_or_darwin_version = glibc_or_darwin_version, .dynamic_linker = dynamic_linker, .standard_dynamic_linker_path = std_dl_z, diff --git a/src/codegen.cpp b/src/codegen.cpp index 3edc99156f..cb1ab6b6b8 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -8782,7 +8782,8 @@ static Error define_builtin_compile_vars(CodeGen *g) { cache_bool(&cache_hash, g->is_single_threaded); cache_bool(&cache_hash, g->test_is_evented); cache_int(&cache_hash, g->code_model); - cache_int(&cache_hash, g->zig_target->is_native); + cache_int(&cache_hash, g->zig_target->is_native_os); + cache_int(&cache_hash, g->zig_target->is_native_cpu); cache_int(&cache_hash, g->zig_target->arch); cache_int(&cache_hash, g->zig_target->vendor); cache_int(&cache_hash, g->zig_target->os); @@ -8917,7 +8918,7 @@ static void init(CodeGen *g) { const char *target_specific_cpu_args = ""; const char *target_specific_features = ""; - if (g->zig_target->is_native) { + if (g->zig_target->is_native_cpu) { target_specific_cpu_args = ZigLLVMGetHostCPUName(); target_specific_features = ZigLLVMGetNativeFeatures(); } @@ -9034,7 +9035,7 @@ static void detect_libc(CodeGen *g) { return; } - if (g->zig_target->is_native) { + if (g->zig_target->is_native_os) { g->libc = heap::c_allocator.create(); // search for native_libc.txt in following dirs: @@ -9672,7 +9673,8 @@ Error create_c_object_cache(CodeGen *g, CacheHash **out_cache_hash, bool verbose cache_int(cache_hash, g->err_color); cache_buf(cache_hash, g->zig_c_headers_dir); cache_list_of_str(cache_hash, g->libc_include_dir_list, g->libc_include_dir_len); - cache_int(cache_hash, g->zig_target->is_native); + cache_int(cache_hash, g->zig_target->is_native_os); + cache_int(cache_hash, g->zig_target->is_native_cpu); cache_int(cache_hash, g->zig_target->arch); cache_int(cache_hash, g->zig_target->vendor); cache_int(cache_hash, g->zig_target->os); @@ -10474,7 +10476,8 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) { cache_list_of_buf(ch, g->forbidden_libs.items, g->forbidden_libs.length); cache_int(ch, g->build_mode); cache_int(ch, g->out_type); - cache_bool(ch, g->zig_target->is_native); + cache_bool(ch, g->zig_target->is_native_os); + cache_bool(ch, g->zig_target->is_native_cpu); cache_int(ch, g->zig_target->arch); cache_int(ch, g->zig_target->vendor); cache_int(ch, g->zig_target->os); @@ -10941,7 +10944,7 @@ CodeGen *codegen_create(Buf *main_pkg_path, Buf *root_src_path, const ZigTarget os_path_join(g->zig_std_dir, buf_sprintf("special"), g->zig_std_special_dir); assert(target != nullptr); - if (!target->is_native) { + if (!target->is_native_os) { g->each_lib_rpath = false; } else { g->each_lib_rpath = true; diff --git a/src/link.cpp b/src/link.cpp index d39736e2a7..25b913be21 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -635,7 +635,7 @@ static const char *build_libunwind(CodeGen *parent, Stage2ProgressNode *progress c_file->args.append("-fPIC"); c_file->args.append("-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS"); c_file->args.append("-Wa,--noexecstack"); - if (parent->zig_target->is_native) { + if (parent->zig_target->is_native_os && parent->zig_target->is_native_cpu) { c_file->args.append("-D_LIBUNWIND_IS_NATIVE_ONLY"); } if (parent->build_mode == BuildModeDebug) { @@ -1829,7 +1829,7 @@ static void construct_linker_job_elf(LinkJob *lj) { } } - if (!g->zig_target->is_native) { + if (!g->zig_target->is_native_os) { lj->args.append("--allow-shlib-undefined"); } } @@ -2460,7 +2460,7 @@ static void construct_linker_job_macho(LinkJob *lj) { lj->args.append(buf_ptr(compiler_rt_o_path)); } - if (g->zig_target->is_native) { + if (g->zig_target->is_native_os) { for (size_t lib_i = 0; lib_i < g->link_libs_list.length; lib_i += 1) { LinkLib *link_lib = g->link_libs_list.at(lib_i); if (target_is_libc_lib_name(g->zig_target, buf_ptr(link_lib->name))) { diff --git a/src/main.cpp b/src/main.cpp index dd7cdead6c..a543b43579 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1325,7 +1325,15 @@ static int main0(int argc, char **argv) { return print_error_usage(arg0); } - if (target.is_native && link_libs.length != 0) { + bool any_non_c_link_libs = false; + for (size_t i = 0; i < link_libs.length; i += 1) { + if (!target_is_libc_lib_name(&target, link_libs.at(i))) { + any_non_c_link_libs = true; + break; + } + } + + if (target.is_native_os && any_non_c_link_libs) { Error err; Stage2NativePaths paths; if ((err = stage2_detect_native_paths(&paths))) { @@ -1338,7 +1346,7 @@ static int main0(int argc, char **argv) { } for (size_t i = 0; i < paths.include_dirs_len; i += 1) { const char *include_dir = paths.include_dirs_ptr[i]; - clang_argv.append("-I"); + clang_argv.append("-isystem"); clang_argv.append(include_dir); } for (size_t i = 0; i < paths.lib_dirs_len; i += 1) { diff --git a/src/stage2.cpp b/src/stage2.cpp index c83b1aa77c..f8a485f93b 100644 --- a/src/stage2.cpp +++ b/src/stage2.cpp @@ -181,7 +181,8 @@ static void get_native_target(ZigTarget *target) { &target->abi, &oformat); target->os = get_zig_os_type(os_type); - target->is_native = true; + target->is_native_os = true; + target->is_native_cpu = true; if (target->abi == ZigLLVM_UnknownEnvironment) { target->abi = target_default_abi(target->arch, target->os); } @@ -204,7 +205,8 @@ Error stage2_target_parse(struct ZigTarget *target, const char *zig_triple, cons target->llvm_cpu_features = ZigLLVMGetNativeFeatures(); target->cache_hash = "native\n\n"; } else if (strcmp(mcpu, "baseline") == 0) { - target->is_native = false; + target->is_native_os = false; + target->is_native_cpu = false; target->llvm_cpu_name = ""; target->llvm_cpu_features = ""; target->cache_hash = "baseline\n\n"; diff --git a/src/stage2.h b/src/stage2.h index 00a3b9451e..4b86fdc059 100644 --- a/src/stage2.h +++ b/src/stage2.h @@ -280,7 +280,8 @@ struct ZigTarget { enum ZigLLVM_EnvironmentType abi; Os os; - bool is_native; + bool is_native_os; + bool is_native_cpu; // null means default. this is double-purposed to be darwin min version struct Stage2SemVer *glibc_or_darwin_version; diff --git a/src/target.cpp b/src/target.cpp index db1e4be809..63360fc029 100644 --- a/src/target.cpp +++ b/src/target.cpp @@ -1239,7 +1239,8 @@ void target_libc_enum(size_t index, ZigTarget *out_target) { out_target->os = libcs_available[index].os; out_target->abi = libcs_available[index].abi; out_target->vendor = ZigLLVM_UnknownVendor; - out_target->is_native = false; + out_target->is_native_os = false; + out_target->is_native_cpu = false; } bool target_has_debug_info(const ZigTarget *target) { -- cgit v1.2.3