You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2020/10/09 22:13:11 UTC

[GitHub] [incubator-tvm] jroesch opened a new pull request #6656: [Rust][Diagnostics][WIP] Add initial boilerplate for Rust diagnostic interface.

jroesch opened a new pull request #6656:
URL: https://github.com/apache/incubator-tvm/pull/6656


   This PR exposes new diagnostics to Rust so we can reuse the better libraries for diagnostics rendering via Rust. 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] tkonolige commented on a change in pull request #6656: [Rust][Diagnostics] Add initial boilerplate for Rust diagnostic interface.

Posted by GitBox <gi...@apache.org>.
tkonolige commented on a change in pull request #6656:
URL: https://github.com/apache/incubator-tvm/pull/6656#discussion_r506766614



##########
File path: cmake/modules/RustExt.cmake
##########
@@ -0,0 +1,26 @@
+if(USE_RUST_EXT AND NOT USE_RUST_EXT EQUAL OFF)

Review comment:
       I think `if(USE_RUST_EXT)` should be fine.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] jroesch commented on a change in pull request #6656: [Rust][Diagnostics] Add initial boilerplate for Rust diagnostic interface.

Posted by GitBox <gi...@apache.org>.
jroesch commented on a change in pull request #6656:
URL: https://github.com/apache/incubator-tvm/pull/6656#discussion_r506761896



##########
File path: rust/compiler-ext/Cargo.toml
##########
@@ -0,0 +1,16 @@
+[package]
+name = "compiler-ext"
+version = "0.1.0"
+authors = ["Jared Roesch <jr...@octoml.ai>"]
+edition = "2018"
+# TODO(@jroesch): would be cool to figure out how to statically link instead.

Review comment:
       I figured out how to do this. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] tkonolige commented on a change in pull request #6656: [Rust][Diagnostics] Add initial boilerplate for Rust diagnostic interface.

Posted by GitBox <gi...@apache.org>.
tkonolige commented on a change in pull request #6656:
URL: https://github.com/apache/incubator-tvm/pull/6656#discussion_r512085151



##########
File path: cmake/modules/LLVM.cmake
##########
@@ -16,7 +16,12 @@
 # under the License.
 
 # LLVM rules
-add_definitions(-DDMLC_USE_FOPEN64=0)
+# Due to LLVM debug symbols you can sometimes face linking issues on
+# certain compiler, platform combinations if you don't set NDEBUG.
+#
+# See https://github.com/imageworks/OpenShadingLanguage/issues/1069
+# for more discussion.
+add_definitions(-DDMLC_USE_FOPEN64=0 -DNDEBUG=1)

Review comment:
       It doesn't seem like a good idea to define `NDEBUG` globally.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] jroesch commented on a change in pull request #6656: [Rust][Diagnostics] Add initial boilerplate for Rust diagnostic interface.

Posted by GitBox <gi...@apache.org>.
jroesch commented on a change in pull request #6656:
URL: https://github.com/apache/incubator-tvm/pull/6656#discussion_r506762857



##########
File path: rust/compiler-ext/src/lib.rs
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use env_logger;
+use tvm;
+use tvm::runtime::function::register_override;
+
+fn test_fn() -> Result<(), tvm::Error> {
+    println!("Hello Greg from Rust!");
+    Ok(())
+}
+
+fn test_fn2(message: tvm::runtime::string::String) -> Result<(), tvm::Error> {
+    println!("The message: {}", message);
+    Ok(())
+}
+
+tvm::export!(test_fn, test_fn2);
+
+#[no_mangle]
+fn compiler_ext_initialize() -> i32 {

Review comment:
       I think extern just sets symbol visibility, seems to have worked. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] jroesch commented on pull request #6656: [Rust][Diagnostics][WIP] Add initial boilerplate for Rust diagnostic interface.

Posted by GitBox <gi...@apache.org>.
jroesch commented on pull request #6656:
URL: https://github.com/apache/incubator-tvm/pull/6656#issuecomment-706418176


   cc @gussmith23 and @mwillsey 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] tkonolige commented on a change in pull request #6656: [Rust][Diagnostics] Add initial boilerplate for Rust diagnostic interface.

