-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[Rust][Diagnostics] Add initial boilerplate for Rust diagnostic interface. #6656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
e6f992e
Add initial boilerplate for Rust diagnostic interface.
jroesch 4fe35b0
Codespan example almost working
jroesch dfacf9e
WIP
jroesch e827660
Hacking on Rust inside of TVM
jroesch a1a4f3e
Borrow code from Egg
jroesch 52177cc
Update CMake and delete old API
jroesch c5b4061
Fix Linux build
jroesch 29754ae
Clean up exporting to show off new diagnostics
jroesch 39c90da
Improve Rust bindings
jroesch c1b994c
Fix calling
jroesch 7ea0c34
Fix
jroesch 46c46ad
Rust Diagnostics work
jroesch 8f219a6
Remove type checker
jroesch 6f28414
Format and cleanup
jroesch af518e1
Fix the extension code
jroesch beb8f1c
More cleanup
jroesch 657c708
Fix some CR
jroesch 06cdc47
Add docs and address feedback
jroesch db6b355
WIP more improvments
jroesch 9aa1a09
Update cmake/modules/RustExt.cmake
jroesch 7e038e0
Update rust/tvm/src/ir/diagnostics/mod.rs
jroesch 9a0e727
Clean up PR
jroesch d086193
Format all
jroesch 62f3e39
Remove dead comment
jroesch 0b5645e
Code review comments and apache headers
jroesch 2f778db
Purge test file
jroesch e8fd9a5
Update cmake/modules/LLVM.cmake
jroesch e92adcc
Format Rust
jroesch 5731a60
Add TK's suggestion
jroesch 0065966
More CR and cleanup
jroesch 5f2ad03
Fix tyck line
jroesch 9700d81
Format
jroesch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8000
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, STATIC, DYNAMIC or OFF") | ||
endif() | ||
|
||
add_custom_command( | ||
OUTPUT "${COMPILER_EXT_PATH}" | ||
COMMAND cargo build --release | ||
MAIN_DEPENDENCY "${RUST_SRC_DIR}" | ||
WORKING_DIRECTORY "${RUST_SRC_DIR}/compiler-ext") | ||
|
||
add_custom_target(rust_ext ALL DEPENDS "${COMPILER_EXT_PATH}") | ||
|
||
# TODO(@jroesch, @tkonolige): move this to CMake target | ||
# target_link_libraries(tvm "${COMPILER_EXT_PATH}" PRIVATE) | ||
list(APPEND TVM_LINKER_LIBS ${COMPILER_EXT_PATH}) | ||
|
||
add_definitions(-DRUST_COMPILER_EXT=1) | ||
endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# 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. | ||
|
||
[package] | ||
name = "compiler-ext" | ||
version = "0.1.0" | ||
authors = ["TVM Contributors"] | ||
edition = "2018" | ||
|
||
[lib] | ||
crate-type = ["staticlib", "cdylib"] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
tvm = { path = "../tvm", default-features = false, features = ["static-linking"] } | ||
log = "*" | ||
jroesch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
env_logger = "*" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* 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::export; | ||
|
||
fn diagnostics() -> Result<(), tvm::Error> { | ||
tvm::ir::diagnostics::codespan::init() | ||
} | ||
|
||
export!(diagnostics); | ||
|
||
#[no_mangle] | ||
extern "C" fn compiler_ext_initialize() -> i32 { | ||
let _ = env_logger::try_init(); | ||
tvm_export("rust_ext").expect("failed to initialize the Rust compiler extensions."); | ||
log::debug!("Loaded the Rust compiler extension."); | ||
return 0; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.