fix building on arm
authorJacob Lifshay <programmerjake@gmail.com>
Fri, 8 Sep 2017 14:03:46 +0000 (07:03 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Fri, 8 Sep 2017 14:12:00 +0000 (07:12 -0700)
src/demo/demo.cpp
src/spirv_to_llvm/spirv_to_llvm.cpp
src/spirv_to_llvm/spirv_to_llvm.h

index 151e9cde3721949ccac3de351c7f3cf0fe93b815..cedf22774eb704dd2542416f534387b325aab59b 100644 (file)
@@ -489,7 +489,7 @@ std::vector<Vertex_input_struct> load_wavefront_obj_file(const char *filename)
                 {
                     std::size_t vertex_count = vertexes.size();
                     std::int64_t max_index = vertex_count;
-                    std::int64_t min_index = -vertex_count;
+                    std::int64_t min_index = -max_index;
                     auto vertex_index =
                         parse_signed_integer(vertex_index_str, max_index, min_index);
                     if(!vertex_index || *vertex_index == 0)
index aae4b0412afb95d346c146b20ffb9b76750fcbea..4864bdd931fb76f4d2e22e915a050a60d70b371e 100644 (file)
@@ -496,6 +496,33 @@ void Spirv_to_llvm::handle_header(unsigned version_number_major,
         id_states.resize(id_bound - 1);
     }
 }
+
+namespace
+{
+#define DECLARE_LIBRARY_SYMBOL(name) \
+    static void library_symbol_##name() __attribute__((weakref(#name)));
+#ifdef __ARM_EABI__
+DECLARE_LIBRARY_SYMBOL(__aeabi_unwind_cpp_pr0)
+#endif
+}
+
+Jit_symbol_resolver::Resolved_symbol Jit_symbol_resolver::resolve(util::string_view name)
+{
+#define RESOLVE_LIBRARY_SYMBOL(symbol_name)                                            \
+    if(#symbol_name == name)                                                           \
+    {                                                                                  \
+        if(library_symbol_##symbol_name == nullptr)                                    \
+            throw std::runtime_error(                                                  \
+                "JIT symbol resolve error: library symbol not linked: " #symbol_name); \
+        return library_symbol_##symbol_name;                                           \
+    }
+
+#ifdef __ARM_EABI__
+    RESOLVE_LIBRARY_SYMBOL(__aeabi_unwind_cpp_pr0)
+#endif
+#warning finish implementing
+    return nullptr;
+}
 }
 
 spirv_to_llvm::Converted_module spirv_to_llvm::spirv_to_llvm(
index d7e312a504c4eba1be6857c13134a79e7f34d385..45c2b5854353afc6c7be0eb64e15bd0a970364a7 100644 (file)
@@ -591,11 +591,7 @@ struct Converted_module
 struct Jit_symbol_resolver
 {
     typedef void (*Resolved_symbol)();
-    Resolved_symbol resolve(util::string_view name)
-    {
-#warning finish implementing
-        return nullptr;
-    }
+    Resolved_symbol resolve(util::string_view name);
     static std::uint64_t resolve(const char *name, void *user_data) noexcept
     {
         return reinterpret_cast<std::uint64_t>(