Posted by GitBox <gi...@apache.org>.
tkonolige commented on a change in pull request #6656:
URL: https://github.com/apache/incubator-tvm/pull/6656#discussion_r506766711



##########
File path: cmake/modules/RustExt.cmake
##########
@@ -0,0 +1,26 @@
+if(USE_RUST_EXT AND NOT USE_RUST_EXT EQUAL OFF)

Review comment:
       _if(<constant>)
   True if the constant is 1, ON, YES, TRUE, Y, or a non-zero number. False if the constant is 0, OFF, NO, FALSE, N, IGNORE, NOTFOUND, the empty string, or ends in the suffix -NOTFOUND. Named boolean constants are case-insensitive. If the argument is not one of these constants, it is treated as a variable._




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] rkimball commented on a change in pull request #6656: [Rust][Diagnostics] Add initial boilerplate for Rust diagnostic interface.

Posted by GitBox <gi...@apache.org>.
rkimball commented on a change in pull request #6656:
URL: https://github.com/apache/incubator-tvm/pull/6656#discussion_r506764888



##########
File path: cmake/modules/RustExt.cmake
##########
@@ -0,0 +1,26 @@
+if(USE_RUST_EXT AND NOT USE_RUST_EXT EQUAL OFF)

Review comment:
       We really need to stop overloading cmake bool and string. cmake is a simple thing and is easily confused. In the meantime us this instead. OFF is only one of the many valid values for cmake bool false.
   ```suggestion
   if(USE_RUST_EXT AND NOT ${USE_RUST_EXT} MATCHES ${IS_FALSE_PATTERN})
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] tkonolige commented on a change in pull request #6656: [Rust][Diagnostics] Add initial boilerplate for Rust diagnostic interface.

Posted by GitBox <gi...@apache.org>.
tkonolige commented on a change in pull request #6656:
URL: https://github.com/apache/incubator-tvm/pull/6656#discussion_r506761995



##########
File path: rust/compiler-ext/src/lib.rs
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use env_logger;
+use tvm;
+use tvm::runtime::function::register_override;
+
+fn test_fn() -> Result<(), tvm::Error> {
+    println!("Hello Greg from Rust!");
+    Ok(())
+}
+
+fn test_fn2(message: tvm::runtime::string::String) -> Result<(), tvm::Error> {
+    println!("The message: {}", message);
+    Ok(())
+}
+
+tvm::export!(test_fn, test_fn2);
+
+#[no_mangle]
+fn compiler_ext_initialize() -> i32 {

Review comment:
       This doesn't need an extern?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] tkonolige commented on a change in pull request #6656: [Rust][Diagnostics] Add initial boilerplate for Rust diagnostic interface.

Posted by GitBox <gi...@apache.org>.
tkonolige commented on a change in pull request #6656:
URL: https://github.com/apache/incubator-tvm/pull/6656#discussion_r506762570



##########
File path: rust/tvm/src/ir/diagnostics/codespan.rs
##########
@@ -0,0 +1,183 @@
+use std::collections::HashMap;

Review comment:
       This file could use some comments

##########
File path: rust/tvm/src/ir/diagnostics/codespan.rs
##########
@@ -0,0 +1,183 @@
+use std::collections::HashMap;

Review comment:
       This file could use some comments/docs




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] rkimball commented on a change in pull request #6656: [Rust][Diagnostics] Add initial boilerplate for Rust diagnostic interface.

Posted by GitBox <gi...@apache.org>.
rkimball commented on a change in pull request #6656:
URL: https://github.com/apache/incubator-tvm/pull/6656#discussion_r510302622



##########
File path: rust/tvm/src/ir/span.rs
##########
@@ -1,22 +1,75 @@
 /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-use crate::runtime::ObjectRef;
-
-pub type Span = ObjectRef;
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+use crate::runtime::{Object, ObjectRef, String as TString};
+use tvm_macros::Object;
+
+/// A source file name, contained in a Span.
+
+#[repr(C)]
+#[derive(Object)]
+#[type_key = "SourceName"]
+#[ref_name = "SourceName"]
+pub struct SourceNameNode {
+    pub base: Object,
+    pub name: TString,
+}
+
+//  /*!
+//   * \brief The source name of a file span.
+//   * \sa SourceNameNode, Span
+//   */
+//  class SourceName : public ObjectRef {
+//   public:
+//    /*!
+//     * \brief Get an SourceName for a given operator name.
+//     *  Will raise an error if the source name has not been registered.
+//     * \param name Name of the operator.
+//     * \return SourceName valid throughout program lifetime.
+//     */
+//    TVM_DLL static SourceName Get(const String& name);
+
+//    TVM_DEFINE_OBJECT_REF_METHODS(SourceName, ObjectRef, SourceNameNode);
+//  };

Review comment:
       Fix this double commented

##########
File path: rust/tvm/src/ir/diagnostics/mod.rs
##########
@@ -0,0 +1,233 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use super::module::IRModule;
+use super::span::*;
+use crate::runtime::function::Result;
+use crate::runtime::object::{Object, ObjectPtr, ObjectRef};
+use crate::runtime::{
+    array::Array,
+    function::{self, Function, ToFunction},
+    string::String as TString,
+};
+/// The diagnostic interface to TVM, used for reporting and rendering
+/// diagnostic information by the compiler. This module exposes
+/// three key abstractions: a Diagnostic, the DiagnosticContext,
+/// and the DiagnosticRenderer.
+use tvm_macros::{external, Object};
+
+pub mod codespan;
+
+external! {
+    #[name("node.ArrayGetItem")]
+    fn get_renderer() -> DiagnosticRenderer;
+
+    #[name("diagnostics.DiagnosticRenderer")]
+    fn diagnostic_renderer(func: Function) -> DiagnosticRenderer;
+
+    #[name("diagnostics.Emit")]
+    fn emit(ctx: DiagnosticContext, diagnostic: Diagnostic) -> ();
+
+    #[name("diagnostics.DiagnosticContextRender")]
+    fn diagnostic_context_render(ctx: DiagnosticContext) -> ();
+
+    #[name("diagnostics.DiagnosticRendererRender")]
+    fn diagnositc_renderer_render(renderer: DiagnosticRenderer,ctx: DiagnosticContext) -> ();
+
+    #[name("diagnostics.ClearRenderer")]
+    fn clear_renderer() -> ();
+}
+
+/// The diagnostic level, controls the printing of the message.
+#[repr(C)]
+pub enum DiagnosticLevel {
+    Bug = 10,
+    Error = 20,
+    Warning = 30,
+    Note = 40,
+    Help = 50,
+}
+
+/// A compiler diagnostic.
+#[repr(C)]
+#[derive(Object)]
+#[ref_name = "Diagnostic"]
+#[type_key = "Diagnostic"]
+pub struct DiagnosticNode {
+    pub base: Object,
+    /// The level.
+    pub level: DiagnosticLevel,
+    /// The span at which to report an error.
+    pub span: Span,
+    /// The diagnostic message.
+    pub message: TString,
+}
+
+impl Diagnostic {
+    pub fn new(level: DiagnosticLevel, span: Span, message: TString) {
+        todo!()
+    }
+
+    pub fn bug(span: Span) -> DiagnosticBuilder {
+        todo!()
+    }
+
+    pub fn error(span: Span) -> DiagnosticBuilder {
+        todo!()
+    }
+
+    pub fn warning(span: Span) -> DiagnosticBuilder {
+        todo!()
+    }
+
+    pub fn note(span: Span) -> DiagnosticBuilder {
+        todo!()
+    }
+
+    pub fn help(span: Span) -> DiagnosticBuilder {
+        todo!()
+    }
+}
+
+/// A wrapper around std::stringstream to build a diagnostic.
+pub struct DiagnosticBuilder {
+    /// The level.
+    pub level: DiagnosticLevel,
+
+    /// The span of the diagnostic.
+    pub span: Span,
+
+    /// The in progress message.
+    pub message: String,
+}
+
+impl DiagnosticBuilder {
+    pub fn new(level: DiagnosticLevel, span: Span) -> DiagnosticBuilder {
+        DiagnosticBuilder { level, span, message: "".into() }
+    }
+}
+
+//   /*! \brief Display diagnostics in a given display format.
+//    *
+//    * A diagnostic renderer is responsible for converting the
+//    * raw diagnostics into consumable output.
+//    *
+//    * For example the terminal renderer will render a sequence
+//    * of compiler diagnostics to std::out and std::err in
+//    * a human readable form.
+//    */

Review comment:
       ```suggestion
   /// \brief Display diagnostics in a given display format.
   ///   
   /// A diagnostic renderer is responsible for converting the
   /// raw diagnostics into consumable output.
   ///  
   /// For example the terminal renderer will render a sequence
   /// of compiler diagnostics to std::out and std::err in
   /// a human readable form.
   ///
   ```

##########
File path: CMakeLists.txt
##########
@@ -79,6 +79,7 @@ tvm_option(USE_ARM_COMPUTE_LIB "Build with Arm Compute Library" OFF)
 tvm_option(USE_ARM_COMPUTE_LIB_GRAPH_RUNTIME "Build with Arm Compute Library graph runtime" OFF)
 tvm_option(USE_TENSORRT_CODEGEN "Build with TensorRT Codegen support" OFF)
 tvm_option(USE_TENSORRT_RUNTIME "Build with TensorRT runtime" OFF)
+tvm_option(USE_RUST_EXT "Build with Rust based compiler extensions" OFF)

Review comment:
       The help string should probably say something about STATIC and DYNAMIC

##########
File path: cmake/modules/RustExt.cmake
##########
@@ -0,0 +1,26 @@
+if(USE_RUST_EXT)
+    set(RUST_SRC_DIR "${CMAKE_SOURCE_DIR}/rust")
+    set(CARGO_OUT_DIR "${CMAKE_SOURCE_DIR}/rust/target")
+
+    if(USE_RUST_EXT STREQUAL "STATIC")
+        set(COMPILER_EXT_PATH "${CARGO_OUT_DIR}/release/libcompiler_ext.a")
+    elseif(USE_RUST_EXT STREQUAL "DYNAMIC")
+        set(COMPILER_EXT_PATH "${CARGO_OUT_DIR}/release/libcompiler_ext.so")
+    else()
+        message(FATAL_ERROR "invalid setting for RUST_EXT")

Review comment:
       ```suggestion
           message(FATAL_ERROR "invalid setting for USE_RUST_EXT")
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] tkonolige commented on a change in pull request #6656: [Rust][Diagnostics] Add initial boilerplate for Rust diagnostic interface.

Posted by GitBox <gi...@apache.org>.
tkonolige commented on a change in pull request #6656:
URL: https://github.com/apache/incubator-tvm/pull/6656#discussion_r512321071



##########
File path: cmake/modules/LLVM.cmake
##########
@@ -16,7 +16,12 @@
 # under the License.
 
 # LLVM rules
-add_definitions(-DDMLC_USE_FOPEN64=0)
+# Due to LLVM debug symbols you can sometimes face linking issues on
+# certain compiler, platform combinations if you don't set NDEBUG.
+#
+# See https://github.com/imageworks/OpenShadingLanguage/issues/1069
+# for more discussion.
+add_definitions(-DDMLC_USE_FOPEN64=0 -DNDEBUG=1)

Review comment:
       ```suggestion
   add_definitions(-DDMLC_USE_FOPEN64=0)
   target_add_definitions(tvm PRIVATE NDEBUG=1)
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] jroesch commented on a change in pull request #6656: [Rust][Diagnostics] Add initial boilerplate for Rust diagnostic interface.

Posted by GitBox <gi...@apache.org>.
jroesch commented on a change in pull request #6656:
URL: https://github.com/apache/incubator-tvm/pull/6656#discussion_r512318133



##########
File path: cmake/modules/LLVM.cmake
##########
@@ -16,7 +16,12 @@
 # under the License.
 
 # LLVM rules
-add_definitions(-DDMLC_USE_FOPEN64=0)
+# Due to LLVM debug symbols you can sometimes face linking issues on
+# certain compiler, platform combinations if you don't set NDEBUG.
+#
+# See https://github.com/imageworks/OpenShadingLanguage/issues/1069
+# for more discussion.
+add_definitions(-DDMLC_USE_FOPEN64=0 -DNDEBUG=1)

Review comment:
       LLVM doesn't link correctly if you don't read the issues.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] tkonolige commented on a change in pull request #6656: [Rust][Diagnostics] Add initial boilerplate for Rust diagnostic interface.

Posted by GitBox <gi...@apache.org>.
tkonolige commented on a change in pull request #6656:
URL: https://github.com/apache/incubator-tvm/pull/6656#discussion_r506766711



##########
File path: cmake/modules/RustExt.cmake
##########
@@ -0,0 +1,26 @@
+if(USE_RUST_EXT AND NOT USE_RUST_EXT EQUAL OFF)

Review comment:
       _if(constant)
   True if the constant is 1, ON, YES, TRUE, Y, or a non-zero number. False if the constant is 0, OFF, NO, FALSE, N, IGNORE, NOTFOUND, the empty string, or ends in the suffix -NOTFOUND. Named boolean constants are case-insensitive. If the argument is not one of these constants, it is treated as a variable._




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] jroesch commented on a change in pull request #6656: [Rust][Diagnostics] Add initial boilerplate for Rust diagnostic interface.

Posted by GitBox <gi...@apache.org>.
jroesch commented on a change in pull request #6656:
URL: https://github.com/apache/incubator-tvm/pull/6656#discussion_r506766408



##########
File path: cmake/modules/RustExt.cmake
##########
@@ -0,0 +1,26 @@
+if(USE_RUST_EXT AND NOT USE_RUST_EXT EQUAL OFF)

Review comment:
       I am not a great CMake user so just let me know what the best way to do things is. I just have no clue what the "right way" in CMake is. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] tkonolige commented on a change in pull request #6656: [Rust][Diagnostics] Add initial boilerplate for Rust diagnostic interface.

Posted by GitBox <gi...@apache.org>.
tkonolige commented on a change in pull request #6656:
URL: https://github.com/apache/incubator-tvm/pull/6656#discussion_r512085469



##########
File path: cmake/modules/RustExt.cmake
##########
@@ -0,0 +1,43 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+if(USE_RUST_EXT)
+    set(RUST_SRC_DIR "${CMAKE_SOURCE_DIR}/rust")
+    set(CARGO_OUT_DIR "${CMAKE_SOURCE_DIR}/rust/target")
+
+    if(USE_RUST_EXT STREQUAL "STATIC")
+        set(COMPILER_EXT_PATH "${CARGO_OUT_DIR}/release/libcompiler_ext.a")
+    elseif(USE_RUST_EXT STREQUAL "DYNAMIC")
+        set(COMPILER_EXT_PATH "${CARGO_OUT_DIR}/release/libcompiler_ext.so")
+    else()
+        message(FATAL_ERROR "invalid setting for USE_RUST_EXT")

Review comment:
       Could you print what the valid settings are here.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] jroesch commented on a change in pull request #6656: [Rust][Diagnostics] Add initial boilerplate for Rust diagnostic interface.

Posted by GitBox <gi...@apache.org>.
jroesch commented on a change in pull request #6656:
URL: https://github.com/apache/incubator-tvm/pull/6656#discussion_r506762875



##########
File path: rust/compiler-ext/src/lib.rs
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use env_logger;
+use tvm;
+use tvm::runtime::function::register_override;
+
+fn test_fn() -> Result<(), tvm::Error> {
+    println!("Hello Greg from Rust!");
+    Ok(())
+}
+
+fn test_fn2(message: tvm::runtime::string::String) -> Result<(), tvm::Error> {
+    println!("The message: {}", message);
+    Ok(())
+}
+
+tvm::export!(test_fn, test_fn2);
+
+#[no_mangle]
+fn compiler_ext_initialize() -> i32 {

Review comment:
       I added it. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] jroesch commented on pull request #6656: [Rust][Diagnostics] Add initial boilerplate for Rust diagnostic interface.

Posted by GitBox <gi...@apache.org>.
jroesch commented on pull request #6656:
URL: https://github.com/apache/incubator-tvm/pull/6656#issuecomment-716341986


   I think this one is now ready to roll.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org